diff --git a/autoload.php b/autoload.php new file mode 100644 index 0000000..ecee5f0 --- /dev/null +++ b/autoload.php @@ -0,0 +1,52 @@ +primary_column ) ) { + if ( ! Helpers::validate_sql_fields( $this->primary_column ) ) { return false; } - if ( ! validate_sql_fields( $this->table_name ) ) { + if ( ! Helpers::validate_sql_fields( $this->table_name ) ) { return false; } - if ( ! validate_sql_fields( $this->column_name ) ) { + if ( ! Helpers::validate_sql_fields( $this->column_name ) ) { return false; } diff --git a/includes/Extension/SearchReplace/REST/class-replace.php b/includes/extension/searchreplace/rest/class-replace.php similarity index 100% rename from includes/Extension/SearchReplace/REST/class-replace.php rename to includes/extension/searchreplace/rest/class-replace.php diff --git a/includes/Extension/SearchReplace/template/error-notice.php b/includes/extension/searchreplace/template/error-notice.php similarity index 100% rename from includes/Extension/SearchReplace/template/error-notice.php rename to includes/extension/searchreplace/template/error-notice.php diff --git a/includes/Extension/SearchReplace/views/replace-form.php b/includes/extension/searchreplace/views/replace-form.php similarity index 100% rename from includes/Extension/SearchReplace/views/replace-form.php rename to includes/extension/searchreplace/views/replace-form.php diff --git a/includes/Extension/SQL/class-edit.php b/includes/extension/sql/class-edit.php similarity index 90% rename from includes/Extension/SQL/class-edit.php rename to includes/extension/sql/class-edit.php index 88e7cd9..4d650d3 100644 --- a/includes/Extension/SQL/class-edit.php +++ b/includes/extension/sql/class-edit.php @@ -5,6 +5,7 @@ namespace StringLocator\Extension\SQL; +use StringLocator\Extension\SQL\Helpers; use StringLocator\String_Locator; /** @@ -74,12 +75,12 @@ public function sql_edit_page( $include_path ) { } // Validate the table name. - if ( ! isset( $_GET['sql-table'] ) || ! validate_sql_fields( $_GET['sql-table'] ) ) { + if ( ! isset( $_GET['sql-table'] ) || ! Helpers::validate_sql_fields( $_GET['sql-table'] ) ) { return $include_path; } // Validate the primary column - if ( ! isset( $_GET['sql-primary-column'] ) || ! validate_sql_fields( $_GET['sql-primary-column'] ) ) { + if ( ! isset( $_GET['sql-primary-column'] ) || ! Helpers::validate_sql_fields( $_GET['sql-primary-column'] ) ) { return $include_path; } diff --git a/includes/extension/sql/class-helpers.php b/includes/extension/sql/class-helpers.php new file mode 100644 index 0000000..6b1f7d0 --- /dev/null +++ b/includes/extension/sql/class-helpers.php @@ -0,0 +1,15 @@ + false, diff --git a/includes/Extension/SQL/Tests/class-serialized-data.php b/includes/extension/sql/tests/class-serialized-data.php similarity index 99% rename from includes/Extension/SQL/Tests/class-serialized-data.php rename to includes/extension/sql/tests/class-serialized-data.php index 4b2c5b5..b359d9f 100644 --- a/includes/Extension/SQL/Tests/class-serialized-data.php +++ b/includes/extension/sql/tests/class-serialized-data.php @@ -135,5 +135,3 @@ public function run( $content ) { return true; } } - -new Serialized_Data(); diff --git a/includes/Extension/SQL/views/editor/sql.php b/includes/extension/sql/views/editor/sql.php similarity index 100% rename from includes/Extension/SQL/views/editor/sql.php rename to includes/extension/sql/views/editor/sql.php diff --git a/includes/Extension/SQL/views/template/search.php b/includes/extension/sql/views/template/search.php similarity index 100% rename from includes/Extension/SQL/views/template/search.php rename to includes/extension/sql/views/template/search.php diff --git a/includes/REST/class-clean.php b/includes/rest/class-clean.php similarity index 100% rename from includes/REST/class-clean.php rename to includes/rest/class-clean.php diff --git a/includes/REST/class-directory-structure.php b/includes/rest/class-directory-structure.php similarity index 100% rename from includes/REST/class-directory-structure.php rename to includes/rest/class-directory-structure.php diff --git a/includes/REST/class-save.php b/includes/rest/class-save.php similarity index 100% rename from includes/REST/class-save.php rename to includes/rest/class-save.php diff --git a/includes/REST/class-search.php b/includes/rest/class-search.php similarity index 100% rename from includes/REST/class-search.php rename to includes/rest/class-search.php diff --git a/includes/Tests/class-loopback.php b/includes/tests/class-loopback.php similarity index 100% rename from includes/Tests/class-loopback.php rename to includes/tests/class-loopback.php diff --git a/includes/Tests/class-smart-scan.php b/includes/tests/class-smart-scan.php similarity index 100% rename from includes/Tests/class-smart-scan.php rename to includes/tests/class-smart-scan.php diff --git a/string-locator.php b/string-locator.php index 236216e..a6e499c 100644 --- a/string-locator.php +++ b/string-locator.php @@ -28,6 +28,8 @@ namespace StringLocator; +use StringLocator\Extensions\SQL\Tests\Serialized_Data; + if ( ! defined( 'ABSPATH' ) ) { die(); } @@ -36,41 +38,11 @@ define( 'STRING_LOCATOR_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); define( 'STRING_LOCATOR_PLUGIN_FILE', __FILE__ ); -/** - * Base classes that other classes may extend. - */ -require_once __DIR__ . '/includes/Base/class-search.php'; -require_once __DIR__ . '/includes/Base/class-rest.php'; - -/** - * Search handlers - */ -require_once __DIR__ . '/includes/Extension/SQL/sql.php'; -require_once __DIR__ . '/includes/Extension/SearchReplace/search-replace.php'; - -/** - * Plugin test runners - */ -require_once __DIR__ . '/includes/Tests/class-loopback.php'; -require_once __DIR__ . '/includes/Tests/class-smart-scan.php'; +require __DIR__ . '/autoload.php'; -/** - * Plugin action classes. - */ -require_once __DIR__ . '/includes/class-save.php'; -require_once __DIR__ . '/includes/class-search.php'; -require_once __DIR__ . '/includes/class-directory-iterator.php'; - -/** - * Prepare REST endpoints. - */ -require_once __DIR__ . '/includes/REST/class-save.php'; -require_once __DIR__ . '/includes/REST/class-clean.php'; -require_once __DIR__ . '/includes/REST/class-search.php'; -require_once __DIR__ . '/includes/REST/class-directory-structure.php'; +new Serialized_Data(); /** * Instantiate the plugin */ -require_once __DIR__ . '/includes/class-string-locator.php'; new String_Locator();