Skip to content

Commit

Permalink
Merge pull request #8 from level-level/wider-cc-version-support
Browse files Browse the repository at this point in the history
Wider cc version support
  • Loading branch information
Mike-Hermans authored Mar 24, 2022
2 parents 04d4f21 + 3beb9f9 commit 1268d58
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 5 deletions.
8 changes: 5 additions & 3 deletions clarkson-404.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ public function settings_field() {
public function options_reading_404() {
echo "<label for='clarkson-page-for-404'>";
printf(
__( 'Page: %s' ), wp_dropdown_pages(
/* translators: Page number */
__( 'Page: %s' ),
wp_dropdown_pages(
array(
'name' => 'clarkson-page-for-404',
'echo' => 0,
Expand Down Expand Up @@ -132,7 +134,7 @@ public function field_content( $post_states, $post ) {
return $post_states;
}

if ( $post->ID === intval( $id ) ) {
if ( intval( $id ) === $post->ID ) {
$post_states['clarkson-page-for-404'] = __( '404', 'clarkson-404' );
}

Expand All @@ -152,7 +154,7 @@ public function exclude_404_from_search( WP_Query $query ): void {
return;
}

$excluded_posts = $query->get( 'post__not_in' ) ?: array();
$excluded_posts = $query->get( 'post__not_in' ) ? $query->get( 'post__not_in' ) : array();
array_push( $excluded_posts, $id );

$query->set( 'post__not_in', $excluded_posts );
Expand Down
20 changes: 19 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,31 @@
{
"name": "level-level/clarkson-404",
"type": "wordpress-muplugin",
"license": "MIT",
"description": "A plugin to set a custom page as 404 for using with Clarkson.",
"authors": [
{
"name": "Level Level",
"homepage": "https://level-level.com"
}
],
"require-dev": {
"wp-coding-standards/wpcs": "^2.3",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.2"
},
"scripts": {
"fix" : [
"phpcbf"
],
"test": [
"composer validate",
"phpcs"
],
"phpunit":[
"phpunit"
]
},
"require": {
"level-level/clarkson-core": "^1.0.0"
"level-level/clarkson-core": "^1 | ^2"
}
}
23 changes: 23 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0"?>
<ruleset name="clarkson_core">
<description>Level Level Clarkson Core ruleset</description>

<file>./clarkson-404.php</file>

<!--<arg name="report" value="summary"/>-->
<arg name="colors"/>
<arg value="sp"/>

<rule ref="Squiz.PHP.CommentedOutCode"/>
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace"/>
<rule ref="Generic.CodeAnalysis.UnusedFunctionParameter"/>
<rule ref="Generic.Commenting.Todo"/>
<rule ref="Generic.ControlStructures.InlineControlStructure"/>

<rule ref="WordPress-Core">
<exclude name="WordPress.Files.FileName.InvalidClassFileName" />
<exclude name="Generic.CodeAnalysis.UnusedFunctionParameter.Found" />
<exclude name="WordPress.Files.FileName.NotHyphenatedLowercase" />
<exclude name="Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed" />
</rule>
</ruleset>
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Custom 404 page for Clarkson

A plugin to set a custom page as 404 when using [Clarkson Core](http://wp-clarkson.com/core){:target="_blank"}
A plugin to set a custom page as 404 when using [Clarkson Core](https://github.com/level-level/clarkson-core)

## How to

Expand Down

0 comments on commit 1268d58

Please sign in to comment.