-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathppb-business-pack.php
executable file
·187 lines (159 loc) · 4.45 KB
/
ppb-business-pack.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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
<?php
/*
* Plugin Name: Business pack
* Plugin URI: http://pootlepress.com/
* Description: Add Tabs, Accordions, Testimonials, Incrementing numbers and Google Maps easily in Pootle Pagebuilder Pro.
* Author: Pootlepress
* Version: 1.0.0
* Author URI: http://pootlepress.com/
* @developer shramee <[email protected]>
*/
/** Plugin admin class */
require 'inc/class-admin.php';
/** Plugin public class */
require 'inc/class-public.php';
/** Intantiating main plugin class */
Pootle_Business_Pack::instance( __FILE__ );
/**
* Business pack main class
* @static string $token Plugin token
* @static string $file Plugin __FILE__
* @static string $url Plugin root dir url
* @static string $path Plugin root dir path
* @static string $version Plugin version
*/
class Pootle_Business_Pack{
/**
* @var Pootle_Business_Pack Instance
* @access private
* @since 1.0.0
*/
private static $_instance = null;
/**
* @var string Token
* @access public
* @since 1.0.0
*/
public static $token;
/**
* @var string Version
* @access public
* @since 1.0.0
*/
public static $version;
/**
* @var string Plugin main __FILE__
* @access public
* @since 1.0.0
*/
public static $file;
/**
* @var string Plugin directory url
* @access public
* @since 1.0.0
*/
public static $url;
/**
* @var string Plugin directory path
* @access public
* @since 1.0.0
*/
public static $path;
/**
* @var Pootle_Business_Pack_Admin Instance
* @access public
* @since 1.0.0
*/
public $admin;
/**
* @var Pootle_Business_Pack_Public Instance
* @access public
* @since 1.0.0
*/
public $public;
/**
* Main Business pack Instance
*
* Ensures only one instance of Storefront_Extension_Boilerplate is loaded or can be loaded.
*
* @since 1.0.0
* @return Pootle_Business_Pack instance
*/
public static function instance( $file ) {
if ( null == self::$_instance ) {
self::$_instance = new self( $file );
}
return self::$_instance;
} // End instance()
/**
* Constructor function.
* @param string $file __FILE__ of the main plugin
* @access private
* @since 1.0.0
*/
private function __construct( $file ) {
self::$token = 'ppb-business-pack-pro';
self::$file = $file;
self::$url = plugin_dir_url( $file );
self::$path = plugin_dir_path( $file );
self::$version = '1.0.0';
add_action( 'plugins_loaded', array( $this, 'init' ) );
} // End __construct()
/**
* Initiates the plugin
* @action init
* @since 1.0.0
*/
public function init() {
if ( class_exists( 'Pootle_Page_Builder' ) ) {
//Initiate admin
$this->_admin();
//Initiate public
$this->_public();
//Mark this add on as active
add_filter( 'pootlepb_installed_add_ons', array( $this, 'add_on_active' ) );
}
} // End init()
/**
* Initiates admin class and adds admin hooks
* @since 1.0.0
*/
private function _admin() {
//Instantiating admin class
$this->admin = Pootle_Business_Pack_Admin::instance();
//Content block panel tabs
add_filter( 'pootlepb_content_block_tabs', array( $this->admin, 'content_block_tabs' ) );
add_filter( 'pootlepb_le_content_block_tabs', array( $this->admin, 'content_block_tabs' ) );
//Content block panel fields
add_filter( 'pootlepb_content_block_fields', array( $this->admin, 'content_block_fields' ) );
// Modules
add_filter( 'pootlepb_modules', array( $this->admin, 'modules' ) );
// Page builder admin scripts
add_action( 'pootlepb_enqueue_admin_scripts', array( $this->admin, 'enqueue' ) );
// Page builder admin scripts
add_action( 'pootlepb_content_block_custom_field_' . $this::$token, array( $this->admin, 'custom_field' ), 10, 2 );
}
/**
* Initiates public class and adds public hooks
* @since 1.0.0
*/
private function _public() {
//Instantiating public class
$this->public = Pootle_Business_Pack_Public::instance();
//Adding front end JS and CSS in /assets folder
add_action( 'wp_enqueue_scripts', array( $this->public, 'enqueue' ) );
//Add/Modify content block html attributes
add_filter( 'pootlepb_render_content_block', array( $this->public, 'content_block' ), 10, 2 );
} // End enqueue()
/**
* Marks this add on as active on
* @param array $active Active add ons
* @return array Active add ons
* @since 1.0.0
*/
public function add_on_active( $active ) {
// To allows ppb add ons page to fetch name, description etc.
$active[ self::$token ] = self::$file;
return $active;
}
}