@@ -1,4 +1,4 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <p class="glsr-field {{ class }}"> |
4 | 4 | {{ label }} |
@@ -1,4 +1,4 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <p class="glsr-field {{ class }}"> |
4 | 4 | {{ label }} |
@@ -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,4 +1,4 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <table class="form-table"> |
4 | 4 | <tbody> |
@@ -8,137 +8,137 @@ |
||
8 | 8 | */ |
9 | 9 | class GL_Plugin_Check_v3 |
10 | 10 | { |
11 | - const MIN_PHP_VERSION = '5.6.0'; |
|
12 | - const MIN_WORDPRESS_VERSION = '4.7.0'; |
|
11 | + const MIN_PHP_VERSION = '5.6.0'; |
|
12 | + const MIN_WORDPRESS_VERSION = '4.7.0'; |
|
13 | 13 | |
14 | - /** |
|
15 | - * @var string |
|
16 | - */ |
|
17 | - protected $file; |
|
14 | + /** |
|
15 | + * @var string |
|
16 | + */ |
|
17 | + protected $file; |
|
18 | 18 | |
19 | - /** |
|
20 | - * @var array |
|
21 | - */ |
|
22 | - protected $versions; |
|
19 | + /** |
|
20 | + * @var array |
|
21 | + */ |
|
22 | + protected $versions; |
|
23 | 23 | |
24 | - /** |
|
25 | - * @param string $file |
|
26 | - */ |
|
27 | - public function __construct($file, array $versions = array()) |
|
28 | - { |
|
29 | - $this->file = realpath($file); |
|
30 | - $this->versions = wp_parse_args($versions, array( |
|
31 | - 'php' => static::MIN_PHP_VERSION, |
|
32 | - 'wordpress' => static::MIN_WORDPRESS_VERSION, |
|
33 | - )); |
|
34 | - } |
|
24 | + /** |
|
25 | + * @param string $file |
|
26 | + */ |
|
27 | + public function __construct($file, array $versions = array()) |
|
28 | + { |
|
29 | + $this->file = realpath($file); |
|
30 | + $this->versions = wp_parse_args($versions, array( |
|
31 | + 'php' => static::MIN_PHP_VERSION, |
|
32 | + 'wordpress' => static::MIN_WORDPRESS_VERSION, |
|
33 | + )); |
|
34 | + } |
|
35 | 35 | |
36 | - /** |
|
37 | - * @return bool |
|
38 | - */ |
|
39 | - public function canProceed() |
|
40 | - { |
|
41 | - if ($this->isValid()) { |
|
42 | - return true; |
|
43 | - } |
|
44 | - add_action('activated_plugin', array($this, 'deactivate')); |
|
45 | - add_action('admin_notices', array($this, 'deactivate')); |
|
46 | - return false; |
|
47 | - } |
|
36 | + /** |
|
37 | + * @return bool |
|
38 | + */ |
|
39 | + public function canProceed() |
|
40 | + { |
|
41 | + if ($this->isValid()) { |
|
42 | + return true; |
|
43 | + } |
|
44 | + add_action('activated_plugin', array($this, 'deactivate')); |
|
45 | + add_action('admin_notices', array($this, 'deactivate')); |
|
46 | + return false; |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * @return bool |
|
51 | - */ |
|
52 | - public function isPhpValid() |
|
53 | - { |
|
54 | - return !version_compare(PHP_VERSION, $this->versions['php'], '<'); |
|
55 | - } |
|
49 | + /** |
|
50 | + * @return bool |
|
51 | + */ |
|
52 | + public function isPhpValid() |
|
53 | + { |
|
54 | + return !version_compare(PHP_VERSION, $this->versions['php'], '<'); |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * @return bool |
|
59 | - */ |
|
60 | - public function isValid() |
|
61 | - { |
|
62 | - return $this->isPhpValid() && $this->isWpValid(); |
|
63 | - } |
|
57 | + /** |
|
58 | + * @return bool |
|
59 | + */ |
|
60 | + public function isValid() |
|
61 | + { |
|
62 | + return $this->isPhpValid() && $this->isWpValid(); |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * @return bool |
|
67 | - */ |
|
68 | - public function isWpValid() |
|
69 | - { |
|
70 | - global $wp_version; |
|
71 | - return !version_compare($wp_version, $this->versions['wordpress'], '<'); |
|
72 | - } |
|
65 | + /** |
|
66 | + * @return bool |
|
67 | + */ |
|
68 | + public function isWpValid() |
|
69 | + { |
|
70 | + global $wp_version; |
|
71 | + return !version_compare($wp_version, $this->versions['wordpress'], '<'); |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * @param string $plugin |
|
76 | - * @return void |
|
77 | - */ |
|
78 | - public function deactivate($plugin) |
|
79 | - { |
|
80 | - if ($this->isValid()) { |
|
81 | - return; |
|
82 | - } |
|
83 | - $pluginSlug = plugin_basename($this->file); |
|
84 | - if ($plugin == $pluginSlug) { |
|
85 | - $this->redirect(); //exit |
|
86 | - } |
|
87 | - $pluginData = get_file_data($this->file, array('name' => 'Plugin Name'), 'plugin'); |
|
88 | - deactivate_plugins($pluginSlug); |
|
89 | - $this->printNotice($pluginData['name']); |
|
90 | - } |
|
74 | + /** |
|
75 | + * @param string $plugin |
|
76 | + * @return void |
|
77 | + */ |
|
78 | + public function deactivate($plugin) |
|
79 | + { |
|
80 | + if ($this->isValid()) { |
|
81 | + return; |
|
82 | + } |
|
83 | + $pluginSlug = plugin_basename($this->file); |
|
84 | + if ($plugin == $pluginSlug) { |
|
85 | + $this->redirect(); //exit |
|
86 | + } |
|
87 | + $pluginData = get_file_data($this->file, array('name' => 'Plugin Name'), 'plugin'); |
|
88 | + deactivate_plugins($pluginSlug); |
|
89 | + $this->printNotice($pluginData['name']); |
|
90 | + } |
|
91 | 91 | |
92 | - /** |
|
93 | - * @return array |
|
94 | - */ |
|
95 | - protected function getMessages() |
|
96 | - { |
|
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'), |
|
105 | - ); |
|
106 | - } |
|
92 | + /** |
|
93 | + * @return array |
|
94 | + */ |
|
95 | + protected function getMessages() |
|
96 | + { |
|
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'), |
|
105 | + ); |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * @param string $pluginName |
|
110 | - * @return void |
|
111 | - */ |
|
112 | - protected function printNotice($pluginName) |
|
113 | - { |
|
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 | - $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 |
|
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]) |
|
128 | - ); |
|
129 | - } |
|
130 | - } |
|
108 | + /** |
|
109 | + * @param string $pluginName |
|
110 | + * @return void |
|
111 | + */ |
|
112 | + protected function printNotice($pluginName) |
|
113 | + { |
|
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 | + $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 |
|
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]) |
|
128 | + ); |
|
129 | + } |
|
130 | + } |
|
131 | 131 | |
132 | - /** |
|
133 | - * @return void |
|
134 | - */ |
|
135 | - protected function redirect() |
|
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 | - ))); |
|
142 | - exit; |
|
143 | - } |
|
132 | + /** |
|
133 | + * @return void |
|
134 | + */ |
|
135 | + protected function redirect() |
|
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 | + ))); |
|
142 | + exit; |
|
143 | + } |
|
144 | 144 | } |
@@ -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 | } |
@@ -120,7 +120,8 @@ |
||
120 | 120 | sprintf($messages[1], $messages[3].' '.$this->versions['php']), |
121 | 121 | sprintf($messages[2], PHP_VERSION).'</p><p>'.$rollbackMessage |
122 | 122 | ); |
123 | - } elseif (!$this->isWpValid()) { |
|
123 | + } |
|
124 | + elseif (!$this->isWpValid()) { |
|
124 | 125 | printf($noticeTemplate, |
125 | 126 | sprintf($messages[0], $pluginName), |
126 | 127 | sprintf($messages[1], $messages[4].' '.$this->versions['wordpress']), |
@@ -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 }} |
@@ -9,148 +9,148 @@ |
||
9 | 9 | |
10 | 10 | class EnqueuePublicAssets |
11 | 11 | { |
12 | - /** |
|
13 | - * @return void |
|
14 | - */ |
|
15 | - public function handle() |
|
16 | - { |
|
17 | - $this->enqueueAssets(); |
|
18 | - $this->enqueuePolyfillService(); |
|
19 | - $this->enqueueRecaptchaScript(); |
|
20 | - $this->inlineScript(); |
|
21 | - $this->inlineStyles(); |
|
22 | - } |
|
12 | + /** |
|
13 | + * @return void |
|
14 | + */ |
|
15 | + public function handle() |
|
16 | + { |
|
17 | + $this->enqueueAssets(); |
|
18 | + $this->enqueuePolyfillService(); |
|
19 | + $this->enqueueRecaptchaScript(); |
|
20 | + $this->inlineScript(); |
|
21 | + $this->inlineStyles(); |
|
22 | + } |
|
23 | 23 | |
24 | - /** |
|
25 | - * @return void |
|
26 | - */ |
|
27 | - public function enqueueAssets() |
|
28 | - { |
|
29 | - if (apply_filters('site-reviews/assets/css', true)) { |
|
30 | - wp_enqueue_style( |
|
31 | - Application::ID, |
|
32 | - $this->getStylesheet(), |
|
33 | - [], |
|
34 | - glsr()->version |
|
35 | - ); |
|
36 | - } |
|
37 | - if (apply_filters('site-reviews/assets/js', true)) { |
|
38 | - $dependencies = apply_filters('site-reviews/assets/polyfill', true) |
|
39 | - ? [Application::ID.'/polyfill'] |
|
40 | - : []; |
|
41 | - $dependencies = apply_filters('site-reviews/enqueue/public/dependencies', $dependencies); |
|
42 | - wp_enqueue_script( |
|
43 | - Application::ID, |
|
44 | - glsr()->url('assets/scripts/'.Application::ID.'.js'), |
|
45 | - $dependencies, |
|
46 | - glsr()->version, |
|
47 | - true |
|
48 | - ); |
|
49 | - } |
|
50 | - } |
|
24 | + /** |
|
25 | + * @return void |
|
26 | + */ |
|
27 | + public function enqueueAssets() |
|
28 | + { |
|
29 | + if (apply_filters('site-reviews/assets/css', true)) { |
|
30 | + wp_enqueue_style( |
|
31 | + Application::ID, |
|
32 | + $this->getStylesheet(), |
|
33 | + [], |
|
34 | + glsr()->version |
|
35 | + ); |
|
36 | + } |
|
37 | + if (apply_filters('site-reviews/assets/js', true)) { |
|
38 | + $dependencies = apply_filters('site-reviews/assets/polyfill', true) |
|
39 | + ? [Application::ID.'/polyfill'] |
|
40 | + : []; |
|
41 | + $dependencies = apply_filters('site-reviews/enqueue/public/dependencies', $dependencies); |
|
42 | + wp_enqueue_script( |
|
43 | + Application::ID, |
|
44 | + glsr()->url('assets/scripts/'.Application::ID.'.js'), |
|
45 | + $dependencies, |
|
46 | + glsr()->version, |
|
47 | + true |
|
48 | + ); |
|
49 | + } |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * @return void |
|
54 | - */ |
|
55 | - public function enqueuePolyfillService() |
|
56 | - { |
|
57 | - if (!apply_filters('site-reviews/assets/polyfill', true)) { |
|
58 | - return; |
|
59 | - } |
|
60 | - wp_enqueue_script(Application::ID.'/polyfill', add_query_arg([ |
|
61 | - 'features' => 'CustomEvent,Element.prototype.closest,Element.prototype.dataset,Event,XMLHttpRequest,MutationObserver', |
|
62 | - 'flags' => 'gated', |
|
63 | - ], 'https://polyfill.io/v3/polyfill.min.js')); |
|
64 | - } |
|
52 | + /** |
|
53 | + * @return void |
|
54 | + */ |
|
55 | + public function enqueuePolyfillService() |
|
56 | + { |
|
57 | + if (!apply_filters('site-reviews/assets/polyfill', true)) { |
|
58 | + return; |
|
59 | + } |
|
60 | + wp_enqueue_script(Application::ID.'/polyfill', add_query_arg([ |
|
61 | + 'features' => 'CustomEvent,Element.prototype.closest,Element.prototype.dataset,Event,XMLHttpRequest,MutationObserver', |
|
62 | + 'flags' => 'gated', |
|
63 | + ], 'https://polyfill.io/v3/polyfill.min.js')); |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * @return void |
|
68 | - */ |
|
69 | - public function enqueueRecaptchaScript() |
|
70 | - { |
|
71 | - // wpforms-recaptcha |
|
72 | - // google-recaptcha |
|
73 | - // nf-google-recaptcha |
|
74 | - if (!glsr(OptionManager::class)->isRecaptchaEnabled()) { |
|
75 | - return; |
|
76 | - } |
|
77 | - $language = apply_filters('site-reviews/recaptcha/language', get_locale()); |
|
78 | - wp_enqueue_script(Application::ID.'/google-recaptcha', add_query_arg([ |
|
79 | - 'hl' => $language, |
|
80 | - 'render' => 'explicit', |
|
81 | - ], 'https://www.google.com/recaptcha/api.js')); |
|
82 | - } |
|
66 | + /** |
|
67 | + * @return void |
|
68 | + */ |
|
69 | + public function enqueueRecaptchaScript() |
|
70 | + { |
|
71 | + // wpforms-recaptcha |
|
72 | + // google-recaptcha |
|
73 | + // nf-google-recaptcha |
|
74 | + if (!glsr(OptionManager::class)->isRecaptchaEnabled()) { |
|
75 | + return; |
|
76 | + } |
|
77 | + $language = apply_filters('site-reviews/recaptcha/language', get_locale()); |
|
78 | + wp_enqueue_script(Application::ID.'/google-recaptcha', add_query_arg([ |
|
79 | + 'hl' => $language, |
|
80 | + 'render' => 'explicit', |
|
81 | + ], 'https://www.google.com/recaptcha/api.js')); |
|
82 | + } |
|
83 | 83 | |
84 | - /** |
|
85 | - * @return void |
|
86 | - */ |
|
87 | - public function inlineScript() |
|
88 | - { |
|
89 | - $variables = [ |
|
90 | - 'action' => Application::PREFIX.'action', |
|
91 | - 'ajaxpagination' => $this->getFixedSelectorsForPagination(), |
|
92 | - 'ajaxurl' => admin_url('admin-ajax.php'), |
|
93 | - 'nameprefix' => Application::ID, |
|
94 | - 'validationconfig' => glsr(Style::class)->validation, |
|
95 | - 'validationstrings' => glsr(ValidationStringsDefaults::class)->defaults(), |
|
96 | - ]; |
|
97 | - $variables = apply_filters('site-reviews/enqueue/public/localize', $variables); |
|
98 | - wp_add_inline_script(Application::ID, $this->buildInlineScript($variables), 'before'); |
|
99 | - } |
|
84 | + /** |
|
85 | + * @return void |
|
86 | + */ |
|
87 | + public function inlineScript() |
|
88 | + { |
|
89 | + $variables = [ |
|
90 | + 'action' => Application::PREFIX.'action', |
|
91 | + 'ajaxpagination' => $this->getFixedSelectorsForPagination(), |
|
92 | + 'ajaxurl' => admin_url('admin-ajax.php'), |
|
93 | + 'nameprefix' => Application::ID, |
|
94 | + 'validationconfig' => glsr(Style::class)->validation, |
|
95 | + 'validationstrings' => glsr(ValidationStringsDefaults::class)->defaults(), |
|
96 | + ]; |
|
97 | + $variables = apply_filters('site-reviews/enqueue/public/localize', $variables); |
|
98 | + wp_add_inline_script(Application::ID, $this->buildInlineScript($variables), 'before'); |
|
99 | + } |
|
100 | 100 | |
101 | - /** |
|
102 | - * @return void |
|
103 | - */ |
|
104 | - public function inlineStyles() |
|
105 | - { |
|
106 | - $inlineStylesheetPath = glsr()->path('assets/styles/inline-styles.css'); |
|
107 | - if (!apply_filters('site-reviews/assets/css', true)) { |
|
108 | - return; |
|
109 | - } |
|
110 | - if (!file_exists($inlineStylesheetPath)) { |
|
111 | - glsr_log()->error('Inline stylesheet is missing: '.$inlineStylesheetPath); |
|
112 | - return; |
|
113 | - } |
|
114 | - $inlineStylesheetValues = glsr()->config('inline-styles'); |
|
115 | - $stylesheet = str_replace( |
|
116 | - array_keys($inlineStylesheetValues), |
|
117 | - array_values($inlineStylesheetValues), |
|
118 | - file_get_contents($inlineStylesheetPath) |
|
119 | - ); |
|
120 | - wp_add_inline_style(Application::ID, $stylesheet); |
|
121 | - } |
|
101 | + /** |
|
102 | + * @return void |
|
103 | + */ |
|
104 | + public function inlineStyles() |
|
105 | + { |
|
106 | + $inlineStylesheetPath = glsr()->path('assets/styles/inline-styles.css'); |
|
107 | + if (!apply_filters('site-reviews/assets/css', true)) { |
|
108 | + return; |
|
109 | + } |
|
110 | + if (!file_exists($inlineStylesheetPath)) { |
|
111 | + glsr_log()->error('Inline stylesheet is missing: '.$inlineStylesheetPath); |
|
112 | + return; |
|
113 | + } |
|
114 | + $inlineStylesheetValues = glsr()->config('inline-styles'); |
|
115 | + $stylesheet = str_replace( |
|
116 | + array_keys($inlineStylesheetValues), |
|
117 | + array_values($inlineStylesheetValues), |
|
118 | + file_get_contents($inlineStylesheetPath) |
|
119 | + ); |
|
120 | + wp_add_inline_style(Application::ID, $stylesheet); |
|
121 | + } |
|
122 | 122 | |
123 | - /** |
|
124 | - * @return string |
|
125 | - */ |
|
126 | - protected function buildInlineScript(array $variables) |
|
127 | - { |
|
128 | - $script = 'window.hasOwnProperty("GLSR")||(window.GLSR={});'; |
|
129 | - foreach ($variables as $key => $value) { |
|
130 | - $script.= sprintf('GLSR.%s=%s;', $key, json_encode($value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); |
|
131 | - } |
|
132 | - $pattern = '/\"([^ \-\"]+)\"(:[{\[\"])/'; // removes unnecessary quotes surrounding object keys |
|
133 | - $optimizedScript = preg_replace($pattern, '$1$2', $script); |
|
134 | - return apply_filters('site-reviews/enqueue/public/inline-script', $optimizedScript, $script, $variables); |
|
135 | - } |
|
123 | + /** |
|
124 | + * @return string |
|
125 | + */ |
|
126 | + protected function buildInlineScript(array $variables) |
|
127 | + { |
|
128 | + $script = 'window.hasOwnProperty("GLSR")||(window.GLSR={});'; |
|
129 | + foreach ($variables as $key => $value) { |
|
130 | + $script.= sprintf('GLSR.%s=%s;', $key, json_encode($value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); |
|
131 | + } |
|
132 | + $pattern = '/\"([^ \-\"]+)\"(:[{\[\"])/'; // removes unnecessary quotes surrounding object keys |
|
133 | + $optimizedScript = preg_replace($pattern, '$1$2', $script); |
|
134 | + return apply_filters('site-reviews/enqueue/public/inline-script', $optimizedScript, $script, $variables); |
|
135 | + } |
|
136 | 136 | |
137 | - /** |
|
138 | - * @return array |
|
139 | - */ |
|
140 | - protected function getFixedSelectorsForPagination() |
|
141 | - { |
|
142 | - $selectors = ['#wpadminbar', '.site-navigation-fixed']; |
|
143 | - return apply_filters('site-reviews/enqueue/public/localize/ajax-pagination', $selectors); |
|
144 | - } |
|
137 | + /** |
|
138 | + * @return array |
|
139 | + */ |
|
140 | + protected function getFixedSelectorsForPagination() |
|
141 | + { |
|
142 | + $selectors = ['#wpadminbar', '.site-navigation-fixed']; |
|
143 | + return apply_filters('site-reviews/enqueue/public/localize/ajax-pagination', $selectors); |
|
144 | + } |
|
145 | 145 | |
146 | - /** |
|
147 | - * @return string |
|
148 | - */ |
|
149 | - protected function getStylesheet() |
|
150 | - { |
|
151 | - $currentStyle = glsr(Style::class)->style; |
|
152 | - return file_exists(glsr()->path('assets/styles/custom/'.$currentStyle.'.css')) |
|
153 | - ? glsr()->url('assets/styles/custom/'.$currentStyle.'.css') |
|
154 | - : glsr()->url('assets/styles/'.Application::ID.'.css'); |
|
155 | - } |
|
146 | + /** |
|
147 | + * @return string |
|
148 | + */ |
|
149 | + protected function getStylesheet() |
|
150 | + { |
|
151 | + $currentStyle = glsr(Style::class)->style; |
|
152 | + return file_exists(glsr()->path('assets/styles/custom/'.$currentStyle.'.css')) |
|
153 | + ? glsr()->url('assets/styles/custom/'.$currentStyle.'.css') |
|
154 | + : glsr()->url('assets/styles/'.Application::ID.'.css'); |
|
155 | + } |
|
156 | 156 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | */ |
27 | 27 | public function enqueueAssets() |
28 | 28 | { |
29 | - if (apply_filters('site-reviews/assets/css', true)) { |
|
29 | + if( apply_filters( 'site-reviews/assets/css', true ) ) { |
|
30 | 30 | wp_enqueue_style( |
31 | 31 | Application::ID, |
32 | 32 | $this->getStylesheet(), |
@@ -34,14 +34,14 @@ discard block |
||
34 | 34 | glsr()->version |
35 | 35 | ); |
36 | 36 | } |
37 | - if (apply_filters('site-reviews/assets/js', true)) { |
|
38 | - $dependencies = apply_filters('site-reviews/assets/polyfill', true) |
|
37 | + if( apply_filters( 'site-reviews/assets/js', true ) ) { |
|
38 | + $dependencies = apply_filters( 'site-reviews/assets/polyfill', true ) |
|
39 | 39 | ? [Application::ID.'/polyfill'] |
40 | 40 | : []; |
41 | - $dependencies = apply_filters('site-reviews/enqueue/public/dependencies', $dependencies); |
|
41 | + $dependencies = apply_filters( 'site-reviews/enqueue/public/dependencies', $dependencies ); |
|
42 | 42 | wp_enqueue_script( |
43 | 43 | Application::ID, |
44 | - glsr()->url('assets/scripts/'.Application::ID.'.js'), |
|
44 | + glsr()->url( 'assets/scripts/'.Application::ID.'.js' ), |
|
45 | 45 | $dependencies, |
46 | 46 | glsr()->version, |
47 | 47 | true |
@@ -54,13 +54,13 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public function enqueuePolyfillService() |
56 | 56 | { |
57 | - if (!apply_filters('site-reviews/assets/polyfill', true)) { |
|
57 | + if( !apply_filters( 'site-reviews/assets/polyfill', true ) ) { |
|
58 | 58 | return; |
59 | 59 | } |
60 | - wp_enqueue_script(Application::ID.'/polyfill', add_query_arg([ |
|
60 | + wp_enqueue_script( Application::ID.'/polyfill', add_query_arg( [ |
|
61 | 61 | 'features' => 'CustomEvent,Element.prototype.closest,Element.prototype.dataset,Event,XMLHttpRequest,MutationObserver', |
62 | 62 | 'flags' => 'gated', |
63 | - ], 'https://polyfill.io/v3/polyfill.min.js')); |
|
63 | + ], 'https://polyfill.io/v3/polyfill.min.js' ) ); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -71,14 +71,14 @@ discard block |
||
71 | 71 | // wpforms-recaptcha |
72 | 72 | // google-recaptcha |
73 | 73 | // nf-google-recaptcha |
74 | - if (!glsr(OptionManager::class)->isRecaptchaEnabled()) { |
|
74 | + if( !glsr( OptionManager::class )->isRecaptchaEnabled() ) { |
|
75 | 75 | return; |
76 | 76 | } |
77 | - $language = apply_filters('site-reviews/recaptcha/language', get_locale()); |
|
78 | - wp_enqueue_script(Application::ID.'/google-recaptcha', add_query_arg([ |
|
77 | + $language = apply_filters( 'site-reviews/recaptcha/language', get_locale() ); |
|
78 | + wp_enqueue_script( Application::ID.'/google-recaptcha', add_query_arg( [ |
|
79 | 79 | 'hl' => $language, |
80 | 80 | 'render' => 'explicit', |
81 | - ], 'https://www.google.com/recaptcha/api.js')); |
|
81 | + ], 'https://www.google.com/recaptcha/api.js' ) ); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -89,13 +89,13 @@ discard block |
||
89 | 89 | $variables = [ |
90 | 90 | 'action' => Application::PREFIX.'action', |
91 | 91 | 'ajaxpagination' => $this->getFixedSelectorsForPagination(), |
92 | - 'ajaxurl' => admin_url('admin-ajax.php'), |
|
92 | + 'ajaxurl' => admin_url( 'admin-ajax.php' ), |
|
93 | 93 | 'nameprefix' => Application::ID, |
94 | - 'validationconfig' => glsr(Style::class)->validation, |
|
95 | - 'validationstrings' => glsr(ValidationStringsDefaults::class)->defaults(), |
|
94 | + 'validationconfig' => glsr( Style::class )->validation, |
|
95 | + 'validationstrings' => glsr( ValidationStringsDefaults::class )->defaults(), |
|
96 | 96 | ]; |
97 | - $variables = apply_filters('site-reviews/enqueue/public/localize', $variables); |
|
98 | - wp_add_inline_script(Application::ID, $this->buildInlineScript($variables), 'before'); |
|
97 | + $variables = apply_filters( 'site-reviews/enqueue/public/localize', $variables ); |
|
98 | + wp_add_inline_script( Application::ID, $this->buildInlineScript( $variables ), 'before' ); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -103,35 +103,35 @@ discard block |
||
103 | 103 | */ |
104 | 104 | public function inlineStyles() |
105 | 105 | { |
106 | - $inlineStylesheetPath = glsr()->path('assets/styles/inline-styles.css'); |
|
107 | - if (!apply_filters('site-reviews/assets/css', true)) { |
|
106 | + $inlineStylesheetPath = glsr()->path( 'assets/styles/inline-styles.css' ); |
|
107 | + if( !apply_filters( 'site-reviews/assets/css', true ) ) { |
|
108 | 108 | return; |
109 | 109 | } |
110 | - if (!file_exists($inlineStylesheetPath)) { |
|
111 | - glsr_log()->error('Inline stylesheet is missing: '.$inlineStylesheetPath); |
|
110 | + if( !file_exists( $inlineStylesheetPath ) ) { |
|
111 | + glsr_log()->error( 'Inline stylesheet is missing: '.$inlineStylesheetPath ); |
|
112 | 112 | return; |
113 | 113 | } |
114 | - $inlineStylesheetValues = glsr()->config('inline-styles'); |
|
114 | + $inlineStylesheetValues = glsr()->config( 'inline-styles' ); |
|
115 | 115 | $stylesheet = str_replace( |
116 | - array_keys($inlineStylesheetValues), |
|
117 | - array_values($inlineStylesheetValues), |
|
118 | - file_get_contents($inlineStylesheetPath) |
|
116 | + array_keys( $inlineStylesheetValues ), |
|
117 | + array_values( $inlineStylesheetValues ), |
|
118 | + file_get_contents( $inlineStylesheetPath ) |
|
119 | 119 | ); |
120 | - wp_add_inline_style(Application::ID, $stylesheet); |
|
120 | + wp_add_inline_style( Application::ID, $stylesheet ); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
124 | 124 | * @return string |
125 | 125 | */ |
126 | - protected function buildInlineScript(array $variables) |
|
126 | + protected function buildInlineScript( array $variables ) |
|
127 | 127 | { |
128 | 128 | $script = 'window.hasOwnProperty("GLSR")||(window.GLSR={});'; |
129 | - foreach ($variables as $key => $value) { |
|
130 | - $script.= sprintf('GLSR.%s=%s;', $key, json_encode($value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); |
|
129 | + foreach( $variables as $key => $value ) { |
|
130 | + $script .= sprintf( 'GLSR.%s=%s;', $key, json_encode( $value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ) ); |
|
131 | 131 | } |
132 | 132 | $pattern = '/\"([^ \-\"]+)\"(:[{\[\"])/'; // removes unnecessary quotes surrounding object keys |
133 | - $optimizedScript = preg_replace($pattern, '$1$2', $script); |
|
134 | - return apply_filters('site-reviews/enqueue/public/inline-script', $optimizedScript, $script, $variables); |
|
133 | + $optimizedScript = preg_replace( $pattern, '$1$2', $script ); |
|
134 | + return apply_filters( 'site-reviews/enqueue/public/inline-script', $optimizedScript, $script, $variables ); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | protected function getFixedSelectorsForPagination() |
141 | 141 | { |
142 | 142 | $selectors = ['#wpadminbar', '.site-navigation-fixed']; |
143 | - return apply_filters('site-reviews/enqueue/public/localize/ajax-pagination', $selectors); |
|
143 | + return apply_filters( 'site-reviews/enqueue/public/localize/ajax-pagination', $selectors ); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -148,9 +148,9 @@ discard block |
||
148 | 148 | */ |
149 | 149 | protected function getStylesheet() |
150 | 150 | { |
151 | - $currentStyle = glsr(Style::class)->style; |
|
152 | - return file_exists(glsr()->path('assets/styles/custom/'.$currentStyle.'.css')) |
|
153 | - ? glsr()->url('assets/styles/custom/'.$currentStyle.'.css') |
|
154 | - : glsr()->url('assets/styles/'.Application::ID.'.css'); |
|
151 | + $currentStyle = glsr( Style::class )->style; |
|
152 | + return file_exists( glsr()->path( 'assets/styles/custom/'.$currentStyle.'.css' ) ) |
|
153 | + ? glsr()->url( 'assets/styles/custom/'.$currentStyle.'.css' ) |
|
154 | + : glsr()->url( 'assets/styles/'.Application::ID.'.css' ); |
|
155 | 155 | } |
156 | 156 | } |