-
Notifications
You must be signed in to change notification settings - Fork 4
/
pootle-page-builder.php
executable file
·279 lines (240 loc) · 8.47 KB
/
pootle-page-builder.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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
<?php
/**
* Plugin Name: Pootle Pagebuilder - WordPress Page builder
* Plugin URI: http://pootlepress.com/
* Description: Pootle Pagebuilder is a front-end, drag and drop page builder that makes it easy to create beautiful WordPress pages and posts.
* Version: 5.7.3
* Author: Pootlepress
* Author URI: http://pootlepress.com/
* License: GPL version 3
* @developer http://wpdevelopment.me <shramee@wpdevelopment.me>
* @fs_premium_only /ppbpro/
*/
if ( ! class_exists( 'Pootle_Page_Builder' ) ) {
/** Pootle page builder current version */
define( 'POOTLEPB_VERSION', '5.7.3' );
/** Pootle page builder __FILE__ */
define( 'POOTLEPB_BASE_FILE', __FILE__ );
/** Pootle page builder plugin directory path */
define( 'POOTLEPB_DIR', dirname( __FILE__ ) . '/' );
/** Pootle page builder plugin directory url */
define( 'POOTLEPB_URL', plugin_dir_url( __FILE__ ) );
/**
* Class Pootle_Page_Builder
* Pootle Page Builder admin class
* @since 0.1.0
*/
final class Pootle_Page_Builder {
/**
* @var Pootle_Page_Builder instance of Pootle_Page_Builder
* @access protected
* @since 0.1.0
*/
protected static $instance;
/**
* @var Pootle_Page_Builder_Admin Admin class instance
* @access protected
* @since 0.1.0
*/
protected $admin;
/**
* @var Pootle_Page_Builder_Public Public class instance
* @access protected
* @since 0.1.0
*/
protected $public;
/**
* @var WP_Query Contains ppb posts
* @access protected
* @since 0.3.0
*/
public $ppb_posts;
/**
* Magic __construct
* @since 0.1.0
*/
public function __construct() {
$this->includes();
$this->hooks();
// Init Freemius and add uninstall hook.
ppb_fs()->add_action( 'after_uninstall', array( $this, 'uninstall' ) );
ppb_fs()->add_filter( 'show_trial', '__return_false' );
}
/**
* Include the required files
* @since 0.1.0
*/
private function includes() {
/** Variables used throughout the plugin */
require_once POOTLEPB_DIR . 'inc/vars.php';
/** Functions used throughout the plugin */
require_once POOTLEPB_DIR . 'inc/funcs.php';
/** Enhancements and fixes */
require_once POOTLEPB_DIR . 'inc/enhancements-and-fixes.php';
/** PPB Admin Class */
require_once POOTLEPB_DIR . 'inc/class-admin.php';
/** @var Pootle_Page_Builder_Admin PPB Admin Class Instance */
$this->admin = $GLOBALS['Pootle_Page_Builder_Admin'] = new Pootle_Page_Builder_Admin();
/** PPB Public Class */
require_once POOTLEPB_DIR . 'inc/class-public.php';
/** @var Pootle_Page_Builder_Public PPB Public Class Instance */
$this->public = $GLOBALS['Pootle_Page_Builder_Public'] = new Pootle_Page_Builder_Public();
if ( ppb_fs()->is__premium_only() ) {
if ( ppb_fs()->is_plan( 'ppbpro' ) ) {
/** PPB Public Class */
require_once POOTLEPB_DIR . 'ppbpro/ppbpro.php';
}
}
/** PPB Live Editor */
require_once POOTLEPB_DIR . 'inc/class-live-editor.php';
/** Intantiating main plugin class */
Pootle_Page_Builder_Live_Editor::instance( __FILE__ );
}
/**
* Adds the actions and filter hooks for plugin functioning
* @since 0.1.0
*/
private function hooks() {
register_activation_hook( __FILE__, array( $this, 'activate' ) );
add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ) );
add_action( 'admin_init', array( $this, 'ppb_compatibility' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ) );
add_action( 'admin_notices', array( $this, 'admin_notices' ) );
add_action( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'plugin_action_links' ) );
add_action( 'activated_plugin', array( $this, 'activation_redirect' ) );
}
public function activation_redirect( $plugin ) {
if ( $plugin == plugin_basename( __FILE__ ) ) {
exit( wp_redirect( admin_url( 'admin.php?page=page_builder' ) ) );
}
}
/**
* Hook for activation of Page Builder.
* @since 0.1.0
*/
public function activate() {
//Updating version
add_option( 'pootlepb_initial_version', POOTLEPB_VERSION, '', 'no' );
$current_user = wp_get_current_user();
//Get first name if set
$username = '';
if ( ! empty( $current_user->user_firstname ) ) {
$username = " {$current_user->user_firstname}";
}
//$welcome_message = "<b>Hey{$username}! Welcome to Page builder.</b> You're all set to start building stunning pages!<br><a class='button pootle' href='" . admin_url( '/admin.php?page=page_builder' ) . "'>Get started</a>";
//pootlepb_add_admin_notice( 'welcome', $welcome_message, 'updated pootle' );
}
/**
* Return Query with all posts using ppb
* @return WP_Query
* @since 0.3.0
*/
public function ppb_posts() {
if ( empty( $this->ppb_posts ) ) {
//Get all posts using page builder
$args = array(
'post_type' => pootlepb_settings( 'post-types' ),
'posts_per_page' => - 1,
'meta_query' => array(
array(
'key' => 'panels_data',
'compare' => 'EXISTS',
),
)
);
$this->ppb_posts = new WP_Query( $args );
}
return $this->ppb_posts;
}
/**
* Return Query with all posts using ppb
* @return WP_Query
* @since 0.3.0
*/
public function ppb_compatibility() {
update_option( 'pootlepb_version', POOTLEPB_VERSION, 'no' );
}
/**
* Initialize the language files
* @action plugins_loaded
* @since 0.1.0
*/
public function plugins_loaded() {
if ( ! function_exists( 'pbtn_script' ) ) {
/** Functions used throughout the plugin */
require_once POOTLEPB_DIR . 'inc/pootle-buttons/pootle-button.php';
}
load_plugin_textdomain( 'ppb-panels', false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
if ( defined( 'WPSEO_VERSION' ) && 0 > version_compare( WPSEO_VERSION, 3 ) ) {
add_filter( 'wpseo_pre_analysis_post_content', 'pootlepb_wp_seo_filter', 10, 2 );
}
}
/**
* Enqueue admin scripts and styles
* @global $pagenow
* @action admin_notices
* @since 0.1.0
*/
public function enqueue() {
global $pagenow;
wp_register_script( 'pootlepb-ui', POOTLEPB_URL . 'js/ppb-ui.js', array(
'jquery-ui-dialog',
'jquery-ui-tabs'
), POOTLEPB_VERSION );
wp_register_style( 'pootlepb-ui-styles', POOTLEPB_URL . 'css/ppb-jq-ui.css', array() );
wp_enqueue_style( 'pootlepage-main-admin', plugin_dir_url( __FILE__ ) . 'css/main-admin.css', array(), POOTLEPB_VERSION );
$page = filter_input( INPUT_GET, 'page' );
if ( $pagenow == 'admin.php' && false !== strpos( $page, 'page_builder' ) ) {
wp_enqueue_script( 'pootlepb-ui' );
wp_enqueue_style( 'pootlepb-ui-styles' );
wp_enqueue_script( 'ppb-settings-script', POOTLEPB_URL . 'js/settings.js', array( 'pootlepb-ui' ) );
wp_enqueue_style( 'ppb-option-admin', POOTLEPB_URL . 'css/option-admin.css', array(), POOTLEPB_VERSION );
if ( 'page_builder_modules' == $page ) {
wp_enqueue_style( 'ppb-option-modules', POOTLEPB_URL . 'css/option-modules.css', array(), POOTLEPB_VERSION );
wp_enqueue_script( 'ppb-option-modules', POOTLEPB_URL . 'js/option-modules.js', array( 'jquery-ui-sortable', ), POOTLEPB_VERSION );
}
add_thickbox();
}
}
/**
* Outputs admin notices
* @action admin_notices
* @since 0.1.0
*/
public function admin_notices() {
$notices = get_option( 'pootlepb_admin_notices', array() );
delete_option( 'pootlepb_admin_notices' );
if ( 0 < count( $notices ) ) {
$html = '';
foreach ( $notices as $k => $v ) {
$html .= '<div id="' . esc_attr( $k ) . '" class="fade ' . esc_attr( $v['type'] ) . '">' . wpautop( $v['message'] ) . '</div>' . "\n";
}
echo $html;
}
}
/**
* Add plugin action links.
*
* @param $links
*
* @action plugin_action_links_$file
* @return array
* @TODO Use this
* @since 0.1.0
*/
public function plugin_action_links( $links ) {
return $links;
}
/**
* Executed by freemius on uninstall
*/
public function uninstall() {
define( 'POOTLEPB_UNINSTALL', true );
include 'run-on-uninstall.php';
}
} //class Pootle_Page_Builder
/** @var Pootle_Page_Builder $Pootle_Page_Builder Instance */
global $Pootle_Page_Builder;
/** @var Pootle_Page_Builder $Pootle_Page_Builder Instance */
$Pootle_Page_Builder = new Pootle_Page_Builder();
}