Skip to content

Commit

Permalink
Merge pull request #106 from WebberZone/oop
Browse files Browse the repository at this point in the history
Autoloading and classes
  • Loading branch information
ajaydsouza authored Jan 17, 2024
2 parents b93c051 + 9b5ab77 commit 9dbb385
Show file tree
Hide file tree
Showing 86 changed files with 8,240 additions and 6,522 deletions.
27 changes: 13 additions & 14 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,25 @@ jobs:
matrix:
# Notes regarding supported versions in WP:
# The base matrix only contains the PHP versions which are supported on all supported WP versions.
php: ['7.1', '7.2', '7.3', '7.4']
php: ['8.0', '7.3', '7.4']
wp: ['latest']
experimental: [false]

include:
# Complement the builds run via the matrix with high/low WP builds for PHP 7.4 and 8.0.
# PHP 8.0 is sort of supported since WP 5.6.
# PHP 7.4 is supported since WP 5.3.
- php: '8.0'
- php: '8.3'
wp: 'latest'
experimental: true
- php: '8.0'
wp: '5.6'
experimental: true
- php: '7.4'
wp: '5.3'
- php: '8.2'
wp: 'latest'
experimental: true
- php: '7.1'
wp: '5.1'
- php: '8.1'
wp: 'latest'
experimental: true
- php: '7.4'
wp: 'nightly'
- php: '8.0'
wp: '5.9'
experimental: true

name: "PHP ${{ matrix.php }} - WP ${{ matrix.wp }}"
Expand Down Expand Up @@ -88,13 +85,15 @@ jobs:
id: set_phpunit
run: |
if [[ "${{ matrix.php }}" > "7.4" ]]; then
echo '::set-output name=PHPUNIT::7.5.*'
echo "PHPUNIT=8.5.*" >> $GITHUB_ENV
else
echo '::set-output name=PHPUNIT::5.7.*||6.*||7.5.*'
echo "PHPUNIT=5.7.*||6.*||7.5.*" >> $GITHUB_ENV
fi
- name: 'Composer: set up PHPUnit'
run: composer require --no-update phpunit/phpunit:"${{ steps.set_phpunit.outputs.PHPUNIT }}"
env:
PHPUNIT: ${{ env.PHPUNIT }}
run: composer require --no-update phpunit/phpunit:"${{ env.PHPUNIT }}"

# Install dependencies and handle caching in one go.
# @link https://github.com/marketplace/actions/install-composer-dependencies
Expand Down
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.3.0' );

/**
* 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": "plugins@webberzone.com",
"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"
}
}
}
Loading

0 comments on commit 9dbb385

Please sign in to comment.