Skip to content

Commit

Permalink
Fixes for 3.0.5 (#144)
Browse files Browse the repository at this point in the history
* Don’t be as strict when parsing a global replace

It won’t accept an empty replace string

* Don’t reset the flags when not doing a global replace

The global flags are still useful for the global search

* Allow preset to be updated from the preset dropdown

* Bump versions
  • Loading branch information
johngodley authored Aug 25, 2022
1 parent 31707e7 commit 048ef31
Show file tree
Hide file tree
Showing 6 changed files with 576 additions and 463 deletions.
5 changes: 0 additions & 5 deletions includes/search/class-preset.php
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,6 @@ public function to_json() {
// Remove replace value if not a global replace
if ( $search['action'] !== 'replace' ) {
$search['replacement'] = '';
$search['searchFlags'] = [];
}

return [
Expand Down Expand Up @@ -450,10 +449,6 @@ public function is_valid() {
return false;
}

if ( empty( $this->search ) && empty( $this->replacement ) ) {
return false;
}

return true;
}

Expand Down
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "search-regex",
"version": "3.0.4",
"version": "3.0.5",
"description": "Adds search and replace functionality across posts, pages, comments, and meta-data, with full regular expression support",
"main": "search-regex.php",
"sideEffects": true,
Expand Down Expand Up @@ -38,15 +38,15 @@
},
"homepage": "https://github.com/johngodley/search-regex",
"devDependencies": {
"@types/jest": "^28.1.7",
"@types/jest": "^28.1.8",
"@types/react": "^18.0.17",
"@types/react-dom": "^18.0.6",
"@types/react-highlight-words": "^0.16.4",
"@types/react-redux": "^7.1.24",
"@wordpress/base-styles": "^4.7.0",
"@wordpress/eslint-plugin": "^12.9.0",
"@wordpress/prettier-config": "^1.4.0",
"@wordpress/scripts": "^23.7.2",
"@wordpress/eslint-plugin": "^13.0.0",
"@wordpress/prettier-config": "^2.0.0",
"@wordpress/scripts": "^24.0.0",
"apidoc": "^0.52.0",
"chai": "^4.3.6",
"download": "^8.0.0",
Expand All @@ -56,13 +56,13 @@
"gulp-po2json": "^1.0.0",
"gulp-zip": "^5.1.0",
"he": "^1.2.0",
"jest": "^28.1.3",
"jest-environment-jsdom": "^28.1.3",
"jest": "^29.0.0",
"jest-environment-jsdom": "^29.0.0",
"mocha": "^10.0.0",
"node-fetch": "2",
"path": "^0.12.7",
"prettier": "npm:[email protected]",
"release-it": "^15.3.0",
"release-it": "^15.4.0",
"request": "^2.88.2",
"through": "^2.3.8",
"through2": "^4.0.2",
Expand All @@ -71,8 +71,8 @@
"dependencies": {
"@emotion/react": "^11.10.0",
"@redux-devtools/extension": "^3.2.3",
"@wordpress/element": "^4.13.0",
"@wordpress/i18n": "^4.15.0",
"@wordpress/element": "^4.14.0",
"@wordpress/i18n": "^4.16.0",
"classnames": "^2.3.1",
"date-fns": "^2.29.2",
"deep-equal": "^2.0.5",
Expand Down
5 changes: 5 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ Full documentation can be found on the [Search Regex](http://searchregex.com/) s

== Changelog ==

= 3.0.5 - August 25th 2022 =
* Fix empty replacement string when saving a preset
* Fix preset being saved from search preset dropdown
* Fix search flags being reset when no replacement

= 3.0.4 - August 19th 2022 =
* Fix 'update preset' dropdown menu not updating
* Fix current preset when switching pages
Expand Down
2 changes: 1 addition & 1 deletion search-regex.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: Search Regex
Plugin URI: https://searchregex.com/
Description: Adds search and replace functionality across posts, pages, comments, and meta-data, with full regular expression support
Version: 3.0.4
Version: 3.0.5
Author: John Godley
Text Domain: search-regex
Domain Path: /locale
Expand Down
15 changes: 11 additions & 4 deletions src/page/home/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const getMenu = () =>
].filter( ( option ) => has_page_access( option.value ) || ( option.value === '' && has_page_access( 'search' ) ) );

function Home( props ) {
const { onClearErrors, onResetPreset, errors, onClearNotices, notices } = props;
const { onClearErrors, onResetPreset, errors, onClearNotices, notices, presets } = props;
const [ page, setPage ] = useState( getPluginPage() );

if ( SEARCHREGEX_VERSION !== SearchRegexi10n.version ) {
Expand All @@ -63,7 +63,12 @@ function Home( props ) {

function pageChange() {
onClearErrors();
onResetPreset();

if ( SearchRegexi10n.settings.defaultPreset && presets.find( ( item ) => item.id === SearchRegexi10n.settings.defaultPreset ) ) {
onResetPreset( presets.find( ( item ) => item.id === SearchRegexi10n.settings.defaultPreset ) );
} else {
onResetPreset( null );
}
}

return (
Expand Down Expand Up @@ -113,8 +118,8 @@ function mapDispatchToProps( dispatch ) {
onClearNotices: () => {
dispatch( clearNotices() );
},
onResetPreset: () => {
dispatch( setPreset( null ) );
onResetPreset: ( preset ) => {
dispatch( setPreset( preset ) );
}
};
}
Expand All @@ -123,10 +128,12 @@ function mapStateToProps( state ) {
const {
message: { errors, notices },
} = state;
const { presets } = state.preset;

return {
errors,
notices,
presets,
};
}

Expand Down
Loading

0 comments on commit 048ef31

Please sign in to comment.