Skip to content

Commit

Permalink
Release 3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
johngodley committed Jul 24, 2022
1 parent 6c978fd commit aa07d75
Show file tree
Hide file tree
Showing 7 changed files with 249 additions and 180 deletions.
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const SVN_SOURCE_FILES = [
function downloadLocale( locale, wpName, type ) {
const url = LOCALE_URL.replace( '$LOCALE', locale ) + type;

download( url, 'locale', {
download( url, 'languages', {
filename: 'search-regex-' + wpName + '.' + type,
} )
.catch( e => {
Expand Down
91 changes: 91 additions & 0 deletions includes/plugin/class-settings-base.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?php

namespace SearchRegex\Plugin;

abstract class Plugin_Settings {
/** @var null|Plugin_Settings */
protected static $instance = null;

/**
* Settings
*
* @var array
*/
protected $settings = [];

// Don't allow this to be created directly
public function __construct() {
$this->settings = $this->load();

$defaults = $this->get_defaults();

foreach ( $defaults as $key => $value ) {
if ( ! isset( $this->settings[ $key ] ) ) {
$this->settings[ $key ] = $value;
}
}

// Remove any expired settings
foreach ( array_keys( $this->settings ) as $key ) {
if ( ! isset( $defaults[ $key ] ) ) {
unset( $this->settings[ $key ] );
}
}
}

abstract protected function get_setting_name();

/**
* Get default Search Regex options
*
* @return Array
*/
protected function get_defaults() {
return [];
}

/**
* Return Search Regex options
*
* @param String $name Name of setting.
* @param mixed $default Default value.
* @return mixed Data to return
*/
protected function get( $name, $default = false ) {
if ( isset( $this->settings[ $name ] ) ) {
return $this->settings[ $name ];
}

return $default;
}

/**
* Set Search Regex options. Can be passed as many options as necessary and the rest will be unchanged
*
* @param Array $settings Array of name => value.
* @return void
*/
protected function set( array $settings ) {
$this->settings = array_merge( $this->settings, $settings );
}

protected function get_save_data( array $settings ) {
return $settings;
}

public function save() {
\update_option( $this->get_setting_name(), $this->get_save_data( $this->settings ) );
}

protected function load() {
return \get_option( $this->get_setting_name() );
}

public function delete() {
\delete_option( $this->get_setting_name() );
}

public function get_as_json() {
return $this->settings;
}
}
90 changes: 2 additions & 88 deletions includes/plugin/class-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace SearchRegex\Plugin;

require_once __DIR__ . '/class-settings-base.php';

class Settings extends Plugin_Settings {
/** @var String */
const OPTION_NAME = 'searchregex_options';
Expand Down Expand Up @@ -143,91 +145,3 @@ public function can_save() {
return true;
}
}

abstract class Plugin_Settings {
/** @var null|Plugin_Settings */
protected static $instance = null;

/**
* Settings
*
* @var array
*/
protected $settings = [];

// Don't allow this to be created directly
public function __construct() {
$this->settings = $this->load();

$defaults = $this->get_defaults();

foreach ( $defaults as $key => $value ) {
if ( ! isset( $this->settings[ $key ] ) ) {
$this->settings[ $key ] = $value;
}
}

// Remove any expired settings
foreach ( array_keys( $this->settings ) as $key ) {
if ( ! isset( $defaults[ $key ] ) ) {
unset( $this->settings[ $key ] );
}
}
}

abstract protected function get_setting_name();

/**
* Get default Search Regex options
*
* @return Array
*/
protected function get_defaults() {
return [];
}

/**
* Return Search Regex options
*
* @param String $name Name of setting.
* @param mixed $default Default value.
* @return mixed Data to return
*/
protected function get( $name, $default = false ) {
if ( isset( $this->settings[ $name ] ) ) {
return $this->settings[ $name ];
}

return $default;
}

/**
* Set Search Regex options. Can be passed as many options as necessary and the rest will be unchanged
*
* @param Array $settings Array of name => value.
* @return void
*/
protected function set( array $settings ) {
$this->settings = array_merge( $this->settings, $settings );
}

protected function get_save_data( array $settings ) {
return $settings;
}

public function save() {
\update_option( $this->get_setting_name(), $this->get_save_data( $this->settings ) );
}

protected function load() {
return \get_option( $this->get_setting_name() );
}

public function delete() {
\delete_option( $this->get_setting_name() );
}

public function get_as_json() {
return $this->settings;
}
}
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "search-regex",
"version": "3.0.0-beta-5",
"version": "3.0.0",
"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 @@ -36,7 +36,7 @@
},
"homepage": "https://github.com/johngodley/search-regex",
"devDependencies": {
"@types/jest": "^28.1.5",
"@types/jest": "^28.1.6",
"@types/react": "^18.0.15",
"@types/react-dom": "^18.0.6",
"@types/react-highlight-words": "^0.16.4",
Expand All @@ -45,7 +45,7 @@
"@wordpress/eslint-plugin": "^12.7.0",
"@wordpress/prettier-config": "^1.4.0",
"@wordpress/scripts": "^23.5.0",
"apidoc": "^0.51.1",
"apidoc": "^0.52.0",
"chai": "^4.3.6",
"download": "^8.0.0",
"glob-all": "^3.3.0",
Expand All @@ -60,7 +60,7 @@
"node-fetch": "2",
"path": "^0.12.7",
"prettier": "npm:[email protected]",
"release-it": "^15.1.1",
"release-it": "^15.1.3",
"request": "^2.88.2",
"through": "^2.3.8",
"through2": "^4.0.2",
Expand All @@ -72,12 +72,12 @@
"@wordpress/element": "^4.11.0",
"@wordpress/i18n": "^4.13.0",
"classnames": "^2.3.1",
"date-fns": "^2.28.0",
"date-fns": "^2.29.1",
"deep-equal": "^2.0.5",
"file-saver": "^2.0.5",
"qs": "^6.11.0",
"rc-progress": "^3.4.0",
"rc-util": "^5.22.5",
"rc-util": "^5.23.0",
"react": "^18.2.0",
"react-copy-to-clipboard": "^5.1.0",
"react-datepicker": "^4.8.0",
Expand All @@ -92,7 +92,7 @@
"redux-thunk": "^2.4.1",
"typescript": "^4.7.4",
"url": "^0.11.0",
"use-debounce": "^8.0.1"
"use-debounce": "^8.0.2"
},
"apidoc": {
"name": "Search Regex REST API",
Expand Down
6 changes: 3 additions & 3 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
Contributors: johnny5
Donate link: http://searchregex.com/donation/
Tags: search, replace, regex, regular expression, database, post, page
Requires at least: 5.4
Tested up to: 5.9
Requires at least: 5.6
Tested up to: 6.0.1
Stable tag: trunk
Requires PHP: 5.6
License: GPLv3
Expand Down Expand Up @@ -113,7 +113,7 @@ Full documentation can be found on the [Search Regex](http://searchregex.com/) s

== Changelog ==

= 3.0 - 2022 =
= 3.0 - July 24th 2022 =
- Major update with many, many, new features
- Advanced searches with fully customisable filters that can be combined together with AND and OR logic
- Search any WordPress table, including posts, comments, users, meta-data, and options
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.0-beta-5
Version: 3.0.0
Author: John Godley
Text Domain: search-regex
Domain Path: /locale
Expand Down
Loading

0 comments on commit aa07d75

Please sign in to comment.