-
Notifications
You must be signed in to change notification settings - Fork 1
/
waterfall-reviews.php
67 lines (55 loc) · 2.48 KB
/
waterfall-reviews.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
/*
Plugin Name: Waterfall Reviews
Plugin URI: https://www.makeitwork.press/wordpress-plugins/waterfall-reviews/
Description: The Waterfall Reviews plugin turns your Waterfall WordPress theme into a killer-review site. Works great with ElasticPress and Elementor too.
Version: 0.2.7
Author: Make it WorkPress
Author URI: https://makeitwork.press/
License: GPL3
License URI: https://www.gnu.org/licenses/gpl-3.0.html
*/
/**
* First, we have to check if the waterfall template is being used
* If it is not used, we return an error in the admin area, indicating that the theme should be present.
*/
$theme = wp_get_theme();
if( $theme->template != 'waterfall' ) {
add_action( 'admin_notices', function() {
echo '<div class="error"><p>' . __('The Waterfall theme is not present or activated. The Waterfall Reviews plugin requires the Waterfall theme to function.', 'wfr') . '</p></div>';
});
return;
}
/**
* Registers the autoloading for plugin classes
*/
spl_autoload_register( function($class_name) {
$called_class = str_replace( '\\', '/', str_replace( '_', '-', $class_name ) );
$class_names = explode( '/', str_replace( 'Waterfall-Reviews/', '', $called_class) );
$final_class = array_pop($class_names);
$class_rel_path = $class_names ? implode('/', $class_names) . '/class-' . $final_class : 'class-' . $final_class;
$class_file = dirname(__FILE__) . '/classes/' . strtolower( $class_rel_path ) . '.php';
if( file_exists($class_file) ) {
require_once( $class_file );
return;
}
// Require Vendor (composer) classes
if( ! isset($class_names[0]) || $class_names[0] !== 'MakeitWorkPress' || ! isset($class_names[1]) ) {
return;
}
array_splice($class_names, 2, 0, 'src');
$class_names[0] = strtolower($class_names[0]);
$class_names[1] = strtolower($class_names[1]);
$vendor_class_file = dirname(__FILE__) . '/vendor/' . implode('/', $class_names) . '/' . $final_class . '.php';
if( file_exists($vendor_class_file) ) {
require_once( $vendor_class_file );
}
} );
/**
* Boots our plugin
*/
add_action( 'plugins_loaded', function() {
defined( 'WFR_PATH' ) or define( 'WFR_PATH', plugin_dir_path( __FILE__ ) );
defined( 'WFR_URI' ) or define( 'WFR_URI', plugin_dir_url( __FILE__ ) );
$plugin = Waterfall_Reviews\Plugin::instance();
} );