Skip to content

Commit dc55cf1

Browse files
chore: address plugin check warnings
1 parent d6ca2f0 commit dc55cf1

26 files changed

Lines changed: 130 additions & 62 deletions

assets/css/index.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22

3-
if( ! defined( 'STB::VERSION' ) ) {
4-
header( 'Status: 403 Forbidden' );
5-
header( 'HTTP/1.1 403 Forbidden' );
3+
if ( ! defined( 'ABSPATH' ) ) {
64
exit;
7-
}
5+
}

assets/img/index.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
2-
if( ! defined( 'STB::VERSION' ) ) {
3-
header( 'Status: 403 Forbidden' );
4-
header( 'HTTP/1.1 403 Forbidden' );
2+
3+
if ( ! defined( 'ABSPATH' ) ) {
54
exit;
6-
}
5+
}

assets/index.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
2-
if( ! defined( 'STB::VERSION' ) ) {
3-
header( 'Status: 403 Forbidden' );
4-
header( 'HTTP/1.1 403 Forbidden' );
2+
3+
if ( ! defined( 'ABSPATH' ) ) {
54
exit;
6-
}
5+
}

assets/js/index.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
<?php exit; ?>
1+
<?php
2+
3+
if ( ! defined( 'ABSPATH' ) ) {
4+
exit;
5+
}

autoload.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<?php
22

3+
if ( ! defined( 'ABSPATH' ) ) {
4+
exit;
5+
}
6+
37
require __DIR__ . '/src/functions.php';
48

59
spl_autoload_register(function ($class) {

bin/create-package

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,10 @@ zip -r "$PACKAGE_FILE" "$PLUGIN_SLUG" \
5454
-x "$PLUGIN_SLUG/*.json" \
5555
-x "$PLUGIN_SLUG/*.lock" \
5656
-x "$PLUGIN_SLUG/phpcs.xml" \
57+
-x "$PLUGIN_SLUG/phpcs.xml.dist" \
5758
-x "$PLUGIN_SLUG/phpunit.xml.dist" \
58-
-x "$PLUGIN_SLUG/bin" \
59+
-x "$PLUGIN_SLUG/phpstan.neon.dist" \
60+
-x "$PLUGIN_SLUG/bin/*" \
5961
-x "$PLUGIN_SLUG/assets/src/*" \
6062
-x "$PLUGIN_SLUG/sample-code-snippets/*"
6163

bin/release_addon.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,16 @@ zip -r "$PACKAGE_FILE" "$PLUGIN_DIR" \
5353
-x "$PLUGIN_DIR/.*" \
5454
-x "$PLUGIN_DIR/vendor/*" \
5555
-x "$PLUGIN_DIR/node_modules/*" \
56+
-x "$PLUGIN_DIR/bin/*" \
5657
-x "$PLUGIN_DIR/gulpfile.js" \
57-
-x "$PLUGIN_DIR/tests" \
58+
-x "$PLUGIN_DIR/tests/*" \
5859
-x "$PLUGIN_DIR/webpack.config*.js" \
59-
-x "$PLUGIN_DIR/*.json" \
60+
-x "$PLUGIN_DIR/*.json" \
6061
-x "$PLUGIN_DIR/*.lock" \
62+
-x "$PLUGIN_DIR/phpcs.xml.dist" \
63+
-x "$PLUGIN_DIR/phpunit.xml.dist" \
6164
-x "$PLUGIN_DIR/*.xml" \
65+
-x "$PLUGIN_DIR/phpstan.neon.dist" \
6266
-x "$PLUGIN_DIR/assets/src/*"
6367

6468
SIZE=$(stat --printf="%s" "$PACKAGE_FILE")

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
],
3838
"check-syntax": "find . -name '*.php' -not -path './vendor/*' -not -path './node_modules/*' -print0 | xargs -0 -n1 php -l",
3939
"check-codestyle": "vendor/bin/phpcs -sn",
40+
"check-plugin": "wp plugin check boxzilla --mode=update --ignore-warnings --ignore-codes=hidden_files,application_detected",
4041
"static-analysis": "vendor/bin/phpstan analyse",
4142
"test": "vendor/bin/phpunit"
4243
},

src/admin/class-admin.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
use WP_Post;
99
use WP_Screen;
1010

11+
if (! defined('ABSPATH')) {
12+
exit;
13+
}
14+
1115
class Admin
1216
{
1317
/**
@@ -184,7 +188,7 @@ public function lazy_add_hooks()
184188
*/
185189
public function post_type_column_box_id_content($post_id)
186190
{
187-
echo $post_id;
191+
echo absint($post_id);
188192
}
189193

190194
/**

src/admin/class-autocomplete.php

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
namespace Boxzilla\Filter;
44

5+
if (! defined('ABSPATH')) {
6+
exit;
7+
}
8+
59
class Autocomplete
610
{
711
public function init(): void
@@ -27,19 +31,19 @@ public function ajax(): void
2731
default:
2832
case 'post':
2933
case 'page':
30-
echo $this->list_posts($q, $type);
34+
echo esc_html($this->list_posts($q, $type));
3135
break;
3236

3337
case 'category':
34-
echo $this->list_categories($q);
38+
echo esc_html($this->list_categories($q));
3539
break;
3640

3741
case 'post_type':
38-
echo $this->list_post_types($q);
42+
echo esc_html($this->list_post_types($q));
3943
break;
4044

4145
case 'post_tag':
42-
echo $this->list_tags($q);
46+
echo esc_html($this->list_tags($q));
4347
break;
4448
}
4549

@@ -55,8 +59,14 @@ public function ajax(): void
5559
protected function list_posts($query, $post_type = 'post')
5660
{
5761
global $wpdb;
58-
$sql = $wpdb->prepare("SELECT p.post_name FROM $wpdb->posts p WHERE p.post_type = %s AND p.post_status = 'publish' AND ( p.post_title LIKE %s OR p.post_name LIKE %s ) GROUP BY p.post_name", $post_type, $query . '%%', $query . '%%');
59-
$post_slugs = $wpdb->get_col($sql);
62+
$post_slugs = $wpdb->get_col(
63+
$wpdb->prepare(
64+
"SELECT p.post_name FROM $wpdb->posts p WHERE p.post_type = %s AND p.post_status = 'publish' AND ( p.post_title LIKE %s OR p.post_name LIKE %s ) GROUP BY p.post_name",
65+
$post_type,
66+
$query . '%%',
67+
$query . '%%'
68+
)
69+
);
6070
return join(PHP_EOL, $post_slugs);
6171
}
6272

0 commit comments

Comments
 (0)