Skip to content

Commit

Permalink
Update Help Topics list query manipulation to support WordPress 6.3 s…
Browse files Browse the repository at this point in the history
…tyle queries with whitespace, different quotes, etc
  • Loading branch information
markjaquith committed Aug 10, 2023
1 parent 98d57c9 commit da4f50b
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
15 changes: 8 additions & 7 deletions classes/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class CWS_WP_Help_Plugin {
const MENU_SLUG = 'wp-help-documents';
const CRON_HOOK = 'cws_wp_help_update';
const POST_TYPE = 'wp-help';
const CSS_JS_VERSION = '1.7.3';
const CSS_JS_VERSION = '1.7.4';

protected function __construct() {
$this->hook( 'init' );
Expand Down Expand Up @@ -280,16 +280,17 @@ public function wp_list_pages( $html ) {
}

public function query( $query ) {
global $wpdb;
if (
$this->filter_wp_list_pages_sql &&
preg_match( '#^SELECT\s+\*\s+FROM\s+' . preg_quote( $wpdb->posts, '#' ) . '#', $query )
$this->filter_wp_list_pages_sql && // We are filtering
preg_match( '#^\s*SELECT\s+#', $query) && // This is a SELECT query
preg_match( '#post_type\s*=\s*([\'"])' . self::POST_TYPE . '\1#', $query ) // This is a query for our post type
) {
$query = str_replace(
"post_type = '" . self::POST_TYPE . "' AND post_status = 'private'",
"post_type = '" . self::POST_TYPE . "' AND post_status IN('private','publish')",
$query = preg_replace(
'#post_status\s*=\s*([\'"])private\1#', // We want private posts, but also:
"post_status IN('private','publish')", // Published ones too.
$query
);

$this->filter_wp_list_pages_sql = false;
}
return $query;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "wp-help",
"title": "WP Help",
"description": "A WordPress plugin",
"version": "1.7.3",
"version": "1.7.4",
"homepage": "",
"author": {
"name": "Mark Jaquith",
Expand Down
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Contributors: markjaquith
Donate link: http://txfx.net/wordpress-plugins/donate
Tags: help, documentation, client sites, clients, docs
Requires at least: 4.9
Tested up to: 6.2.2
Stable tag: 1.7.3
Tested up to: 6.3
Stable tag: 1.7.4

Site operators can create detailed, hierarchical documentation for the site's authors, editors, and contributors, viewable in the WordPress admin.

Expand Down
4 changes: 2 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Contributors: markjaquith
Donate link: http://txfx.net/wordpress-plugins/donate
Tags: help, documentation, client sites, clients, docs
Requires at least: 4.9
Tested up to: 6.2.2
Stable tag: 1.7.3
Tested up to: 6.3
Stable tag: 1.7.4

Site operators can create detailed, hierarchical documentation for the site's authors, editors, and contributors, viewable in the WordPress admin.

Expand Down
2 changes: 1 addition & 1 deletion wp-help.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/*
Plugin Name: WP Help
Description: Administrators can create detailed, hierarchical documentation for the site's authors and editors, viewable in the WordPress admin.
Version: 1.7.3
Version: 1.7.4
License: GPL
Plugin URI: http://txfx.net/wordpress-plugins/wp-help/
Author: Mark Jaquith
Expand Down

0 comments on commit da4f50b

Please sign in to comment.