Skip to content

Commit

Permalink
Merge branch 'develop' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
2ndkauboy committed Jul 5, 2024
2 parents 6e29b0e + 3cd3fa2 commit d43dcb5
Show file tree
Hide file tree
Showing 8 changed files with 137 additions and 35 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/wordpress-plugin-deploy.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
name: Deploy to WordPress.org
on:
push:
tags:
- "*"
- "!*-*"
release:
types: [published]

jobs:
tag:
name: New tag
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.lock
/vendor/
18 changes: 18 additions & 0 deletions .wordpress-org/blueprints/blueprint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"preferredVersions": {
"php": "8.3",
"wp": "latest"
},
"phpExtensionBundles": [
"kitchen-sink"
],
"features": {},
"steps": [
{
"step": "login",
"username": "admin",
"password": "password"
}
],
"landingPage": "\/wp-admin\/edit.php?post_type=page"
}
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Unique Title Checker #
**Contributors:** Kau-Boy
**Tags:** title, seo, duplicate title, unique title
**Tested up to:** 6.3
**Stable tag:** 1.7.0
**Tested up to:** 6.6
**Stable tag:** 1.7.1
>>>>>>> develop
**License:** GPLv3
**License URI:** http://www.gnu.org/licenses/gpl-3.0

Expand Down Expand Up @@ -56,9 +57,9 @@ Yes, you can simply use the filter `unique_title_checker_only_unique_error` with

## Changelog ##

### 1.7.0 ###
* Fixing the detection of Classic editor in WordPress 6.2
* Time invested for this release: 60min
### 1.7.1 ###
* Add blueprint.json file for live demo
* Time invested for this release: 30min

### 1.6.0 ###
* Fixing the check for the Block Editor in new WordPress versions.
Expand Down
21 changes: 21 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "2ndkauboy/unique-title-checker",
"description": "Checks if the title of a post, page or custom post type is unique and warn the editor if not.",
"license": "GPL-3.0-or-later",
"authors": [
{
"name": "Bernhard Kau"
}
],
"minimum-stability": "stable",
"require-dev": {
"php": ">=5.6",
"wp-coding-standards/wpcs": "^3.0",
"phpcompatibility/phpcompatibility-wp": "^2.1"
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
2 changes: 1 addition & 1 deletion js/unique-title-checker-block-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ var closeListener = wp.data.subscribe( function () {
if ( 'error' === data.status || !unique_title_checker.only_unique_error ) {
( function ( wp ) {
// Overwrite status from 'updated' to 'success' in block editor.
status = 'error' === data.status ? 'error' : 'success';
var status = 'error' === data.status ? 'error' : 'success';
wp.data.dispatch( 'core/notices' ).createNotice(
status, // Can be one of: success, info, warning, error.
data.message, // Text string to display.
Expand Down
86 changes: 86 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?xml version="1.0"?>
<ruleset name="WordPress Coding Standards based custom ruleset for your plugin">
<description>Generally-applicable sniffs for WordPress plugins.</description>
<!--
#############################################################################
COMMAND LINE ARGUMENTS
https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml
#############################################################################
-->

<!-- Pass some flags to PHPCS:
p flag: Show progress of the run.
s flag: Show sniff codes in all reports.
-->
<arg value="ps"/>

<!-- Strip the filepaths down to the relevant bit. -->
<arg name="basepath" value="./"/>

<!-- Check up to 8 files simultanously. -->
<arg name="parallel" value="8"/>

<!-- Only check the PHP. CSS/SCSS/JS files are checked separately with linters. -->
<arg name="extensions" value="php"/>

<!-- Enable colors in the output -->
<arg name="colors"/>

<!-- Check all files in this directory and the directories below it. -->
<file>.</file>

<!--
#############################################################################
EXCLUDE SOME FILES AND FOLDERS
#############################################################################
-->

<exclude-pattern>/build/</exclude-pattern>
<exclude-pattern>/vendor/</exclude-pattern>
<exclude-pattern>/node_modules/</exclude-pattern>

<!--
#############################################################################
USE THE WordPress RULESET
#############################################################################
-->

<!-- https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards -->
<!-- https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties -->
<config name="minimum_supported_wp_version" value="5.7"/>

<rule ref="WordPress">
<!-- As we use PHP 5.4+ now, we can use the short array syntax -->
<exclude name="Universal.Arrays.DisallowShortArraySyntax.Found" />
</rule>
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
<properties>
<!-- Value: replace the function, class, and variable prefixes used. Separate multiple prefixes with a comma. -->
<property name="prefixes" type="array" value="Unique_Title_Checker"/>
</properties>
</rule>
<rule ref="WordPress.WP.I18n">
<properties>
<!-- Value: replace the text domain used. Separate multiple prefixes with a comma. -->
<property name="text_domain" type="array" value="unique-title-checker"/>
</properties>
</rule>
<rule ref="WordPress.WhiteSpace.ControlStructureSpacing">
<properties>
<property name="blank_line_check" value="true"/>
</properties>
</rule>


<!--
#############################################################################
USE THE PHPCompatibility RULESET
#############################################################################
-->

<!-- https://github.com/PHPCompatibility/PHPCompatibility#sniffing-your-code-for-compatibility-with-specific-php-versions -->
<config name="testVersion" value="5.6-"/>
<!-- https://github.com/PHPCompatibility/PHPCompatibilityWP -->
<rule ref="PHPCompatibilityWP"/>

</ruleset>
25 changes: 0 additions & 25 deletions unique-title-checker.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ class Unique_Title_Checker {
* @return object of this class
*/
public static function get_instance() {

if ( null === self::$instance ) {
self::$instance = new self();
}
Expand All @@ -93,10 +92,8 @@ public static function get_instance() {
* @return void
*/
public function plugin_setup() {

$this->plugin_url = plugins_url( '/', __FILE__ );
$this->plugin_path = plugin_dir_path( __FILE__ );
$this->load_language( 'unique-title-checker' );

// Enqueue the main JavaScript file.
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
Expand All @@ -120,27 +117,6 @@ public function plugin_setup() {
public function __construct() {
}


/**
* Loads translation file.
*
* Accessible to other classes to load different language files (admin and front-end for example).
*
* @wp-hook init
*
* @param string $domain The text domain for this plugin.
*
* @return void
*/
public function load_language( $domain ) {

load_plugin_textdomain(
$domain,
false,
dirname( plugin_basename( __FILE__ ) ) . '/languages'
);
}

/**
* Add the JavaScript files to the admin pages
*
Expand Down Expand Up @@ -258,7 +234,6 @@ public function uniqueness_admin_notice() {
* @return array The status and message for the response
*/
public function check_uniqueness( $args ) {

// Use the posts_where hook to add thr filter for the post_title, as it is not available through WP_Query args.
add_filter( 'posts_where', array( $this, 'post_title_where' ), 10, 1 );

Expand Down

0 comments on commit d43dcb5

Please sign in to comment.