Skip to content

Commit fc75ea3

Browse files
committed
finish fixing phpcs wp ruleset 1.x updates
1 parent 5a9ad2f commit fc75ea3

File tree

5 files changed

+42
-27
lines changed

5 files changed

+42
-27
lines changed

.circleci/codesniffer.ruleset.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,7 @@
1111
<exclude name="WordPress.VIP.RestrictedFunctions.get_page_by_title_get_page_by_title" />
1212
</rule>
1313
<rule ref="WordPress-Core"></rule>
14-
<rule ref="WordPress"></rule>
14+
<rule ref="WordPress">
15+
<exclude name="WordPress.WhiteSpace.PrecisionAlignment.Found" />
16+
</rule>
1517
</ruleset>

app/admin/class-navigator.php

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ public static function register_widgets() {
2727
public static function list_sm_pagetree() {
2828
// get and combine child pages and revision.
2929
$memstart2 = \memory_get_usage();
30-
$output = '';
31-
$output .= '<div id="smPagetree"><p><a href="#" id="expand">Expand All</a> | <a href="#" id="collapse">Collapse All</a></p>' . static::get_sm_pagetree( 0, 0 ) . '</div>' . PHP_EOL;
30+
$output = '<div id="smPagetree"><p><a href="#" id="expand">Expand All</a> | <a href="#" id="collapse">Collapse All</a></p>' . static::get_sm_pagetree( 0, 0 ) . '</div>' . PHP_EOL;
3231
$memend2 = \memory_get_usage();
3332
$mem_usage = (float) ( $memend2 - $memstart2 );
3433
if ( defined( 'WP_DEBUG' ) && 'true' === WP_DEBUG ) {
@@ -47,26 +46,31 @@ public static function list_sm_pagetree() {
4746
* @return string
4847
*/
4948
public static function get_sm_pagetree( $parent_id, $lvl ) {
50-
$output = $child_count = '';
51-
$pages = get_pages( [
52-
'child_of' => $parent_id,
53-
'parent' => $parent_id,
54-
'post_type' => 'page',
55-
'post_status' => [ 'publish', 'pending', 'draft', 'private' ],
56-
] );
57-
$post_revisions_query = new \WP_Query( [
58-
'post_parent' => $parent_id,
59-
'post_type' => 'revision',
60-
'post_status' => 'pending',
61-
] );
49+
$output = '';
50+
$child_count = '';
51+
$pages = get_pages(
52+
[
53+
'child_of' => $parent_id,
54+
'parent' => $parent_id,
55+
'post_type' => 'page',
56+
'post_status' => [ 'publish', 'pending', 'draft', 'private' ],
57+
]
58+
);
59+
$post_revisions_query = new \WP_Query(
60+
[
61+
'post_parent' => $parent_id,
62+
'post_type' => 'revision',
63+
'post_status' => 'pending',
64+
]
65+
);
6266
$post_revisions = $post_revisions_query->posts;
6367
$pages = array_merge( (array) $post_revisions, (array) $pages );
6468

6569
if ( $pages ) {
6670
if ( $lvl < 1 ) {
67-
$output .= "<ul id=\"simpletree\" class='level" . $lvl ++ . "'>" . PHP_EOL;
71+
$output .= "<ul id=\"simpletree\" class='level" . ( $lvl ++ ) . "'>" . PHP_EOL;
6872
} else {
69-
$output .= "<ul class='treebranch level" . $lvl ++ . "'>" . PHP_EOL;
73+
$output .= "<ul class='treebranch level" . ( $lvl ++ ) . "'>" . PHP_EOL;
7074
}
7175

7276
// loop through pages and add them to treebranch.
@@ -108,7 +112,7 @@ public static function get_sm_pagetree( $parent_id, $lvl ) {
108112
$output .= 'Placeholder Page ';
109113
}
110114

111-
$rev_author_id = $page->post_author;
115+
$rev_author_id = $page->post_author;
112116
$post_type_object = get_post_type_object( $page->post_type );
113117

114118
if ( current_user_can( 'edit_others_pages' ) || ( $rev_author_id === $GLOBALS['current_user']->ID && current_user_can( 'edit_pages' ) ) ) {

app/class-fe-sitemap.php

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,11 @@ public static function sm_exclude_form() {
9191
?>
9292
<div style="margin-bottom:10px;">
9393
<input type="checkbox" name="sm_sitemap_exclude" id="sm_sitemap_exclude"
94-
value="yes" <?php echo esc_attr( $sm_sitemap_exclude_cb_attr ) ?> >
94+
value="yes" <?php echo esc_attr( $sm_sitemap_exclude_cb_attr ); ?> >
9595
<label for="sm_sitemap_exclude">Display page name in sitemap without link</label>
9696
</div>
9797
<input type="checkbox" name="sm_sitemap_exclude_completely" id="sm_sitemap_exclude_completely"
98-
value="yes" <?php echo esc_attr( $sm_sitemap_exclude_completely_cb_attr ) ?> >
98+
value="yes" <?php echo esc_attr( $sm_sitemap_exclude_completely_cb_attr ); ?> >
9999
<label for="sm_sitemap_exclude_completely">Exclude this page from sitemap</label>
100100
<?php
101101
// Output nonce for verification on submit.
@@ -143,7 +143,10 @@ public static function sm_sitemap_exclude_save() {
143143
public static function sm_pages_recursive( $parent_id, $lvl ) {
144144
$output = '';
145145
// get child pages.
146-
$args = [ 'child_of' => $parent_id, 'parent' => $parent_id ];
146+
$args = [
147+
'child_of' => $parent_id,
148+
'parent' => $parent_id,
149+
];
147150
$pages = get_pages( $args );
148151

149152
if ( $pages ) {
@@ -206,7 +209,11 @@ public static function sm_google_sitemap_recursive( $parent_id, $lvl ) {
206209
// @codingStandardsIgnoreLine get_pages is fine to use ignore rule
207210
$the_pages = get_pages( $args );
208211

209-
$args = [ 'post_parent' => $parent_id, 'post_type' => 'post', 'numberposts' => - 1 ];
212+
$args = [
213+
'post_parent' => $parent_id,
214+
'post_type' => 'post',
215+
'numberposts' => - 1,
216+
];
210217

211218
// @codingStandardsIgnoreLine get_posts is fine to use ignore rule
212219
$the_posts = get_posts( $args );
@@ -242,6 +249,7 @@ public static function sm_google_sitemap_recursive( $parent_id, $lvl ) {
242249
*/
243250
public static function get_sm_google_sitemap() {
244251
$ouput = '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL;
252+
// extend output.
245253
$ouput .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . PHP_EOL;
246254
$ouput .= static::sm_google_sitemap_recursive( 0, 0 ) . PHP_EOL;
247255
$ouput .= '</urlset> ' . PHP_EOL;
@@ -273,6 +281,7 @@ public static function sm_google_sitemap() {
273281
*/
274282
public static function sm_sitemap( $atts, $content = null ) {
275283
$ouput = '<style>' . PHP_EOL;
284+
// extend output.
276285
$ouput .= '#smSitemap h1,#smSitemap h2,#smSitemap h3,#smSitemap h4,#smSitemap h5,#smSitemap h6 { display:inline; }' . PHP_EOL;
277286
$ouput .= '</style>' . PHP_EOL;
278287
$ouput .= '<div id="smSitemap">' . static::sm_pages_recursive( 0, 0 ) . '</div>' . PHP_EOL;
@@ -288,8 +297,8 @@ public static function sm_sitemap( $atts, $content = null ) {
288297
* @return string
289298
*/
290299
public static function get_server_post_param( $key ) {
291-
if ( isset( $_POST[ $key ], $_POST['sm_sitemap_nonce'] )
292-
&& wp_verify_nonce( sanitize_key( $_POST['sm_sitemap_nonce'] ), plugin_basename( __FILE__ ) ) ) {
300+
if ( isset( $_POST[ $key ], $_POST['sm_sitemap_nonce'] ) &&
301+
wp_verify_nonce( sanitize_key( $_POST['sm_sitemap_nonce'] ), plugin_basename( __FILE__ ) ) ) {
293302
return sanitize_text_field( wp_unslash( $_POST[ $key ] ) );
294303
} else {
295304
return false;

lib/wordpress-phoenix/abstract-plugin-base/src/abstract-plugin.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ protected function configure_defaults() {
261261
if ( file_exists( $this->plugin_file ) ) {
262262
$this->installed_url = plugins_url( '/', $this->plugin_file );
263263
// Ensure get_plugin_data is available.
264-
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
264+
require_once ABSPATH . 'wp-admin/includes/plugin.php';
265265
$this->plugin_data = get_plugin_data( $this->plugin_file, $markup = true, $translate = true );
266266
if ( is_array( $this->plugin_data ) && isset( $this->plugin_data['Version'] ) ) {
267267
$this->version = $this->plugin_data['Version'];
@@ -398,7 +398,7 @@ abstract public function onload( $instance );
398398
*/
399399
private function load_file( $path ) {
400400
if ( $path && is_readable( $path ) ) {
401-
include_once( $path );
401+
include_once $path;
402402
$success = true;
403403
}
404404

sm-dashboard-pages-navigator-tree.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@
3636
/**
3737
* INTERNAL DEPENDENCIES (autoloader defined in main plugin class)
3838
*/
39-
include_once $current_dir . 'app/class-plugin.php';
39+
require_once $current_dir . 'app/class-plugin.php';
4040

4141
SM\Pages_Navigator\Plugin::run( __FILE__ );

0 commit comments

Comments
 (0)