@@ -12,10 +12,10 @@ |
||
12 | 12 | */ |
13 | 13 | public function handle( Command $command ) |
14 | 14 | { |
15 | - if( !get_post( $command->id )) { |
|
15 | + if( !get_post( $command->id ) ) { |
|
16 | 16 | return false; |
17 | 17 | } |
18 | - if( is_null( $command->pinned )) { |
|
18 | + if( is_null( $command->pinned ) ) { |
|
19 | 19 | $meta = get_post_meta( $command->id, 'pinned', true ); |
20 | 20 | $command->pinned = !wp_validate_boolean( $meta ); |
21 | 21 | } |
@@ -13,7 +13,7 @@ |
||
13 | 13 | public function build( $partialPath, array $args = [] ) |
14 | 14 | { |
15 | 15 | $className = glsr( Helper::class )->buildClassName( $partialPath, 'Modules\Html\Partials' ); |
16 | - if( !class_exists( $className )) { |
|
16 | + if( !class_exists( $className ) ) { |
|
17 | 17 | glsr_log()->error( 'Partial missing: '.$className ); |
18 | 18 | return; |
19 | 19 | } |
@@ -10,7 +10,7 @@ |
||
10 | 10 | public function __construct( $input ) |
11 | 11 | { |
12 | 12 | $this->id = $input['id']; |
13 | - $this->pinned = isset( $input['pinned'] ) |
|
13 | + $this->pinned = isset($input['pinned']) |
|
14 | 14 | ? wp_validate_boolean( $input['pinned'] ) |
15 | 15 | : null; |
16 | 16 | } |
@@ -31,7 +31,7 @@ |
||
31 | 31 | $diff = time() - strtotime( $date ); |
32 | 32 | foreach( static::$TIME_PERIODS as $i => $timePeriod ) { |
33 | 33 | if( $diff > $timePeriod[0] )continue; |
34 | - $unit = intval( floor( $diff / $timePeriod[1] )); |
|
34 | + $unit = intval( floor( $diff / $timePeriod[1] ) ); |
|
35 | 35 | $relativeDates = [ |
36 | 36 | _n( '%s second ago', '%s seconds ago', $unit, 'site-reviews' ), |
37 | 37 | _n( '%s minute ago', '%s minutes ago', $unit, 'site-reviews' ), |
@@ -30,7 +30,9 @@ |
||
30 | 30 | { |
31 | 31 | $diff = time() - strtotime( $date ); |
32 | 32 | foreach( static::$TIME_PERIODS as $i => $timePeriod ) { |
33 | - if( $diff > $timePeriod[0] )continue; |
|
33 | + if( $diff > $timePeriod[0] ) { |
|
34 | + continue; |
|
35 | + } |
|
34 | 36 | $unit = intval( floor( $diff / $timePeriod[1] )); |
35 | 37 | $relativeDates = [ |
36 | 38 | _n( '%s second ago', '%s seconds ago', $unit, 'site-reviews' ), |
@@ -22,7 +22,8 @@ |
||
22 | 22 | protected $public; |
23 | 23 | protected $translator; |
24 | 24 | |
25 | - public function __construct( Application $app ) { |
|
25 | + public function __construct( Application $app ) |
|
26 | + { |
|
26 | 27 | $this->app = $app; |
27 | 28 | $this->admin = $app->make( AdminController::class ); |
28 | 29 | $this->basename = plugin_basename( $app->file ); |
@@ -41,33 +41,33 @@ |
||
41 | 41 | */ |
42 | 42 | public function run() |
43 | 43 | { |
44 | - add_filter( 'map_meta_cap', [$this->admin, 'filterCreateCapability'], 10, 2 ); |
|
45 | - add_filter( 'mce_external_plugins', [$this->admin, 'filterTinymcePlugins'], 15 ); |
|
46 | - add_filter( 'plugin_action_links_'.$this->basename, [$this->admin, 'filterActionLinks'] ); |
|
47 | - add_filter( 'dashboard_glance_items', [$this->admin, 'filterDashboardGlanceItems'] ); |
|
48 | - add_filter( 'block_categories', [$this->blocks, 'filterBlockCategories'] ); |
|
49 | - add_filter( 'classic_editor_enabled_editors_for_post_type', [$this->blocks, 'filterEnabledEditors'], 10, 2 ); |
|
50 | - add_filter( 'use_block_editor_for_post_type', [$this->blocks, 'filterUseBlockEditor'], 10, 2 ); |
|
51 | - add_filter( 'wp_editor_settings', [$this->editor, 'filterEditorSettings'] ); |
|
52 | - add_filter( 'the_editor', [$this->editor, 'filterEditorTextarea'] ); |
|
53 | - add_filter( 'gettext', [$this->editor, 'filterPostStatusLabels'], 10, 3 ); |
|
54 | - add_filter( 'gettext_with_context', [$this->editor, 'filterPostStatusLabelsWithContext'], 10, 4 ); |
|
55 | - add_filter( 'post_updated_messages', [$this->editor, 'filterUpdateMessages'] ); |
|
56 | - add_filter( 'bulk_post_updated_messages', [$this->listtable, 'filterBulkUpdateMessages'], 10, 2 ); |
|
57 | - add_filter( 'manage_'.Application::POST_TYPE.'_posts_columns', [$this->listtable, 'filterColumnsForPostType'] ); |
|
58 | - add_filter( 'post_date_column_status', [$this->listtable, 'filterDateColumnStatus'], 10, 2 ); |
|
59 | - add_filter( 'default_hidden_columns', [$this->listtable, 'filterDefaultHiddenColumns'], 10, 2 ); |
|
60 | - add_filter( 'display_post_states', [$this->listtable, 'filterPostStates'], 10, 2 ); |
|
61 | - add_filter( 'post_row_actions', [$this->listtable, 'filterRowActions'], 10, 2 ); |
|
44 | + add_filter( 'map_meta_cap', [$this->admin, 'filterCreateCapability'], 10, 2 ); |
|
45 | + add_filter( 'mce_external_plugins', [$this->admin, 'filterTinymcePlugins'], 15 ); |
|
46 | + add_filter( 'plugin_action_links_'.$this->basename, [$this->admin, 'filterActionLinks'] ); |
|
47 | + add_filter( 'dashboard_glance_items', [$this->admin, 'filterDashboardGlanceItems'] ); |
|
48 | + add_filter( 'block_categories', [$this->blocks, 'filterBlockCategories'] ); |
|
49 | + add_filter( 'classic_editor_enabled_editors_for_post_type', [$this->blocks, 'filterEnabledEditors'], 10, 2 ); |
|
50 | + add_filter( 'use_block_editor_for_post_type', [$this->blocks, 'filterUseBlockEditor'], 10, 2 ); |
|
51 | + add_filter( 'wp_editor_settings', [$this->editor, 'filterEditorSettings'] ); |
|
52 | + add_filter( 'the_editor', [$this->editor, 'filterEditorTextarea'] ); |
|
53 | + add_filter( 'gettext', [$this->editor, 'filterPostStatusLabels'], 10, 3 ); |
|
54 | + add_filter( 'gettext_with_context', [$this->editor, 'filterPostStatusLabelsWithContext'], 10, 4 ); |
|
55 | + add_filter( 'post_updated_messages', [$this->editor, 'filterUpdateMessages'] ); |
|
56 | + add_filter( 'bulk_post_updated_messages', [$this->listtable, 'filterBulkUpdateMessages'], 10, 2 ); |
|
57 | + add_filter( 'manage_'.Application::POST_TYPE.'_posts_columns', [$this->listtable, 'filterColumnsForPostType'] ); |
|
58 | + add_filter( 'post_date_column_status', [$this->listtable, 'filterDateColumnStatus'], 10, 2 ); |
|
59 | + add_filter( 'default_hidden_columns', [$this->listtable, 'filterDefaultHiddenColumns'], 10, 2 ); |
|
60 | + add_filter( 'display_post_states', [$this->listtable, 'filterPostStates'], 10, 2 ); |
|
61 | + add_filter( 'post_row_actions', [$this->listtable, 'filterRowActions'], 10, 2 ); |
|
62 | 62 | add_filter( 'manage_edit-'.Application::POST_TYPE.'_sortable_columns', [$this->listtable, 'filterSortableColumns'] ); |
63 | - add_filter( 'ngettext', [$this->listtable, 'filterStatusText'], 10, 5 ); |
|
64 | - add_filter( 'script_loader_tag', [$this->public, 'filterEnqueuedScripts'], 10, 2 ); |
|
65 | - add_filter( 'site-reviews/config/forms/submission-form', [$this->public, 'filterFieldOrder'], 11 ); |
|
66 | - add_filter( 'query_vars', [$this->public, 'filterQueryVars'] ); |
|
67 | - add_filter( 'site-reviews/render/view', [$this->public, 'filterRenderView'] ); |
|
68 | - add_filter( 'gettext', [$this->translator, 'filterGettext'], 10, 3 ); |
|
69 | - add_filter( 'gettext_with_context', [$this->translator, 'filterGettextWithContext'], 10, 4 ); |
|
70 | - add_filter( 'ngettext', [$this->translator, 'filterNgettext'], 10, 5 ); |
|
71 | - add_filter( 'ngettext_with_context', [$this->translator, 'filterNgettextWithContext'], 10, 6 ); |
|
63 | + add_filter( 'ngettext', [$this->listtable, 'filterStatusText'], 10, 5 ); |
|
64 | + add_filter( 'script_loader_tag', [$this->public, 'filterEnqueuedScripts'], 10, 2 ); |
|
65 | + add_filter( 'site-reviews/config/forms/submission-form', [$this->public, 'filterFieldOrder'], 11 ); |
|
66 | + add_filter( 'query_vars', [$this->public, 'filterQueryVars'] ); |
|
67 | + add_filter( 'site-reviews/render/view', [$this->public, 'filterRenderView'] ); |
|
68 | + add_filter( 'gettext', [$this->translator, 'filterGettext'], 10, 3 ); |
|
69 | + add_filter( 'gettext_with_context', [$this->translator, 'filterGettextWithContext'], 10, 4 ); |
|
70 | + add_filter( 'ngettext', [$this->translator, 'filterNgettext'], 10, 5 ); |
|
71 | + add_filter( 'ngettext_with_context', [$this->translator, 'filterNgettextWithContext'], 10, 6 ); |
|
72 | 72 | } |
73 | 73 | } |
@@ -10,7 +10,7 @@ |
||
10 | 10 | const EXPIRY_TIME = WEEK_IN_SECONDS; |
11 | 11 | |
12 | 12 | /** |
13 | - * @return array |
|
13 | + * @return array |
|
14 | 14 | */ |
15 | 15 | public function getCloudflareIps() |
16 | 16 | { |
@@ -20,16 +20,16 @@ discard block |
||
20 | 20 | foreach( array_keys( $ipAddresses ) as $version ) { |
21 | 21 | $url = 'https://www.cloudflare.com/ips-'.$version; |
22 | 22 | $response = wp_remote_get( $url ); |
23 | - if( is_wp_error( $response )) { |
|
23 | + if( is_wp_error( $response ) ) { |
|
24 | 24 | glsr_log()->error( $response->get_error_message() ); |
25 | 25 | continue; |
26 | 26 | } |
27 | - if(( $statusCode = wp_remote_retrieve_response_code( $response )) != '200' ) { |
|
27 | + if( ($statusCode = wp_remote_retrieve_response_code( $response )) != '200' ) { |
|
28 | 28 | glsr_log()->error( 'Unable to connect to '.$url.' ['.$statusCode.']' ); |
29 | 29 | continue; |
30 | 30 | } |
31 | 31 | $ipAddresses[$version] = array_filter( |
32 | - (array)preg_split( '/\R/', wp_remote_retrieve_body( $response )) |
|
32 | + (array)preg_split( '/\R/', wp_remote_retrieve_body( $response ) ) |
|
33 | 33 | ); |
34 | 34 | } |
35 | 35 | set_transient( Application::ID.'_cloudflare_ips', $ipAddresses, static::EXPIRY_TIME ); |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | if( $test === false ) { |
65 | 65 | $response = wp_remote_post( 'https://api.wordpress.org/stats/php/1.0/' ); |
66 | 66 | $test = !is_wp_error( $response ) |
67 | - && in_array( $response['response']['code'], range( 200, 299 )) |
|
67 | + && in_array( $response['response']['code'], range( 200, 299 ) ) |
|
68 | 68 | ? 'Works' |
69 | 69 | : 'Does not work'; |
70 | 70 | set_transient( Application::ID.'_remote_post_test', $test, static::EXPIRY_TIME ); |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php defined( 'WPINC' ) || die; |
2 | 2 | |
3 | -include trailingslashit(__DIR__).'header.php'; |
|
4 | -include trailingslashit(__DIR__).'body.php'; |
|
5 | -include trailingslashit(__DIR__).'footer.php'; |
|
3 | +include trailingslashit( __DIR__ ).'header.php'; |
|
4 | +include trailingslashit( __DIR__ ).'body.php'; |
|
5 | +include trailingslashit( __DIR__ ).'footer.php'; |
@@ -53,7 +53,9 @@ |
||
53 | 53 | protected function normalize( array $settings ) |
54 | 54 | { |
55 | 55 | array_walk( $settings, function( &$setting ) { |
56 | - if( isset( $setting['default'] ))return; |
|
56 | + if( isset( $setting['default'] )) { |
|
57 | + return; |
|
58 | + } |
|
57 | 59 | $setting['default'] = ''; |
58 | 60 | }); |
59 | 61 | return $settings; |
@@ -13,11 +13,11 @@ discard block |
||
13 | 13 | public function defaults() |
14 | 14 | { |
15 | 15 | $settings = $this->settings(); |
16 | - $defaults = array_combine( array_keys( $settings ), glsr_array_column( $settings, 'default' )); |
|
16 | + $defaults = array_combine( array_keys( $settings ), glsr_array_column( $settings, 'default' ) ); |
|
17 | 17 | return wp_parse_args( $defaults, [ |
18 | 18 | 'version' => '', |
19 | 19 | 'version_upgraded_from' => '', |
20 | - ]); |
|
20 | + ] ); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | /** |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function settings() |
48 | 48 | { |
49 | - $settings = apply_filters( 'site-reviews/addon/settings', glsr()->config( 'settings' )); |
|
49 | + $settings = apply_filters( 'site-reviews/addon/settings', glsr()->config( 'settings' ) ); |
|
50 | 50 | return $this->normalize( $settings ); |
51 | 51 | } |
52 | 52 | |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | protected function normalize( array $settings ) |
57 | 57 | { |
58 | 58 | array_walk( $settings, function( &$setting ) { |
59 | - if( isset( $setting['default'] ))return; |
|
59 | + if( isset($setting['default']) )return; |
|
60 | 60 | $setting['default'] = ''; |
61 | 61 | }); |
62 | 62 | return $settings; |
@@ -42,7 +42,9 @@ discard block |
||
42 | 42 | $options = $this->all(); |
43 | 43 | $pointer = &$options; |
44 | 44 | foreach( $keys as $key ) { |
45 | - if( !isset( $pointer[$key] ) || !is_array( $pointer[$key] ))continue; |
|
45 | + if( !isset( $pointer[$key] ) || !is_array( $pointer[$key] )) { |
|
46 | + continue; |
|
47 | + } |
|
46 | 48 | $pointer = &$pointer[$key]; |
47 | 49 | } |
48 | 50 | unset( $pointer[$last] ); |
@@ -77,7 +79,9 @@ discard block |
||
77 | 79 | glsr( DefaultsManager::class )->defaults() |
78 | 80 | ); |
79 | 81 | array_walk( $options, function( &$value ) { |
80 | - if( !is_string( $value ))return; |
|
82 | + if( !is_string( $value )) { |
|
83 | + return; |
|
84 | + } |
|
81 | 85 | $value = wp_kses( $value, wp_kses_allowed_html( 'post' )); |
82 | 86 | }); |
83 | 87 | return glsr( Helper::class )->convertDotNotationArray( $options ); |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function all() |
30 | 30 | { |
31 | - if( empty( $this->options )) { |
|
31 | + if( empty($this->options) ) { |
|
32 | 32 | $this->reset(); |
33 | 33 | } |
34 | 34 | return $this->options; |
@@ -45,10 +45,10 @@ discard block |
||
45 | 45 | $options = $this->all(); |
46 | 46 | $pointer = &$options; |
47 | 47 | foreach( $keys as $key ) { |
48 | - if( !isset( $pointer[$key] ) || !is_array( $pointer[$key] ))continue; |
|
48 | + if( !isset($pointer[$key]) || !is_array( $pointer[$key] ) )continue; |
|
49 | 49 | $pointer = &$pointer[$key]; |
50 | 50 | } |
51 | - unset( $pointer[$last] ); |
|
51 | + unset($pointer[$last]); |
|
52 | 52 | return $this->set( $options ); |
53 | 53 | } |
54 | 54 | |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | public function getWP( $path, $fallback = '' ) |
82 | 82 | { |
83 | 83 | $option = get_option( $path, $fallback ); |
84 | - return empty( $option ) |
|
84 | + return empty($option) |
|
85 | 85 | ? $fallback |
86 | 86 | : $option; |
87 | 87 | } |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | glsr( DefaultsManager::class )->defaults() |
105 | 105 | ); |
106 | 106 | array_walk( $options, function( &$value ) { |
107 | - if( !is_string( $value ))return; |
|
108 | - $value = wp_kses( $value, wp_kses_allowed_html( 'post' )); |
|
107 | + if( !is_string( $value ) )return; |
|
108 | + $value = wp_kses( $value, wp_kses_allowed_html( 'post' ) ); |
|
109 | 109 | }); |
110 | 110 | return glsr( Helper::class )->convertDotNotationArray( $options ); |
111 | 111 | } |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | public function isRecaptchaEnabled() |
117 | 117 | { |
118 | 118 | $integration = $this->get( 'settings.submissions.recaptcha.integration' ); |
119 | - return $integration == 'all' || ( $integration == 'guest' && !is_user_logged_in() ); |
|
119 | + return $integration == 'all' || ($integration == 'guest' && !is_user_logged_in()); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | public function reset() |
126 | 126 | { |
127 | 127 | $options = get_option( static::databaseKey(), [] ); |
128 | - if( !is_array( $options ) || empty( $options )) { |
|
128 | + if( !is_array( $options ) || empty($options) ) { |
|
129 | 129 | delete_option( static::databaseKey() ); |
130 | 130 | $options = wp_parse_args( glsr()->defaults, ['settings' => []] ); |
131 | 131 | } |
@@ -139,10 +139,10 @@ discard block |
||
139 | 139 | */ |
140 | 140 | public function set( $pathOrOptions, $value = '' ) |
141 | 141 | { |
142 | - if( is_string( $pathOrOptions )) { |
|
142 | + if( is_string( $pathOrOptions ) ) { |
|
143 | 143 | $pathOrOptions = glsr( Helper::class )->dataSet( $this->all(), $pathOrOptions, $value ); |
144 | 144 | } |
145 | - if( $result = update_option( static::databaseKey(), (array)$pathOrOptions )) { |
|
145 | + if( $result = update_option( static::databaseKey(), (array)$pathOrOptions ) ) { |
|
146 | 146 | $this->reset(); |
147 | 147 | } |
148 | 148 | return $result; |