Skip to content

Commit 791ab48

Browse files
authored
Modify plugin for OOP code (#199)
* Initial commit of OOP implementation * Update class-cache.php * Update class-settings-api.php * Enqueue correct scripts/styles * Link to Tools page
1 parent ca8aa80 commit 791ab48

File tree

85 files changed

+9029
-7046
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+9029
-7046
lines changed

composer.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,9 @@
3737
"phpstan/extension-installer": true,
3838
"dealerdirect/phpcodesniffer-composer-installer": true
3939
}
40+
},
41+
"scripts": {
42+
"phpstan": "vendor/bin/phpstan analyse --memory-limit=2048M",
43+
"phpstan-baseline": "vendor/bin/phpstan analyse --generate-baseline --memory-limit=2048M"
4044
}
4145
}

contextual-related-posts.php

Lines changed: 30 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
* @author Ajay D'Souza
1010
* @license GPL-2.0+
1111
* @link https://webberzone.com
12-
* @copyright 2009-2023 Ajay D'Souza
12+
* @copyright 2009-2024 Ajay D'Souza
1313
*
1414
* @wordpress-plugin
1515
* Plugin Name: Contextual Related Posts
1616
* Plugin URI: https://webberzone.com/plugins/contextual-related-posts/
1717
* Description: Display related posts on your website or in your feed. Increase reader retention and reduce bounce rates
18-
* Version: 3.4.2
18+
* Version: 3.5.0-beta1
1919
* Author: WebberZone
2020
* Author URI: https://webberzone.com
2121
* License: GPL-2.0+
@@ -25,7 +25,8 @@
2525
* GitHub Plugin URI: https://github.com/WebberZone/contextual-related-posts/
2626
*/
2727

28-
// If this file is called directly, abort.
28+
namespace WebberZone\Contextual_Related_Posts;
29+
2930
if ( ! defined( 'WPINC' ) ) {
3031
die;
3132
}
@@ -36,7 +37,7 @@
3637
* @since 2.9.3
3738
*/
3839
if ( ! defined( 'CRP_VERSION' ) ) {
39-
define( 'CRP_VERSION', '3.4.1' );
40+
define( 'CRP_VERSION', '3.5.0' );
4041
}
4142

4243

@@ -86,59 +87,40 @@
8687
define( 'CRP_CACHE_TIME', MONTH_IN_SECONDS );
8788
}
8889

89-
/*
90-
*----------------------------------------------------------------------------
91-
* CRP modules & includes
92-
*----------------------------------------------------------------------------
93-
*/
94-
95-
require_once CRP_PLUGIN_DIR . 'includes/admin/default-settings.php';
96-
require_once CRP_PLUGIN_DIR . 'includes/admin/register-settings.php';
97-
require_once CRP_PLUGIN_DIR . 'includes/plugin-activator.php';
98-
require_once CRP_PLUGIN_DIR . 'includes/i10n.php';
99-
require_once CRP_PLUGIN_DIR . 'includes/class-crp-query.php';
100-
require_once CRP_PLUGIN_DIR . 'includes/main-query.php';
101-
require_once CRP_PLUGIN_DIR . 'includes/output-generator.php';
102-
require_once CRP_PLUGIN_DIR . 'includes/media.php';
103-
require_once CRP_PLUGIN_DIR . 'includes/tools.php';
104-
require_once CRP_PLUGIN_DIR . 'includes/header.php';
105-
require_once CRP_PLUGIN_DIR . 'includes/content.php';
106-
require_once CRP_PLUGIN_DIR . 'includes/modules/manual-posts.php';
107-
require_once CRP_PLUGIN_DIR . 'includes/modules/cache.php';
108-
require_once CRP_PLUGIN_DIR . 'includes/modules/shortcode.php';
109-
require_once CRP_PLUGIN_DIR . 'includes/modules/taxonomies.php';
110-
require_once CRP_PLUGIN_DIR . 'includes/modules/exclusions.php';
111-
require_once CRP_PLUGIN_DIR . 'includes/modules/class-crp-rest-api.php';
112-
require_once CRP_PLUGIN_DIR . 'includes/modules/class-crp-widget.php';
113-
require_once CRP_PLUGIN_DIR . 'includes/blocks/register-blocks.php';
114-
90+
// Load the autoloader.
91+
require_once CRP_PLUGIN_DIR . 'includes/autoloader.php';
11592

116-
/*
117-
*----------------------------------------------------------------------------
118-
* Dashboard and Administrative Functionality
119-
*----------------------------------------------------------------------------
93+
/**
94+
* The code that runs during plugin activation.
95+
*
96+
* @since 3.5.0
97+
*
98+
* @param bool $network_wide Whether the plugin is being activated network-wide.
12099
*/
100+
function activate_tptn( $network_wide ) {
101+
\WebberZone\Contextual_Related_Posts\Admin\Activator::activation_hook( $network_wide );
102+
}
103+
register_activation_hook( __FILE__, __NAMESPACE__ . '\activate_tptn' );
121104

122-
if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
123-
124-
require_once CRP_PLUGIN_DIR . 'includes/admin/admin.php';
125-
require_once CRP_PLUGIN_DIR . 'includes/admin/settings-page.php';
126-
require_once CRP_PLUGIN_DIR . 'includes/admin/save-settings.php';
127-
require_once CRP_PLUGIN_DIR . 'includes/admin/help-tab.php';
128-
require_once CRP_PLUGIN_DIR . 'includes/admin/modules/tools.php';
129-
require_once CRP_PLUGIN_DIR . 'includes/admin/modules/loader.php';
130-
require_once CRP_PLUGIN_DIR . 'includes/admin/modules/metabox.php';
131-
require_once CRP_PLUGIN_DIR . 'includes/admin/modules/class-bulk-edit.php';
132-
} // End if.
105+
/**
106+
* The main function responsible for returning the one true WebberZone Snippetz instance to functions everywhere.
107+
*
108+
* @since 3.5.0
109+
*/
110+
function load_tptn() {
111+
\WebberZone\Contextual_Related_Posts\Main::get_instance();
112+
}
113+
add_action( 'plugins_loaded', __NAMESPACE__ . '\load_tptn' );
133114

134115

135116
/*
136117
*----------------------------------------------------------------------------
137-
* Deprecated functions
118+
* Include files
138119
*----------------------------------------------------------------------------
139120
*/
140-
141-
require_once CRP_PLUGIN_DIR . 'includes/deprecated.php';
121+
require_once CRP_PLUGIN_DIR . 'includes/options-api.php';
122+
require_once CRP_PLUGIN_DIR . 'includes/class-crp-query.php';
123+
require_once CRP_PLUGIN_DIR . 'includes/functions.php';
142124

143125

144126
/**
@@ -150,27 +132,3 @@
150132
*/
151133
global $crp_settings;
152134
$crp_settings = crp_get_settings();
153-
154-
155-
/**
156-
* Get Settings.
157-
*
158-
* Retrieves all plugin settings
159-
*
160-
* @since 2.6.0
161-
* @return array Contextual Related Posts settings
162-
*/
163-
function crp_get_settings() {
164-
165-
$settings = get_option( 'crp_settings' );
166-
167-
/**
168-
* Settings array
169-
*
170-
* Retrieves all plugin settings
171-
*
172-
* @since 2.0.0
173-
* @param array $settings Settings array
174-
*/
175-
return apply_filters( 'crp_get_settings', $settings );
176-
}

includes/admin/admin.php

Lines changed: 0 additions & 204 deletions
This file was deleted.

0 commit comments

Comments
 (0)