-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathatik-assistant.php
More file actions
137 lines (122 loc) · 3.19 KB
/
Copy pathatik-assistant.php
File metadata and controls
137 lines (122 loc) · 3.19 KB
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
<?php
/**
* Plugin Name: Atik Assistant
* Plugin URI: https://github.com/Codestag/atik-assistant
* Description: A plugin to assist Atik theme in adding widgets.
* Author: Codestag
* Author URI: https://codestag.com
* Version: 1.0.1
* Text Domain: atik-assistant
* License: GPL2+
* License URI: https://www.gnu.org/licenses/gpl-2.0.txt
*
* @package Atik
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'Atik_Assistant' ) ) :
/**
* Crux Assistant.
*
* @since 1.0
*/
class Atik_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 Atik_Assistant ) ) {
self::$instance = new Atik_Assistant();
self::$instance->define_constants();
self::$instance->includes();
}
}
/**
* Defines plugin constants.
*
* @since 1.0
*/
public function define_constants() {
$this->define( 'AA_VERSION', '1.0.1' );
$this->define( 'AA_DEBUG', true );
$this->define( 'AA_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
$this->define( 'AA_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() {
require_once AA_PLUGIN_PATH . 'includes/class-widget.php';
require_once AA_PLUGIN_PATH . 'includes/widgets/section-category-boxes.php';
require_once AA_PLUGIN_PATH . 'includes/widgets/static-content.php';
require_once AA_PLUGIN_PATH . 'includes/widgets/featured-slide.php';
require_once AA_PLUGIN_PATH . 'includes/widgets/section-featured-slides.php';
require_once AA_PLUGIN_PATH . 'includes/widgets/section-feature-callout.php';
require_once AA_PLUGIN_PATH . 'includes/widgets/section-blog-post.php';
if ( class_exists( 'woocommerce' ) ) {
require_once AA_PLUGIN_PATH . 'includes/widgets/section-feature-product.php';
}
}
}
endif;
/**
* Plugin class instance.
*
* @since 1.0
*/
function atik_assistant() {
return Atik_Assistant::register();
}
/**
* Plugin activation notice.
*
* @since 1.0
*/
function atik_assistant_activation_notice() {
echo '<div class="error"><p>';
echo esc_html__( 'Atik Assistant requires Atik WordPress Theme to be installed and activated.', 'atik-assistant' );
echo '</p></div>';
}
/**
* Plugin activation check.
*
* @since 1.0
*/
function atik_assistant_activation_check() {
$theme = wp_get_theme(); // gets the current theme.
if ( 'Atik' === $theme->name || 'Atik' === $theme->parent_theme ) {
add_action( 'after_setup_theme', 'atik_assistant' );
} else {
if ( ! function_exists( 'deactivate_plugins' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
deactivate_plugins( plugin_basename( __FILE__ ) );
add_action( 'admin_notices', 'atik_assistant_activation_notice' );
}
}
// Plugin loads.
atik_assistant_activation_check();