Skip to content

Commit 8bfb04e

Browse files
committed
chore(NO-TASK): Testing pre-commit
1 parent b35ded3 commit 8bfb04e

File tree

13 files changed

+2934
-74
lines changed

13 files changed

+2934
-74
lines changed

.distignore

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,12 @@ output.log
4242
phpdoc.dist.xml
4343
release-please-config.json
4444
docker_tag
45-
package.json
45+
package.json
46+
.eslintrc.js
47+
.prettierrc.js
48+
.phpstan.neon.dist.yml
49+
.phpstan.neon.dist
50+
.phpstan-baseline.neon
51+
.phpstan.neon.dist.yml
52+
.phpstan.neon.dist
53+
.phpstan-baseline.neon

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
npx lint-staged
1+
# npx lint-staged

FAQ.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
# Frequently Asked Questions #
1+
# Frequently Asked Questions
22

3-
## Does this plugin work with Full Page Caching or WordPress Object Caching? ##
3+
## Does this plugin work with Full Page Caching or WordPress Object Caching?
44

55
Yes
66

7-
## I'm looking for a specific type of notice that courier doesn't have, what's next? ##
7+
## I'm looking for a specific type of notice that courier doesn't have, what's next?
88

99
The great thing is that Courier Notices is highly extendable and our team is adding new features constantly since release. You can always create a pull request in GitHub or add an issue. You can also take a look at the Pro version which also has some great features.
10+
11+
## Is the compatible with the block editor?
12+
13+
No but our next release v2.0.0 will be

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"name": "linchpin/courier-notices",
33
"description": "Courier Notices, a highly extendable advanced front end notification plugin for WordPress",
44
"homepage": "https://github.com/linchpin/courier-notices",
5-
"version": "1.7.1",
65
"authors": [
76
{
87
"name": "Linchpin",
@@ -85,7 +84,8 @@
8584
"yoast/phpunit-polyfills": "^4.0",
8685
"phpstan/php-8-stubs": "^0.4.0",
8786
"phpstan/phpstan-strict-rules": "^1.6",
88-
"wpackagist-plugin/plugin-check": "^1.5"
87+
"wpackagist-plugin/plugin-check": "^1.5",
88+
"php-stubs/wordpress-stubs": "^6.8"
8989
},
9090
"extra": {
9191
"installer-paths": {

composer.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

includes/Helper/Functions.php

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,25 @@
2020
*
2121
* @param string $notice The notice text.
2222
* @param string|array $types The type(s) of notice.
23-
* @param bool $global Whether this notice is global or not.
23+
* @param bool $is_global Whether this notice is global or not.
2424
* @param bool $dismissible Whether this notice is dismissible or not.
2525
* @param int $user_id The ID of the user this notice is for.
26+
* @param string $style The style of notice.
27+
* @param array $placement The placement of the notice.
2628
*
2729
* @since 1.2.0
2830
*
2931
* @return bool|int Return either false or the Post ID for the created courier_notice.
3032
*/
31-
function courier_notices_add_notice( $notice = '', $types = array( 'Informational' ), $global = false, $dismissible = true, $user_id = 0, $style = 'Informational', $placement = array( 'header' ) ) {
33+
function courier_notices_add_notice(
34+
string $notice = '',
35+
array $types = [ 'Informational' ],
36+
bool $is_global = false,
37+
bool $dismissible = true,
38+
int $user_id = 0,
39+
string $style = 'Informational',
40+
array $placement = [ 'header' ]
41+
) {
3242
$user_id = empty( $user_id ) ? get_current_user_id() : intval( $user_id );
3343

3444
if ( 0 !== $user_id ) {
@@ -70,7 +80,7 @@ function courier_notices_add_notice( $notice = '', $types = array( 'Informationa
7080
wp_set_object_terms( $notice_id, $types, 'courier_type', true );
7181
wp_set_object_terms( $notice_id, $placement, 'courier_placement', true );
7282

73-
if ( $global ) {
83+
if ( $is_global ) {
7484
wp_set_object_terms( $notice_id, array( 'Global' ), 'courier_scope', false );
7585

7686
// Clear the global notice cache.
@@ -134,12 +144,12 @@ function courier_notices_get_global_notices( $args = array() ) {
134144
*
135145
* @since 1.2.0
136146
*
137-
* @param array $args Query Args
147+
* @param array $args Query Args.
138148
* @param bool $ids_only Whether to return only IDs.
139149
*
140150
* @return array|bool|mixed
141151
*/
142-
function courier_notices_get_dismissible_global_notices( $args = array(), $ids_only = false ) {
152+
function courier_notices_get_dismissible_global_notices( array $args = [], bool $ids_only = false ) {
143153
$data = new Courier_Notice_Data();
144154

145155
return $data->get_dismissible_global_notices( $args, $ids_only );
@@ -155,7 +165,7 @@ function courier_notices_get_dismissible_global_notices( $args = array(), $ids_o
155165
*
156166
* @return array|bool|mixed
157167
*/
158-
function courier_notices_get_persistent_global_notices( $args = array() ) {
168+
function courier_notices_get_persistent_global_notices( array $args = [] ) {
159169
$data = new Courier_Notice_Data();
160170

161171
return $data->get_persistent_global_notices( $args );
@@ -310,24 +320,24 @@ function courier_notices_get_global_dismissed_notices( $user_id = 0 ) {
310320
* @return bool True if any notices exist, false otherwise.
311321
*/
312322
function courier_notices_has_any_notices( $user_id = 0 ) {
313-
// Check cache first
323+
// Check cache first.
314324
$cache_key = 'courier_has_notices_' . $user_id;
315325
$cached = wp_cache_get( $cache_key, 'courier-notices' );
316-
326+
317327
if ( false !== $cached ) {
318328
return (bool) $cached;
319329
}
320-
321-
// Quick check for any published notices
330+
331+
// Quick check for any published notices.
322332
$args = array(
323333
'post_type' => 'courier_notice',
324334
'post_status' => 'publish',
325335
'posts_per_page' => 1,
326336
'fields' => 'ids',
327337
'no_found_rows' => true,
328338
);
329-
330-
// If user ID provided, check for user-specific notices
339+
340+
// If user ID provided, check for user-specific notices.
331341
if ( $user_id ) {
332342
$args['tax_query'] = array(
333343
'relation' => 'OR',
@@ -343,13 +353,13 @@ function courier_notices_has_any_notices( $user_id = 0 ) {
343353
),
344354
);
345355
}
346-
347-
$query = new WP_Query( $args );
356+
357+
$query = new WP_Query( $args );
348358
$has_notices = $query->have_posts();
349-
350-
// Cache for 5 minutes
359+
360+
// Cache for 5 minutes.
351361
wp_cache_set( $cache_key, $has_notices, 'courier-notices', 300 );
352-
362+
353363
return $has_notices;
354364
}
355365

@@ -451,7 +461,7 @@ function courier_notices_clear_cache() {
451461
// Clear object cache for courier-notices group.
452462
wp_cache_flush_group( 'courier-notices' );
453463

454-
// Clear has_notices cache for all users
464+
// Clear has_notices cache for all users.
455465
global $wpdb;
456466
$wpdb->query(
457467
"DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_courier_has_notices_%' OR option_name LIKE '_transient_timeout_courier_has_notices_%'"
@@ -518,22 +528,22 @@ function courier_notices_get_css() {
518528
*
519529
* @since 1.3.0
520530
*
521-
* @param $title
522-
* @param string $before
523-
* @param string $after
524-
* @param bool $echo
531+
* @param string $title The title of the notice.
532+
* @param string $before The HTML to display before the title.
533+
* @param string $after The HTML to display after the title.
534+
* @param bool $echo_output Whether to echo the output or return it.
525535
*
526536
* @return mixed|string|void
527537
*/
528-
function courier_notices_the_notice_title( $title, $before = '', $after = '', $echo = true ) {
538+
function courier_notices_the_notice_title( $title, $before = '', $after = '', bool $echo_output = true ) {
529539
if ( 0 === strlen( $title ) ) {
530540
return '';
531541
}
532542

533543
$title = $before . $title . $after;
534544
$title = apply_filters( 'courier_notices_the_notice_title', $title );
535545

536-
if ( $echo ) {
546+
if ( $echo_output ) {
537547
echo wp_kses_post( $title );
538548
} else {
539549
return $title;

lint-staged.config.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* External dependencies
3+
*/
4+
const fs = require("fs");
5+
6+
/**
7+
* @type {import('lint-staged').Configuration}
8+
*/
9+
const config = {
10+
"**/*.{js,ts,mjs}": (filenames) => {
11+
// Exclude config files from JS linting
12+
const filteredFiles = filenames.filter(
13+
(file) =>
14+
!file.includes("lint-staged.config.js") &&
15+
!file.includes("webpack.config.js") &&
16+
!file.includes(".config.js"),
17+
);
18+
return filteredFiles.length > 0
19+
? ["npm run lint-js", () => "npm run tsc"]
20+
: [];
21+
},
22+
// Temporarily disable PHPStan due to memory issues
23+
"**/*.php": () => "composer phpstan",
24+
"courier-notices.php": "composer lint",
25+
// Exclude problematic files from linting for now
26+
"*.php": "composer lint",
27+
"/tools/**.php": "composer lint",
28+
"composer.json": () => "composer validate --strict",
29+
};
30+
31+
module.exports = config;

package.json

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"format-js": "wp-scripts format",
1717
"lint-js": "wp-scripts lint-js",
1818
"tsc": "tsc",
19-
"format-php": "composer format:all",
19+
"format-php": "composer format",
2020
"phpstan": "composer phpstan",
2121
"lint-php": "composer lint:all",
2222
"prepare": "husky"
@@ -46,20 +46,5 @@
4646
"browserslist": [
4747
"defaults"
4848
],
49-
"private": true,
50-
"lint-staged": {
51-
"*.js": [
52-
"eslint --fix",
53-
"prettier --write"
54-
],
55-
"*.css": [
56-
"prettier --write"
57-
],
58-
"*.scss": [
59-
"prettier --write"
60-
],
61-
"*.php": [
62-
"composer format"
63-
]
64-
}
49+
"private": true
6550
}

phpcs.xml.dist

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
<!-- Exclude the Node Modules directory. -->
3737
<exclude-pattern>/node_modules/*</exclude-pattern>
3838

39+
<!-- Exclude the tools directory. -->
40+
<exclude-pattern>./tools/*</exclude-pattern>
41+
3942
<!-- Exclude minified Javascript files. -->
4043
<exclude-pattern>*.min.js</exclude-pattern>
4144

0 commit comments

Comments
 (0)