forked from wp-plugins/page-layout-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpage-layout-builder.php
209 lines (182 loc) · 6.69 KB
/
page-layout-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
<?php
/*
Plugin Name: MiniMax - Page Layout Builder
Description: MiniMax - Drag and Drop Page Builder / Layout Builder / Content Builder for WordPress
Plugin URI: http://wpeden.com/minimax-wordpress-page-layout-builder-plugin/
GitHub Plugin URI: https://github.com/suqld/page-layout-builder
Author: Shaon
Version: 2.0.4
Author URI: http://wpeden.com
*/
// Exit if accessed directly
if (!defined('ABSPATH')) {
exit;
}
define("MX_THEME_DIR", dirname(__FILE__));
define("MX_PLUG_DIR", dirname(__FILE__));
define("MX_CACHE_DIR", dirname(__FILE__) . '/cache/');
define("MX_THEME_URL", get_stylesheet_directory_uri());
if (!defined('MX_THEME'))
define('MX_THEME', 'minimax_root');
global $minimax_layout_holder;
$minimax_layout_holder = array(
'header' => 'Header Layout',
'footer' => 'Footer Layout'
);
if (!isset($content_width))
$content_width = 960;
include("includes/core.php");
/* Theme Option Menu */
function minimax_opt_menu() {
add_menu_page("MiniMax", "MiniMax", 'administrator', 'minimax', 'minimax_options', 'dashicons-layout');
}
/* Theme Option Function */
function minimax_options() {
global $minimax_options;
require_once("includes/theme-options.php");
}
function minimax_squeeze_page_canvas() {
if (get_post_meta(get_the_ID(), 'squeeze_page', true) == 1):
$template = get_post_meta(get_the_ID(), 'sptemplate', true);
include("canvas/{$template}/index.php");
die();
endif;
}
function minimax_module_status_change() {
if (isset($_POST['module']) && $_POST['module']) {
$modules = get_option("minimax_allowed_modules");
if ($_POST['status'] == "power_off") {
$modules[$_POST['module']] = $_POST['module'];
$stats_return = "power_on";
} else {
unset($modules[$_POST['module']]);
$stats_return = "power_off";
}
update_option("minimax_allowed_modules", $modules);
die($stats_return);
}
}
function custom_init() {
register_post_type("minimax_tabs", array(
'labels' => array(
'name' => __('Tabs'),
'singular_name' => __('Tabs'),
'add_new' => __('Add New'),
'add_new_item' => __('Add New'),
'edit_item' => __('Edit Tab'),
'new_item' => __('New Tab'),
'view_item' => __('View Tab'),
'search_items' => __('Search Tab'),
'not_found' => __('No Tab found'),
'not_found_in_trash' => __('No Tab found in Trash'),
'parent_item_colon' => ''
),
'public' => true,
'publicly_queryable' => true,
'has_archive' => true,
'show_ui' => true,
'query_var' => true,
'rewrite' => array('slug' => 'minimax-tabs', 'with_front' => true),
'capability_type' => 'post',
'hierarchical' => false,
'menu_icon' => 'dashicons-editor-kitchensink',
'supports' => array('title', 'editor')
)
);
register_post_type("minimax_accordion", array(
'labels' => array(
'name' => __('Accordions'),
'singular_name' => __('Accordion'),
'add_new' => __('Add New'),
'add_new_item' => __('Add New'),
'edit_item' => __('Edit Accordion'),
'new_item' => __('New Accordion'),
'view_item' => __('View Accordion'),
'search_items' => __('Search Accordion'),
'not_found' => __('No Accordion found'),
'not_found_in_trash' => __('No Accordion found in Trash'),
'parent_item_colon' => ''
),
'public' => true,
'publicly_queryable' => true,
'has_archive' => true,
'show_ui' => true,
'query_var' => true,
'rewrite' => array('slug' => 'minimax-accordion', 'with_front' => true),
'capability_type' => 'post',
'hierarchical' => false,
'menu_icon' => 'dashicons-menu',
'supports' => array('title', 'editor')
)
);
}
function minimax_add_custom_box() {
add_meta_box('minimax_slider_link', __('Slider Link', 'wp'), 'minimax_slider_link', 'minimax_slider', 'side', 'core');
}
function minimax_slider_link($post) {
?>
<input type="text" class="widefat" name="minimax_slider_link" value="<?php echo get_post_meta($post->ID, "minimax_slider_link", true); ?>">
<?php
}
function minimax_save_link($post_id) {
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
return;
if (!current_user_can('edit_post', $post_id))
return;
if (!isset($_POST['minimax_slider_link']))
return;
update_post_meta($post_id, 'minimax_slider_link', $_POST['minimax_slider_link']);
}
function minimax_module_update_checker() {
$module = $_POST['module'];
$modinfo = get_plugin_data(dirname(__FILE__) . '/modules/' . $module . '/' . $module . '.php');
$version = $modinfo['Version'];
$data = array('task' => 'updatecheck', 'module' => $module, 'version' => $version);
$res = wp_remote_post("http://localhost/minimax-server/index.php", array(
'method' => 'POST',
'timeout' => 45,
'redirection' => 5,
'httpversion' => '1.0',
'blocking' => true,
'headers' => array(),
'body' => $data,
'cookies' => array()
));
if ($res['body'] == 0)
$data = 0;
else
$data = array("version" => $res['body'], "module" => $_POST['module'] . ".v." . $res['body']);
echo json_encode($data);
die();
}
// add a link to the WP Toolbar
function activate_front_editor($wp_admin_bar) {
if(is_admin()) return;
$args = array(
'id' => 'minimax_admin_toolbar',
'title' => 'Edit With MiniMax',
'href' => home_url('/?mxfrontend=1'),
'meta' => array(
'class' => 'minimax_admin_toolbar',
'title' => 'Edit With MiniMax'
)
);
$wp_admin_bar->add_node($args);
}
//add_action('admin_bar_menu', 'activate_front_editor', 999);
function minimax_add_settings_link( $links ) {
$settings_link = '<a href="admin.php?page=minimax">' . __( 'Settings' ) . '</a>';
array_push( $links, $settings_link );
$support_link = '<a target="_blank" href="http://wpeden.com/forums/forum/plugin-support/minimax/">' . __( 'Support Forum' ) . '</a>';
array_push( $links, $support_link );
return $links;
}
$pbn = plugin_basename( __FILE__ );
add_filter( "plugin_action_links_$pbn", 'minimax_add_settings_link' );
//add_action('add_meta_boxes', 'minimax_add_custom_box');
add_action('save_post', 'minimax_save_link');
add_action('init', 'custom_init');
add_action('admin_menu', 'minimax_opt_menu');
add_action('template_redirect', 'minimax_squeeze_page_canvas');
add_action('wp_ajax_module_status_change', 'minimax_module_status_change');
add_action('wp_ajax_check_module_update', 'minimax_module_update_checker');