Skip to content

Commit

Permalink
OOP implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
ajaydsouza committed Jan 14, 2024
1 parent b93c051 commit e740480
Show file tree
Hide file tree
Showing 79 changed files with 7,994 additions and 6,493 deletions.
125 changes: 37 additions & 88 deletions better-search.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,48 +29,32 @@
}

/**
* Holds the version of Contextual Related Posts.
* Holds the version of Better Search.
*
* @since 2.9.3
*
* @var string Contextual Related Posts Version.
*/
if ( ! defined( 'BETTER_SEARCH_VERSION' ) ) {
define( 'BETTER_SEARCH_VERSION', '3.2.2' );
}
define( 'BETTER_SEARCH_VERSION', '3.2.2' );

/**
* Holds the filesystem directory path (with trailing slash) for Better Search
*
* @since 2.2.0
*
* @var string Plugin folder path
*/
if ( ! defined( 'BETTER_SEARCH_PLUGIN_DIR' ) ) {
define( 'BETTER_SEARCH_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
}
define( 'BETTER_SEARCH_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );

/**
* Holds the filesystem directory path (with trailing slash) for Better Search
*
* @since 2.2.0
*
* @var string Plugin folder URL
*/
if ( ! defined( 'BETTER_SEARCH_PLUGIN_URL' ) ) {
define( 'BETTER_SEARCH_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
}
define( 'BETTER_SEARCH_PLUGIN_URL', plugin_dir_url( __FILE__ ) );

/**
* Holds the filesystem directory path (with trailing slash) for Better Search
*
* @since 2.2.0
*
* @var string Plugin Root File
*/
if ( ! defined( 'BETTER_SEARCH_PLUGIN_FILE' ) ) {
define( 'BETTER_SEARCH_PLUGIN_FILE', __FILE__ );
}
 */
define( 'BETTER_SEARCH_PLUGIN_FILE', __FILE__ );

/**
* Global variable holding the current database version of Better Search
Expand All @@ -82,83 +66,48 @@
global $bsearch_db_version;
$bsearch_db_version = '1.0';

/*
* ----------------------------------------------------------------------------*
* Include files
*----------------------------------------------------------------------------
// Load the autoloader.
require_once BETTER_SEARCH_PLUGIN_DIR . 'includes/autoloader.php';

/**
* The code that runs during plugin activation.
*
* @since 3.3.0
*
* @param bool $network_wide Whether the plugin is being activated network-wide.
*/
function activate_bsearch( $network_wide ) {
\WebberZone\Better_Search\Admin\Activator::activation_hook( $network_wide );
}
register_activation_hook( __FILE__, __NAMESPACE__ . '\activate_bsearch' );

require_once BETTER_SEARCH_PLUGIN_DIR . 'includes/admin/register-settings.php';
require_once BETTER_SEARCH_PLUGIN_DIR . 'includes/admin/default-settings.php';
require_once BETTER_SEARCH_PLUGIN_DIR . 'includes/activation.php';
require_once BETTER_SEARCH_PLUGIN_DIR . 'includes/class-better-search.php';
require_once BETTER_SEARCH_PLUGIN_DIR . 'includes/class-better-search-query.php';
require_once BETTER_SEARCH_PLUGIN_DIR . 'includes/main-functions.php';
require_once BETTER_SEARCH_PLUGIN_DIR . 'includes/general-template.php';
require_once BETTER_SEARCH_PLUGIN_DIR . 'includes/l10n.php';
require_once BETTER_SEARCH_PLUGIN_DIR . 'includes/template-redirect.php';
require_once BETTER_SEARCH_PLUGIN_DIR . 'includes/utilities.php';
require_once BETTER_SEARCH_PLUGIN_DIR . 'includes/media.php';
require_once BETTER_SEARCH_PLUGIN_DIR . 'includes/wp-filters.php';
require_once BETTER_SEARCH_PLUGIN_DIR . 'includes/modules/tracker.php';
require_once BETTER_SEARCH_PLUGIN_DIR . 'includes/modules/cache.php';
require_once BETTER_SEARCH_PLUGIN_DIR . 'includes/modules/class-better-search-heatmap.php';
require_once BETTER_SEARCH_PLUGIN_DIR . 'includes/modules/class-bsearch-search-box.php';
require_once BETTER_SEARCH_PLUGIN_DIR . 'includes/modules/heatmap.php';
require_once BETTER_SEARCH_PLUGIN_DIR . 'includes/modules/shortcode.php';
require_once BETTER_SEARCH_PLUGIN_DIR . 'includes/deprecated.php';
/**
* The main function responsible for returning the one true WebberZone Snippetz instance to functions everywhere.
*
* @since 3.3.0
*/
function load_bsearch() {
\WebberZone\Better_Search\Main::get_instance();
}
add_action( 'plugins_loaded', __NAMESPACE__ . '\load_bsearch' );

/*
*----------------------------------------------------------------------------*
* Dashboard and Administrative Functionality
*----------------------------------------------------------------------------
* Include files
*----------------------------------------------------------------------------
*/
if ( is_admin() ) {

/**
* Load the admin pages if we're in the Admin.
*/
require_once BETTER_SEARCH_PLUGIN_DIR . 'includes/admin/admin.php';
require_once BETTER_SEARCH_PLUGIN_DIR . 'includes/admin/settings-page.php';
require_once BETTER_SEARCH_PLUGIN_DIR . 'includes/admin/save-settings.php';
require_once BETTER_SEARCH_PLUGIN_DIR . 'includes/admin/help-tab.php';
require_once BETTER_SEARCH_PLUGIN_DIR . 'includes/admin/tools.php';
require_once BETTER_SEARCH_PLUGIN_DIR . 'includes/admin/admin-dashboard.php';
require_once BETTER_SEARCH_PLUGIN_DIR . 'includes/admin/class-better-search-statistics.php';
require_once BETTER_SEARCH_PLUGIN_DIR . 'includes/admin/class-better-search-statistics-table.php';

}
require_once BETTER_SEARCH_PLUGIN_DIR . 'includes/options-api.php';
require_once BETTER_SEARCH_PLUGIN_DIR . 'includes/class-better-search.php';
require_once BETTER_SEARCH_PLUGIN_DIR . 'includes/class-better-search-query.php';
require_once BETTER_SEARCH_PLUGIN_DIR . 'includes/functions.php';
require_once BETTER_SEARCH_PLUGIN_DIR . 'includes/general-template.php';
require_once BETTER_SEARCH_PLUGIN_DIR . 'includes/heatmap.php';


/**
* Declare $bsearch_settings global so that it can be accessed in every function
*
* @since 1.3
* @since 1.3
*/
global $bsearch_settings;
$bsearch_settings = bsearch_get_settings();


/**
* Get Settings.
*
* Retrieves all plugin settings
*
* @since 2.2.0
*
* @return array Better Search settings
*/
function bsearch_get_settings() {

$settings = get_option( 'bsearch_settings' );

/**
* Settings array
*
* Retrieves all plugin settings
*
* @since 1.2.0
* @param array $settings Settings array
*/
return apply_filters( 'bsearch_get_settings', $settings );
}
23 changes: 21 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,30 @@
"authors": [
{
"name": "WebberZone",
"email": "[email protected]",
"role": "Developer"
}
],
"requires": {
"php": ">=7.4"
},
"require-dev": {
"szepeviktor/phpstan-wordpress": "^1.3",
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan": "^1.10",
"php-stubs/wordpress-stubs": "^6.2",
"wp-coding-standards/wpcs": "^2.3",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7",
"phpcompatibility/phpcompatibility-wp": "^2.1",
"yoast/phpunit-polyfills": "^1.0",
"phpunit/phpunit": "^5.7.21 || ^6.5 || ^7.5"
},
"config": {
"allow-plugins": {
"phpstan/extension-installer": true,
"dealerdirect/phpcodesniffer-composer-installer": true
}
},
"scripts": {
"phpstan": "vendor/bin/phpstan analyse --memory-limit=2048M"
}
}
}
187 changes: 0 additions & 187 deletions includes/activation.php

This file was deleted.

Loading

0 comments on commit e740480

Please sign in to comment.