@@ -1,7 +1,7 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | -<p><?= __('The JSON-LD schema is disabled by default. To use it, please enable the option in your blocks or shortcodes. The schema appears in Google\'s search results and shows the star rating and other information about your reviews. If the schema has been enabled, you can use Google\'s <a href="https://search.google.com/structured-data/testing-tool">Structured Data Testing Tool</a> to test your pages for valid schema data.', 'site-reviews'); ?></p> |
|
4 | -<p><?= __('You may override any of these options on a per-post/page basis by using its Custom Field name and adding a custom value using the <a href="https://codex.wordpress.org/Using_Custom_Fields#Usage">Custom Fields</a> metabox.', 'site-reviews'); ?></p> |
|
3 | +<p><?= __( 'The JSON-LD schema is disabled by default. To use it, please enable the option in your blocks or shortcodes. The schema appears in Google\'s search results and shows the star rating and other information about your reviews. If the schema has been enabled, you can use Google\'s <a href="https://search.google.com/structured-data/testing-tool">Structured Data Testing Tool</a> to test your pages for valid schema data.', 'site-reviews' ); ?></p> |
|
4 | +<p><?= __( 'You may override any of these options on a per-post/page basis by using its Custom Field name and adding a custom value using the <a href="https://codex.wordpress.org/Using_Custom_Fields#Usage">Custom Fields</a> metabox.', 'site-reviews' ); ?></p> |
|
5 | 5 | <table class="form-table"> |
6 | 6 | <tbody> |
7 | 7 | {{ rows }} |
@@ -18,11 +18,11 @@ |
||
18 | 18 | defined('WPINC') || die; |
19 | 19 | |
20 | 20 | if (!class_exists('GL_Plugin_Check_v3')) { |
21 | - require_once __DIR__.'/activate.php'; |
|
21 | + require_once __DIR__.'/activate.php'; |
|
22 | 22 | } |
23 | 23 | $check = new GL_Plugin_Check_v3(__FILE__); |
24 | 24 | if (!$check->canProceed()) { |
25 | - return; |
|
25 | + return; |
|
26 | 26 | } |
27 | 27 | require_once __DIR__.'/autoload.php'; |
28 | 28 | require_once __DIR__.'/compatibility.php'; |
@@ -15,13 +15,13 @@ discard block |
||
15 | 15 | * Text Domain: site-reviews |
16 | 16 | * Domain Path: languages |
17 | 17 | */ |
18 | -defined('WPINC') || die; |
|
18 | +defined( 'WPINC' ) || die; |
|
19 | 19 | |
20 | -if (!class_exists('GL_Plugin_Check_v3')) { |
|
20 | +if( !class_exists( 'GL_Plugin_Check_v3' ) ) { |
|
21 | 21 | require_once __DIR__.'/activate.php'; |
22 | 22 | } |
23 | -$check = new GL_Plugin_Check_v3(__FILE__); |
|
24 | -if (!$check->canProceed()) { |
|
23 | +$check = new GL_Plugin_Check_v3( __FILE__ ); |
|
24 | +if( !$check->canProceed() ) { |
|
25 | 25 | return; |
26 | 26 | } |
27 | 27 | require_once __DIR__.'/autoload.php'; |
@@ -30,8 +30,8 @@ discard block |
||
30 | 30 | require_once __DIR__.'/helpers.php'; |
31 | 31 | |
32 | 32 | $app = new GeminiLabs\SiteReviews\Application(); |
33 | -$app->make('Provider')->register($app); |
|
34 | -register_activation_hook(__FILE__, array($app, 'activate')); |
|
35 | -register_deactivation_hook(__FILE__, array($app, 'deactivate')); |
|
36 | -register_shutdown_function(array($app, 'catchFatalError')); |
|
33 | +$app->make( 'Provider' )->register( $app ); |
|
34 | +register_activation_hook( __FILE__, array( $app, 'activate' ) ); |
|
35 | +register_deactivation_hook( __FILE__, array( $app, 'deactivate' ) ); |
|
36 | +register_shutdown_function( array( $app, 'catchFatalError' ) ); |
|
37 | 37 | $app->init(); |
@@ -8,112 +8,112 @@ |
||
8 | 8 | |
9 | 9 | class Notice |
10 | 10 | { |
11 | - /** |
|
12 | - * @param string $type |
|
13 | - * @param string|array|WP_Error $message |
|
14 | - * @return void |
|
15 | - */ |
|
16 | - public function add($type, $message, array $args = []) |
|
17 | - { |
|
18 | - if (empty(array_filter([$message, $type]))) { |
|
19 | - return; |
|
20 | - } |
|
21 | - $args['message'] = $message; |
|
22 | - $args['type'] = $type; |
|
23 | - add_settings_error(Application::ID, '', json_encode($this->normalize($args))); |
|
24 | - } |
|
11 | + /** |
|
12 | + * @param string $type |
|
13 | + * @param string|array|WP_Error $message |
|
14 | + * @return void |
|
15 | + */ |
|
16 | + public function add($type, $message, array $args = []) |
|
17 | + { |
|
18 | + if (empty(array_filter([$message, $type]))) { |
|
19 | + return; |
|
20 | + } |
|
21 | + $args['message'] = $message; |
|
22 | + $args['type'] = $type; |
|
23 | + add_settings_error(Application::ID, '', json_encode($this->normalize($args))); |
|
24 | + } |
|
25 | 25 | |
26 | - /** |
|
27 | - * @param string|array|WP_Error $message |
|
28 | - * @return void |
|
29 | - */ |
|
30 | - public function addError($message, array $args = []) |
|
31 | - { |
|
32 | - $this->add('error', $message, $args); |
|
33 | - } |
|
26 | + /** |
|
27 | + * @param string|array|WP_Error $message |
|
28 | + * @return void |
|
29 | + */ |
|
30 | + public function addError($message, array $args = []) |
|
31 | + { |
|
32 | + $this->add('error', $message, $args); |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * @param string|array|WP_Error $message |
|
37 | - * @return void |
|
38 | - */ |
|
39 | - public function addSuccess($message, array $args = []) |
|
40 | - { |
|
41 | - $this->add('success', $message, $args); |
|
42 | - } |
|
35 | + /** |
|
36 | + * @param string|array|WP_Error $message |
|
37 | + * @return void |
|
38 | + */ |
|
39 | + public function addSuccess($message, array $args = []) |
|
40 | + { |
|
41 | + $this->add('success', $message, $args); |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * @param string|array|WP_Error $message |
|
46 | - * @return void |
|
47 | - */ |
|
48 | - public function addWarning($message, array $args = []) |
|
49 | - { |
|
50 | - $this->add('warning', $message, $args); |
|
51 | - } |
|
44 | + /** |
|
45 | + * @param string|array|WP_Error $message |
|
46 | + * @return void |
|
47 | + */ |
|
48 | + public function addWarning($message, array $args = []) |
|
49 | + { |
|
50 | + $this->add('warning', $message, $args); |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * @return static |
|
55 | - */ |
|
56 | - public function clear() |
|
57 | - { |
|
58 | - global $wp_settings_errors; |
|
59 | - $wp_settings_errors = []; |
|
60 | - delete_transient('settings_errors'); |
|
61 | - return $this; |
|
62 | - } |
|
53 | + /** |
|
54 | + * @return static |
|
55 | + */ |
|
56 | + public function clear() |
|
57 | + { |
|
58 | + global $wp_settings_errors; |
|
59 | + $wp_settings_errors = []; |
|
60 | + delete_transient('settings_errors'); |
|
61 | + return $this; |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * @return string |
|
66 | - */ |
|
67 | - public function get() |
|
68 | - { |
|
69 | - $notices = array_map('unserialize', |
|
70 | - array_unique(array_map('serialize', get_settings_errors(Application::ID))) |
|
71 | - ); |
|
72 | - $notices = array_reduce($notices, function ($carry, $notice) { |
|
73 | - return $carry.$this->buildNotice(json_decode($notice['message'], true)); |
|
74 | - }); |
|
75 | - return apply_filters('site-reviews/notices', $notices); |
|
76 | - } |
|
64 | + /** |
|
65 | + * @return string |
|
66 | + */ |
|
67 | + public function get() |
|
68 | + { |
|
69 | + $notices = array_map('unserialize', |
|
70 | + array_unique(array_map('serialize', get_settings_errors(Application::ID))) |
|
71 | + ); |
|
72 | + $notices = array_reduce($notices, function ($carry, $notice) { |
|
73 | + return $carry.$this->buildNotice(json_decode($notice['message'], true)); |
|
74 | + }); |
|
75 | + return apply_filters('site-reviews/notices', $notices); |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * @return string |
|
80 | - */ |
|
81 | - protected function buildNotice(array $args) |
|
82 | - { |
|
83 | - $messages = array_reduce($args['messages'], function ($carry, $message) { |
|
84 | - return $carry.glsr(Builder::class)->p($message); |
|
85 | - }); |
|
86 | - $class = 'notice notice-'.$args['type']; |
|
87 | - if ($args['inline']) { |
|
88 | - $class.= ' inline'; |
|
89 | - } |
|
90 | - if ($args['dismissible']) { |
|
91 | - $class.= ' is-dismissible'; |
|
92 | - } |
|
93 | - return glsr(Builder::class)->div($messages, [ |
|
94 | - 'class' => $class, |
|
95 | - ]); |
|
96 | - } |
|
78 | + /** |
|
79 | + * @return string |
|
80 | + */ |
|
81 | + protected function buildNotice(array $args) |
|
82 | + { |
|
83 | + $messages = array_reduce($args['messages'], function ($carry, $message) { |
|
84 | + return $carry.glsr(Builder::class)->p($message); |
|
85 | + }); |
|
86 | + $class = 'notice notice-'.$args['type']; |
|
87 | + if ($args['inline']) { |
|
88 | + $class.= ' inline'; |
|
89 | + } |
|
90 | + if ($args['dismissible']) { |
|
91 | + $class.= ' is-dismissible'; |
|
92 | + } |
|
93 | + return glsr(Builder::class)->div($messages, [ |
|
94 | + 'class' => $class, |
|
95 | + ]); |
|
96 | + } |
|
97 | 97 | |
98 | - /** |
|
99 | - * @return array |
|
100 | - */ |
|
101 | - protected function normalize(array $args) |
|
102 | - { |
|
103 | - $defaults = [ |
|
104 | - 'dismissible' => true, |
|
105 | - 'inline' => true, |
|
106 | - 'message' => '', |
|
107 | - 'type' => '', |
|
108 | - ]; |
|
109 | - $args = shortcode_atts($defaults, $args); |
|
110 | - if (!in_array($args['type'], ['error', 'warning', 'success'])) { |
|
111 | - $args['type'] = 'success'; |
|
112 | - } |
|
113 | - $args['messages'] = is_wp_error($args['message']) |
|
114 | - ? (array) $args['message']->get_error_message() |
|
115 | - : (array) $args['message']; |
|
116 | - unset($args['message']); |
|
117 | - return $args; |
|
118 | - } |
|
98 | + /** |
|
99 | + * @return array |
|
100 | + */ |
|
101 | + protected function normalize(array $args) |
|
102 | + { |
|
103 | + $defaults = [ |
|
104 | + 'dismissible' => true, |
|
105 | + 'inline' => true, |
|
106 | + 'message' => '', |
|
107 | + 'type' => '', |
|
108 | + ]; |
|
109 | + $args = shortcode_atts($defaults, $args); |
|
110 | + if (!in_array($args['type'], ['error', 'warning', 'success'])) { |
|
111 | + $args['type'] = 'success'; |
|
112 | + } |
|
113 | + $args['messages'] = is_wp_error($args['message']) |
|
114 | + ? (array) $args['message']->get_error_message() |
|
115 | + : (array) $args['message']; |
|
116 | + unset($args['message']); |
|
117 | + return $args; |
|
118 | + } |
|
119 | 119 | } |
@@ -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,39 +66,39 @@ 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 | - $notices = array_reduce($notices, function ($carry, $notice) { |
|
73 | - return $carry.$this->buildNotice(json_decode($notice['message'], true)); |
|
72 | + $notices = array_reduce( $notices, function( $carry, $notice ) { |
|
73 | + return $carry.$this->buildNotice( json_decode( $notice['message'], true ) ); |
|
74 | 74 | }); |
75 | - return apply_filters('site-reviews/notices', $notices); |
|
75 | + return apply_filters( 'site-reviews/notices', $notices ); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
79 | 79 | * @return string |
80 | 80 | */ |
81 | - protected function buildNotice(array $args) |
|
81 | + protected function buildNotice( array $args ) |
|
82 | 82 | { |
83 | - $messages = array_reduce($args['messages'], function ($carry, $message) { |
|
84 | - return $carry.glsr(Builder::class)->p($message); |
|
83 | + $messages = array_reduce( $args['messages'], function( $carry, $message ) { |
|
84 | + return $carry.glsr( Builder::class )->p( $message ); |
|
85 | 85 | }); |
86 | 86 | $class = 'notice notice-'.$args['type']; |
87 | - if ($args['inline']) { |
|
88 | - $class.= ' inline'; |
|
87 | + if( $args['inline'] ) { |
|
88 | + $class .= ' inline'; |
|
89 | 89 | } |
90 | - if ($args['dismissible']) { |
|
91 | - $class.= ' is-dismissible'; |
|
90 | + if( $args['dismissible'] ) { |
|
91 | + $class .= ' is-dismissible'; |
|
92 | 92 | } |
93 | - return glsr(Builder::class)->div($messages, [ |
|
93 | + return glsr( Builder::class )->div( $messages, [ |
|
94 | 94 | 'class' => $class, |
95 | - ]); |
|
95 | + ] ); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
99 | 99 | * @return array |
100 | 100 | */ |
101 | - protected function normalize(array $args) |
|
101 | + protected function normalize( array $args ) |
|
102 | 102 | { |
103 | 103 | $defaults = [ |
104 | 104 | 'dismissible' => true, |
@@ -106,13 +106,13 @@ discard block |
||
106 | 106 | 'message' => '', |
107 | 107 | 'type' => '', |
108 | 108 | ]; |
109 | - $args = shortcode_atts($defaults, $args); |
|
110 | - if (!in_array($args['type'], ['error', 'warning', 'success'])) { |
|
109 | + $args = shortcode_atts( $defaults, $args ); |
|
110 | + if( !in_array( $args['type'], ['error', 'warning', 'success'] ) ) { |
|
111 | 111 | $args['type'] = 'success'; |
112 | 112 | } |
113 | - $args['messages'] = is_wp_error($args['message']) |
|
114 | - ? (array) $args['message']->get_error_message() |
|
115 | - : (array) $args['message']; |
|
113 | + $args['messages'] = is_wp_error( $args['message'] ) |
|
114 | + ? (array)$args['message']->get_error_message() |
|
115 | + : (array)$args['message']; |
|
116 | 116 | unset($args['message']); |
117 | 117 | return $args; |
118 | 118 | } |
@@ -4,13 +4,13 @@ |
||
4 | 4 | |
5 | 5 | class Password extends Field |
6 | 6 | { |
7 | - /** |
|
8 | - * @return array |
|
9 | - */ |
|
10 | - public static function defaults() |
|
11 | - { |
|
12 | - return [ |
|
13 | - 'class' => 'regular-text', |
|
14 | - ]; |
|
15 | - } |
|
7 | + /** |
|
8 | + * @return array |
|
9 | + */ |
|
10 | + public static function defaults() |
|
11 | + { |
|
12 | + return [ |
|
13 | + 'class' => 'regular-text', |
|
14 | + ]; |
|
15 | + } |
|
16 | 16 | } |
@@ -101,7 +101,8 @@ |
||
101 | 101 | { |
102 | 102 | if (is_wp_error($response)) { |
103 | 103 | $this->message = $response->get_error_message(); |
104 | - } else { |
|
104 | + } |
|
105 | + else { |
|
105 | 106 | $responseBody = wp_remote_retrieve_body($response); |
106 | 107 | $responseCode = wp_remote_retrieve_response_code($response); |
107 | 108 | $responseData = (array) json_decode($responseBody, true); |
@@ -10,143 +10,143 @@ |
||
10 | 10 | |
11 | 11 | class Rebusify |
12 | 12 | { |
13 | - const API_URL = 'https://www.rebusify.com/api/rbs/'; |
|
14 | - const WEB_URL = 'https://rebusify.com/plans?ref=105'; |
|
13 | + const API_URL = 'https://www.rebusify.com/api/rbs/'; |
|
14 | + const WEB_URL = 'https://rebusify.com/plans?ref=105'; |
|
15 | 15 | |
16 | - public $message; |
|
17 | - public $response; |
|
18 | - public $success; |
|
16 | + public $message; |
|
17 | + public $response; |
|
18 | + public $success; |
|
19 | 19 | |
20 | - /** |
|
21 | - * @return mixed |
|
22 | - */ |
|
23 | - public function __get($key) |
|
24 | - { |
|
25 | - return property_exists($this, $key) |
|
26 | - ? $this->$key |
|
27 | - : Arr::get($this->response, $key, null); |
|
28 | - } |
|
20 | + /** |
|
21 | + * @return mixed |
|
22 | + */ |
|
23 | + public function __get($key) |
|
24 | + { |
|
25 | + return property_exists($this, $key) |
|
26 | + ? $this->$key |
|
27 | + : Arr::get($this->response, $key, null); |
|
28 | + } |
|
29 | 29 | |
30 | - /** |
|
31 | - * @return self |
|
32 | - */ |
|
33 | - public function activateKey($apiKey = '', $email = '') |
|
34 | - { |
|
35 | - $this->send('api_key_activation.php', [ |
|
36 | - 'body' => [ |
|
37 | - 'apikey' => $apiKey ?: 0, |
|
38 | - 'domain' => get_home_url(), |
|
39 | - 'email' => $email ?: 0, |
|
40 | - ], |
|
41 | - ]); |
|
42 | - return $this; |
|
43 | - } |
|
30 | + /** |
|
31 | + * @return self |
|
32 | + */ |
|
33 | + public function activateKey($apiKey = '', $email = '') |
|
34 | + { |
|
35 | + $this->send('api_key_activation.php', [ |
|
36 | + 'body' => [ |
|
37 | + 'apikey' => $apiKey ?: 0, |
|
38 | + 'domain' => get_home_url(), |
|
39 | + 'email' => $email ?: 0, |
|
40 | + ], |
|
41 | + ]); |
|
42 | + return $this; |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * @return self |
|
47 | - */ |
|
48 | - public function reset() |
|
49 | - { |
|
50 | - $this->message = ''; |
|
51 | - $this->response = []; |
|
52 | - $this->success = false; |
|
53 | - return $this; |
|
54 | - } |
|
45 | + /** |
|
46 | + * @return self |
|
47 | + */ |
|
48 | + public function reset() |
|
49 | + { |
|
50 | + $this->message = ''; |
|
51 | + $this->response = []; |
|
52 | + $this->success = false; |
|
53 | + return $this; |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * @return self |
|
58 | - */ |
|
59 | - public function sendReview(Review $review) |
|
60 | - { |
|
61 | - $this->send('index.php', [ |
|
62 | - 'body' => $this->getBodyForReview($review), |
|
63 | - 'timeout' => 120, |
|
64 | - ]); |
|
65 | - return $this; |
|
66 | - } |
|
56 | + /** |
|
57 | + * @return self |
|
58 | + */ |
|
59 | + public function sendReview(Review $review) |
|
60 | + { |
|
61 | + $this->send('index.php', [ |
|
62 | + 'body' => $this->getBodyForReview($review), |
|
63 | + 'timeout' => 120, |
|
64 | + ]); |
|
65 | + return $this; |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * @return self |
|
70 | - */ |
|
71 | - public function sendReviewResponse(Review $review) |
|
72 | - { |
|
73 | - $this->send('fetch_customer_reply.php', [ |
|
74 | - 'body' => $this->getBodyForResponse($review), |
|
75 | - ]); |
|
76 | - return $this; |
|
77 | - } |
|
68 | + /** |
|
69 | + * @return self |
|
70 | + */ |
|
71 | + public function sendReviewResponse(Review $review) |
|
72 | + { |
|
73 | + $this->send('fetch_customer_reply.php', [ |
|
74 | + 'body' => $this->getBodyForResponse($review), |
|
75 | + ]); |
|
76 | + return $this; |
|
77 | + } |
|
78 | 78 | |
79 | - /** |
|
80 | - * @return array |
|
81 | - */ |
|
82 | - protected function getBodyForResponse(Review $review) |
|
83 | - { |
|
84 | - $rebusifyResponse = [ |
|
85 | - 'reply' => Str::truncate($review->response, 300), |
|
86 | - 'review_id' => glsr(Database::class)->get($review->ID, 'rebusify'), // this is the rebusify review ID |
|
87 | - 'review_transaction_id' => $review->review_id, |
|
88 | - 'type' => 'M', |
|
89 | - ]; |
|
90 | - return apply_filters('site-reviews/rebusify/response', $rebusifyResponse, $review); |
|
91 | - } |
|
79 | + /** |
|
80 | + * @return array |
|
81 | + */ |
|
82 | + protected function getBodyForResponse(Review $review) |
|
83 | + { |
|
84 | + $rebusifyResponse = [ |
|
85 | + 'reply' => Str::truncate($review->response, 300), |
|
86 | + 'review_id' => glsr(Database::class)->get($review->ID, 'rebusify'), // this is the rebusify review ID |
|
87 | + 'review_transaction_id' => $review->review_id, |
|
88 | + 'type' => 'M', |
|
89 | + ]; |
|
90 | + return apply_filters('site-reviews/rebusify/response', $rebusifyResponse, $review); |
|
91 | + } |
|
92 | 92 | |
93 | - /** |
|
94 | - * @return array |
|
95 | - */ |
|
96 | - protected function getBodyForReview(Review $review) |
|
97 | - { |
|
98 | - $rebusifyReview = [ |
|
99 | - 'domain' => get_home_url(), |
|
100 | - 'firstname' => Str::truncate(Str::convertName($review->author, 'first'), 25), |
|
101 | - 'rate' => $review->rating, |
|
102 | - 'review_transaction_id' => $review->review_id, |
|
103 | - 'reviews' => Str::truncate($review->content, 280), |
|
104 | - 'title' => Str::truncate($review->title, 35), |
|
105 | - 'transaction' => Application::ID, // woocommerce field, not needed for Site Reviews |
|
106 | - ]; |
|
107 | - return apply_filters('site-reviews/rebusify/review', $rebusifyReview, $review); |
|
108 | - } |
|
93 | + /** |
|
94 | + * @return array |
|
95 | + */ |
|
96 | + protected function getBodyForReview(Review $review) |
|
97 | + { |
|
98 | + $rebusifyReview = [ |
|
99 | + 'domain' => get_home_url(), |
|
100 | + 'firstname' => Str::truncate(Str::convertName($review->author, 'first'), 25), |
|
101 | + 'rate' => $review->rating, |
|
102 | + 'review_transaction_id' => $review->review_id, |
|
103 | + 'reviews' => Str::truncate($review->content, 280), |
|
104 | + 'title' => Str::truncate($review->title, 35), |
|
105 | + 'transaction' => Application::ID, // woocommerce field, not needed for Site Reviews |
|
106 | + ]; |
|
107 | + return apply_filters('site-reviews/rebusify/review', $rebusifyReview, $review); |
|
108 | + } |
|
109 | 109 | |
110 | - /** |
|
111 | - * @param \WP_Error|array $response |
|
112 | - * @return void |
|
113 | - */ |
|
114 | - protected function handleResponse($response) |
|
115 | - { |
|
116 | - if (is_wp_error($response)) { |
|
117 | - $this->message = $response->get_error_message(); |
|
118 | - } else { |
|
119 | - $responseBody = wp_remote_retrieve_body($response); |
|
120 | - $responseCode = wp_remote_retrieve_response_code($response); |
|
121 | - $responseData = (array) json_decode($responseBody, true); |
|
122 | - $this->response = array_shift($responseData); |
|
123 | - $this->message = Arr::get($this->response, 'msg'); |
|
124 | - $this->success = 'success' === Arr::get($this->response, 'result') || 'yes' === Arr::get($this->response, 'success'); // @todo remove this ugly hack! |
|
125 | - if (200 !== $responseCode) { |
|
126 | - glsr_log()->error('Bad response code ['.$responseCode.']'); |
|
127 | - } |
|
128 | - if (!$this->success) { |
|
129 | - glsr_log()->error($this->message); |
|
130 | - } |
|
131 | - } |
|
132 | - } |
|
110 | + /** |
|
111 | + * @param \WP_Error|array $response |
|
112 | + * @return void |
|
113 | + */ |
|
114 | + protected function handleResponse($response) |
|
115 | + { |
|
116 | + if (is_wp_error($response)) { |
|
117 | + $this->message = $response->get_error_message(); |
|
118 | + } else { |
|
119 | + $responseBody = wp_remote_retrieve_body($response); |
|
120 | + $responseCode = wp_remote_retrieve_response_code($response); |
|
121 | + $responseData = (array) json_decode($responseBody, true); |
|
122 | + $this->response = array_shift($responseData); |
|
123 | + $this->message = Arr::get($this->response, 'msg'); |
|
124 | + $this->success = 'success' === Arr::get($this->response, 'result') || 'yes' === Arr::get($this->response, 'success'); // @todo remove this ugly hack! |
|
125 | + if (200 !== $responseCode) { |
|
126 | + glsr_log()->error('Bad response code ['.$responseCode.']'); |
|
127 | + } |
|
128 | + if (!$this->success) { |
|
129 | + glsr_log()->error($this->message); |
|
130 | + } |
|
131 | + } |
|
132 | + } |
|
133 | 133 | |
134 | - /** |
|
135 | - * @param string $endpoint |
|
136 | - * @return void |
|
137 | - */ |
|
138 | - protected function send($endpoint, array $args = []) |
|
139 | - { |
|
140 | - $args = wp_parse_args($args, [ |
|
141 | - 'body' => null, |
|
142 | - 'headers' => ['Content-Type' => 'application/x-www-form-urlencoded'], |
|
143 | - 'redirection' => 5, |
|
144 | - 'sslverify' => false, |
|
145 | - 'timeout' => 5, |
|
146 | - ]); |
|
147 | - $this->reset(); |
|
148 | - $this->handleResponse( |
|
149 | - wp_remote_post(trailingslashit(static::API_URL).$endpoint, $args) |
|
150 | - ); |
|
151 | - } |
|
134 | + /** |
|
135 | + * @param string $endpoint |
|
136 | + * @return void |
|
137 | + */ |
|
138 | + protected function send($endpoint, array $args = []) |
|
139 | + { |
|
140 | + $args = wp_parse_args($args, [ |
|
141 | + 'body' => null, |
|
142 | + 'headers' => ['Content-Type' => 'application/x-www-form-urlencoded'], |
|
143 | + 'redirection' => 5, |
|
144 | + 'sslverify' => false, |
|
145 | + 'timeout' => 5, |
|
146 | + ]); |
|
147 | + $this->reset(); |
|
148 | + $this->handleResponse( |
|
149 | + wp_remote_post(trailingslashit(static::API_URL).$endpoint, $args) |
|
150 | + ); |
|
151 | + } |
|
152 | 152 | } |
@@ -20,25 +20,25 @@ discard block |
||
20 | 20 | /** |
21 | 21 | * @return mixed |
22 | 22 | */ |
23 | - public function __get($key) |
|
23 | + public function __get( $key ) |
|
24 | 24 | { |
25 | - return property_exists($this, $key) |
|
25 | + return property_exists( $this, $key ) |
|
26 | 26 | ? $this->$key |
27 | - : Arr::get($this->response, $key, null); |
|
27 | + : Arr::get( $this->response, $key, null ); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
31 | 31 | * @return self |
32 | 32 | */ |
33 | - public function activateKey($apiKey = '', $email = '') |
|
33 | + public function activateKey( $apiKey = '', $email = '' ) |
|
34 | 34 | { |
35 | - $this->send('api_key_activation.php', [ |
|
35 | + $this->send( 'api_key_activation.php', [ |
|
36 | 36 | 'body' => [ |
37 | 37 | 'apikey' => $apiKey ?: 0, |
38 | 38 | 'domain' => get_home_url(), |
39 | 39 | 'email' => $email ?: 0, |
40 | 40 | ], |
41 | - ]); |
|
41 | + ] ); |
|
42 | 42 | return $this; |
43 | 43 | } |
44 | 44 | |
@@ -56,77 +56,77 @@ discard block |
||
56 | 56 | /** |
57 | 57 | * @return self |
58 | 58 | */ |
59 | - public function sendReview(Review $review) |
|
59 | + public function sendReview( Review $review ) |
|
60 | 60 | { |
61 | - $this->send('index.php', [ |
|
62 | - 'body' => $this->getBodyForReview($review), |
|
61 | + $this->send( 'index.php', [ |
|
62 | + 'body' => $this->getBodyForReview( $review ), |
|
63 | 63 | 'timeout' => 120, |
64 | - ]); |
|
64 | + ] ); |
|
65 | 65 | return $this; |
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
69 | 69 | * @return self |
70 | 70 | */ |
71 | - public function sendReviewResponse(Review $review) |
|
71 | + public function sendReviewResponse( Review $review ) |
|
72 | 72 | { |
73 | - $this->send('fetch_customer_reply.php', [ |
|
74 | - 'body' => $this->getBodyForResponse($review), |
|
75 | - ]); |
|
73 | + $this->send( 'fetch_customer_reply.php', [ |
|
74 | + 'body' => $this->getBodyForResponse( $review ), |
|
75 | + ] ); |
|
76 | 76 | return $this; |
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
80 | 80 | * @return array |
81 | 81 | */ |
82 | - protected function getBodyForResponse(Review $review) |
|
82 | + protected function getBodyForResponse( Review $review ) |
|
83 | 83 | { |
84 | 84 | $rebusifyResponse = [ |
85 | - 'reply' => Str::truncate($review->response, 300), |
|
86 | - 'review_id' => glsr(Database::class)->get($review->ID, 'rebusify'), // this is the rebusify review ID |
|
85 | + 'reply' => Str::truncate( $review->response, 300 ), |
|
86 | + 'review_id' => glsr( Database::class )->get( $review->ID, 'rebusify' ), // this is the rebusify review ID |
|
87 | 87 | 'review_transaction_id' => $review->review_id, |
88 | 88 | 'type' => 'M', |
89 | 89 | ]; |
90 | - return apply_filters('site-reviews/rebusify/response', $rebusifyResponse, $review); |
|
90 | + return apply_filters( 'site-reviews/rebusify/response', $rebusifyResponse, $review ); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
94 | 94 | * @return array |
95 | 95 | */ |
96 | - protected function getBodyForReview(Review $review) |
|
96 | + protected function getBodyForReview( Review $review ) |
|
97 | 97 | { |
98 | 98 | $rebusifyReview = [ |
99 | 99 | 'domain' => get_home_url(), |
100 | - 'firstname' => Str::truncate(Str::convertName($review->author, 'first'), 25), |
|
100 | + 'firstname' => Str::truncate( Str::convertName( $review->author, 'first' ), 25 ), |
|
101 | 101 | 'rate' => $review->rating, |
102 | 102 | 'review_transaction_id' => $review->review_id, |
103 | - 'reviews' => Str::truncate($review->content, 280), |
|
104 | - 'title' => Str::truncate($review->title, 35), |
|
103 | + 'reviews' => Str::truncate( $review->content, 280 ), |
|
104 | + 'title' => Str::truncate( $review->title, 35 ), |
|
105 | 105 | 'transaction' => Application::ID, // woocommerce field, not needed for Site Reviews |
106 | 106 | ]; |
107 | - return apply_filters('site-reviews/rebusify/review', $rebusifyReview, $review); |
|
107 | + return apply_filters( 'site-reviews/rebusify/review', $rebusifyReview, $review ); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |
111 | 111 | * @param \WP_Error|array $response |
112 | 112 | * @return void |
113 | 113 | */ |
114 | - protected function handleResponse($response) |
|
114 | + protected function handleResponse( $response ) |
|
115 | 115 | { |
116 | - if (is_wp_error($response)) { |
|
116 | + if( is_wp_error( $response ) ) { |
|
117 | 117 | $this->message = $response->get_error_message(); |
118 | 118 | } else { |
119 | - $responseBody = wp_remote_retrieve_body($response); |
|
120 | - $responseCode = wp_remote_retrieve_response_code($response); |
|
121 | - $responseData = (array) json_decode($responseBody, true); |
|
122 | - $this->response = array_shift($responseData); |
|
123 | - $this->message = Arr::get($this->response, 'msg'); |
|
124 | - $this->success = 'success' === Arr::get($this->response, 'result') || 'yes' === Arr::get($this->response, 'success'); // @todo remove this ugly hack! |
|
125 | - if (200 !== $responseCode) { |
|
126 | - glsr_log()->error('Bad response code ['.$responseCode.']'); |
|
119 | + $responseBody = wp_remote_retrieve_body( $response ); |
|
120 | + $responseCode = wp_remote_retrieve_response_code( $response ); |
|
121 | + $responseData = (array)json_decode( $responseBody, true ); |
|
122 | + $this->response = array_shift( $responseData ); |
|
123 | + $this->message = Arr::get( $this->response, 'msg' ); |
|
124 | + $this->success = 'success' === Arr::get( $this->response, 'result' ) || 'yes' === Arr::get( $this->response, 'success' ); // @todo remove this ugly hack! |
|
125 | + if( 200 !== $responseCode ) { |
|
126 | + glsr_log()->error( 'Bad response code ['.$responseCode.']' ); |
|
127 | 127 | } |
128 | - if (!$this->success) { |
|
129 | - glsr_log()->error($this->message); |
|
128 | + if( !$this->success ) { |
|
129 | + glsr_log()->error( $this->message ); |
|
130 | 130 | } |
131 | 131 | } |
132 | 132 | } |
@@ -135,18 +135,18 @@ discard block |
||
135 | 135 | * @param string $endpoint |
136 | 136 | * @return void |
137 | 137 | */ |
138 | - protected function send($endpoint, array $args = []) |
|
138 | + protected function send( $endpoint, array $args = [] ) |
|
139 | 139 | { |
140 | - $args = wp_parse_args($args, [ |
|
140 | + $args = wp_parse_args( $args, [ |
|
141 | 141 | 'body' => null, |
142 | 142 | 'headers' => ['Content-Type' => 'application/x-www-form-urlencoded'], |
143 | 143 | 'redirection' => 5, |
144 | 144 | 'sslverify' => false, |
145 | 145 | 'timeout' => 5, |
146 | - ]); |
|
146 | + ] ); |
|
147 | 147 | $this->reset(); |
148 | 148 | $this->handleResponse( |
149 | - wp_remote_post(trailingslashit(static::API_URL).$endpoint, $args) |
|
149 | + wp_remote_post( trailingslashit( static::API_URL ).$endpoint, $args ) |
|
150 | 150 | ); |
151 | 151 | } |
152 | 152 | } |
@@ -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=site-review&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=site-review&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,4 +1,4 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <p class="about-description">If you are using any Site Reviews code snippets or have built any custom integrations with Site Reviews, please make sure to read this upgrade guide.</p> |
4 | 4 | <div class="is-fullwidth"> |
@@ -1,3 +1,3 @@ |
||
1 | 1 | <div class="notice notice-warning is-dismissible"> |
2 | - <p><?= __('Expect to see these add-ons released in the coming months! Thank you again for your continued patience.', 'site-reviews'); ?></p> |
|
2 | + <p><?= __( 'Expect to see these add-ons released in the coming months! Thank you again for your continued patience.', 'site-reviews' ); ?></p> |
|
3 | 3 | </div> |
@@ -9,65 +9,65 @@ |
||
9 | 9 | |
10 | 10 | class Reviews extends ArrayObject |
11 | 11 | { |
12 | - /** |
|
13 | - * @var array |
|
14 | - */ |
|
15 | - public $args; |
|
12 | + /** |
|
13 | + * @var array |
|
14 | + */ |
|
15 | + public $args; |
|
16 | 16 | |
17 | - /** |
|
18 | - * @var int |
|
19 | - */ |
|
20 | - public $max_num_pages; |
|
17 | + /** |
|
18 | + * @var int |
|
19 | + */ |
|
20 | + public $max_num_pages; |
|
21 | 21 | |
22 | - /** |
|
23 | - * @var array |
|
24 | - */ |
|
25 | - public $reviews; |
|
22 | + /** |
|
23 | + * @var array |
|
24 | + */ |
|
25 | + public $reviews; |
|
26 | 26 | |
27 | - public function __construct(array $reviews, $maxPageCount, array $args) |
|
28 | - { |
|
29 | - $this->args = $args; |
|
30 | - $this->max_num_pages = $maxPageCount; |
|
31 | - $this->reviews = $reviews; |
|
32 | - parent::__construct($reviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS); |
|
33 | - } |
|
27 | + public function __construct(array $reviews, $maxPageCount, array $args) |
|
28 | + { |
|
29 | + $this->args = $args; |
|
30 | + $this->max_num_pages = $maxPageCount; |
|
31 | + $this->reviews = $reviews; |
|
32 | + parent::__construct($reviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS); |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * @return string |
|
37 | - */ |
|
38 | - public function __toString() |
|
39 | - { |
|
40 | - return (string) $this->build(); |
|
41 | - } |
|
35 | + /** |
|
36 | + * @return string |
|
37 | + */ |
|
38 | + public function __toString() |
|
39 | + { |
|
40 | + return (string) $this->build(); |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * @return ReviewsHtml |
|
45 | - */ |
|
46 | - public function build() |
|
47 | - { |
|
48 | - $args = glsr(SiteReviewsDefaults::class)->merge($this->args); |
|
49 | - return glsr(SiteReviewsPartial::class)->build($args, $this); |
|
50 | - } |
|
43 | + /** |
|
44 | + * @return ReviewsHtml |
|
45 | + */ |
|
46 | + public function build() |
|
47 | + { |
|
48 | + $args = glsr(SiteReviewsDefaults::class)->merge($this->args); |
|
49 | + return glsr(SiteReviewsPartial::class)->build($args, $this); |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * @param mixed $key |
|
54 | - * @return mixed |
|
55 | - */ |
|
56 | - public function offsetGet($key) |
|
57 | - { |
|
58 | - if (property_exists($this, $key)) { |
|
59 | - return $this->$key; |
|
60 | - } |
|
61 | - return array_key_exists($key, $this->reviews) |
|
62 | - ? $this->reviews[$key] |
|
63 | - : null; |
|
64 | - } |
|
52 | + /** |
|
53 | + * @param mixed $key |
|
54 | + * @return mixed |
|
55 | + */ |
|
56 | + public function offsetGet($key) |
|
57 | + { |
|
58 | + if (property_exists($this, $key)) { |
|
59 | + return $this->$key; |
|
60 | + } |
|
61 | + return array_key_exists($key, $this->reviews) |
|
62 | + ? $this->reviews[$key] |
|
63 | + : null; |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * @return void |
|
68 | - */ |
|
69 | - public function render() |
|
70 | - { |
|
71 | - echo $this->build(); |
|
72 | - } |
|
66 | + /** |
|
67 | + * @return void |
|
68 | + */ |
|
69 | + public function render() |
|
70 | + { |
|
71 | + echo $this->build(); |
|
72 | + } |
|
73 | 73 | } |
@@ -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 (property_exists($this, $key)) { |
|
58 | + if( property_exists( $this, $key ) ) { |
|
59 | 59 | return $this->$key; |
60 | 60 | } |
61 | - return array_key_exists($key, $this->reviews) |
|
61 | + return array_key_exists( $key, $this->reviews ) |
|
62 | 62 | ? $this->reviews[$key] |
63 | 63 | : null; |
64 | 64 | } |