-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcrux-assistant.php
143 lines (128 loc) · 3.54 KB
/
crux-assistant.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<?php
/**
* Plugin Name: Crux Assistant
* Plugin URI: https://github.com/Codestag/crux-assistant
* Description: A plugin to assist Crux theme in adding widgets.
* Author: Codestag
* Author URI: https://codestag.com
* Version: 1.0.1
* Text Domain: crux-assistant
* License: GPL2+
* License URI: https://www.gnu.org/licenses/gpl-2.0.txt
*
* @package Crux
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'Crux_Assistant' ) ) :
/**
* Crux Assistant.
*
* @since 1.0
*/
class Crux_Assistant {
/**
* Class instance.
*
* @since 1.0
*/
private static $instance;
/**
* Register method to create a new instance.
*
* @since 1.0
*/
public static function register() {
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Crux_Assistant ) ) {
self::$instance = new Crux_Assistant();
self::$instance->define_constants();
self::$instance->includes();
}
}
/**
* Defines plugin constants.
*
* @since 1.0
*/
public function define_constants() {
$this->define( 'CA_VERSION', '1.0' );
$this->define( 'CA_DEBUG', true );
$this->define( 'CA_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
$this->define( 'CA_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
}
/**
* Method to define a constant.
*
* @param string $name
* @param string $value
* @since 1.0
*/
private function define( $name, $value ) {
if ( ! defined( $name ) ) {
define( $name, $value );
}
}
/**
* Includes plugin files.
*
* @since 1.0
*/
public function includes() {
if ( is_admin() ) {
require_once CA_PLUGIN_PATH . 'includes/meta/stag-admin-metabox.php';
}
require_once CA_PLUGIN_PATH . 'includes/meta/layout-meta.php';
require_once CA_PLUGIN_PATH . 'includes/meta/page-meta.php';
require_once CA_PLUGIN_PATH . 'includes/meta/slider-meta.php';
require_once CA_PLUGIN_PATH . 'includes/widgets/widget-category-box.php';
require_once CA_PLUGIN_PATH . 'includes/widgets/widget-section-category-boxes.php';
require_once CA_PLUGIN_PATH . 'includes/widgets/widget-static-content.php';
if ( class_exists( 'woocommerce' ) ) {
require_once CA_PLUGIN_PATH . 'includes/widgets/widget-woo-best-sellers.php';
require_once CA_PLUGIN_PATH . 'includes/widgets/widget-woo-featured-products.php';
require_once CA_PLUGIN_PATH . 'includes/widgets/widget-woo-latest-products.php';
require_once CA_PLUGIN_PATH . 'includes/widgets/widget-woo-on-sale-products.php';
require_once CA_PLUGIN_PATH . 'includes/widgets/widget-woo-top-rated.php';
}
}
}
endif;
/**
* Invokes Crux_Assistant Class.
*
* @since 1.0
*/
function crux_assistant() {
return Crux_Assistant::register();
}
/**
* Activation notice.
*
* @since 1.0
*/
function crux_assistant_activation_notice() {
echo '<div class="error"><p>';
echo esc_html__( 'Crux Assistant requires Crux WordPress Theme to be installed and activated.', 'crux-assistant' );
echo '</p></div>';
}
/**
* Assistant activation check.
*
* @since 1.0
*/
function crux_assistant_activation_check() {
$theme = wp_get_theme(); // gets the current theme.
if ( 'Crux' === $theme->name || 'Crux' === $theme->parent_theme ) {
add_action( 'after_setup_theme', 'crux_assistant' );
} else {
if ( ! function_exists( 'deactivate_plugins' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
deactivate_plugins( plugin_basename( __FILE__ ) );
add_action( 'admin_notices', 'crux_assistant_activation_notice' );
}
}
// Plugin loads.
crux_assistant_activation_check();