Aqua Page Builder - Version 1.1.0

Version Description

Download this release

Release Info

Developer syamilmj
Plugin Icon wp plugin Aqua Page Builder
Version 1.1.0
Comparing to
See all releases

Version 1.1.0

aq-page-builder.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /** بسم الله الرحمن الرحيم **
3
+
4
+ Plugin Name: Aqua Page Builder
5
+ Plugin URI: http://aquagraphite.com/page-builder
6
+ Description: Easily create custom page templates with intuitive drag-and-drop interface. Requires PHP5 and WP3.5
7
+ Version: 1.1.0
8
+ Author: Syamil MJ
9
+ Author URI: http://aquagraphite.com
10
+
11
+ */
12
+
13
+ /**
14
+ * Copyright (c) 2013 Syamil MJ. All rights reserved.
15
+ *
16
+ * Released under the GPL license
17
+ * http://www.opensource.org/licenses/gpl-license.php
18
+ *
19
+ * This is an add-on for WordPress
20
+ * http://wordpress.org/
21
+ *
22
+ * **********************************************************************
23
+ * This program is free software; you can redistribute it and/or modify
24
+ * it under the terms of the GNU General Public License as published by
25
+ * the Free Software Foundation; either version 2 of the License, or
26
+ * (at your option) any later version.
27
+ *
28
+ * This program is distributed in the hope that it will be useful,
29
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
30
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31
+ * GNU General Public License for more details.
32
+ * **********************************************************************
33
+ */
34
+
35
+ //definitions
36
+ if(!defined('AQPB_VERSION')) define( 'AQPB_VERSION', '1.1.0' );
37
+ if(!defined('AQPB_PATH')) define( 'AQPB_PATH', plugin_dir_path(__FILE__) );
38
+ if(!defined('AQPB_DIR')) define( 'AQPB_DIR', plugin_dir_url(__FILE__) );
39
+
40
+ //required functions & classes
41
+ require_once(AQPB_PATH . 'functions/aqpb_config.php');
42
+ require_once(AQPB_PATH . 'functions/aqpb_blocks.php');
43
+ require_once(AQPB_PATH . 'classes/class-aq-page-builder.php');
44
+ require_once(AQPB_PATH . 'classes/class-aq-block.php');
45
+ //require_once(AQPB_PATH . 'classes/class-aq-plugin-updater.php');
46
+ require_once(AQPB_PATH . 'functions/aqpb_functions.php');
47
+
48
+ //some default blocks
49
+ require_once(AQPB_PATH . 'blocks/aq-text-block.php');
50
+ require_once(AQPB_PATH . 'blocks/aq-column-block.php');
51
+ require_once(AQPB_PATH . 'blocks/aq-clear-block.php');
52
+ require_once(AQPB_PATH . 'blocks/aq-widgets-block.php');
53
+ require_once(AQPB_PATH . 'blocks/aq-alert-block.php');
54
+ require_once(AQPB_PATH . 'blocks/aq-tabs-block.php');
55
+ //require_once(AQPB_PATH . 'blocks/aq-richtext-block.php'); //buggy
56
+
57
+ //register default blocks
58
+ aq_register_block('AQ_Text_Block');
59
+ //aq_register_block('AQ_Richtext_Block'); //buggy
60
+ aq_register_block('AQ_Column_Block');
61
+ aq_register_block('AQ_Clear_Block');
62
+ aq_register_block('AQ_Widgets_Block');
63
+ aq_register_block('AQ_Alert_Block');
64
+ aq_register_block('AQ_Tabs_Block');
65
+
66
+ //fire up page builder
67
+ $aqpb_config = aq_page_builder_config();
68
+ $aq_page_builder =& new AQ_Page_Builder($aqpb_config);
69
+ if(!is_network_admin()) $aq_page_builder->init();
70
+
71
+ /** @legacy
72
+ //set up & fire up plugin updater
73
+ $aqpb_updater_config = array(
74
+ 'api_url' => 'http://aquagraphite.com/api/',
75
+ 'slug' => 'aqua-page-builder',
76
+ 'filename' => 'aq-page-builder.php'
77
+ );
78
+ $aqpb_updater = new AQ_Plugin_Updater($aqpb_updater_config);
79
+ */
assets/css/aqpb-view.css ADDED
@@ -0,0 +1,392 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ Core Front-end Styling for Aqua Page Builder
3
+
4
+ Themes should include their own styling for the blocks.
5
+ That includes for responsive design etc, please don't
6
+ ask me to add that for you. I hate responsive designs
7
+
8
+ DO NOT EDIT THIS
9
+
10
+ **/
11
+
12
+ /** MISC **/
13
+ .cf:after{visibility:hidden;display:block;font-size:0;content:" ";clear:both;height:0;}
14
+ .cf{display:block;}
15
+
16
+ /** Basic grid columns
17
+ -----------------------*/
18
+ /**
19
+ For those who fancy fixed widths,
20
+ copy this into your theme stylesheet
21
+
22
+ [class*="aq_span"] {
23
+ float: left;
24
+ margin-left: 20px;
25
+ }
26
+
27
+ .aq-template-wrapper .aq_span12 {width: 940px;}
28
+ .aq-template-wrapper .aq_span11 {width: 860px;}
29
+ .aq-template-wrapper .aq_span10 {width: 780px;}
30
+ .aq-template-wrapper .aq_span9 {width: 700px;}
31
+ .aq-template-wrapper .aq_span8 {width: 620px;}
32
+ .aq-template-wrapper .aq_span7 {width: 540px;}
33
+ .aq-template-wrapper .aq_span6 {width: 460px;}
34
+ .aq-template-wrapper .aq_span5 {width: 380px;}
35
+ .aq-template-wrapper .aq_span4 {width: 300px;}
36
+ .aq-template-wrapper .aq_span3 {width: 220px;}
37
+ .aq-template-wrapper .aq_span2 {width: 140px;}
38
+ .aq-template-wrapper .aq_span1 {width: 60px;}
39
+
40
+ */
41
+
42
+ [class*="aq_span"] {
43
+ float: left;
44
+ margin-left: 3%;
45
+ }
46
+
47
+ .aq-template-wrapper .aq_span1 { width:5.58%; }
48
+ .aq-template-wrapper .aq_span2 { width:14.16%; }
49
+ .aq-template-wrapper .aq_span3 { width:22.75%; }
50
+ .aq-template-wrapper .aq_span4 { width:31.33%; }
51
+ .aq-template-wrapper .aq_span5 { width:39.92%; }
52
+ .aq-template-wrapper .aq_span6 { width:48.5%; }
53
+ .aq-template-wrapper .aq_span7 { width:57.08%; }
54
+ .aq-template-wrapper .aq_span8 { width:65.67%; }
55
+ .aq-template-wrapper .aq_span9 { width:74.25%; }
56
+ .aq-template-wrapper .aq_span10 { width:82.83%; }
57
+ .aq-template-wrapper .aq_span11 { width:91.42%; }
58
+ .aq-template-wrapper .aq_span12 { width:100%; }
59
+
60
+ .aq-template-wrapper .aq-first {margin-left: 0;}
61
+
62
+ /** Blocks
63
+ -----------------------*/
64
+ .aq-block { }
65
+
66
+ /* clear block */
67
+ .aq-block-aq_clear_block { margin-bottom: 0px; }
68
+ .aq-block-hr-single { margin-bottom: 20px; }
69
+ .aq-block-hr-double { margin-bottom: 0px; }
70
+
71
+
72
+ /* column block */
73
+
74
+ /* To calculate the widths, use this (PHP):
75
+ echo '<pre>';
76
+
77
+ $columns = range(1,12);
78
+ $childcols = array();
79
+ foreach($columns as $column) {
80
+ $childcols = range(1, $column);
81
+ foreach($childcols as $childcol) {
82
+ $class = '.aq-template-wrapper .aq_span'.$column.' .aq_span'.$childcol;
83
+
84
+ $margin = 5;
85
+
86
+ $width = ( 100 + $margin ) / ( $column ) * ( $childcol ) - ( $margin );
87
+
88
+ $width = round($width, 2);
89
+
90
+ print_r($class . ' { width:'. $width .'%; }<br/>');
91
+ }
92
+
93
+ }
94
+
95
+ echo '</pre>';
96
+
97
+ **/
98
+ .aq-block-aq_column_block { margin-bottom: 0px; }
99
+ .aq-template-wrapper .aq_span1 .aq_span1 { width:100%; }
100
+ .aq-template-wrapper .aq_span2 .aq_span1 { width:47.5%; }
101
+ .aq-template-wrapper .aq_span2 .aq_span2 { width:100%; }
102
+ .aq-template-wrapper .aq_span3 .aq_span1 { width:30%; }
103
+ .aq-template-wrapper .aq_span3 .aq_span2 { width:65%; }
104
+ .aq-template-wrapper .aq_span3 .aq_span3 { width:100%; }
105
+ .aq-template-wrapper .aq_span4 .aq_span1 { width:21.25%; }
106
+ .aq-template-wrapper .aq_span4 .aq_span2 { width:47.5%; }
107
+ .aq-template-wrapper .aq_span4 .aq_span3 { width:73.75%; }
108
+ .aq-template-wrapper .aq_span4 .aq_span4 { width:100%; }
109
+ .aq-template-wrapper .aq_span5 .aq_span1 { width:16%; }
110
+ .aq-template-wrapper .aq_span5 .aq_span2 { width:37%; }
111
+ .aq-template-wrapper .aq_span5 .aq_span3 { width:58%; }
112
+ .aq-template-wrapper .aq_span5 .aq_span4 { width:79%; }
113
+ .aq-template-wrapper .aq_span5 .aq_span5 { width:100%; }
114
+ .aq-template-wrapper .aq_span6 .aq_span1 { width:12.5%; }
115
+ .aq-template-wrapper .aq_span6 .aq_span2 { width:30%; }
116
+ .aq-template-wrapper .aq_span6 .aq_span3 { width:47.5%; }
117
+ .aq-template-wrapper .aq_span6 .aq_span4 { width:65%; }
118
+ .aq-template-wrapper .aq_span6 .aq_span5 { width:82.5%; }
119
+ .aq-template-wrapper .aq_span6 .aq_span6 { width:100%; }
120
+ .aq-template-wrapper .aq_span7 .aq_span1 { width:10%; }
121
+ .aq-template-wrapper .aq_span7 .aq_span2 { width:25%; }
122
+ .aq-template-wrapper .aq_span7 .aq_span3 { width:40%; }
123
+ .aq-template-wrapper .aq_span7 .aq_span4 { width:55%; }
124
+ .aq-template-wrapper .aq_span7 .aq_span5 { width:70%; }
125
+ .aq-template-wrapper .aq_span7 .aq_span6 { width:85%; }
126
+ .aq-template-wrapper .aq_span7 .aq_span7 { width:100%; }
127
+ .aq-template-wrapper .aq_span8 .aq_span1 { width:8.13%; }
128
+ .aq-template-wrapper .aq_span8 .aq_span2 { width:21.25%; }
129
+ .aq-template-wrapper .aq_span8 .aq_span3 { width:34.38%; }
130
+ .aq-template-wrapper .aq_span8 .aq_span4 { width:47.5%; }
131
+ .aq-template-wrapper .aq_span8 .aq_span5 { width:60.63%; }
132
+ .aq-template-wrapper .aq_span8 .aq_span6 { width:73.75%; }
133
+ .aq-template-wrapper .aq_span8 .aq_span7 { width:86.88%; }
134
+ .aq-template-wrapper .aq_span8 .aq_span8 { width:100%; }
135
+ .aq-template-wrapper .aq_span9 .aq_span1 { width:6.67%; }
136
+ .aq-template-wrapper .aq_span9 .aq_span2 { width:18.33%; }
137
+ .aq-template-wrapper .aq_span9 .aq_span3 { width:30%; }
138
+ .aq-template-wrapper .aq_span9 .aq_span4 { width:41.67%; }
139
+ .aq-template-wrapper .aq_span9 .aq_span5 { width:53.33%; }
140
+ .aq-template-wrapper .aq_span9 .aq_span6 { width:65%; }
141
+ .aq-template-wrapper .aq_span9 .aq_span7 { width:76.67%; }
142
+ .aq-template-wrapper .aq_span9 .aq_span8 { width:88.33%; }
143
+ .aq-template-wrapper .aq_span9 .aq_span9 { width:100%; }
144
+ .aq-template-wrapper .aq_span10 .aq_span1 { width:5.5%; }
145
+ .aq-template-wrapper .aq_span10 .aq_span2 { width:16%; }
146
+ .aq-template-wrapper .aq_span10 .aq_span3 { width:26.5%; }
147
+ .aq-template-wrapper .aq_span10 .aq_span4 { width:37%; }
148
+ .aq-template-wrapper .aq_span10 .aq_span5 { width:47.5%; }
149
+ .aq-template-wrapper .aq_span10 .aq_span6 { width:58%; }
150
+ .aq-template-wrapper .aq_span10 .aq_span7 { width:68.5%; }
151
+ .aq-template-wrapper .aq_span10 .aq_span8 { width:79%; }
152
+ .aq-template-wrapper .aq_span10 .aq_span9 { width:89.5%; }
153
+ .aq-template-wrapper .aq_span10 .aq_span10 { width:100%; }
154
+ .aq-template-wrapper .aq_span11 .aq_span1 { width:4.55%; }
155
+ .aq-template-wrapper .aq_span11 .aq_span2 { width:14.09%; }
156
+ .aq-template-wrapper .aq_span11 .aq_span3 { width:23.64%; }
157
+ .aq-template-wrapper .aq_span11 .aq_span4 { width:33.18%; }
158
+ .aq-template-wrapper .aq_span11 .aq_span5 { width:42.73%; }
159
+ .aq-template-wrapper .aq_span11 .aq_span6 { width:52.27%; }
160
+ .aq-template-wrapper .aq_span11 .aq_span7 { width:61.82%; }
161
+ .aq-template-wrapper .aq_span11 .aq_span8 { width:71.36%; }
162
+ .aq-template-wrapper .aq_span11 .aq_span9 { width:80.91%; }
163
+ .aq-template-wrapper .aq_span11 .aq_span10 { width:90.45%; }
164
+ .aq-template-wrapper .aq_span11 .aq_span11 { width:100%; }
165
+ .aq-template-wrapper .aq_span12 .aq_span1 { width:3.75%; }
166
+ .aq-template-wrapper .aq_span12 .aq_span2 { width:12.5%; }
167
+ .aq-template-wrapper .aq_span12 .aq_span3 { width:21.25%; }
168
+ .aq-template-wrapper .aq_span12 .aq_span4 { width:30%; }
169
+ .aq-template-wrapper .aq_span12 .aq_span5 { width:38.75%; }
170
+ .aq-template-wrapper .aq_span12 .aq_span6 { width:47.5%; }
171
+ .aq-template-wrapper .aq_span12 .aq_span7 { width:56.25%; }
172
+ .aq-template-wrapper .aq_span12 .aq_span8 { width:65%; }
173
+ .aq-template-wrapper .aq_span12 .aq_span9 { width:73.75%; }
174
+ .aq-template-wrapper .aq_span12 .aq_span10 { width:82.5%; }
175
+ .aq-template-wrapper .aq_span12 .aq_span11 { width:91.25%; }
176
+ .aq-template-wrapper .aq_span12 .aq_span12 { width:100%; }
177
+
178
+ /* General
179
+ ========================================================================*/
180
+ h4.aq-block-title { margin: 0 0 20px; }
181
+
182
+ /* Alert Boxes
183
+ ========================================================================*/
184
+ .aq_alert{
185
+ border:1px solid #d8d8d8;
186
+ background-color:#FEFEFE;
187
+ padding:10px 20px;
188
+ margin:0.5em 0 20px;
189
+ }
190
+ .aq_alert h1,
191
+ .aq_alert h2,
192
+ .aq_alert h3,
193
+ .aq_alert h4,
194
+ .aq_alert h5,
195
+ .aq_alert h6 {
196
+ margin: 0 0 5px;
197
+ }
198
+ .aq_alert.info{background-color:#EFF9FF;border:1px solid #b4ddfa; color: #2b6181;}
199
+ .aq_alert.info h1,
200
+ .aq_alert.info h2,
201
+ .aq_alert.info h3,
202
+ .aq_alert.info h4,
203
+ .aq_alert.info h5,
204
+ .aq_alert.info h6 {
205
+ color: #2b6181;
206
+ }
207
+ .aq_alert.note{background-color:#FFFCE5;border:1px solid #ffdc7d; color:#D69A2A;}
208
+ .aq_alert.note h1,
209
+ .aq_alert.note h2,
210
+ .aq_alert.note h3,
211
+ .aq_alert.note h4,
212
+ .aq_alert.note h5,
213
+ .aq_alert.note h6 {
214
+ color: #D69A2A;
215
+ }
216
+ .aq_alert.warn{background-color:#ffcaca;border:1px solid #eb8d8d; color: #da3838;}
217
+ .aq_alert.warn h1,
218
+ .aq_alert.warn h2,
219
+ .aq_alert.warn h3,
220
+ .aq_alert.warn h4,
221
+ .aq_alert.warn h5,
222
+ .aq_alert.warn h6 {
223
+ color: #da3838;
224
+ }
225
+ .aq_alert.tips{background-color:#d6fedd;border:1px solid #86d492; color:#589261;}
226
+ .aq_alert.tips h1,
227
+ .aq_alert.tips h2,
228
+ .aq_alert.tips h3,
229
+ .aq_alert.tips h4,
230
+ .aq_alert.tips h5,
231
+ .aq_alert.tips h6 {
232
+ color:#589261;
233
+ }
234
+ .aq_alert h1, .aq_alert h2, .aq_alert h3 { margin: 0; }
235
+
236
+
237
+ /* Tabs
238
+ ========================================================================*/
239
+ .aq_block_tabs .ui-tabs-hide {
240
+ position: absolute;
241
+ left: -9999px;
242
+ }
243
+
244
+ .aq_block_tabs {
245
+ background: none;
246
+ margin: 0.5em 0 2em 0;
247
+ }
248
+
249
+ .aq_block_tabs ul.aq-nav {
250
+ list-style: none;
251
+ margin: 0;
252
+ padding: 0;
253
+ background: none;
254
+ border: 0;
255
+ float: none;
256
+ }
257
+
258
+ .aq_block_tabs ul.aq-nav li {
259
+ float: left;
260
+ position: relative;
261
+ margin: 0 2px -1px 0!important;
262
+ z-index: 10;
263
+ list-style: none;
264
+ }
265
+
266
+
267
+ .aq_block_tabs ul.aq-nav li a {
268
+ border: 1px solid #e1e1e1;
269
+ border-bottom: none;
270
+ display: block;
271
+ overflow: hidden;
272
+ padding: 5px 10px 0 10px;
273
+ height: 26px;
274
+ background: #FBFBFB;
275
+ margin: 0;
276
+ text-decoration: none;
277
+ color: #373737;
278
+ -webkit-border-radius: 3px 3px 0 0;
279
+ -moz-border-radius: 3px 3px 0 0;
280
+ border-radius: 3px 3px 0 0;
281
+ }
282
+
283
+ .aq_block_tabs ul.aq-nav li a:hover {
284
+ background: #fff;
285
+ margin: 0;
286
+ }
287
+
288
+ .aq_block_tabs ul.aq-nav li.ui-tabs-active a {
289
+ height: 27px;
290
+ background: #fff;
291
+ }
292
+
293
+ .aq_block_tabs .aq-tab {
294
+ background: #fff;
295
+ padding: 15px 15px 5px;
296
+ border: 1px solid #dfdfdf;
297
+ display: none;
298
+ }
299
+ .aq_block_tabs .aq-tab.first-child {
300
+ position: relative;
301
+ left: 0;
302
+ }
303
+
304
+ /* Toggles & Accordion
305
+ ====================================================================*/
306
+ .aq_block_toggle,
307
+ .aq_block_accordion {
308
+ background: #fff;
309
+ border: 1px solid #D8D8D8;
310
+ -moz-border-radius: 3px;
311
+ -webkit-border-radius: 3px;
312
+ border-radius: 3px;
313
+ margin: 0.5em 0 10px;
314
+ position: relative;
315
+ }
316
+ .aq_block_toggles_wrapper { margin: 0 0 20px; }
317
+ .aq_block_accordion_wrapper { margin: 0.5em 0 20px; }
318
+ .aq_block_accordion {
319
+ -moz-border-radius: 0px;
320
+ -webkit-border-radius: 0px;
321
+ border-radius: 0px;
322
+ border-top: none;
323
+ margin: 0;
324
+ }
325
+ .aq_block_accordion.first-child {
326
+ border-top: 1px solid #D8D8D8;
327
+ margin: 0.5em 0 0;
328
+ -webkit-border-top-left-radius: 3px;
329
+ -webkit-border-top-right-radius: 3px;
330
+ -moz-border-radius-topleft: 3px;
331
+ -moz-border-radius-topright: 3px;
332
+ border-top-left-radius: 3px;
333
+ border-top-right-radius: 3px;
334
+ }
335
+ .aq_block_accordion.last-child {
336
+ margin: 0 0 10px;
337
+ -webkit-border-bottom-right-radius: 3px;
338
+ -webkit-border-bottom-left-radius: 3px;
339
+ -moz-border-radius-bottomright: 3px;
340
+ -moz-border-radius-bottomleft: 3px;
341
+ border-bottom-right-radius: 3px;
342
+ border-bottom-left-radius: 3px;
343
+ }
344
+
345
+ .aq_block_toggle div.arrow,
346
+ .aq_block_accordion div.arrow {
347
+ display: block;
348
+ float: right;
349
+ width: 14px;
350
+ height: 14px;
351
+ position: absolute;
352
+ right: 15px;
353
+ top: 13px;
354
+ background-image: url(../images/dropdown-arrows.png);
355
+ background-repeat: no-repeat;
356
+ background-position: -40px -3px;
357
+ }
358
+ .aq_block_toggle h2.tab-head,
359
+ .aq_block_accordion h2.tab-head {
360
+ font-size: 14px;
361
+ line-height: 21px;
362
+ font-weight: normal;
363
+ margin: 0;
364
+ padding: 10px 70px 10px 15px;
365
+ -webkit-touch-callout: none;
366
+ -webkit-user-select: none;
367
+ -khtml-user-select: none;
368
+ -moz-user-select: none;
369
+ -ms-user-select: none;
370
+ user-select: none;
371
+ }
372
+ .aq_block_toggle h2.tab-head a,
373
+ .aq_block_accordion h2.tab-head a { }
374
+ .aq_block_toggle:hover div.arrow,
375
+ .aq_block_accordion:hover div.arrow { background-position: -9px -3px; }
376
+ .aq_block_toggle .tab-body,
377
+ .aq_block_accordion .tab-body {
378
+ display: none;
379
+ background: url(../images/drop-bg.png) repeat-x 0 top;
380
+ overflow: hidden;
381
+ padding: 15px 15px 5px;
382
+ -webkit-border-bottom-right-radius: 3px;
383
+ -webkit-border-bottom-left-radius: 3px;
384
+ -moz-border-radius-bottomright: 3px;
385
+ -moz-border-radius-bottomleft: 3px;
386
+ border-bottom-right-radius: 3px;
387
+ border-bottom-left-radius: 3px;
388
+ }
389
+ .aq_block_toggle .tab-body.open,
390
+ .aq_block_accordion .tab-body.open{
391
+ display: block;
392
+ }
assets/css/aqpb.css ADDED
@@ -0,0 +1,388 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ Core Styling for Aqua Page Builder
3
+
4
+ If you want to add your own styling, use the aqpb_blocks.css file
5
+ or add your own css file using the hooks
6
+
7
+ DO NOT EDIT THIS
8
+
9
+ **/
10
+
11
+ /*generic*/
12
+ .cf:after{visibility:hidden;display:block;font-size:0;content:" ";clear:both;height:0;}
13
+ .cf{display:block;}
14
+ * html .cf{height:1%;}
15
+ a:hover, a:active, a:focus { color: #d54e21; }
16
+ /*builder page*/
17
+ #page-builder-frame {
18
+ margin-left: 300px;
19
+ }
20
+
21
+ #page-builder-archive {
22
+ width: 270px;
23
+ float: left;
24
+ background: #fcfcfc;
25
+ }
26
+ #page-builder-archive.postbox .hndle { cursor: auto; }
27
+ #page-builder-fixed {
28
+ float: left;
29
+ width: 746px;
30
+ }
31
+ #page-builder {
32
+ position: relative;
33
+ margin-top: -3px;
34
+ }
35
+ .aqpbdiv {
36
+ -webkit-border-radius: 3px;
37
+ border-radius: 3px;
38
+ border-width: 1px;
39
+ border-style: solid;
40
+ }
41
+ #page-builder .aqpb-wrap {
42
+ border-color: #dfdfdf;
43
+ }
44
+
45
+ #aqpb-header, #aqpb-footer {
46
+ background-color: #f1f1f1;
47
+ background-image: -ms-linear-gradient(top,#f9f9f9,#ececec);
48
+ background-image: -moz-linear-gradient(top,#f9f9f9,#ececec);
49
+ background-image: -o-linear-gradient(top,#f9f9f9,#ececec);
50
+ background-image: -webkit-gradient(linear,left top,left bottom,from(#f9f9f9),to(#ececec));
51
+ background-image: -webkit-linear-gradient(top,#f9f9f9,#ececec);
52
+ background-image: linear-gradient(top,#f9f9f9,#ececec);
53
+ padding: 0 10px;
54
+ }
55
+ #aqpb-header {
56
+ border-bottom: 1px solid #dfdfdf;
57
+ }
58
+ #aqpb-body {
59
+ background: #fff;
60
+ border-bottom: 1px solid #dfdfdf;
61
+ border-top: 1px solid #fff;
62
+ padding: 0 10px;
63
+ }
64
+ #aqpb-footer {
65
+ border-top: 1px solid #fff;
66
+ }
67
+
68
+
69
+ /*tabs nav*/
70
+ #page-builder .aqpb-tabs-nav {
71
+ margin: 0 20px;
72
+ }
73
+ #page-builder .aqpb-tabs-arrow {
74
+ display: none;
75
+ width: 10px;
76
+ padding: 0 5px 4px;
77
+ cursor: pointer;
78
+ position: absolute;
79
+ top: 0;
80
+ line-height: 22px;
81
+ font-size: 18px;
82
+ text-shadow: 0 1px 0 #fff;
83
+ }
84
+ #page-builder .aqpb-tabs-arrow-right { right: 0; }
85
+ #page-builder .aqpb-tabs-arrow-left { left: 0; }
86
+ #page-builder .aqpb-tabs-arrow a { color: #c1c1c1; }
87
+ #page-builder .aqpb-tabs-arrow a:hover { color: #d54e21; }
88
+
89
+ #page-builder .aqpb-tabs-wrapper {
90
+ height: 28px;
91
+ margin-bottom: -1px;
92
+ overflow: hidden;
93
+ }
94
+ #page-builder .aqpb-tabs {
95
+ float: left;
96
+ margin-left: 0;
97
+ margin-right: -4000px;
98
+ padding-right: 10px;
99
+ }
100
+ .aqpb-tab {
101
+ color: #aaa;
102
+ font-family: Georgia,"Times New Roman","Bitstream Charter",Times,serif;
103
+ font-size: 14px;
104
+ background: #fbfbfb;
105
+ border-color: #dfdfdf;
106
+ border-style: solid;
107
+ border-color: #dfdfdf #dfdfdf #fff;
108
+ border-width: 1px 1px 0;
109
+ text-shadow: #fff 0 1px 0;
110
+ line-height: 16px;
111
+ display: inline-block;
112
+ padding: 4px 14px 6px;
113
+ text-decoration: none;
114
+ margin: 0 6px -1px 0;
115
+ -webkit-border-top-left-radius: 3px;
116
+ -webkit-border-top-right-radius: 3px;
117
+ border-top-left-radius: 3px;
118
+ border-top-right-radius: 3px;
119
+ }
120
+ #page-builder .aqpb-tab abbr { font-weight: bold; }
121
+ #page-builder .aqpb-tab-active {
122
+ background: #f9f9f9;
123
+ border-bottom: 1px solid #f9f9f9;
124
+ color: #464646;
125
+ -moz-box-shadow: inset 0 1px 0 #fff;
126
+ -webkit-box-shadow: inset 0 1px 0 #fff;
127
+ box-shadow: inset 0 1px 0 #fff;
128
+ }
129
+ .aqpb-tab-sortable {
130
+ float: left;
131
+ }
132
+
133
+ /*header*/
134
+ #page-builder .major-publishing-actions {
135
+ clear: both;
136
+ padding: 3px 0 5px;
137
+ }
138
+ #page-builder .major-publishing-actions .open-label {
139
+ color: #666;
140
+ display: block;
141
+ float: left;
142
+ margin-right: 15px;
143
+ }
144
+ #page-builder .major-publishing-actions .form-invalid {
145
+ padding-left: 4px;
146
+ margin-left: -4px;
147
+ }
148
+
149
+ #page-builder .publishing-action {
150
+ text-align: right;
151
+ float: right;
152
+ line-height: 23px;
153
+ margin: 5px 0 1px;
154
+ }
155
+ #page-builder .delete-action {
156
+ vertical-align: middle;
157
+ text-align: left;
158
+ float: left;
159
+ padding-right: 15px;
160
+ margin-top: 5px;
161
+ }
162
+ #page-builder .delete-action .submitdelete {
163
+ display: block;
164
+ float: left;
165
+ margin: 4px 0;
166
+ line-height: 15px;
167
+ }
168
+ #template-shortcode input {
169
+ width: 120px;
170
+ }
171
+
172
+ /*blocks*/
173
+ #page-builder .blocks {
174
+ padding: 1em 0 2em;
175
+ margin-left: -20px;
176
+ width: 744px;
177
+ }
178
+ #page-builder .block {
179
+ margin-bottom: 0;
180
+ position: relative;
181
+ max-width: 724px;
182
+ }
183
+ #page-builder .block-edit-active { min-width: 228px; }
184
+ #page-builder .block-bar {
185
+ clear: both;
186
+ line-height: 1.5em;
187
+ position: relative;
188
+ margin: 13px 0 0 0;
189
+ }
190
+ #page-builder .block-handle,
191
+ #blocks-archive .block-handle {
192
+ cursor: move;
193
+ white-space:nowrap;
194
+ text-overflow: hidden;
195
+ -moz-box-shadow: inset 0 1px 0 #fff;
196
+ -webkit-box-shadow: inset 0 1px 0 #fff;
197
+ box-shadow: inset 0 1px 0 #fff;
198
+ border: 1px solid #dfdfdf;
199
+ position: relative;
200
+ padding-left: 10px;
201
+ height: 34px;
202
+ line-height: 35px;
203
+ text-shadow: 0 1px 0 #fff;
204
+ overflow: hidden;
205
+ background-color: #f1f1f1;
206
+ background-image: -ms-linear-gradient(top,#f9f9f9,#ececec);
207
+ background-image: -moz-linear-gradient(top,#f9f9f9,#ececec);
208
+ background-image: -o-linear-gradient(top,#f9f9f9,#ececec);
209
+ background-image: -webkit-gradient(linear,left top,left bottom,from(#f9f9f9),to(#ececec));
210
+ background-image: -webkit-linear-gradient(top,#f9f9f9,#ececec);
211
+ background-image: linear-gradient(top,#f9f9f9,#ececec);
212
+ -webkit-border-radius: 3px;
213
+ border-radius: 3px;
214
+ }
215
+ #page-builder .block-edit-active .block-handle {
216
+ -webkit-border-bottom-right-radius: 0;
217
+ -webkit-border-bottom-left-radius: 0;
218
+ border-bottom-right-radius: 0;
219
+ border-bottom-left-radius: 0;
220
+ }
221
+ #page-builder .block-title,
222
+ #blocks-archive .block-title {
223
+ font-size: 12px;
224
+ font-weight: bold;
225
+ display: block;
226
+ margin-right: 20px;
227
+ }
228
+ #page-builder .block-title {overflow: hidden;}
229
+ #blocks-archive .block-title {position: absolute;}
230
+ .in-block-title { color: #606060; }
231
+ #page-builder .block-controls {
232
+ font-size: 12px;
233
+ position: absolute;
234
+ right: 20px;
235
+ top: -1px;
236
+ }
237
+ #page-builder .block-type {
238
+ color: #999;
239
+ font-size: 12px;
240
+ padding-right: 10px;
241
+ }
242
+ #page-builder .block-edit {
243
+ position: absolute;
244
+ right: -20px;
245
+ top: 0;
246
+ display: block;
247
+ width: 30px;
248
+ height: 36px;
249
+ text-indent: -999em;
250
+ border-bottom: 1px solid;
251
+ -webkit-border-bottom-left-radius: 3px;
252
+ border-bottom-left-radius: 3px;
253
+ background: transparent url(../images/arrows.png) no-repeat 8px 10px;
254
+ border-bottom-color: #eee;
255
+ }
256
+ #page-builder .block-edit:hover{ background-image: url(../images/arrows-dark.png); }
257
+ #page-builder .block-settings {
258
+ display: none;
259
+ border: solid;
260
+ border-width: 0 1px 1px 1px;
261
+ border-color: #dfdfdf;
262
+ padding: 10px 12px;
263
+ -webkit-border-bottom-right-radius: 3px;
264
+ -webkit-border-bottom-left-radius: 3px;
265
+ border-bottom-left-radius: 3px;
266
+ border-bottom-right-radius: 3px;
267
+ background-color: #f5f5f5;
268
+ background-image: -ms-linear-gradient(top,#f9f9f9,#f5f5f5);
269
+ background-image: -moz-linear-gradient(top,#f9f9f9,#f5f5f5);
270
+ background-image: -o-linear-gradient(top,#f9f9f9,#f5f5f5);
271
+ background-image: -webkit-gradient(linear,left top,left bottom,from(#f9f9f9),to(#f5f5f5));
272
+ background-image: -webkit-linear-gradient(top,#f9f9f9,#f5f5f5);
273
+ background-image: linear-gradient(top,#f9f9f9,#f5f5f5);
274
+ -moz-box-shadow: inset 0 1px 0 #fff;
275
+ -webkit-box-shadow: inset 0 1px 0 #fff;
276
+ box-shadow: inset 0 1px 0 #fff;
277
+ }
278
+
279
+ #page-builder .empty-template {
280
+ margin: 0 10px 0 30px;
281
+ }
282
+
283
+ /*blocks archive*/
284
+ #blocks-archive {
285
+ margin-right: -12px;
286
+ padding: 10px 0 0;
287
+ }
288
+ #blocks-archive .block {
289
+ margin: 0 10px 10px 0;
290
+ width: 120px;
291
+ float: left;
292
+ }
293
+ #blocks-archive .block-settings,
294
+ #blocks-archive .block-controls,
295
+ #blocks-archive .placeholder {
296
+ display: none;
297
+ }
298
+
299
+ #blocks-archive dl { margin: 0; }
300
+ #blocks-archive .block-handle {
301
+ background-color: #f5f5f5;
302
+ background-image: -ms-linear-gradient(top,#f9f9f9,#f5f5f5);
303
+ background-image: -moz-linear-gradient(top,#f9f9f9,#f5f5f5);
304
+ background-image: -o-linear-gradient(top,#f9f9f9,#f5f5f5);
305
+ background-image: -webkit-gradient(linear,left top,left bottom,from(#f9f9f9),to(#f5f5f5));
306
+ background-image: -webkit-linear-gradient(top,#f9f9f9,#f5f5f5);
307
+ background-image: linear-gradient(top,#f9f9f9,#f5f5f5);
308
+ }
309
+ .ui-draggable-dragging {
310
+ z-index: 50;
311
+ }
312
+
313
+ /*staging column*/
314
+ #page-builder-column.metabox-holder {
315
+ padding-top: 24px;
316
+ margin-left: -300px;
317
+ float: left;
318
+ }
319
+ #removing-block {
320
+ display: none;
321
+ color: #d54e21;
322
+ font-weight: normal;
323
+ padding-left: 15px;
324
+ font-size: 12px;
325
+ line-height: 1;
326
+ }
327
+ .block-control-actions {
328
+ float: left;
329
+ padding: 5px 0 0;
330
+ width: 100%;
331
+ }
332
+ .block-control-actions a { text-decoration: none; }
333
+ .block-control-actions a:hover { text-decoration: underline; }
334
+ .block-control-actions a.delete:hover { color: red; }
335
+
336
+ /*grid*/
337
+ .span12 { width: 724px; }
338
+ .span11 { width: 662px; }
339
+ .span10 { width: 600px; }
340
+ .span9 { width: 538px; }
341
+ .span8 { width: 476px; }
342
+ .span7 { width: 414px; }
343
+ .span6 { width: 352px; }
344
+ .span5 { width: 290px; }
345
+ .span4 { width: 228px; }
346
+ .span3 { width: 166px; }
347
+ .span2 { width: 104px; }
348
+ .span1 { width: 42px; }
349
+ [class*="span"] {
350
+ float: left;
351
+ margin-left: 20px;
352
+ }
353
+
354
+ /*misc*/
355
+ #page-builder .ui-resizable-handle {
356
+ position: absolute;
357
+ font-size: 0.1px;
358
+ display: block;
359
+ top: 0;
360
+ height: 100%;
361
+ width: 15px;
362
+ }
363
+ #page-builder .ui-resizable-e {
364
+ cursor: e-resize;
365
+ right: -10px;
366
+ }
367
+ #page-builder .ui-resizable-w {
368
+ cursor: w-resize;
369
+ left: -10px;
370
+ }
371
+ #page-builder .placeholder {
372
+ background: #f5f5f5;
373
+ border: 1px dashed #bbb;
374
+ float: left;
375
+ height: 36px;
376
+ margin: 13px 0 0 20px;
377
+ width: 300px;
378
+ -webkit-box-sizing: border-box;
379
+ -moz-box-sizing: border-box;
380
+ box-sizing: border-box;
381
+ }
382
+ #message.error ul {
383
+ margin-top: 0;
384
+ }
385
+ #message.error ul li {
386
+ margin-left: 20px;
387
+ list-style-type: disc;
388
+ }
assets/css/aqpb_blocks.css ADDED
@@ -0,0 +1,187 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ Blocks styling
3
+
4
+ Styles for the individual blocks in the Aqua Page Builder
5
+
6
+ DO NOT EDIT THIS
7
+
8
+ */
9
+
10
+ /** BASIC FORM ELEMENTS **/
11
+ .block-settings .description,
12
+ .block-settings p {
13
+ margin: 5px 0 7px;
14
+ }
15
+ .block-settings > p.description:last-child,
16
+ .block-settings > p:last-child {
17
+ margin-bottom: 0;
18
+ }
19
+ .block-settings .description.half {
20
+ width: 49%;
21
+ margin-right: 2%;
22
+ float: left;
23
+ }
24
+ .block-settings .description.third {
25
+ width: 32%;
26
+ margin-right: 2%;
27
+ float: left;
28
+ }
29
+ .block-settings .description.two-third {
30
+ width: 64%;
31
+ margin-right: 2%;
32
+ float: left;
33
+ }
34
+ .block-settings .description.fourth {
35
+ width: 23.5%;
36
+ margin-right: 2%;
37
+ float: left;
38
+ }
39
+ .block-settings .description.half.last,
40
+ .block-settings .description.third.last,
41
+ .block-settings .description.two-third.last,
42
+ .block-settings .description.fourth.last {
43
+ margin-right: 0;
44
+ }
45
+ .span2 .block-settings .description.half,
46
+ .span3 .block-settings .description.half,
47
+ .span4 .block-settings .description.half,
48
+ .span5 .block-settings .description.half,
49
+ .span6 .block-settings .description.half,
50
+ .span7 .block-settings .description.half,
51
+ .span2 .block-settings .description.third,
52
+ .span3 .block-settings .description.third,
53
+ .span4 .block-settings .description.third,
54
+ .span5 .block-settings .description.third,
55
+ .span6 .block-settings .description.third,
56
+ .span7 .block-settings .description.third,
57
+ .span2 .block-settings .description.two-third,
58
+ .span3 .block-settings .description.two-third,
59
+ .span4 .block-settings .description.two-third,
60
+ .span5 .block-settings .description.two-third,
61
+ .span6 .block-settings .description.two-third,
62
+ .span7 .block-settings .description.two-third,
63
+ .span3 .block-settings .description.fourth,
64
+ .span4 .block-settings .description.fourth,
65
+ .span5 .block-settings .description.fourth,
66
+ .span6 .block-settings .description.fourth,
67
+ .span7 .block-settings .description.fourth {
68
+ width: 100%;
69
+ margin-right: 0;
70
+ float: none;
71
+ }
72
+
73
+ .block-settings .description.note {
74
+ font-style: normal;
75
+ }
76
+
77
+ /** BASIC FORM INPUTS **/
78
+
79
+ /* Inputs */
80
+ .block-settings input[type="text"], .block-settings textarea {
81
+ -webkit-box-sizing: border-box;
82
+ -moz-box-sizing: border-box;
83
+ box-sizing: border-box;
84
+ }
85
+ .block-settings .input-min { width: 50px; }
86
+ .block-settings .input-small { width: 150px; }
87
+ .block-settings .input-full { width: 100%; }
88
+
89
+ .block-settings .textarea-full { width: 100%; }
90
+ .block-settings select { width: 100%; }
91
+
92
+ .block-settings .description-float {
93
+ margin-right: 10px;
94
+ float: left;
95
+ }
96
+
97
+ /* Columns */
98
+ #blocks-to-edit .block-aq_column_block {
99
+ padding: 4px;
100
+ background: #FCFCFC;
101
+ margin: 8px -5px -5px 15px;
102
+ border: 1px dotted #E3E3E3;
103
+ max-width: 734px;
104
+ }
105
+ #blocks-to-edit .block-aq_column_block ul.blocks {
106
+ min-height: 50px;
107
+ padding: 0;
108
+ margin: 0 0 0 -20px;
109
+ width: 110%;
110
+ }
111
+ #blocks-to-edit .empty-column {
112
+ margin: 0;
113
+ padding: 8px 10px 0;
114
+ color: #888;
115
+ }
116
+
117
+ /* Color Picker */
118
+ .aqpb-color-picker {
119
+ position: relative;
120
+ margin-bottom: 5px;
121
+ }
122
+ .block-settings .input-color-picker {
123
+ width: 70px;
124
+ }
125
+
126
+
127
+ /** Sortable list field **/
128
+ .aq-sortable-list { position: relative; }
129
+ .aq-sortable-list .sortable-item {
130
+ background: #fff;
131
+ border: 1px solid #d8d8d8;
132
+ -webkit-border-radius: 3px;
133
+ -moz-border-radius: 3px;
134
+ border-radius: 3px;
135
+ }
136
+ .aq-sortable-list .sortable-head,
137
+ .aq-sortable-list .sortable-body {
138
+ padding: 10px;
139
+ position: relative;
140
+ }
141
+ .aq-sortable-list .sortable-title {
142
+ margin-right: 20px;
143
+ float: left;
144
+ }
145
+ .aq-sortable-list .sortable-body {
146
+ padding-top: 0;
147
+ display: none;
148
+ }
149
+ .aq-sortable-list .sortable-handle { float: right; }
150
+ .aq-sortable-list .sortable-handle a {
151
+ position: absolute;
152
+ right: 0px;
153
+ top: 0;
154
+ display: block;
155
+ width: 30px;
156
+ height: 30px;
157
+ text-indent: -999em;
158
+ background: transparent url(../images/tab-arrows.png) no-repeat 8px -64px;
159
+ border-bottom-color: #eee;
160
+ }
161
+ .aq-sortable-list .sortable-delete { font-style: normal; }
162
+ .aq-sortable-add-new { margin-top: 10px; }
163
+ #page-builder .aq-sortable-list .ui-state-highlight {
164
+ height: 38px;
165
+ margin: 0 0 6px;
166
+ float: none;
167
+ }
168
+
169
+
170
+ /* Upload */
171
+ #TB_window {
172
+ z-index: 9999;
173
+ }
174
+ .screenshot {
175
+ float: left;
176
+ padding: 7px;
177
+ background: #fff;
178
+ border: 1px solid #dedede;
179
+ line-height: 0;
180
+ margin: 0 0 10px;
181
+ }
182
+ .screenshot img { max-width: 100% }
183
+ .input-upload { margin: 0 0 8px; }
184
+
185
+ /** Customs
186
+ Insert your own custom CSS below this line **/
187
+ #blocks-archive .block-featured_portfolio .block-title { font-size: 11px; }
assets/images/aqua-media-button.png ADDED
Binary file
assets/images/arrows-dark.png ADDED
Binary file
assets/images/arrows.png ADDED
Binary file
assets/images/drop-bg.png ADDED
Binary file
assets/images/dropdown-arrows.png ADDED
Binary file
assets/images/tab-arrows.png ADDED
Binary file
assets/js/aqpb-fields.js ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * AQPB Fields JS
3
+ *
4
+ * JS functionalities for some of the default fields
5
+ */
6
+
7
+ jQuery.noConflict();
8
+
9
+ /** Fire up jQuery - let's dance!
10
+ */
11
+ jQuery(document).ready(function($){
12
+
13
+ /** Colorpicker Field
14
+ ----------------------------------------------- */
15
+ function aqpb_colorpicker() {
16
+ $('#page-builder .input-color-picker').each(function(){
17
+ var $this = $(this),
18
+ parent = $this.parent();
19
+
20
+ $this.wpColorPicker();
21
+ });
22
+ }
23
+
24
+ aqpb_colorpicker();
25
+
26
+ $('ul.blocks').bind('sortstop', function() {
27
+ aqpb_colorpicker();
28
+ });
29
+
30
+ /** Media Uploader
31
+ ----------------------------------------------- */
32
+ $(document).on('click', '.aq_upload_button', function(event) {
33
+ var $clicked = $(this), frame,
34
+ input_id = $clicked.prev().attr('id'),
35
+ media_type = $clicked.attr('rel');
36
+
37
+ event.preventDefault();
38
+
39
+ // If the media frame already exists, reopen it.
40
+ if ( frame ) {
41
+ frame.open();
42
+ return;
43
+ }
44
+
45
+ // Create the media frame.
46
+ frame = wp.media.frames.aq_media_uploader = wp.media({
47
+ // Set the media type
48
+ library: {
49
+ type: media_type
50
+ },
51
+ view: {
52
+
53
+ }
54
+ });
55
+
56
+ // When an image is selected, run a callback.
57
+ frame.on( 'select', function() {
58
+ // Grab the selected attachment.
59
+ var attachment = frame.state().get('selection').first();
60
+
61
+ $('#' + input_id).val(attachment.attributes.url);
62
+
63
+ if(media_type == 'image') $('#' + input_id).parent().parent().parent().find('.screenshot img').attr('src', attachment.attributes.url);
64
+
65
+ });
66
+
67
+ frame.open();
68
+
69
+ });
70
+
71
+ /** Sortable Lists
72
+ ----------------------------------------------- */
73
+ // AJAX Add New <list-item>
74
+ function aq_sortable_list_add_item(action_id, items) {
75
+
76
+ var blockID = items.attr('rel'),
77
+ numArr = items.find('li').map(function(i, e){
78
+ return $(e).attr("rel");
79
+ });
80
+
81
+ var maxNum = Math.max.apply(Math, numArr);
82
+ if (maxNum < 1 ) { maxNum = 0};
83
+ var newNum = maxNum + 1;
84
+
85
+ var data = {
86
+ action: 'aq_block_'+action_id+'_add_new',
87
+ security: $('#aqpb-nonce').val(),
88
+ count: newNum,
89
+ block_id: blockID
90
+ };
91
+
92
+ $.post(ajaxurl, data, function(response) {
93
+ var check = response.charAt(response.length - 1);
94
+
95
+ //check nonce
96
+ if(check == '-1') {
97
+ alert('An unknown error has occurred');
98
+ } else {
99
+ items.append(response);
100
+ }
101
+
102
+ });
103
+ };
104
+
105
+ // Initialise sortable list fields
106
+ function aq_sortable_list_init() {
107
+ $('.aq-sortable-list').sortable({
108
+ containment: "parent",
109
+ placeholder: "ui-state-highlight"
110
+ });
111
+ }
112
+ aq_sortable_list_init();
113
+
114
+ $('ul.blocks').bind('sortstop', function() {
115
+ aq_sortable_list_init();
116
+ });
117
+
118
+
119
+ $(document).on('click', 'a.aq-sortable-add-new', function() {
120
+ var action_id = $(this).attr('rel'),
121
+ items = $(this).parent().children('ul.aq-sortable-list');
122
+
123
+ aq_sortable_list_add_item(action_id, items);
124
+ aq_sortable_list_init
125
+ return false;
126
+ });
127
+
128
+ // Delete Sortable Item
129
+ $(document).on('click', '.aq-sortable-list a.sortable-delete', function() {
130
+ var $parent = $(this.parentNode.parentNode.parentNode);
131
+ $parent.children('.block-tabs-tab-head').css('background', 'red');
132
+ $parent.slideUp(function() {
133
+ $(this).remove();
134
+ }).fadeOut('fast');
135
+ return false;
136
+ });
137
+
138
+ // Open/Close Sortable Item
139
+ $(document).on('click', '.aq-sortable-list .sortable-handle a', function() {
140
+ var $clicked = $(this);
141
+
142
+ $clicked.addClass('sortable-clicked');
143
+
144
+ $clicked.parents('.aq-sortable-list').find('.sortable-body').each(function(i, el) {
145
+ if($(el).is(':visible') && $(el).prev().find('a').hasClass('sortable-clicked') == false) {
146
+ $(el).slideUp();
147
+ }
148
+ });
149
+ $(this.parentNode.parentNode.parentNode).children('.sortable-body').slideToggle();
150
+
151
+ $clicked.removeClass('sortable-clicked');
152
+
153
+ return false;
154
+ });
155
+
156
+
157
+
158
+ });
assets/js/aqpb-view.js ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * AQPB View JS
3
+ * Front-end js for Aqua Page Builder blocks
4
+ */
5
+
6
+ /** Fire up jQuery - let's dance! */
7
+ jQuery(document).ready(function($){
8
+
9
+ /** Tabs & Toggles
10
+ -------------------------------*/
11
+ // Tabs
12
+ if(jQuery().tabs) {
13
+ $(".aq_block_tabs").tabs({
14
+ show: true
15
+ });
16
+ }
17
+
18
+ // Toggles
19
+ $('.aq_block_toggle .tab-head, .aq_block_toggle .arrow').each( function() {
20
+ var toggle = $(this).parent();
21
+
22
+ $(this).click(function() {
23
+ toggle.find('.tab-body').slideToggle();
24
+ return false;
25
+ });
26
+
27
+ });
28
+
29
+ // Accordion
30
+ $(document).on('click', '.aq_block_accordion_wrapper .tab-head, .aq_block_accordion_wrapper .arrow', function() {
31
+ var $clicked = $(this);
32
+
33
+ $clicked.addClass('clicked');
34
+
35
+ $clicked.parents('.aq_block_accordion_wrapper').find('.tab-body').each(function(i, el) {
36
+ if($(el).is(':visible') && ( $(el).prev().hasClass('clicked') || $(el).prev().prev().hasClass('clicked') ) == false ) {
37
+ $(el).slideUp();
38
+ }
39
+ });
40
+
41
+ $clicked.parent().children('.tab-body').slideToggle();
42
+
43
+ $clicked.removeClass('clicked');
44
+
45
+ return false;
46
+ });
47
+
48
+ });
assets/js/aqpb.js ADDED
@@ -0,0 +1,413 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * AQPB js
3
+ *
4
+ * contains the core js functionalities to be used
5
+ * inside AQPB
6
+ */
7
+
8
+ jQuery.noConflict();
9
+
10
+ /** Fire up jQuery - let's dance! **/
11
+ jQuery(document).ready(function($){
12
+
13
+ /** Variables
14
+ ------------------------------------------------------------------------------------**/
15
+
16
+ var block_archive,
17
+ block_number,
18
+ parent_id,
19
+ block_id,
20
+ intervalId,
21
+ resizable_args = {
22
+ grid: 62,
23
+ handles: 'w,e',
24
+ maxWidth: 724,
25
+ minWidth: 104,
26
+ resize: function(event, ui) {
27
+ ui.helper.css("height", "inherit");
28
+ },
29
+ stop: function(event, ui) {
30
+ ui.helper.css('left', ui.originalPosition.left);
31
+ ui.helper.removeClass (function (index, css) {
32
+ return (css.match (/\bspan\S+/g) || []).join(' ');
33
+ }).addClass(block_size( $(ui.helper).css('width') ));
34
+ ui.helper.find('> div > .size').val(block_size( $(ui.helper).css('width') ));
35
+ }
36
+ },
37
+ tabs_width = $('.aqpb-tabs').outerWidth(),
38
+ mouseStilldown = false,
39
+ max_marginLeft = 720 - Math.abs(tabs_width),
40
+ activeTab_pos = $('.aqpb-tab-active').next().position(),
41
+ act_mleft,
42
+ $parent,
43
+ $clicked;
44
+
45
+
46
+ /** Functions
47
+ ------------------------------------------------------------------------------------**/
48
+
49
+ /** create unique id **/
50
+ function makeid()
51
+ {
52
+ var text = "";
53
+ var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
54
+
55
+ for( var i=0; i < 5; i++ )
56
+ text += possible.charAt(Math.floor(Math.random() * possible.length));
57
+
58
+ return text;
59
+ }
60
+
61
+ /** Get correct class for block size **/
62
+ function block_size(width) {
63
+ var span = "span12";
64
+
65
+ width = parseInt(width);
66
+
67
+ if (width > 0 && width < 130){ span = "span2"; }
68
+ else if (width == 166){ span = "span3"; }
69
+ else if (width == 228){ span = "span4"; }
70
+ else if (width == 290){ span = "span5"; }
71
+ else if (width == 352){ span = "span6"; }
72
+ else if (width == 414){ span = "span7"; }
73
+ else if (width == 476){ span = "span8"; }
74
+ else if (width == 538){ span = "span9"; }
75
+ else if (width == 600){ span = "span10"; }
76
+ else if (width == 662){ span = "span11"; }
77
+ else if (width == 724){ span = "span12"; }
78
+
79
+ return span;
80
+ }
81
+
82
+ /** Blocks resizable dynamic width **/
83
+ function resizable_dynamic_width(blockID) {
84
+ var blockPar = $('#' + blockID).parent(),
85
+ maxWidth = parseInt($(blockPar).parent().parent().css('width'));
86
+
87
+ //set maxWidth for blocks inside columns
88
+ if($(blockPar).hasClass('column-blocks')) {
89
+ $('#' + blockID + '.ui-resizable').resizable( "option", "maxWidth", maxWidth );
90
+ }
91
+
92
+ //set widths when the parent resized
93
+ $('#' + blockID).bind( "resizestop", function(event, ui) {
94
+ if($('#' + blockID).hasClass('block-aq_column_block')) {
95
+ var $blockColumn = $('#' + blockID),
96
+ new_maxWidth = parseInt($blockColumn.css('width'));
97
+ child_maxWidth = new Array();
98
+
99
+ //reset maxWidth for child blocks
100
+ $blockColumn.find('ul.blocks > li').each(function() {
101
+ child_blockID = $(this).attr('id');
102
+ $('#' + child_blockID + '.ui-resizable').resizable( "option", "maxWidth", new_maxWidth );
103
+ child_maxWidth.push(parseInt($('#' + child_blockID).css('width')));
104
+ });
105
+
106
+ //get maxWidth of child blocks, use it to set the minWidth for column
107
+ var minWidth = Math.max.apply( Math, child_maxWidth );
108
+ $('#' + blockID + '.ui-resizable').resizable( "option", "minWidth", minWidth );
109
+ }
110
+ });
111
+
112
+ }
113
+
114
+ /** Update block order **/
115
+ function update_block_order() {
116
+ $('ul.blocks').each( function() {
117
+ $(this).children('li.block').each( function(index, el) {
118
+ $(el).find('.order').last().val(index + 1);
119
+
120
+ if($(el).parent().hasClass('column-blocks')) {
121
+ parent_order = $(el).parent().siblings('.order').val();
122
+ $(el).find('.parent').last().val(parent_order);
123
+ } else {
124
+ $(el).find('.parent').last().val(0);
125
+ if($(el).hasClass('block-aq_column_block')) {
126
+ block_order = $(el).find('.order').last().val();
127
+ $(el).find('li.block').each(function(index,elem) {
128
+ $(elem).find('.parent').val(block_order);
129
+ });
130
+ }
131
+ }
132
+
133
+ });
134
+ });
135
+ }
136
+
137
+ /** Update block number **/
138
+ function update_block_number() {
139
+ $('ul.blocks li.block').each( function(index, el) {
140
+ $(el).find('.number').last().val(index + 1);
141
+ });
142
+ }
143
+
144
+ function columns_sortable() {
145
+ //$('ul#blocks-to-edit, .block-aq_column_block ul.blocks').sortable('disable');
146
+ $('#page-builder .column-blocks').sortable({
147
+ placeholder: 'placeholder',
148
+ connectWith: '#blocks-to-edit, .column-blocks',
149
+ items: 'li.block'
150
+ });
151
+ }
152
+
153
+ /** Menu functions **/
154
+ function moveTabsLeft() {
155
+ if(max_marginLeft < $('.aqpb-tabs').css('margin-left').replace("px", "") ) {
156
+ $('.aqpb-tabs').animate({'marginLeft': ($('.aqpb-tabs').css('margin-left').replace("px", "") - 7) + 'px' },
157
+ 1,
158
+ function() {
159
+ if(mouseStilldown) {
160
+ moveTabsLeft();
161
+ }
162
+ });
163
+ }
164
+ }
165
+
166
+ function moveTabsRight() {
167
+ if($('.aqpb-tabs').css('margin-left').replace("px", "") < 0) {
168
+ $('.aqpb-tabs').animate({'marginLeft': Math.abs($('.aqpb-tabs').css('margin-left').replace("px", ""))*(-1) + 7 + 'px' },
169
+ 1,
170
+ function() {
171
+ if(mouseStilldown) {
172
+ moveTabsRight();
173
+ }
174
+ });
175
+ }
176
+ }
177
+
178
+ function centerActiveTab() {
179
+ if($('.aqpb-tab-active').hasClass('aqpb-tab-add')) {
180
+ act_mleft = 690 - $('.aqpb-tab-active').position().left - $('.aqpb-tab-active').width();
181
+ $('.aqpb-tabs').css('margin-left' , act_mleft + 'px');
182
+ } else
183
+ if(720 < activeTab_pos.left) {
184
+ act_mleft = 730 - activeTab_pos.left;
185
+ $('.aqpb-tabs').css('margin-left' , act_mleft + 'px');
186
+ }
187
+ }
188
+
189
+ /** Actions
190
+ ------------------------------------------------------------------------------------**/
191
+ /** Apply CSS float:left to blocks **/
192
+ $('li.block').css('float', 'none');
193
+
194
+ /** Open/close blocks **/
195
+ $(document).on('click', '#page-builder a.block-edit', function() {
196
+ var blockID = $(this).parents('li').attr('id');
197
+ $('#' + blockID + ' .block-settings').slideToggle('fast');
198
+
199
+ if( $('#' + blockID).hasClass('block-edit-active') == false ) {
200
+ $('#' + blockID).addClass('block-edit-active');
201
+ } else {
202
+ $('#' + blockID).removeClass('block-edit-active');
203
+ };
204
+
205
+ return false;
206
+ });
207
+
208
+ /** Blocks resizable **/
209
+ $('ul.blocks li.block').each(function() {
210
+ var blockID = $(this).attr('id'),
211
+ blockPar = $(this).parent();
212
+
213
+ //blocks resizing
214
+ $('#' + blockID).resizable(resizable_args);
215
+
216
+ //set dynamic width for blocks inside columns
217
+ resizable_dynamic_width(blockID);
218
+
219
+ //trigger resize
220
+ $('#' + blockID).trigger("resize");
221
+ $('#' + blockID).trigger("resizestop");
222
+
223
+ //disable resizable on .not-resizable blocks
224
+ $(".ui-resizable.not-resizable").resizable("destroy");
225
+
226
+ });
227
+
228
+ /** Blocks draggable (archive) **/
229
+ $('#blocks-archive > li.block').each(function() {
230
+ $(this).draggable({
231
+ connectToSortable: "#blocks-to-edit",
232
+ helper: 'clone',
233
+ revert: 'invalid',
234
+ start: function(event, ui) {
235
+ block_archive = $(this).attr('id');
236
+ }
237
+ });
238
+ });
239
+
240
+ /** Blocks sorting (settings) **/
241
+ $('#blocks-to-edit').sortable({
242
+ placeholder: "placeholder",
243
+ handle: '.block-handle, .block-settings-column',
244
+ connectWith: '#blocks-archive, .column-blocks',
245
+ items: 'li.block'
246
+ });
247
+
248
+ /** Columns Sortable **/
249
+ columns_sortable();
250
+
251
+ /** Sortable bindings **/
252
+ $( "ul.blocks" ).bind( "sortstart", function(event, ui) {
253
+ ui.placeholder.css('width', ui.helper.css('width'));
254
+ ui.placeholder.css('height', ( ui.helper.css('height').replace("px", "") - 13 ) + 'px' );
255
+ $('.empty-template').remove();
256
+ });
257
+
258
+ $( "ul.blocks" ).bind( "sortstop", function(event, ui) {
259
+
260
+ //if coming from archive
261
+ if (ui.item.hasClass('ui-draggable')) {
262
+
263
+ //remove draggable class
264
+ ui.item.removeClass('ui-draggable');
265
+
266
+ //set random block id
267
+ block_number = makeid();
268
+
269
+ //replace id
270
+ ui.item.html(ui.item.html().replace(/<[^<>]+>/g, function(obj) {
271
+ return obj.replace(/__i__|%i%/g, block_number)
272
+ }));
273
+
274
+ ui.item.attr("id", block_archive.replace("__i__", block_number));
275
+
276
+ //if column, remove handle bar
277
+ if(ui.item.hasClass('block-aq_column_block')) {
278
+ ui.item.find('.block-bar').remove();
279
+ ui.item.find('.block-settings').removeClass('block-settings').addClass('block-settings-column');
280
+ }
281
+
282
+ //init resize on newly added block
283
+ ui.item.resizable(resizable_args);
284
+
285
+ //set dynamic width for blocks inside columns
286
+ resizable_dynamic_width(ui.item.attr('id'));
287
+
288
+ //trigger resize
289
+ ui.item.trigger("resize");
290
+ ui.item.trigger("resizestop");
291
+
292
+ //open on drop
293
+ ui.item.find('a.block-edit').click();
294
+
295
+ //disable resizable on .not-resizable blocks
296
+ $(".ui-resizable.not-resizable").resizable("destroy");
297
+
298
+ }
299
+
300
+ //if moving column inside column, cancel it
301
+ if(ui.item.hasClass('block-aq_column_block')) {
302
+ if(ui.item.parent().hasClass('column-blocks')) {
303
+ $(this).sortable('cancel');
304
+ return false;
305
+ }
306
+ columns_sortable();
307
+ }
308
+
309
+ //@todo - resize column to maximum width of dropped item
310
+
311
+ //update order & parent ids
312
+ update_block_order();
313
+
314
+ //update number
315
+ update_block_number();
316
+
317
+ });
318
+
319
+ /** Blocks droppable (removing blocks) **/
320
+ $('#page-builder-archive').droppable({
321
+ accept: "#blocks-to-edit .block",
322
+ tolerance: "pointer",
323
+ over : function(event, ui) {
324
+ $(this).find('#removing-block').fadeIn('fast');
325
+ ui.draggable.parent().find('.placeholder').hide();
326
+ },
327
+ out : function(event, ui) {
328
+ $(this).find('#removing-block').fadeOut('fast');
329
+ ui.draggable.parent().find('.placeholder').show();
330
+ },
331
+ drop: function(ev, ui) {
332
+ ui.draggable.remove();
333
+ $(this).find('#removing-block').fadeOut('fast');
334
+ }
335
+ });
336
+
337
+ /** Delete Block (via "Delete" anchor) **/
338
+ $(document).on('click', '.block-control-actions a', function() {
339
+ $clicked = $(this);
340
+ $parent = $(this.parentNode.parentNode.parentNode);
341
+
342
+ if($clicked.hasClass('delete')) {
343
+ $parent.find('> .block-bar .block-handle').css('background', 'red');
344
+ $parent.slideUp(function() {
345
+ $(this).remove();
346
+ update_block_order();
347
+ update_block_number();
348
+ }).fadeOut('fast');
349
+ } else if($clicked.hasClass('close')) {
350
+ $parent.find('> .block-bar a.block-edit').click();
351
+ }
352
+ return false;
353
+ });
354
+
355
+ /** Disable blocks archive if no template **/
356
+ $('#page-builder-column.metabox-holder-disabled').click( function() { return false })
357
+ $('#page-builder-column.metabox-holder-disabled #blocks-archive .block').draggable("destroy");
358
+
359
+ /** Confirm delete template **/
360
+ $('a.template-delete').click( function() {
361
+ var agree = confirm('You are about to permanently delete this template. \'Cancel\' to stop, \'OK\' to delete.');
362
+ if(agree) { return } else { return false }
363
+ });
364
+
365
+ /** Cancel template save/create if no template name **/
366
+ $('#save_template_header, #save_template_footer').click(function() {
367
+ var template_name = $('#template-name').val().trim();
368
+ if(template_name.length === 0) {
369
+ $('.major-publishing-actions .open-label').addClass('form-invalid');
370
+ return false;
371
+ }
372
+ });
373
+
374
+ /** Nav tabs scrolling **/
375
+ if(720 < tabs_width) {
376
+ $('.aqpb-tabs-arrow').show();
377
+ centerActiveTab();
378
+ $('.aqpb-tabs-arrow-right a').mousedown(function() {
379
+ mouseStilldown = true;
380
+ moveTabsLeft();
381
+ }).bind('mouseup mouseleave', function() {
382
+ mouseStilldown = false;
383
+ });
384
+
385
+ $('.aqpb-tabs-arrow-left a').mousedown(function() {
386
+ mouseStilldown = true;
387
+ moveTabsRight();
388
+ }).bind('mouseup mouseleave', function() {
389
+ mouseStilldown = false;
390
+ });
391
+
392
+ }
393
+
394
+ /** Sort nav order **/
395
+ $('.aqpb-tabs').sortable({
396
+ items: '.aqpb-tab-sortable',
397
+ axis: 'x',
398
+ });
399
+
400
+ /** Apply CSS float:left to blocks **/
401
+ $('li.block').css('float', '');
402
+
403
+ /** prompt save on page change **
404
+ var aqpb_html = $('#update-page-template').html();
405
+ $(window).bind('beforeunload', function(e) {
406
+ var aqpb_html_new = $('#update-page-template').html();
407
+ if(aqpb_html_new != aqpb_html) {
408
+ return "The changes you made will be lost if you navigate away from this page.";
409
+ }
410
+ }); */
411
+
412
+ // what fish?
413
+ });
blocks/aq-alert-block.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /** Notifications block **/
3
+
4
+ if(!class_exists('AQ_Alert_Block')) {
5
+ class AQ_Alert_Block extends AQ_Block {
6
+
7
+ //set and create block
8
+ function __construct() {
9
+ $block_options = array(
10
+ 'name' => 'Alerts',
11
+ 'size' => 'span6',
12
+ );
13
+
14
+ //create the block
15
+ parent::__construct('aq_alert_block', $block_options);
16
+ }
17
+
18
+ function form($instance) {
19
+
20
+ $defaults = array(
21
+ 'content' => '',
22
+ 'type' => 'note',
23
+ 'style' => ''
24
+ );
25
+ $instance = wp_parse_args($instance, $defaults);
26
+ extract($instance);
27
+
28
+ $type_options = array(
29
+ 'default' => 'Standard',
30
+ 'info' => 'Info',
31
+ 'note' => 'Notification',
32
+ 'warn' => 'Warning',
33
+ 'tips' => 'Tips'
34
+ );
35
+
36
+ ?>
37
+
38
+ <p class="description">
39
+ <label for="<?php echo $this->get_field_id('title') ?>">
40
+ Title (optional)<br/>
41
+ <?php echo aq_field_input('title', $block_id, $title) ?>
42
+ </label>
43
+ </p>
44
+ <p class="description">
45
+ <label for="<?php echo $this->get_field_id('content') ?>">
46
+ Alert Text (required)<br/>
47
+ <?php echo aq_field_textarea('content', $block_id, $content) ?>
48
+ </label>
49
+ </p>
50
+ <p class="description half">
51
+ <label for="<?php echo $this->get_field_id('type') ?>">
52
+ Alert Type<br/>
53
+ <?php echo aq_field_select('type', $block_id, $type_options, $type) ?>
54
+ </label>
55
+ </p>
56
+ <p class="description half last">
57
+ <label for="<?php echo $this->get_field_id('style') ?>">
58
+ Additional inline css styling (optional)<br/>
59
+ <?php echo aq_field_input('style', $block_id, $style) ?>
60
+ </label>
61
+ </p>
62
+ <?php
63
+
64
+ }
65
+
66
+ function block($instance) {
67
+ extract($instance);
68
+
69
+ echo '<div class="aq_alert '.$type.' cf" style="'. $style .'">' . do_shortcode(htmlspecialchars_decode($content)) . '</div>';
70
+
71
+ }
72
+
73
+ }
74
+ }
blocks/aq-clear-block.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /** "Clear" block
3
+ *
4
+ * Clear the floats vertically
5
+ * Optional to use horizontal lines/images
6
+ **/
7
+ class AQ_Clear_Block extends AQ_Block {
8
+
9
+ //set and create block
10
+ function __construct() {
11
+ $block_options = array(
12
+ 'name' => 'Clear',
13
+ 'size' => 'span12',
14
+ );
15
+
16
+ //create the block
17
+ parent::__construct('aq_clear_block', $block_options);
18
+ }
19
+
20
+ function form($instance) {
21
+
22
+ $defaults = array(
23
+ 'horizontal_line' => 'none',
24
+ 'line_color' => '#353535',
25
+ 'pattern' => '1',
26
+ 'height' => ''
27
+ );
28
+
29
+ $line_options = array(
30
+ 'none' => 'None',
31
+ 'single' => 'Single',
32
+ 'double' => 'Double',
33
+ 'image' => 'Use Image',
34
+ );
35
+
36
+ $instance = wp_parse_args($instance, $defaults);
37
+ extract($instance);
38
+
39
+ $line_color = isset($line_color) ? $line_color : '#353535';
40
+
41
+ ?>
42
+ <p class="description note">
43
+ <?php _e('Use this block to clear the floats between two or more separate blocks vertically.', 'framework') ?>
44
+ </p>
45
+ <p class="description fourth">
46
+ <label for="<?php echo $this->get_field_id('line_color') ?>">
47
+ Pick a horizontal line<br/>
48
+ <?php echo aq_field_select('horizontal_line', $block_id, $line_options, $horizontal_line, $block_id); ?>
49
+ </label>
50
+ </p>
51
+ <div class="description fourth">
52
+ <label for="<?php echo $this->get_field_id('height') ?>">
53
+ Height (optional)<br/>
54
+ <?php echo aq_field_input('height', $block_id, $height, 'min', 'number') ?> px
55
+ </label>
56
+ </div>
57
+ <div class="description half last">
58
+ <label for="<?php echo $this->get_field_id('line_color') ?>">
59
+ Pick a line color<br/>
60
+ <?php echo aq_field_color_picker('line_color', $block_id, $line_color, $defaults['line_color']) ?>
61
+ </label>
62
+
63
+ </div>
64
+ <?php
65
+
66
+ }
67
+
68
+ function block($instance) {
69
+ extract($instance);
70
+
71
+ switch($horizontal_line) {
72
+ case 'none':
73
+ break;
74
+ case 'single':
75
+ echo '<hr class="aq-block-clear aq-block-hr-single" style="background:'.$line_color.';"/>';
76
+ break;
77
+ case 'double':
78
+ echo '<hr class="aq-block-clear aq-block-hr-double" style="background:'.$line_color.';"/>';
79
+ echo '<hr class="aq-block-clear aq-block-hr-single" style="background:'.$line_color.';"/>';
80
+ break;
81
+ case 'image':
82
+ echo '<hr class="aq-block-clear aq-block-hr-image cf"/>';
83
+ break;
84
+ }
85
+
86
+ if($height) {
87
+ echo '<div class="cf" style="height:'.$height.'px"></div>';
88
+ }
89
+
90
+ }
91
+
92
+ }
blocks/aq-column-block.php ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /** A simple text block **/
3
+ class AQ_Column_Block extends AQ_Block {
4
+
5
+ /* PHP5 constructor */
6
+ function __construct() {
7
+
8
+ $block_options = array(
9
+ 'name' => 'Column',
10
+ 'size' => 'span6',
11
+ );
12
+
13
+ //create the widget
14
+ parent::__construct('aq_column_block', $block_options);
15
+
16
+ }
17
+
18
+ function form($instance) {
19
+ echo '<p class="empty-column">',
20
+ __('Drag block items into this column box', 'framework'),
21
+ '</p>';
22
+ echo '<ul class="blocks column-blocks cf"></ul>';
23
+ }
24
+
25
+ function form_callback($instance = array()) {
26
+ $instance = is_array($instance) ? wp_parse_args($instance, $this->block_options) : $this->block_options;
27
+
28
+ //insert the dynamic block_id & block_saving_id into the array
29
+ $this->block_id = 'aq_block_' . $instance['number'];
30
+ $instance['block_saving_id'] = 'aq_blocks[aq_block_'. $instance['number'] .']';
31
+
32
+ extract($instance);
33
+
34
+ $col_order = $order;
35
+
36
+ //column block header
37
+ if(isset($template_id)) {
38
+ echo '<li id="template-block-'.$number.'" class="block block-aq_column_block '.$size.'">',
39
+ '<div class="block-settings-column cf" id="block-settings-'.$number.'">',
40
+ '<p class="empty-column">',
41
+ __('Drag block items into this column box', 'framework'),
42
+ '</p>',
43
+ '<ul class="blocks column-blocks cf">';
44
+
45
+ //check if column has blocks inside it
46
+ $blocks = aq_get_blocks($template_id);
47
+
48
+ //outputs the blocks
49
+ if($blocks) {
50
+ foreach($blocks as $key => $child) {
51
+ global $aq_registered_blocks;
52
+ extract($child);
53
+
54
+ //get the block object
55
+ $block = $aq_registered_blocks[$id_base];
56
+
57
+ if($parent == $col_order) {
58
+ $block->form_callback($child);
59
+ }
60
+ }
61
+ }
62
+ echo '</ul>';
63
+
64
+ } else {
65
+ $this->before_form($instance);
66
+ $this->form($instance);
67
+ }
68
+
69
+ //form footer
70
+ $this->after_form($instance);
71
+ }
72
+
73
+ //form footer
74
+ function after_form($instance) {
75
+ extract($instance);
76
+
77
+ $block_saving_id = 'aq_blocks[aq_block_'.$number.']';
78
+
79
+ echo '<div class="block-control-actions cf"><a href="#" class="delete">Delete</a></div>';
80
+ echo '<input type="hidden" class="id_base" name="'.$this->get_field_name('id_base').'" value="'.$id_base.'" />';
81
+ echo '<input type="hidden" class="name" name="'.$this->get_field_name('name').'" value="'.$name.'" />';
82
+ echo '<input type="hidden" class="order" name="'.$this->get_field_name('order').'" value="'.$order.'" />';
83
+ echo '<input type="hidden" class="size" name="'.$this->get_field_name('size').'" value="'.$size.'" />';
84
+ echo '<input type="hidden" class="parent" name="'.$this->get_field_name('parent').'" value="'.$parent.'" />';
85
+ echo '<input type="hidden" class="number" name="'.$this->get_field_name('number').'" value="'.$number.'" />';
86
+ echo '</div>',
87
+ '</li>';
88
+ }
89
+
90
+ function block_callback($instance) {
91
+ $instance = is_array($instance) ? wp_parse_args($instance, $this->block_options) : $this->block_options;
92
+
93
+ extract($instance);
94
+
95
+ $col_order = $order;
96
+ $col_size = absint(preg_replace("/[^0-9]/", '', $size));
97
+
98
+ //column block header
99
+ if(isset($template_id)) {
100
+ $this->before_block($instance);
101
+
102
+ //define vars
103
+ $overgrid = 0; $span = 0; $first = false;
104
+
105
+ //check if column has blocks inside it
106
+ $blocks = aq_get_blocks($template_id);
107
+
108
+ //outputs the blocks
109
+ if($blocks) {
110
+ foreach($blocks as $key => $child) {
111
+ global $aq_registered_blocks;
112
+ extract($child);
113
+
114
+ if(class_exists($id_base)) {
115
+ //get the block object
116
+ $block = $aq_registered_blocks[$id_base];
117
+
118
+ //insert template_id into $child
119
+ $child['template_id'] = $template_id;
120
+
121
+ //display the block
122
+ if($parent == $col_order) {
123
+
124
+ $child_col_size = absint(preg_replace("/[^0-9]/", '', $size));
125
+
126
+ $overgrid = $span + $child_col_size;
127
+
128
+ if($overgrid > $col_size || $span == $col_size || $span == 0) {
129
+ $span = 0;
130
+ $first = true;
131
+ }
132
+
133
+ if($first == true) {
134
+ $child['first'] = true;
135
+ }
136
+
137
+ $block->block_callback($child);
138
+
139
+ $span = $span + $child_col_size;
140
+
141
+ $overgrid = 0; //reset $overgrid
142
+ $first = false; //reset $first
143
+ }
144
+ }
145
+ }
146
+ }
147
+
148
+ $this->after_block($instance);
149
+
150
+ } else {
151
+ //show nothing
152
+ }
153
+ }
154
+
155
+ }
blocks/aq-richtext-block.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /** A simple rich textarea block **/
3
+ class AQ_Richtext_Block extends AQ_Block {
4
+
5
+ //set and create block
6
+ function __construct() {
7
+ $block_options = array(
8
+ 'name' => 'Rich Text',
9
+ 'size' => 'span6',
10
+ );
11
+
12
+ //create the block
13
+ parent::__construct('aq_richtext_block', $block_options);
14
+ }
15
+
16
+ function form($instance) {
17
+
18
+ $defaults = array(
19
+ 'text' => ''
20
+ );
21
+ $instance = wp_parse_args($instance, $defaults);
22
+ extract($instance);
23
+
24
+ ?>
25
+ <p class="description">
26
+ <label for="<?php echo $this->get_field_id('title') ?>">
27
+ Title (optional)
28
+ <?php echo aq_field_input('title', $block_id, $title, $size = 'full') ?>
29
+ </label>
30
+ </p>
31
+
32
+ <p class="description">
33
+ <label for="<?php echo $this->get_field_id('text') ?>">
34
+ Content
35
+ <?php
36
+ $args = array (
37
+ // 'tinymce' => false,
38
+ 'quicktags' => true,
39
+ );
40
+ wp_editor( htmlspecialchars_decode($text), 'aq_blocks['.$block_id.'][text]', $args );
41
+ ?>
42
+ </label>
43
+ </p>
44
+
45
+ <?php
46
+ }
47
+
48
+ function block($instance) {
49
+ extract($instance);
50
+
51
+ if($title) echo '<h4 class="aq-block-title">'.strip_tags($title).'</h4>';
52
+ echo wpautop(do_shortcode(htmlspecialchars_decode($text)));
53
+ }
54
+
55
+ }
blocks/aq-tabs-block.php ADDED
@@ -0,0 +1,208 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* Aqua Tabs Block */
3
+ if(!class_exists('AQ_Tabs_Block')) {
4
+ class AQ_Tabs_Block extends AQ_Block {
5
+
6
+ function __construct() {
7
+ $block_options = array(
8
+ 'name' => 'Tabs &amp; Toggles',
9
+ 'size' => 'span6',
10
+ );
11
+
12
+ //create the widget
13
+ parent::__construct('AQ_Tabs_Block', $block_options);
14
+
15
+ //add ajax functions
16
+ add_action('wp_ajax_aq_block_tab_add_new', array($this, 'add_tab'));
17
+
18
+ }
19
+
20
+ function form($instance) {
21
+
22
+ $defaults = array(
23
+ 'tabs' => array(
24
+ 1 => array(
25
+ 'title' => 'My New Tab',
26
+ 'content' => 'My tab contents',
27
+ )
28
+ ),
29
+ 'type' => 'tab',
30
+ );
31
+
32
+ $instance = wp_parse_args($instance, $defaults);
33
+ extract($instance);
34
+
35
+ $tab_types = array(
36
+ 'tab' => 'Tabs',
37
+ 'toggle' => 'Toggles',
38
+ 'accordion' => 'Accordion'
39
+ );
40
+
41
+ ?>
42
+ <div class="description cf">
43
+ <ul id="aq-sortable-list-<?php echo $block_id ?>" class="aq-sortable-list" rel="<?php echo $block_id ?>">
44
+ <?php
45
+ $tabs = is_array($tabs) ? $tabs : $defaults['tabs'];
46
+ $count = 1;
47
+ foreach($tabs as $tab) {
48
+ $this->tab($tab, $count);
49
+ $count++;
50
+ }
51
+ ?>
52
+ </ul>
53
+ <p></p>
54
+ <a href="#" rel="tab" class="aq-sortable-add-new button">Add New</a>
55
+ <p></p>
56
+ </div>
57
+ <p class="description">
58
+ <label for="<?php echo $this->get_field_id('type') ?>">
59
+ Tabs style<br/>
60
+ <?php echo aq_field_select('type', $block_id, $tab_types, $type) ?>
61
+ </label>
62
+ </p>
63
+ <?php
64
+ }
65
+
66
+ function tab($tab = array(), $count = 0) {
67
+
68
+ ?>
69
+ <li id="<?php echo $this->get_field_id('tabs') ?>-sortable-item-<?php echo $count ?>" class="sortable-item" rel="<?php echo $count ?>">
70
+
71
+ <div class="sortable-head cf">
72
+ <div class="sortable-title">
73
+ <strong><?php echo $tab['title'] ?></strong>
74
+ </div>
75
+ <div class="sortable-handle">
76
+ <a href="#">Open / Close</a>
77
+ </div>
78
+ </div>
79
+
80
+ <div class="sortable-body">
81
+ <p class="tab-desc description">
82
+ <label for="<?php echo $this->get_field_id('tabs') ?>-<?php echo $count ?>-title">
83
+ Tab Title<br/>
84
+ <input type="text" id="<?php echo $this->get_field_id('tabs') ?>-<?php echo $count ?>-title" class="input-full" name="<?php echo $this->get_field_name('tabs') ?>[<?php echo $count ?>][title]" value="<?php echo $tab['title'] ?>" />
85
+ </label>
86
+ </p>
87
+ <p class="tab-desc description">
88
+ <label for="<?php echo $this->get_field_id('tabs') ?>-<?php echo $count ?>-content">
89
+ Tab Content<br/>
90
+ <textarea id="<?php echo $this->get_field_id('tabs') ?>-<?php echo $count ?>-content" class="textarea-full" name="<?php echo $this->get_field_name('tabs') ?>[<?php echo $count ?>][content]" rows="5"><?php echo $tab['content'] ?></textarea>
91
+ </label>
92
+ </p>
93
+ <p class="tab-desc description"><a href="#" class="sortable-delete">Delete</a></p>
94
+ </div>
95
+
96
+ </li>
97
+ <?php
98
+ }
99
+
100
+ function block($instance) {
101
+ extract($instance);
102
+
103
+ wp_enqueue_script('jquery-ui-tabs');
104
+
105
+ $output = '';
106
+
107
+ if($type == 'tab') {
108
+
109
+ $output .= '<div id="aq_block_tabs_'. rand(1, 100) .'" class="aq_block_tabs"><div class="aq-tab-inner">';
110
+ $output .= '<ul class="aq-nav cf">';
111
+
112
+ $i = 1;
113
+ foreach( $tabs as $tab ){
114
+ $tab_selected = $i == 1 ? 'ui-tabs-active' : '';
115
+ $output .= '<li class="'.$tab_selected.'"><a href="#aq-tab-'. sanitize_title( $tab['title'] ) . $i .'">' . $tab['title'] . '</a></li>';
116
+ $i++;
117
+ }
118
+
119
+ $output .= '</ul>';
120
+
121
+ $i = 1;
122
+ foreach($tabs as $tab) {
123
+
124
+ $output .= '<div id="aq-tab-'. sanitize_title( $tab['title'] ) . $i .'" class="aq-tab">'. wpautop(do_shortcode(htmlspecialchars_decode($tab['content']))) .'</div>';
125
+
126
+ $i++;
127
+ }
128
+
129
+ $output .= '</div></div>';
130
+
131
+ } elseif ($type == 'toggle') {
132
+
133
+ $output .= '<div id="aq_block_toggles_wrapper_'.rand(1,100).'" class="aq_block_toggles_wrapper">';
134
+
135
+ foreach( $tabs as $tab ){
136
+ $output .= '<div class="aq_block_toggle">';
137
+ $output .= '<h2 class="tab-head">'. $tab['title'] .'</h2>';
138
+ $output .= '<div class="arrow"></div>';
139
+ $output .= '<div class="tab-body close cf">';
140
+ $output .= wpautop(do_shortcode(htmlspecialchars_decode($tab['content'])));
141
+ $output .= '</div>';
142
+ $output .= '</div>';
143
+ }
144
+
145
+ $output .= '</div>';
146
+
147
+ } elseif ($type == 'accordion') {
148
+
149
+ $count = count($tabs);
150
+ $i = 1;
151
+
152
+ $output .= '<div id="aq_block_accordion_wrapper_'.rand(1,100).'" class="aq_block_accordion_wrapper">';
153
+
154
+ foreach( $tabs as $tab ){
155
+
156
+ $open = $i == 1 ? 'open' : 'close';
157
+
158
+ $child = '';
159
+ if($i == 1) $child = 'first-child';
160
+ if($i == $count) $child = 'last-child';
161
+ $i++;
162
+
163
+ $output .= '<div class="aq_block_accordion '.$child.'">';
164
+ $output .= '<h2 class="tab-head">'. $tab['title'] .'</h2>';
165
+ $output .= '<div class="arrow"></div>';
166
+ $output .= '<div class="tab-body '.$open.' cf">';
167
+ $output .= wpautop(do_shortcode(htmlspecialchars_decode($tab['content'])));
168
+ $output .= '</div>';
169
+ $output .= '</div>';
170
+ }
171
+
172
+ $output .= '</div>';
173
+
174
+ }
175
+
176
+ echo $output;
177
+
178
+ }
179
+
180
+ /* AJAX add tab */
181
+ function add_tab() {
182
+ $nonce = $_POST['security'];
183
+ if (! wp_verify_nonce($nonce, 'aqpb-settings-page-nonce') ) die('-1');
184
+
185
+ $count = isset($_POST['count']) ? absint($_POST['count']) : false;
186
+ $this->block_id = isset($_POST['block_id']) ? $_POST['block_id'] : 'aq-block-9999';
187
+
188
+ //default key/value for the tab
189
+ $tab = array(
190
+ 'title' => 'New Tab',
191
+ 'content' => ''
192
+ );
193
+
194
+ if($count) {
195
+ $this->tab($tab, $count);
196
+ } else {
197
+ die(-1);
198
+ }
199
+
200
+ die();
201
+ }
202
+
203
+ function update($new_instance, $old_instance) {
204
+ $new_instance = aq_recursive_sanitize($new_instance);
205
+ return $new_instance;
206
+ }
207
+ }
208
+ }
blocks/aq-text-block.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /** A simple text block **/
3
+ class AQ_Text_Block extends AQ_Block {
4
+
5
+ //set and create block
6
+ function __construct() {
7
+ $block_options = array(
8
+ 'name' => 'Text',
9
+ 'size' => 'span6',
10
+ );
11
+
12
+ //create the block
13
+ parent::__construct('aq_text_block', $block_options);
14
+ }
15
+
16
+ function form($instance) {
17
+
18
+ $defaults = array(
19
+ 'text' => '',
20
+ );
21
+ $instance = wp_parse_args($instance, $defaults);
22
+ extract($instance);
23
+
24
+ ?>
25
+ <p class="description">
26
+ <label for="<?php echo $this->get_field_id('title') ?>">
27
+ Title (optional)
28
+ <?php echo aq_field_input('title', $block_id, $title, $size = 'full') ?>
29
+ </label>
30
+ </p>
31
+
32
+ <p class="description">
33
+ <label for="<?php echo $this->get_field_id('text') ?>">
34
+ Content
35
+ <?php echo aq_field_textarea('text', $block_id, $text, $size = 'full') ?>
36
+ </label>
37
+ </p>
38
+
39
+ <?php
40
+ }
41
+
42
+ function block($instance) {
43
+ extract($instance);
44
+
45
+ if($title) echo '<h4 class="aq-block-title">'.strip_tags($title).'</h4>';
46
+ echo wpautop(do_shortcode(htmlspecialchars_decode($text)));
47
+ }
48
+
49
+ }
blocks/aq-upload-block.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* Media Uploader Block */
3
+ if(!class_exists('AQ_Upload_Block') {
4
+ class AQ_Upload_Block {
5
+
6
+ function __construct() {
7
+ $block_options = array(
8
+ 'name' => 'Media',
9
+ 'size' => 'span6',
10
+ );
11
+
12
+ //create the block
13
+ parent::__construct('aq_upload_block', $block_options);
14
+ }
15
+
16
+ function form($instance) {
17
+ $defaults = array(
18
+ 'media' => '',
19
+ );
20
+ $instance = wp_parse_args($instance, $defaults);
21
+ extract($instance);
22
+
23
+
24
+ }
25
+
26
+ function block($instance) {
27
+ if($title) echo '<h4 class="aq-block-title">'.strip_tags($title).'</h4>';
28
+ }
29
+
30
+ }
31
+ }
blocks/aq-widgets-block.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* Registered Sidebars Blocks */
3
+ class AQ_Widgets_Block extends AQ_Block {
4
+
5
+ function __construct() {
6
+ $block_options = array(
7
+ 'name' => 'Widgets',
8
+ 'size' => 'span4',
9
+ );
10
+
11
+ parent::__construct('AQ_Widgets_Block', $block_options);
12
+ }
13
+
14
+ function form($instance) {
15
+
16
+
17
+ //get all registered sidebars
18
+ global $wp_registered_sidebars;
19
+ $sidebar_options = array(); $default_sidebar = '';
20
+ foreach ($wp_registered_sidebars as $registered_sidebar) {
21
+ $default_sidebar = empty($default_sidebar) ? $registered_sidebar['id'] : $default_sidebar;
22
+ $sidebar_options[$registered_sidebar['id']] = $registered_sidebar['name'];
23
+ }
24
+
25
+ $defaults = array(
26
+ 'sidebar' => $default_sidebar,
27
+ );
28
+ $instance = wp_parse_args($instance, $defaults);
29
+ extract($instance);
30
+
31
+ ?>
32
+ <p class="description half">
33
+ <label for="<?php echo $block_id ?>_title">
34
+ Title (optional)<br/>
35
+ <?php echo aq_field_input('title', $block_id, $title, $size = 'full') ?>
36
+ </label>
37
+ </p>
38
+ <p class="description half last">
39
+ <label for="">
40
+ Choose widget area<br/>
41
+ <?php echo aq_field_select('sidebar', $block_id, $sidebar_options, $sidebar); ?>
42
+ </label>
43
+ </p>
44
+ <?php
45
+ }
46
+
47
+ function block($instance) {
48
+ extract($instance);
49
+ dynamic_sidebar($sidebar);
50
+ }
51
+
52
+ }
classes/class-aq-block.php ADDED
@@ -0,0 +1,190 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * The class to register, update and display blocks
4
+ *
5
+ * It provides an easy API for people to add their own blocks
6
+ * to the Aqua Page Builder
7
+ *
8
+ * @package Aqua Page Builder
9
+ */
10
+
11
+ $aq_registered_blocks = array();
12
+
13
+ if(!class_exists('AQ_Block')) {
14
+ class AQ_Block {
15
+
16
+ //some vars
17
+ var $id_base;
18
+ var $block_options;
19
+ var $instance;
20
+
21
+ /* PHP4 constructor */
22
+ function AQ_Block($id_base = false, $block_options = array()) {
23
+ AQ_Block::__construct($id_base, $block_options);
24
+ }
25
+
26
+ /* PHP5 constructor */
27
+ function __construct($id_base = false, $block_options = array()) {
28
+ $this->id_base = isset($id_base) ? strtolower($id_base) : strtolower(get_class($this));
29
+ $this->name = isset($block_options['name']) ? $block_options['name'] : ucwords(preg_replace("/[^A-Za-z0-9 ]/", '', $this->id_base));
30
+ $this->block_options = $this->parse_block($block_options);
31
+ }
32
+
33
+ /**
34
+ * Block - display the block on front end
35
+ *
36
+ * Sub-class MUST override this or it will output an error
37
+ * with the class name for reference
38
+ */
39
+ function block($instance) {
40
+ extract($instance);
41
+ echo __('function AQ_Block::block should not be accessed directly. Output generated by the ', 'framework') . strtoupper($id_base). ' Class';
42
+ }
43
+
44
+ /**
45
+ * The callback function to be called on blocks saving
46
+ *
47
+ * You should use this to do any filtering, sanitation etc. The default
48
+ * filtering is sufficient for most cases, but nowhere near perfect!
49
+ */
50
+ function update($new_instance, $old_instance) {
51
+ $new_instance = array_map('htmlspecialchars', array_map('stripslashes', $new_instance));
52
+ return $new_instance;
53
+ }
54
+
55
+ /**
56
+ * The block settings form
57
+ *
58
+ * Use subclasses to override this function and generate
59
+ * its own block forms
60
+ */
61
+ function form($instance) {
62
+ echo '<p class="no-options-block">' . __('There are no options for this block.', 'framework') . '</p>';
63
+ return 'noform';
64
+ }
65
+
66
+ /**
67
+ * Form callback function
68
+ *
69
+ * Sets up some default values and construct the basic
70
+ * structure of the form. Unless you know exactly what you're
71
+ * doing, DO NOT override this function
72
+ */
73
+ function form_callback($instance = array()) {
74
+ //insert block options into instance
75
+ $instance = is_array($instance) ? wp_parse_args($instance, $this->block_options) : $this->block_options;
76
+
77
+ //insert the dynamic block_id
78
+ $this->block_id = 'aq_block_' . $instance['number'];
79
+ $instance['block_id'] = $this->block_id;
80
+
81
+ //display the block
82
+ $this->before_form($instance);
83
+ $this->form($instance);
84
+ $this->after_form($instance);
85
+ }
86
+
87
+ /**
88
+ * Block callback function
89
+ *
90
+ * Sets up some default values. Unless you know exactly what you're
91
+ * doing, DO NOT override this function
92
+ */
93
+ function block_callback($instance) {
94
+ //insert block options into instance
95
+ $instance = is_array($instance) ? wp_parse_args($instance, $this->block_options) : $this->block_options;
96
+
97
+ //insert the dynamic block_id
98
+ $this->block_id = 'aq_block_' . $instance['number'];
99
+ $instance['block_id'] = $this->block_id;
100
+
101
+ //display the block
102
+ $this->before_block($instance);
103
+ $this->block($instance);
104
+ $this->after_block($instance);
105
+ }
106
+
107
+ /* assign default block options if not yet set */
108
+ function parse_block($block_options) {
109
+ $defaults = array(
110
+ 'id_base' => $this->id_base, //the classname
111
+ 'order' => 0, //block order
112
+ 'name' => $this->name, //block name
113
+ 'size' => 'span12', //default size
114
+ 'title' => '', //title field
115
+ 'parent' => 0, //block parent (for blocks inside columns)
116
+ 'number' => '__i__', //block consecutive numbering
117
+ 'first' => false, //column first
118
+ 'resizable' => 1, //whether block is resizable/not
119
+ );
120
+
121
+ $block_options = is_array($block_options) ? wp_parse_args($block_options, $defaults) : $defaults;
122
+
123
+ return $block_options;
124
+ }
125
+
126
+
127
+ //form header
128
+ function before_form($instance) {
129
+ extract($instance);
130
+
131
+ $title = $title ? '<span class="in-block-title"> : '.$title.'</span>' : '';
132
+ $resizable = $resizable ? '' : 'not-resizable';
133
+
134
+ echo '<li id="template-block-'.$number.'" class="block block-'.$id_base.' '. $size .' '.$resizable.'">',
135
+ '<dl class="block-bar">',
136
+ '<dt class="block-handle">',
137
+ '<div class="block-title">',
138
+ $name , $title,
139
+ '</div>',
140
+ '<span class="block-controls">',
141
+ '<a class="block-edit" id="edit-'.$number.'" title="Edit Block" href="#block-settings-'.$number.'">Edit Block</a>',
142
+ '</span>',
143
+ '</dt>',
144
+ '</dl>',
145
+ '<div class="block-settings cf" id="block-settings-'.$number.'">';
146
+ }
147
+
148
+ //form footer
149
+ function after_form($instance) {
150
+ extract($instance);
151
+
152
+ $block_saving_id = 'aq_blocks[aq_block_'.$number.']';
153
+
154
+ echo '<div class="block-control-actions cf"><a href="#" class="delete">Delete</a> | <a href="#" class="close">Close</a></div>';
155
+ echo '<input type="hidden" class="id_base" name="'.$this->get_field_name('id_base').'" value="'.$id_base.'" />';
156
+ echo '<input type="hidden" class="name" name="'.$this->get_field_name('name').'" value="'.$name.'" />';
157
+ echo '<input type="hidden" class="order" name="'.$this->get_field_name('order').'" value="'.$order.'" />';
158
+ echo '<input type="hidden" class="size" name="'.$this->get_field_name('size').'" value="'.$size.'" />';
159
+ echo '<input type="hidden" class="parent" name="'.$this->get_field_name('parent').'" value="'.$parent.'" />';
160
+ echo '<input type="hidden" class="number" name="'.$this->get_field_name('number').'" value="'.$number.'" />';
161
+ echo '</div>',
162
+ '</li>';
163
+ }
164
+
165
+ /* block header */
166
+ function before_block($instance) {
167
+ extract($instance);
168
+ $column_class = $first ? 'aq-first' : '';
169
+
170
+ echo '<div id="aq-block-'.$template_id.'-'.$number.'" class="aq-block aq-block-'.$id_base.' aq_'.$size.' '.$column_class.' cf">';
171
+ }
172
+
173
+ /* block footer */
174
+ function after_block($instance) {
175
+ extract($instance);
176
+ echo '</div>';
177
+ }
178
+
179
+ function get_field_id($field) {
180
+ $field_id = isset($this->block_id) ? $this->block_id . '_' . $field : '';
181
+ return $field_id;
182
+ }
183
+
184
+ function get_field_name($field) {
185
+ $field_name = isset($this->block_id) ? 'aq_blocks[' . $this->block_id. '][' . $field . ']': '';
186
+ return $field_name;
187
+ }
188
+
189
+ }
190
+ }
classes/class-aq-page-builder.php ADDED
@@ -0,0 +1,732 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * AQ_Page_Builder class
4
+ *
5
+ * The core class that generates the functionalities for the
6
+ * Aqua Page Builder. Almost nothing inside in the class should
7
+ * be overridden by theme authors
8
+ *
9
+ * @since forever
10
+ **/
11
+
12
+ if(!class_exists('AQ_Page_Builder')) {
13
+ class AQ_Page_Builder {
14
+
15
+ public $url = AQPB_DIR;
16
+ public $config = array();
17
+ private $admin_notices;
18
+
19
+ /**
20
+ * Stores public queryable vars
21
+ */
22
+ function __construct( $config = array()) {
23
+
24
+ $defaults['menu_title'] = __('Page Builder', 'framework');
25
+ $defaults['page_title'] = __('Page Builder', 'framework');
26
+ $defaults['page_slug'] = __('aq-page-builder', 'framework');
27
+ $defaults['debug'] = false;
28
+
29
+ $this->args = wp_parse_args($config, $defaults);
30
+
31
+ $this->args['page_url'] = esc_url(add_query_arg(
32
+ array('page' => $this->args['page_slug']),
33
+ admin_url( 'themes.php' )
34
+ ));
35
+
36
+ }
37
+
38
+ /**
39
+ * Initialise Page Builder page and its settings
40
+ *
41
+ * @since 1.0.0
42
+ */
43
+ function init() {
44
+
45
+ add_action('admin_menu', array(&$this, 'admin_pages'));
46
+ add_action('init', array(&$this, 'register_template_post_type'));
47
+ add_action('init', array(&$this, 'add_shortcode'));
48
+ add_action('template_redirect', array(&$this, 'preview_template'));
49
+ add_filter('contextual_help', array(&$this, 'contextual_help'));
50
+ if(!is_admin()) add_action('init', array(&$this, 'view_enqueue'));
51
+ add_action('admin_bar_menu', array(&$this, 'add_admin_bar'), 1000);
52
+
53
+ /** TinyMCE button */
54
+ add_filter('media_buttons_context', array(&$this, 'add_media_button') );
55
+ add_action('admin_footer', array(&$this, 'add_media_display') );
56
+
57
+ }
58
+
59
+ /**
60
+ * Create Admin Pages
61
+ *
62
+ * @since 1.0.0
63
+ */
64
+ function admin_pages() {
65
+
66
+ $this->page = add_theme_page( $this->args['page_title'], $this->args['menu_title'], 'manage_options', $this->args['page_slug'], array(&$this, 'builder_page_show'));
67
+
68
+ //enqueueu styles/scripts on the builder page
69
+ add_action('admin_print_styles-'.$this->page, array(&$this, 'admin_enqueue'));
70
+
71
+ }
72
+
73
+ /**
74
+ * Add shortcut to Admin Bar menu
75
+ *
76
+ * @since 1.0.4
77
+ */
78
+ function add_admin_bar(){
79
+ global $wp_admin_bar;
80
+ $wp_admin_bar->add_menu( array( 'id' => 'aq-page-builder', 'parent' => 'appearance', 'title' => 'Page Builder', 'href' => admin_url('themes.php?page='.$this->args['page_slug']) ) );
81
+
82
+ }
83
+
84
+ /**
85
+ * Register and enqueueu styles/scripts
86
+ *
87
+ * @since 1.0.0
88
+ * @todo min versions
89
+ */
90
+ function admin_enqueue() {
91
+
92
+ // Register 'em
93
+ wp_register_style( 'aqpb-css', $this->url.'assets/css/aqpb.css', array(), time(), 'all');
94
+ wp_register_style( 'aqpb-blocks-css', $this->url.'assets/css/aqpb_blocks.css', array(), time(), 'all');
95
+ wp_register_script('aqpb-js', $this->url . 'assets/js/aqpb.js', array('jquery'), time(), true);
96
+ wp_register_script('aqpb-fields-js', $this->url . 'assets/js/aqpb-fields.js', array('jquery'), time(), true);
97
+
98
+ // Enqueue 'em
99
+ wp_enqueue_style('aqpb-css');
100
+ wp_enqueue_style('aqpb-blocks-css');
101
+ wp_enqueue_style('wp-color-picker');
102
+ wp_enqueue_script('jquery');
103
+ wp_enqueue_script('jquery-ui-sortable');
104
+ wp_enqueue_script('jquery-ui-resizable');
105
+ wp_enqueue_script('jquery-ui-draggable');
106
+ wp_enqueue_script('jquery-ui-droppable');
107
+ wp_enqueue_script('iris');
108
+ wp_enqueue_script('wp-color-picker');
109
+ wp_enqueue_script('aqpb-js');
110
+ wp_enqueue_script('aqpb-fields-js');
111
+
112
+ // Media library uploader
113
+ wp_enqueue_script('thickbox');
114
+ wp_enqueue_style('thickbox');
115
+ wp_enqueue_script('media-upload');
116
+ wp_enqueue_media();
117
+
118
+ // Hook to register custom style/scripts
119
+ do_action('aq-page-builder-admin-enqueue');
120
+
121
+ }
122
+
123
+ /**
124
+ * Register and enqueueu styles/scripts on front-end
125
+ *
126
+ * @since 1.0.0
127
+ * @todo min versions
128
+ */
129
+ function view_enqueue() {
130
+
131
+ // front-end css
132
+ wp_register_style( 'aqpb-view-css', $this->url.'assets/css/aqpb-view.css', array(), time(), 'all');
133
+ wp_enqueue_style('aqpb-view-css');
134
+
135
+ // front-end js
136
+ wp_register_script('aqpb-view-js', $this->url . 'assets/js/aqpb-view.js', array('jquery'), time(), true);
137
+ wp_enqueue_script('aqpb-view-js');
138
+
139
+ //hook to register custom styles/scripts
140
+ do_action('aq-page-builder-view-enqueue');
141
+
142
+ }
143
+
144
+ /**
145
+ * Register template post type
146
+ *
147
+ * @uses register_post_type
148
+ * @since 1.0.0
149
+ */
150
+ function register_template_post_type() {
151
+
152
+ if(!post_type_exists('template')) {
153
+
154
+ $template_args = array(
155
+ 'labels' => array(
156
+ 'name' => 'Templates',
157
+ ),
158
+ 'public' => false,
159
+ 'show_ui' => false,
160
+ 'capability_type' => 'page',
161
+ 'hierarchical' => false,
162
+ 'rewrite' => false,
163
+ 'supports' => array( 'title', 'editor' ),
164
+ 'query_var' => false,
165
+ 'can_export' => true,
166
+ 'show_in_nav_menus' => false
167
+ );
168
+
169
+ if($this->args['debug'] == true && WP_DEBUG == true) {
170
+ $template_args['public'] = true;
171
+ $template_args['show_ui'] = true;
172
+ }
173
+
174
+ register_post_type( 'template', $template_args);
175
+
176
+ } else {
177
+ add_action('admin_notices', create_function('', "echo '<div id=\"message\" class=\"error\"><p><strong>Aqua Page Builder notice: </strong>'. __('The \"template\" post type already exists, possibly added by the theme or other plugins. Please consult with theme author to consult with this issue', 'framework') .'</p></div>';"));
178
+ }
179
+
180
+ }
181
+
182
+ /**
183
+ * Checks if template with given id exists
184
+ *
185
+ * @since 1.0.0
186
+ */
187
+ function is_template($template_id) {
188
+
189
+ $template = get_post($template_id);
190
+
191
+ if($template) {
192
+ if($template->post_type != 'template' || $template->post_status != 'publish') return false;
193
+ } else {
194
+ return false;
195
+ }
196
+
197
+ return true;
198
+
199
+ }
200
+
201
+ /**
202
+ * Retrieve all blocks from template id
203
+ *
204
+ * @return array - $blocks
205
+ * @since 1.0.0
206
+ */
207
+ function get_blocks($template_id) {
208
+
209
+ //verify template
210
+ if(!$template_id) return;
211
+ if(!$this->is_template($template_id)) return;
212
+
213
+ //filter post meta to get only blocks data
214
+ $blocks = array();
215
+ $all = get_post_custom($template_id);
216
+ foreach($all as $key => $block) {
217
+ if(substr($key, 0, 9) == 'aq_block_') {
218
+ $block_instance = get_post_meta($template_id, $key, true);
219
+ if(is_array($block_instance)) $blocks[$key] = $block_instance;
220
+ }
221
+ }
222
+
223
+ //sort by order
224
+ $sort = array();
225
+ foreach($blocks as $block) {
226
+ $sort[] = $block['order'];
227
+ }
228
+ array_multisort($sort, SORT_NUMERIC, $blocks);
229
+
230
+ return $blocks;
231
+
232
+ }
233
+
234
+ /**
235
+ * Display blocks archive
236
+ *
237
+ * @since 1.0.0
238
+ */
239
+ function blocks_archive() {
240
+
241
+ global $aq_registered_blocks;
242
+ foreach($aq_registered_blocks as $block) {
243
+ $block->form_callback();
244
+ }
245
+
246
+ }
247
+
248
+ /**
249
+ * Display template blocks
250
+ *
251
+ * @since 1.0.0
252
+ */
253
+ function display_blocks( $template_id ) {
254
+
255
+ //verify template
256
+ if(!$template_id) return;
257
+ if(!$this->is_template($template_id)) return;
258
+
259
+ $blocks = $this->get_blocks($template_id);
260
+ $blocks = is_array($blocks) ? $blocks : array();
261
+
262
+ //return early if no blocks
263
+ if(empty($blocks)) {
264
+ echo '<p class="empty-template">';
265
+ echo __('Drag block items from the left into this area to begin building your template.', 'framework');
266
+ echo '</p>';
267
+ return;
268
+
269
+ } else {
270
+ //outputs the blocks
271
+ foreach($blocks as $key => $instance) {
272
+ global $aq_registered_blocks;
273
+ extract($instance);
274
+
275
+ if(isset($aq_registered_blocks[$id_base])) {
276
+ //get the block object
277
+ $block = $aq_registered_blocks[$id_base];
278
+
279
+ //insert template_id into $instance
280
+ $instance['template_id'] = $template_id;
281
+
282
+ //display the block
283
+ if($parent == 0) {
284
+ $block->form_callback($instance);
285
+ }
286
+ }
287
+ }
288
+
289
+ }
290
+
291
+ }
292
+
293
+ /**
294
+ * Get all saved templates
295
+ *
296
+ * @since 1.0.0
297
+ */
298
+ function get_templates() {
299
+
300
+ $args = array (
301
+ 'nopaging' => true,
302
+ 'post_type' => 'template',
303
+ 'status' => 'publish',
304
+ 'orderby' => 'title',
305
+ 'order' => 'ASC',
306
+ );
307
+
308
+ $templates = get_posts($args);
309
+
310
+ return $templates;
311
+
312
+ }
313
+
314
+ /**
315
+ * Creates a new template
316
+ *
317
+ * @since 1.0.0
318
+ */
319
+ function create_template($title) {
320
+
321
+ //wp security layer
322
+ check_admin_referer( 'create-template', 'create-template-nonce' );
323
+
324
+ //create new template only if title don't yet exist
325
+ if(!get_page_by_title( $title, 'OBJECT', 'template' )) {
326
+ //set up template name
327
+ $template = array(
328
+ 'post_title' => wp_strip_all_tags($title),
329
+ 'post_type' => 'template',
330
+ 'post_status' => 'publish',
331
+ );
332
+
333
+ //create the template
334
+ $template_id = wp_insert_post($template);
335
+
336
+ } else {
337
+ return new WP_Error('duplicate_template', 'Template names must be unique, try a different name');
338
+ }
339
+
340
+ //return the new id of the template
341
+ return $template_id;
342
+
343
+ }
344
+
345
+ /**
346
+ * Function to update templates
347
+ *
348
+ * @since 1.0.0
349
+ **/
350
+ function update_template($template_id, $blocks, $title) {
351
+
352
+ //first let's check if template id is valid
353
+ if(!$this->is_template($template_id)) wp_die('Error : Template id is not valid');
354
+
355
+ //wp security layer
356
+ check_admin_referer( 'update-template', 'update-template-nonce' );
357
+
358
+ //update the title
359
+ $template = array('ID' => $template_id, 'post_title'=> $title);
360
+ wp_update_post( $template );
361
+
362
+ //now let's save our blocks & prepare haystack
363
+ $blocks = is_array($blocks) ? $blocks : array();
364
+ $haystack = array();
365
+ $template_transient_data = array();
366
+ $i = 1;
367
+
368
+ foreach ($blocks as $new_instance) {
369
+ global $aq_registered_blocks;
370
+
371
+ $old_key = isset($new_instance['number']) ? 'aq_block_' . $new_instance['number'] : 'aq_block_0';
372
+ $new_key = isset($new_instance['number']) ? 'aq_block_' . $i : 'aq_block_0';
373
+
374
+ $old_instance = get_post_meta($template_id, $old_key, true);
375
+
376
+ extract($new_instance);
377
+
378
+ if(class_exists($id_base)) {
379
+ //get the block object
380
+ $block = $aq_registered_blocks[$id_base];
381
+
382
+ //insert template_id into $instance
383
+ $new_instance['template_id'] = $template_id;
384
+
385
+ //sanitize instance with AQ_Block::update()
386
+ $new_instance = $block->update($new_instance, $old_instance);
387
+ }
388
+
389
+ //update block
390
+ update_post_meta($template_id, $new_key, $new_instance);
391
+
392
+ //store instance into $template_transient_data
393
+ $template_transient_data[$new_key] = $new_instance;
394
+
395
+ //prepare haystack
396
+ $haystack[] = $new_key;
397
+
398
+ $i++;
399
+ }
400
+
401
+ //update transient
402
+ $template_transient = 'aq_template_' . $template_id;
403
+ set_transient( $template_transient, $template_transient_data );
404
+
405
+ //use haystack to check for deleted blocks
406
+ $curr_blocks = $this->get_blocks($template_id);
407
+ $curr_blocks = is_array($curr_blocks) ? $curr_blocks : array();
408
+ foreach($curr_blocks as $key => $block){
409
+ if(!in_array($key, $haystack))
410
+ delete_post_meta($template_id, $key);
411
+ }
412
+
413
+ }
414
+
415
+ /**
416
+ * Delete page template
417
+ *
418
+ * @since 1.0.0
419
+ **/
420
+ function delete_template($template_id) {
421
+
422
+ //first let's check if template id is valid
423
+ if(!$this->is_template($template_id)) return false;
424
+
425
+ //wp security layer
426
+ check_admin_referer( 'delete-template', '_wpnonce' );
427
+
428
+ //delete template, hard!
429
+ wp_delete_post( $template_id, true );
430
+
431
+ //delete template transient
432
+ $template_transient = 'aq_template_' . $template_id;
433
+ delete_transient( $template_transient );
434
+
435
+ }
436
+
437
+ /**
438
+ * Preview template
439
+ *
440
+ * Theme authors should attempt to make the preview
441
+ * layout to be consistent with their themes by using
442
+ * the filter provided in the function
443
+ *
444
+ * @since 1.0.0
445
+ */
446
+ function preview_template() {
447
+
448
+ global $wp_query, $aq_page_builder;
449
+ $post_type = $wp_query->query_vars['post_type'];
450
+
451
+ if($post_type == 'template') {
452
+ get_header();
453
+ ?>
454
+ <div id="main" class="cf">
455
+ <div id="content" class="cf">
456
+ <?php $this->display_template(get_the_ID()); ?>
457
+ <?php if($this->args['debug'] == true) print_r(aq_get_blocks(get_the_ID())) //for debugging ?>
458
+ </div>
459
+ </div>
460
+ <?php
461
+ get_footer();
462
+ exit;
463
+ }
464
+
465
+ }
466
+
467
+ /**
468
+ * Display the template on the front end
469
+ *
470
+ * @since 1.0.0
471
+ **/
472
+ function display_template($template_id) {
473
+
474
+ //verify template
475
+ if(!$template_id) return;
476
+ if(!$this->is_template($template_id)) return;
477
+
478
+ //get transient if available
479
+ $template_transient = 'aq_template_' . $template_id;
480
+ $template_transient_data = get_transient($template_transient);
481
+
482
+ if($template_transient_data == false) {
483
+ $blocks = $this->get_blocks($template_id);
484
+ } else {
485
+ $blocks = $template_transient_data;
486
+ }
487
+
488
+ $blocks = is_array($blocks) ? $blocks : array();
489
+
490
+ //return early if no blocks
491
+ if(empty($blocks)) {
492
+
493
+ echo '<p class="empty-template">';
494
+ echo __('This template is empty', 'framework');
495
+ echo '</p>';
496
+
497
+ } else {
498
+ //template wrapper
499
+ echo '<div id="aq-template-wrapper-'.$template_id.'" class="aq-template-wrapper aq_row">';
500
+
501
+ $overgrid = 0; $span = 0; $first = false;
502
+
503
+ //outputs the blocks
504
+ foreach($blocks as $key => $instance) {
505
+ global $aq_registered_blocks;
506
+ extract($instance);
507
+
508
+ if(class_exists($id_base)) {
509
+ //get the block object
510
+ $block = $aq_registered_blocks[$id_base];
511
+
512
+ //insert template_id into $instance
513
+ $instance['template_id'] = $template_id;
514
+
515
+ //display the block
516
+ if($parent == 0) {
517
+
518
+ $col_size = absint(preg_replace("/[^0-9]/", '', $size));
519
+
520
+ $overgrid = $span + $col_size;
521
+
522
+ if($overgrid > 12 || $span == 12 || $span == 0) {
523
+ $span = 0;
524
+ $first = true;
525
+ }
526
+
527
+ if($first == true) {
528
+ $instance['first'] = true;
529
+ }
530
+
531
+ $block->block_callback($instance);
532
+
533
+ $span = $span + $col_size;
534
+
535
+ $overgrid = 0; //reset $overgrid
536
+ $first = false; //reset $first
537
+ }
538
+ }
539
+ }
540
+
541
+ //close template wrapper
542
+ echo '</div>';
543
+ }
544
+
545
+ }
546
+
547
+ /**
548
+ * Add the [template] shortcode
549
+ *
550
+ * @since 1.0.0
551
+ */
552
+ function add_shortcode() {
553
+
554
+ global $shortcode_tags;
555
+ if ( !array_key_exists( 'template', $shortcode_tags ) ) {
556
+ add_shortcode( 'template', array(&$this, 'do_shortcode') );
557
+ } else {
558
+ add_action('admin_notices', create_function('', "echo '<div id=\"message\" class=\"error\"><p><strong>Aqua Page Builder notice: </strong>'. __('The \"[template]\" shortcode already exists, possibly added by the theme or other plugins. Please consult with the theme author to consult with this issue', 'framework') .'</p></div>';"));
559
+ }
560
+
561
+ }
562
+
563
+ /**
564
+ * Shortcode function
565
+ *
566
+ * @since 1.0.0
567
+ */
568
+ function do_shortcode($atts, $content = null) {
569
+
570
+ $defaults = array('id' => 0);
571
+ extract( shortcode_atts( $defaults, $atts ) );
572
+
573
+ //capture template output into string
574
+ ob_start();
575
+ $this->display_template($id);
576
+ $template = ob_get_contents();
577
+ ob_end_clean();
578
+
579
+ return $template;
580
+
581
+ }
582
+
583
+
584
+ /**
585
+ * Media button shortcode
586
+ *
587
+ * @since 1.0.6
588
+ */
589
+ function add_media_button( $button ) {
590
+
591
+ global $pagenow, $wp_version;
592
+
593
+ $output = '';
594
+
595
+ if ( in_array( $pagenow, array( 'post.php', 'page.php', 'post-new.php', 'post-edit.php' ) ) ) {
596
+
597
+ if ( version_compare( $wp_version, '3.5', '<' ) ) {
598
+ $img = '<img src="' . AQPB_DIR . '/assets/images/aqua-media-button.png" width="16px" height="16px" alt="' . esc_attr__( 'Add Page Template', 'framework' ) . '" />';
599
+ $output = '<a href="#TB_inline?width=640&inlineId=aqpb-iframe-container" class="thickbox" title="' . esc_attr__( 'Add Page Template', 'framework' ) . '">' . $img . '</a>';
600
+ } else {
601
+ $img = '<span class="wp-media-buttons-icon" style="background-image: url(' . AQPB_DIR . '/assets/images/aqua-media-button.png ); margin-top: -1px;"></span>';
602
+ $output = '<a href="#TB_inline?width=640&inlineId=aqpb-iframe-container" class="thickbox button" title="' . esc_attr__( 'Add Page Template', 'framework' ) . '" style="padding-left: .4em;">' . $img . ' ' . esc_attr__( 'Add Template', 'framework' ) . '</a>';
603
+ }
604
+
605
+ }
606
+
607
+ return $button . $output;
608
+
609
+ }
610
+
611
+ /**
612
+ * Media button display
613
+ *
614
+ * @since 1.0.6
615
+ */
616
+ function add_media_display() {
617
+
618
+ global $pagenow;
619
+
620
+ /** Only run in post/page new and edit */
621
+ if ( in_array( $pagenow, array( 'post.php', 'page.php', 'post-new.php', 'post-edit.php' ) ) ) {
622
+ /** Get all published templates */
623
+ $templates = get_posts( array(
624
+ 'post_type' => 'template',
625
+ 'posts_per_page' => -1,
626
+ 'post_status' => 'publish',
627
+ 'order' => 'ASC',
628
+ 'orderby' => 'title'
629
+ )
630
+ );
631
+
632
+ ?>
633
+ <script type="text/javascript">
634
+ function insertTemplate() {
635
+ var id = jQuery( '#select-aqpb-template' ).val();
636
+
637
+ /** Alert user if there is no template selected */
638
+ if ( '' == id ) {
639
+ alert("<?php echo esc_js( __( 'Please select your template first!', 'framework' ) ); ?>");
640
+ return;
641
+ }
642
+
643
+ /** Send shortcode to editor */
644
+ window.send_to_editor('[template id="' + id + '"]');
645
+ }
646
+ </script>
647
+
648
+ <div id="aqpb-iframe-container" style="display: none;">
649
+ <div class="wrap" style="padding: 1em">
650
+
651
+ <?php do_action( 'aqpb_before_iframe_display', $templates ); ?>
652
+
653
+ <?php
654
+ /** If there is no template created yet */
655
+ if ( empty( $templates ) ) {
656
+ echo sprintf( __( 'You don\'t have any template yet. Let\'s %s create %s one!', 'framework' ), '<a href="' .admin_url().'themes.php?page=aq-page-builder">', '</a>' );
657
+ return;
658
+ }
659
+ ?>
660
+
661
+ <h3><?php _e( 'Choose Your Page Template', 'framework' ); ?></h3><br />
662
+ <select id="select-aqpb-template" style="clear: both; min-width:200px; display: inline-block; margin-right: 3em;">
663
+ <?php
664
+ foreach ( $templates as $template )
665
+ echo '<option value="' . absint( $template->ID ) . '">' . esc_attr( $template->post_title ) . '</option>';
666
+ ?>
667
+ </select>
668
+
669
+ <input type="button" id="aqpb-insert-template" class="button-primary" value="<?php echo esc_attr__( 'Insert Template', 'framework' ); ?>" onclick="insertTemplate();" />
670
+ <a id="aqpb-cancel-template" class="button-secondary" onclick="tb_remove();" title="<?php echo esc_attr__( 'Cancel', 'framework' ); ?>"><?php echo esc_attr__( 'Cancel', 'framework' ); ?></a>
671
+
672
+ <?php do_action( 'aqpb_after_iframe_display', $templates ); ?>
673
+
674
+ </div>
675
+ </div>
676
+
677
+ <?php
678
+ } /** End Coditional Statement for post, page, new and edit post */
679
+
680
+ }
681
+
682
+ /**
683
+ * Contextual help tabs
684
+ *
685
+ * @since 1.0.0
686
+ */
687
+ function contextual_help() {
688
+
689
+ $screen = get_current_screen();
690
+ $contextual_helps = apply_filters('aqpb_contextual_helps', array());
691
+
692
+ if($screen->id == $this->page) {
693
+ // Help tab sidebar
694
+ $screen->set_help_sidebar(
695
+ '<p><strong>' . __('For more information:') . '</strong></p>' .
696
+ '<p>' . __('<a href="http://aquagraphite.com/api/documentation/aqua-page-builder" target="_blank">Documentation</a>') . '</p>' .
697
+ '<p>' . __('<a href="http://aquagraphite.com/api/changelog/aqua-page-builder" target="_blank">Changelog</a>') . '</p>'
698
+ );
699
+
700
+ // Main overview tab
701
+ $screen->add_help_tab( array(
702
+ 'id' => 'overview',
703
+ 'title' => __('Overview'),
704
+ 'content' => $this->args['contextual_help'],
705
+ ) );
706
+
707
+ /** Additional help tabs */
708
+ if(!empty($contextual_helps)) {
709
+ foreach($contextual_helps as $help) {
710
+ $screen->add_help_tab($help);
711
+ }
712
+ }
713
+
714
+ }
715
+
716
+ }
717
+
718
+ /**
719
+ * Main page builder page display
720
+ *
721
+ * @since 1.0.0
722
+ */
723
+ function builder_page_show(){
724
+
725
+ require_once(AQPB_PATH . 'view/view-builder-page.php');
726
+
727
+ }
728
+
729
+
730
+ }
731
+ }
732
+ // not much to say when you're high above the mucky-muck
classes/class-aq-plugin-updater.php ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @legacy
4
+ * AQ_Plugin_Updater Class
5
+ *
6
+ * Request for any later version of the plugin available
7
+ * on Github. Downloads it if user chose to update
8
+ *
9
+ * @author Syamil MJ <http://aquagraphite.com>
10
+ */
11
+
12
+ // Take over the update check
13
+ if(!class_exists('AQ_Plugin_Updater')) {
14
+ class AQ_Plugin_Updater {
15
+ function __construct($config = array()) {
16
+
17
+ $defaults = array(
18
+ 'api_url' => 'http://aquagraphite.com/api/',
19
+ 'slug' => '',
20
+ 'filename' => ''
21
+ );
22
+
23
+ $this->args = wp_parse_args($config, $defaults);
24
+
25
+ if(empty($this->args['slug']) || empty($this->args['filename'])) return false;
26
+
27
+ //hook filters
28
+ add_filter('pre_set_site_transient_update_plugins', array($this, 'check_update'));
29
+ add_filter('plugins_api', array($this, 'plugin_api_call'), 10, 3);
30
+ add_filter('upgrader_post_install', array($this, 'upgrader_post_install'), 10, 3 );
31
+
32
+ }
33
+
34
+ function check_update($checked_data) {
35
+ global $wp_version;
36
+
37
+ if (empty($checked_data->checked)) {
38
+ return $checked_data;//Comment out this line during testing.
39
+ }
40
+
41
+ $args = array(
42
+ 'slug' => $this->args['slug'],
43
+ 'version' => $checked_data->checked[$this->args['slug'] .'/'. $this->args['filename']],
44
+ );
45
+
46
+ $request_string = array(
47
+ 'body' => array(
48
+ 'action' => 'basic_check',
49
+ 'request' => json_encode($args),
50
+ 'site-url' => site_url()
51
+ ),
52
+ 'user-agent' => 'WordPress/' . $wp_version . '; ' . site_url(),
53
+ 'timeout' => 30,
54
+ 'redirection' => 0
55
+ );
56
+
57
+ // Start checking for an update
58
+ $raw_response = wp_remote_post($this->args['api_url'], $request_string);
59
+
60
+ // Process update data
61
+ if (!is_wp_error($raw_response) && ($raw_response['response']['code'] == 200))
62
+ $response = json_decode($raw_response['body']);
63
+
64
+ // Feed the update data into WP updater
65
+ if (isset($response) && is_object($response) && !empty($response))
66
+ $checked_data->response[$this->args['slug'] .'/'. $this->args['filename']] = $response;
67
+
68
+ return $checked_data;
69
+ }
70
+
71
+ /**
72
+ * API Call
73
+ *
74
+ * Handles the Plugin API Call
75
+ */
76
+ function plugin_api_call($defaults, $action, $args) {
77
+ global $wp_version;
78
+
79
+ if (!isset($args->slug) || $args->slug != $this->args['slug'])
80
+ return false;
81
+
82
+ // Get the current version
83
+ $plugin_info = get_site_transient('update_plugins');
84
+ $current_version = $plugin_info->checked[$this->args['slug'] .'/'. $this->args['filename']];
85
+ $args->version = $current_version;
86
+
87
+ $request_string = array(
88
+ 'body' => array(
89
+ 'action' => $action,
90
+ 'request' => json_encode($args),
91
+ 'site-url' => site_url()
92
+ ),
93
+ 'user-agent' => 'WordPress/' . $wp_version . '; ' . site_url(),
94
+ 'timeout' => 30,
95
+ 'redirection' => 0
96
+ );
97
+
98
+ $request = wp_remote_post($this->args['api_url'], $request_string);
99
+
100
+ if (is_wp_error($request)) {
101
+ $result = new WP_Error('plugins_api_failed', __('An Unexpected HTTP Error occurred during the API request.</p> <p><a href="?" onclick="document.location.reload(); return false;">Try again</a>', 'framework'), $request->get_error_message());
102
+ } else {
103
+ $result = unserialize($request['body']);
104
+ if ($result === false) {
105
+ $result = new WP_Error('plugins_api_failed', __('An unknown error occurred'), $request['body']);
106
+ }
107
+ }
108
+ return $result;
109
+ }
110
+
111
+ /**
112
+ * Hook that move, rename & install the unzipped plugin
113
+ */
114
+ function upgrader_post_install( $true, $hook_extra, $result ) {
115
+ global $wp_filesystem;
116
+
117
+ if( isset($hook_extra['plugin']) && stristr($hook_extra['plugin'], $this->args['slug']) ) {
118
+
119
+ echo '<p>' . __('Correcting plugin folder name & activating plugin...', 'framework') .'</p>';
120
+
121
+ // Move & Activate
122
+ $proper_destination = WP_PLUGIN_DIR.'/'.$this->args['slug'] .'/';
123
+ $wp_filesystem->move( $result['destination'], $proper_destination );
124
+ $result['destination'] = $proper_destination;
125
+ $activate = activate_plugin( $proper_destination .$this->args['filename'] );
126
+
127
+ // Output the update message
128
+ $fail = __('The plugin has been updated, but could not be reactivated. Please reactivate it manually.', 'framework');
129
+ $success = __('Plugin reactivated successfully.', 'framework');
130
+ echo is_wp_error( $activate ) ? $fail : $success;
131
+
132
+ }
133
+
134
+ return $result;
135
+
136
+ }
137
+ }
138
+ }
functions/aqpb_blocks.php ADDED
@@ -0,0 +1,263 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Page Builder Blocks
4
+ * @desc Contains block elements to be inserted into custom page templates
5
+ * @since 1.0.0
6
+ * @todo add tooltip to explain option (hover on ? icon)
7
+ */
8
+
9
+ // Text Block
10
+ function aq_block_text($block) {
11
+ extract( $block, EXTR_OVERWRITE );
12
+
13
+ $block_id = 'aq_block_' . $number;
14
+ $block_saving_id = 'aq_blocks[aq_block_'.$number.']';
15
+
16
+ ?>
17
+ <p class="description">
18
+ <label for="<?php echo $block_id ?>_title">
19
+ Title (optional)
20
+ <input type="text" class="input-full" id="<?php echo $block_id ?>_title" value="<?php echo $title ?>" name="<?php echo $block_saving_id ?>[title]">
21
+ </label>
22
+ </p>
23
+
24
+ <p class="description">
25
+ <label for="<?php echo $block_id ?>_text">
26
+ Content
27
+ <textarea id="<?php echo $block_id ?>_text" class="textarea-full" name="<?php echo $block_saving_id ?>[text]" rows="5"><?php echo $text ?></textarea>
28
+ </label>
29
+ </p>
30
+ <?php
31
+ }
32
+
33
+ //slogan
34
+ function aq_block_slogan($block) {
35
+ extract( $block, EXTR_OVERWRITE );
36
+ $block_id = 'aq_block_' . $number;
37
+ $block_saving_id = 'aq_blocks[aq_block_'.$number.']';
38
+
39
+ ?>
40
+ <p class="description">
41
+ <label for="<?php echo $block_id ?>_title">
42
+ Title (optional)<br/>
43
+ <input type="text" class="input-full" id="<?php echo $block_id ?>_title" value="<?php echo $title ?>" name="<?php echo $block_saving_id ?>[title]">
44
+ </label>
45
+ </p>
46
+ <p class="description">
47
+ <label for="<?php echo $block_id ?>_text">
48
+ Enter your text slogan below
49
+ <textarea id="<?php echo $block_id ?>_text" class="textarea-full" name="<?php echo $block_saving_id ?>[text]" rows="5"><?php echo $text ?></textarea>
50
+ </label>
51
+ </p>
52
+ <?php
53
+ }
54
+
55
+ // Slider
56
+ function aq_block_slider($block) {
57
+ extract( $block, EXTR_OVERWRITE );
58
+ $block_id = 'aq_block_' . $number;
59
+ $block_saving_id = 'aq_blocks[aq_block_'.$number.']';
60
+
61
+ ?>
62
+ <p class="description">
63
+ <label for="<?php echo $block_id ?>_title">
64
+ Title (optional)<br/>
65
+ <input type="text" class="input-full" id="<?php echo $block_id ?>_title" value="<?php echo $title ?>" name="<?php echo $block_saving_id ?>[title]">
66
+ </label>
67
+ </p>
68
+ <p class="description">
69
+ <label for="<?php echo $block_id ?>_slide">
70
+ <?php
71
+ $args = array (
72
+ 'nopaging' => true,
73
+ 'post_type' => 'slider',
74
+ 'status' => 'publish',
75
+ );
76
+ $slides = get_posts($args);
77
+
78
+ echo '<select id="'.$block_id.'" class="select" name="'.$block_saving_id.'[slide]">';
79
+ echo '<option>Choose a slider</option>';
80
+ foreach($slides as $slide) {
81
+ echo '<option value="'.$slide->ID.'">'.htmlspecialchars($slide->post_title).'</option>';
82
+ }
83
+ echo '</select>';
84
+ ?>
85
+ </label>
86
+ </p>
87
+ <p class="description description-float">
88
+ <label for="<?php echo $block_id ?>_speed">
89
+ Slider Speed<br/>
90
+ <input type="text" class="input-small" id="<?php echo $block_id ?>_speed" value="<?php echo $speed ?>" name="<?php echo $block_saving_id ?>[speed]">
91
+ </label>
92
+ </p>
93
+ <p class="description description-float">
94
+ <label for="<?php echo $block_id ?>_transition">
95
+ Slider Speed<br/>
96
+ <input type="text" class="input-small" id="<?php echo $block_id ?>_speed" value="<?php echo $speed ?>" name="<?php echo $block_saving_id ?>[speed]">
97
+ </label>
98
+ </p>
99
+ <?php
100
+ }
101
+
102
+ // Google Map
103
+ function aq_block_googlemap($block) {
104
+ extract( $block, EXTR_OVERWRITE );
105
+ $block_id = 'aq_block_' . $number;
106
+ $block_saving_id = 'aq_blocks[aq_block_'.$number.']';
107
+
108
+ ?>
109
+
110
+ <p class="description half">
111
+ <label for="<?php echo $block_id ?>_title">
112
+ Title (optional)<br/>
113
+ <input type="text" class="input-full" id="<?php echo $block_id ?>_title" value="<?php echo $title ?>" name="<?php echo $block_saving_id ?>[title]">
114
+ </label>
115
+ </p>
116
+ <p class="description half last">
117
+ <label for="<?php echo $block_id ?>_address">
118
+ Address<br/>
119
+ <input type="text" class="input-full" id="<?php echo $block_id ?>_address" value="<?php echo $address ?>" name="<?php echo $block_saving_id ?>[address]">
120
+ </label>
121
+ </p>
122
+ <p class="description two-third">
123
+ <label for="<?php echo $block_id ?>_coordinates">
124
+ Coordinates (optional) e.g. "3.82497,103.32390"<br/>
125
+ <input type="text" class="input-full" id="<?php echo $block_id ?>_coordinates" value="<?php echo $coordinates ?>" name="<?php echo $block_saving_id ?>[coordinates]">
126
+ </label>
127
+ </p>
128
+ <p class="description third last">
129
+ <label for="<?php echo $block_id ?>_height">
130
+ Map height, in pixels.<br/>
131
+ <input type="number" class="input-min" id="<?php echo $block_id ?>_height" value="<?php echo $height ?>" name="<?php echo $block_saving_id ?>[height]"> &nbsp; px
132
+ </label>
133
+ </p>
134
+
135
+ <?php
136
+ }
137
+
138
+ // Portfolio
139
+ function aq_block_portfolio($block) {
140
+ extract( $block, EXTR_OVERWRITE );
141
+ $block_id = 'aq_block_' . $number;
142
+ $block_saving_id = 'aq_blocks['.$block_id.']';
143
+
144
+ $columns_options = array(
145
+ 'one' => 'Single',
146
+ 'two' => 'Two Columns',
147
+ 'three' => 'Three Columns',
148
+ 'four' => 'Four Columns',
149
+ );
150
+ //todo image as checkbox
151
+
152
+ $types = ''; //get all portfolio 'type' taxonomy terms
153
+ ?>
154
+ <p class="description">
155
+ <label for="<?php echo $block_id ?>_title">
156
+ Title (optional)<br/>
157
+ <input type="text" class="input-full" id="<?php echo $block_id ?>_title" value="<?php echo $title ?>" name="<?php echo $block_saving_id ?>[title]">
158
+ </label>
159
+ </p>
160
+ <p class="description">
161
+ <label for="">
162
+ Number of Columns<br/>
163
+ <?php echo aqpb_select($columns_options, $columns, $block_id, 'columns'); ?>
164
+ </label>
165
+ </p>
166
+ <?php
167
+ }
168
+
169
+ function aq_block_featured_portfolio($block) {
170
+ extract( $block, EXTR_OVERWRITE );
171
+ $block_id = 'aq_block_' . $number;
172
+ $block_saving_id = 'aq_blocks[aq_block_'.$number.']';
173
+
174
+ ?>
175
+ <p class="description">
176
+ <label for="<?php echo $block_id ?>_title">
177
+ Title (optional)<br/>
178
+ <input type="text" class="input-full" id="<?php echo $block_id ?>_title" value="<?php echo $title ?>" name="<?php echo $block_saving_id ?>[title]">
179
+ </label>
180
+ </p>
181
+ <p class="description">
182
+ <label for="<?php echo $block_id ?>_items">
183
+ Maximum number of items<br/>
184
+ <input type="number" class="input-min" id="<?php echo $block_id ?>_items" value="<?php echo $items ?>" name="<?php echo $block_saving_id ?>[items]">
185
+ </label>
186
+ </p>
187
+ <?php
188
+
189
+ }
190
+
191
+ function aq_block_widgets($block) {
192
+ extract( $block, EXTR_OVERWRITE );
193
+ $block_id = 'aq_block_' . $number;
194
+ $block_saving_id = 'aq_blocks[aq_block_'.$number.']';
195
+
196
+ //get all registered sidebars
197
+ global $wp_registered_sidebars;
198
+ $sidebar_options = array();
199
+ foreach ($wp_registered_sidebars as $registered_sidebar) {
200
+ $sidebar_options[$registered_sidebar['id']] = $registered_sidebar['name'];
201
+ }
202
+
203
+ ?>
204
+ <p class="description half">
205
+ <label for="<?php echo $block_id ?>_title">
206
+ Title (optional)<br/>
207
+ <input type="text" class="input-full" id="<?php echo $block_id ?>_title" value="<?php echo $title ?>" name="<?php echo $block_saving_id ?>[title]">
208
+ </label>
209
+ </p>
210
+ <p class="description half last">
211
+ <label for="">
212
+ Choose sidebar/widget area<br/>
213
+ <?php echo aqpb_select($sidebar_options, $sidebar, $block_id, 'sidebar'); ?>
214
+ </label>
215
+ </p>
216
+ <?php
217
+
218
+ }
219
+
220
+ function aq_block_column($block) {
221
+ echo '<p class="empty-column">',
222
+ __('Drag block items into this box', 'framework'),
223
+ '</p>';
224
+ echo '<ul class="blocks column-blocks cf"></ul>';
225
+ }
226
+
227
+ function aq_block_clear($block) {
228
+ echo '<p class="description">';
229
+ echo 'This block has no editable attributes. You can use it to clear the floats between two or more separate blocks vertically.';
230
+ echo '</p>';
231
+ }
232
+
233
+
234
+ /**
235
+ * Ajax drag n drop slider handler
236
+ *
237
+ * This can be served as an example how you can provide custom
238
+ * ajax handler and use in the blocks
239
+ *
240
+ * Also see the aqpb_config on adding extra js
241
+ */
242
+ function aq_ajax_slider_handler() {
243
+
244
+ }
245
+
246
+ function aq_ajax_slider_display() {
247
+
248
+ }
249
+
250
+
251
+
252
+
253
+
254
+
255
+
256
+
257
+
258
+
259
+
260
+
261
+
262
+
263
+ ?>
functions/aqpb_config.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Aqua Page Builder Config
4
+ *
5
+ * This file handles various configurations
6
+ * of the page builder page
7
+ *
8
+ */
9
+ function aq_page_builder_config() {
10
+
11
+ $config = array(); //initialise array
12
+
13
+ /* Page Config */
14
+ $config['menu_title'] = __('Page Builder', 'framework');
15
+ $config['page_title'] = __('Page Builder', 'framework');
16
+ $config['page_slug'] = __('aq-page-builder', 'framework');
17
+
18
+ /* This holds the contextual help text - the more info, the better.
19
+ * HTML is of course allowed in all of its glory! */
20
+ $config['contextual_help'] =
21
+ '<p>' . __('The page builder allows you to create custom page templates which you can later use for your pages.', 'framework') . '<p>' .
22
+ '<p>' . __('To use the page builder, start by adding a new template. You can drag and drop the blocks on the left into the building area on the right of the screen. Each block has its own unique configuration which you can manually configure to suit your needs', 'framework') . '<p>' .
23
+ '<p>' . __('Please refer to the', 'framework') . '<a href="http://aquagraphite.com/api/documentation/aqua-page-builder" target="_blank" alt="Aqua Page Builder Documentation">'. __(' documentation page ', 'framework') . '</a>'. __('for more information on how to use this feature.', 'framework') . '<p>';
24
+
25
+ /* Debugging */
26
+ $config['debug'] = false;
27
+
28
+ return $config;
29
+
30
+ }
functions/aqpb_functions.php ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Aqua Page Builder functions
4
+ *
5
+ * This holds the external functions which can be used by the theme
6
+ * Requires the AQ_Page_Builder class
7
+ *
8
+ * @todo - multicheck, image checkbox, better colorpicker
9
+ **/
10
+
11
+ if(class_exists('AQ_Page_Builder')) {
12
+
13
+ /**
14
+ * Core functions
15
+ *******************/
16
+
17
+ /* Register a block */
18
+ function aq_register_block($block_class) {
19
+ global $aq_registered_blocks;
20
+ $aq_registered_blocks[strtolower($block_class)] = new $block_class;
21
+ }
22
+
23
+ /** Un-register a block **/
24
+ function aq_unregister_block($block_class) {
25
+ global $aq_registered_blocks;
26
+ $block_class = strtolower($block_class);
27
+ foreach($aq_registered_blocks as $block) {
28
+ if($block->id_base == $block_class) unset($aq_registered_blocks[$block_class]);
29
+ }
30
+ }
31
+
32
+ /** Get list of all blocks **/
33
+ function aq_get_blocks($template_id) {
34
+ global $aq_page_builder;
35
+ $blocks = $aq_page_builder->get_blocks($template_id);
36
+
37
+ return $blocks;
38
+ }
39
+
40
+ /**
41
+ * Form Field Helper functions
42
+ *
43
+ * Provides some default fields for use in the blocks
44
+ ********************************************************/
45
+
46
+ /* Input field - Options: $size = min, small, full */
47
+ function aq_field_input($field_id, $block_id, $input, $size = 'full', $type = 'text') {
48
+ $output = '<input type="'.$type.'" id="'. $block_id .'_'.$field_id.'" class="input-'.$size.'" value="'.$input.'" name="aq_blocks['.$block_id.']['.$field_id.']">';
49
+
50
+ return $output;
51
+ }
52
+
53
+ /* Textarea field */
54
+ function aq_field_textarea($field_id, $block_id, $text, $size = 'full') {
55
+ $output = '<textarea id="'. $block_id .'_'.$field_id.'" class="textarea-'.$size.'" name="aq_blocks['.$block_id.']['.$field_id.']" rows="5">'.$text.'</textarea>';
56
+
57
+ return $output;
58
+ }
59
+
60
+
61
+ /* Select field */
62
+ function aq_field_select($field_id, $block_id, $options, $selected) {
63
+ $options = is_array($options) ? $options : array();
64
+ $output = '<select id="'. $block_id .'_'.$field_id.'" name="aq_blocks['.$block_id.']['.$field_id.']">';
65
+ foreach($options as $key=>$value) {
66
+ $output .= '<option value="'.$key.'" '.selected( $selected, $key, false ).'>'.htmlspecialchars($value).'</option>';
67
+ }
68
+ $output .= '</select>';
69
+
70
+ return $output;
71
+ }
72
+
73
+ /* Multiselect field */
74
+ function aq_field_multiselect($field_id, $block_id, $options, $selected_keys = array()) {
75
+ $output = '<select id="'. $block_id .'_'.$field_id.'" multiple="multiple" class="select of-input" name="aq_blocks['.$block_id.']['.$field_id.'][]">';
76
+ foreach ($options as $key => $option) {
77
+ $selected = (is_array($selected_keys) && in_array($key, $selected_keys)) ? $selected = 'selected="selected"' : '';
78
+ $output .= '<option id="'. $block_id .'_'.$field_id.'_'. $key .'" value="'.$key.'" '. $selected .' />'.$option.'</option>';
79
+ }
80
+ $output .= '</select>';
81
+
82
+ return $output;
83
+ }
84
+
85
+ /* Color picker field */
86
+ function aq_field_color_picker($field_id, $block_id, $color, $default = '') {
87
+ $output = '<div class="aqpb-color-picker">';
88
+ $output .= '<input type="text" id="'. $block_id .'_'.$field_id.'" class="input-color-picker" value="'. $color .'" name="aq_blocks['.$block_id.']['.$field_id.']" data-default-color="'. $default .'"/>';
89
+ $output .= '</div>';
90
+
91
+ return $output;
92
+ }
93
+
94
+ /* Single Checkbox */
95
+ function aq_field_checkbox($field_id, $block_id, $check) {
96
+ $output = '<input type="hidden" name="aq_blocks['.$block_id.']['.$field_id.']" value="0" />';
97
+ $output .= '<input type="checkbox" id="'. $block_id .'_'.$field_id.'" class="input-checkbox" name="aq_blocks['.$block_id.']['.$field_id.']" '. checked( 1, $check, false ) .' value="1"/>';
98
+
99
+ return $output;
100
+ }
101
+
102
+ /* Multi Checkbox */
103
+ function aq_field_multicheck($field_id, $block_id, $fields = array(), $selected = array()) {
104
+
105
+ }
106
+
107
+ /* Media Uploader */
108
+ function aq_field_upload($field_id, $block_id, $media, $media_type = 'image') {
109
+ $output = '<input type="text" id="'. $block_id .'_'.$field_id.'" class="input-full input-upload" value="'.$media.'" name="aq_blocks['.$block_id.']['.$field_id.']">';
110
+ $output .= '<a href="#" class="aq_upload_button button" rel="'.$media_type.'">Upload</a><p></p>';
111
+
112
+ return $output;
113
+ }
114
+
115
+ /**
116
+ * Misc Helper Functions
117
+ **************************/
118
+
119
+ /** Get column width
120
+ * @parameters - $size (column size), $grid (grid size e.g 940), $margin
121
+ */
122
+ function aq_get_column_width($size, $grid = 940, $margin = 20) {
123
+
124
+ $columns = range(1,12);
125
+ $widths = array();
126
+ foreach($columns as $column) {
127
+ $width = (( $grid + $margin ) / 12 * $column) - $margin;
128
+ $width = round($width);
129
+ $widths[$column] = $width;
130
+ }
131
+
132
+ $column_id = absint(preg_replace("/[^0-9]/", '', $size));
133
+ $column_width = $widths[$column_id];
134
+ return $column_width;
135
+ }
136
+
137
+ /** Recursive sanitize
138
+ * For those complex multidim arrays
139
+ * Has impact on server load on template save, so use only where necessary
140
+ */
141
+ function aq_recursive_sanitize($value) {
142
+ if(is_array($value)) {
143
+ $value = array_map('aq_recursive_sanitize', $value);
144
+ } else {
145
+ $value = htmlspecialchars(stripslashes($value));
146
+ }
147
+ return $value;
148
+ }
149
+
150
+ }
readme.txt ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Aqua Page Builder ===
2
+ Author URI: http://aquagraphite.com
3
+ Plugin URI: http://aquagraphite.com/2012/10/aqua-page-builder/
4
+ Contributors: syamilmj
5
+ Tags: page builder, aquagraphite, syamil mj
6
+ Requires at least: 3.3
7
+ Tested up to: 3.6
8
+
9
+ Stable Tag: 1.1.0
10
+ License: GNU Version 2 or Any Later Version
11
+
12
+
13
+ Powerful Drag & Drop Page Builder with UI that feels like home with WordPress.
14
+
15
+ == Description ==
16
+
17
+ Aqua Page Builder is a powerful WordPress plugin that allows you to create an unlimited number of template variations for use in your WordPress themes. It follows the same user interface used by the Menus & Widgets admin pages - making you feel right at home with the UI.
18
+
19
+ Similar to the Widgets & Menus, Aqua Page Builder features the drag and drop interaction to build its templates.
20
+
21
+ **Follow this plugin on [GitHub](https://github.com/sy4mil/Aqua-Page-Builder)**
22
+
23
+ Features of the plugin include:
24
+
25
+ * Highly intuitive, drag-and-drop user interface
26
+ * Integrate seamlessly with WordPress admin interface
27
+ * Compatible with WordPress Import/Exporter
28
+ * Unlimited number of reusable templates
29
+ * Highly extensible
30
+ * Developer friendly with dozens of actions and filters
31
+
32
+ More information at [Aquagraphite.com](http://aquagraphite.com/2012/10/aqua-page-builder/).
33
+
34
+ == Installation ==
35
+
36
+ 1. Activate the plugin
37
+ 2. Go to Appearance > Page Builder and create new templates
38
+ 3. For detailed instructions please refer to the complete [Documentation](http://aquagraphite.com/api/documentation/aqua-page-builder) page.
39
+
40
+ == Frequently Asked Questions ==
41
+
42
+ = How do I Add My Own Custom Blocks? =
43
+
44
+ Please see our [Wiki](https://github.com/sy4mil/Aqua-Page-Builder/wiki) section on how to develop your own custom blocks.
45
+
46
+ == Screenshots ==
47
+
48
+ 1. Screenshot 1
49
+ 2. Screenshot 2
50
+ 3. Screenshot 3
51
+
52
+ == Changelog ==
53
+
54
+ = 1.1.0: April =
55
+
56
+ * First offical release!
57
+ * For complete list of changelog from previous versions, please see the [Changelog](http://aquagraphite.com/api/changelog/aqua-page-builder) Page
58
+
59
+ == Upgrade Notice ==
60
+
61
+ - null
view/view-builder-page.php ADDED
@@ -0,0 +1,283 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Builder Page
4
+ *
5
+ * @description Main admin UI settings page
6
+ * @package Aqua Page Builder
7
+ *
8
+ */
9
+
10
+ // Debugging
11
+ if(isset($_POST) && $this->args['debug'] == true) {
12
+ echo '<pre>';
13
+ print_r($_POST);
14
+ echo '</pre>';
15
+ }
16
+
17
+ // Permissions Check
18
+ if ( ! current_user_can('edit_theme_options') )
19
+ wp_die( __( 'Cheatin&#8217; uh?' ) );
20
+
21
+ $messages = array();
22
+
23
+ // Get selected template id
24
+ $selected_template_id = isset($_REQUEST['template']) ? (int) $_REQUEST['template'] : 0;
25
+
26
+ // Actions
27
+ $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'edit';
28
+ $template = isset($_REQUEST['template']) ? $_REQUEST['template'] : 0;
29
+
30
+ // DEBUG
31
+ //echo '<pre>';
32
+ //print_r($_POST);
33
+ //echo '</pre>';
34
+
35
+ // Template title & layout
36
+ $template_name = isset($_REQUEST['template-name']) && !empty($_REQUEST['template-name']) ? htmlspecialchars($_REQUEST['template-name']) : 'No Title';
37
+
38
+ // Get all templates
39
+ $templates = $this->get_templates();
40
+
41
+ // Get recently edited template
42
+ $recently_edited_template = (int) get_user_option( 'recently_edited_template' );
43
+
44
+ if( ! isset( $_REQUEST['template'] ) && $recently_edited_template && $this->is_template( $recently_edited_template )) {
45
+ $selected_template_id = $recently_edited_template;
46
+ } elseif ( ! isset( $_REQUEST['template'] ) && $selected_template_id == 0 && !empty($templates)) {
47
+ $selected_template_id = $templates[0]->ID;
48
+ }
49
+
50
+ //define selected template object
51
+ $selected_template_object = get_post($selected_template_id);
52
+
53
+ // saving action
54
+ switch($action) {
55
+
56
+ case 'create' :
57
+
58
+ $new_id = $this->create_template($template_name);
59
+
60
+ if(!is_wp_error($new_id)) {
61
+ $selected_template_id = $new_id;
62
+
63
+ //refresh templates var
64
+ $templates = $this->get_templates();
65
+ $selected_template_object = get_post($selected_template_id);
66
+
67
+ $messages[] = '<div id="message" class="updated"><p>' . __('The ', 'framework') . '<strong>' . $template_name . '</strong>' . __(' page template has been successfully created', 'framework') . '</p></div>';
68
+ } else {
69
+ $errors = '<ul>';
70
+ foreach( $new_id->get_error_messages() as $error ) {
71
+ $errors .= '<li><strong>'. $error . '</strong></li>';
72
+ }
73
+ $errors .= '</ul>';
74
+
75
+ $messages[] = '<div id="message" class="error"><p>' . __('Sorry, the operation was unsuccessful for the following reason(s): ', 'framework') . '</p>' . $errors . '</div>';
76
+ }
77
+
78
+ break;
79
+
80
+ case 'update' :
81
+
82
+ $blocks = isset($_REQUEST['aq_blocks']) ? $_REQUEST['aq_blocks'] : '';
83
+
84
+ $this->update_template($selected_template_id, $blocks, $template_name);
85
+
86
+ //refresh templates var
87
+ $templates = $this->get_templates();
88
+ $selected_template_object = get_post($selected_template_id);
89
+
90
+ $messages[] = '<div id="message" class="updated"><p>' . __('The ', 'framework') . '<strong>' . $template_name . '</strong>' . __(' page template has been updated', 'framework') . '</p></div>';
91
+ break;
92
+
93
+ case 'delete' :
94
+
95
+ $this->delete_template($selected_template_id);
96
+
97
+ //refresh templates var
98
+ $templates = $this->get_templates();
99
+ $selected_template_id = !empty($templates) ? $templates[0]->ID : 0;
100
+ $selected_template_object = get_post($selected_template_id);
101
+
102
+ $messages[] = '<div id="message" class="updated"><p>' . __('The template has been successfully deleted', 'framework') . '</p></div>';
103
+ break;
104
+ }
105
+
106
+ global $current_user;
107
+ update_user_option($current_user->ID, 'recently_edited_template', $selected_template_id);
108
+
109
+ //display admin notices & messages
110
+ if(!empty($messages)) foreach($messages as $message) { echo $message; }
111
+
112
+ //disable blocks archive if no template
113
+ $disabled = $selected_template_id === 0 ? 'metabox-holder-disabled' : '';
114
+
115
+ ?>
116
+
117
+ <div class="wrap">
118
+ <div id="icon-themes" class="icon32"><br/></div>
119
+ <h2><?php echo $this->args['page_title'] ?></h2>
120
+
121
+ <div id="page-builder-frame">
122
+
123
+ <div id="page-builder-column" class="metabox-holder <?php echo $disabled ?>">
124
+ <div id="page-builder-archive" class="postbox">
125
+ <h3 class="hndle"><span><?php _e('Available Blocks', 'framework') ?></span><span id="removing-block"><?php _e('Deleting', 'framework') ?></span></h3>
126
+ <div class="inside">
127
+ <ul id="blocks-archive" class="cf">
128
+ <?php $this->blocks_archive() ?>
129
+ </ul>
130
+ <p><?php _e('Need help? Use the Help tab in the upper right of your screen.', 'framework') ?></p>
131
+ </div>
132
+ </div>
133
+ </div>
134
+
135
+ <div id="page-builder-fixed">
136
+ <div id="page-builder">
137
+ <div class="aqpb-tabs-nav">
138
+
139
+ <div class="aqpb-tabs-arrow aqpb-tabs-arrow-left">
140
+ <a>&laquo;</a>
141
+ </div>
142
+
143
+ <div class="aqpb-tabs-wrapper">
144
+ <div class="aqpb-tabs">
145
+
146
+ <?php
147
+ foreach ( (array) $templates as $template ) {
148
+ if($selected_template_id == $template->ID) {
149
+ echo '<span class="aqpb-tab aqpb-tab-active aqpb-tab-sortable">'. htmlspecialchars($template->post_title) .'</span>';
150
+ } else {
151
+ echo '<a class="aqpb-tab aqpb-tab-sortable" data-template_id="'.$template->ID.'" href="' . esc_url(add_query_arg(
152
+ array(
153
+ 'page' => $this->args['page_slug'],
154
+ 'action' => 'edit',
155
+ 'template' => $template->ID,
156
+ ),
157
+ admin_url( 'themes.php' )
158
+ )) . '">'. htmlspecialchars($template->post_title) .'</a>';
159
+ }
160
+ }
161
+ ?>
162
+
163
+ <!--add new template button-->
164
+ <?php if($selected_template_id == 0) { ?>
165
+ <span class="aqpb-tab aqpb-tab-add aqpb-tab-active"><abbr title="Add Template">+</abbr></span>
166
+ <?php } else { ?>
167
+ <a class="aqpb-tab aqpb-tab-add" href="<?php
168
+ echo esc_url(add_query_arg(
169
+ array(
170
+ 'page' => $this->args['page_slug'],
171
+ 'action' => 'edit',
172
+ 'template' => 0,
173
+ ),
174
+ admin_url( 'themes.php' )
175
+ ));
176
+ ?>">
177
+ <abbr title="Add Template">+</abbr>
178
+ </a>
179
+ <?php } ?>
180
+
181
+ </div>
182
+ </div>
183
+
184
+ <div class="aqpb-tabs-arrow aqpb-tabs-arrow-right">
185
+ <a>&raquo;</a>
186
+ </div>
187
+
188
+ </div>
189
+ <div class="aqpb-wrap aqpbdiv">
190
+ <form id="update-page-template" action="<?php echo $this->args['page_url'] ?>" method="post" enctype="multipart/form-data">
191
+ <div id="aqpb-header">
192
+
193
+ <div id="submitpost" class="submitbox">
194
+ <div class="major-publishing-actions cf">
195
+
196
+ <label class="open-label" for="template-name">
197
+ <span><?php _e('Template Name', 'framework') ?></span>
198
+ <input name="template-name" id="template-name" type="text" class="template-name regular-text" title="Enter template name here" placeholder="Enter template name here" value="<?php echo is_object($selected_template_object) ? $selected_template_object->post_title : ''; ?>">
199
+ </label>
200
+
201
+ <div id="template-shortcode">
202
+ <input type="text" readonly="readonly" value='[template id="<?php echo $selected_template_id ?>"]' onclick="select()"/>
203
+ </div>
204
+
205
+ <div class="publishing-action">
206
+ <?php submit_button( empty( $selected_template_id ) ? __( 'Create Template', 'framework' ) : __( 'Save Template', 'framework' ), 'button-primary ', 'save_template', false, array( 'id' => 'save_template_header' ) ); ?>
207
+ </div><!-- END .publishing-action -->
208
+
209
+ <?php if(!empty($selected_template_id)) { ?>
210
+ <div class="delete-action">
211
+ <?php
212
+ echo '<a class="submitdelete deletion template-delete" href="' . esc_url(add_query_arg(
213
+ array(
214
+ 'page' => $this->args['page_slug'],
215
+ 'action' => 'delete',
216
+ 'template' => $selected_template_id,
217
+ '_wpnonce' => wp_create_nonce('delete-template'),
218
+ ),
219
+ admin_url( 'themes.php' )
220
+ )) . '">'. __('Delete Template', 'framework') .'</a>';
221
+ ?>
222
+ </div><!-- END .delete-action -->
223
+ <?php } ?>
224
+
225
+ </div><!-- END .major-publishing-actions -->
226
+ </div><!-- END #submitpost .submitbox -->
227
+
228
+ <?php
229
+ if($selected_template_id === 0) {
230
+ wp_nonce_field( 'create-template', 'create-template-nonce' );
231
+ } else {
232
+ wp_nonce_field( 'update-template', 'update-template-nonce' );
233
+ }
234
+ ?>
235
+ <input type="hidden" name="action" value="<?php echo empty( $selected_template_id ) ? 'create' : 'update' ?>"/>
236
+ <input type="hidden" name="template" id="template" value="<?php echo $selected_template_id ?>"/>
237
+ <input type="hidden" id="aqpb-nonce" name="aqpb-nonce" value="<?php echo wp_create_nonce('aqpb-settings-page-nonce') ?>"/>
238
+
239
+ </div>
240
+
241
+ <div id="aqpb-body">
242
+
243
+ <ul class="blocks cf" id="blocks-to-edit">
244
+ <?php
245
+ if($selected_template_id === 0) {
246
+ echo '<p class="empty-template">';
247
+ echo __('To create a custom page template, give it a name above and click Create Template. Then choose blocks like text, widgets or tabs &amp; toggles from the left column to add to this template.
248
+ <br/><br/>
249
+ You can drag and drop the blocks to put them in the order you want. Click on the small arrow at the corner of each block to reveal additional configuration options. You can also resize each block by clicking on either side of the block (Note that some blocks are not resizable)
250
+ <br/><br/>
251
+ When you have finished building your custom page template, make sure you click the Save Template button.', 'framework');
252
+ echo '</p>';
253
+
254
+
255
+ } else {
256
+ $this->display_blocks($selected_template_id);
257
+ }
258
+ ?>
259
+ </ul>
260
+
261
+ </div>
262
+
263
+ <div id="aqpb-footer">
264
+ <div class="major-publishing-actions cf">
265
+ <div class="publishing-action">
266
+ <?php if(!empty($selected_template_id)) {
267
+ submit_button( __( 'Save Template' ), 'button-primary ', 'save_template', false, array( 'id' => 'save_template_footer' ) );
268
+ } ?>
269
+ </div><!-- END .publishing-action -->
270
+ </div><!-- END .major-publishing-actions -->
271
+ </div>
272
+
273
+ </div>
274
+ </form>
275
+ </div>
276
+ <p style="float:left"><small>Aqua Page Builder &copy; 2012 by <a href="http://aquagraphite.com">Syamil MJ</a></small></p>
277
+ <p style="float:right"><small>Version <?php echo AQPB_VERSION ?></small></p>
278
+
279
+ </div>
280
+
281
+
282
+ </div>
283
+ </div>