Version Description
- Update: Show confirm message before leave a View page to prevent missing changes
- Update: Some update styles for Scrollable, Collapsible layouts
- Tested up to: 4.2.1
Download this release
Release Info
Developer | PT Guy |
Plugin | Content Views – Post Grid & List for WordPress |
Version | 1.5.7 |
Comparing to | |
See all releases |
Code changes from version 1.5.6 to 1.5.7
- README.txt +7 -2
- admin/assets/js/admin.js +225 -211
- admin/content-views-admin.php +72 -92
- admin/includes/options.php +82 -80
- admin/includes/plugin.php +32 -34
- admin/includes/templates/settings-section-two.php +4 -4
- admin/views/admin.php +0 -1
- admin/views/list.php +2 -2
- admin/views/view.php +485 -518
- content-views.php +9 -9
- includes/assets.php +43 -40
- includes/defines.php +2 -2
- includes/functions.php +206 -213
- includes/hooks.php +22 -26
- includes/html-viewtype.php +37 -38
- includes/html.php +139 -140
- includes/settings.php +233 -260
- includes/update.php +1 -2
- includes/values.php +99 -98
- public/assets/css/public.css +21 -12
- public/assets/js/public.js +67 -72
- public/content-views.php +29 -31
- public/templates/collapsible/html/main.php +9 -10
- public/templates/grid/html/main.php +7 -7
- public/templates/scrollable/html/main.php +10 -9
README.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: pt-guy
|
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=JGUF974QBRKQE
|
4 |
Tags: post, posts, page, pages, query, queries, search, display, show, grid, column, layout, author, blog, categories, category, comment, content, custom, editor, filter, Formatting, image, list, meta, plugin, responsive, shortcode, excerpt, title, tag, term, Taxonomy, thumbnail, pagination, date, scrollable, slider, collapsible
|
5 |
Requires at least: 3.3
|
6 |
-
Tested up to: 4.
|
7 |
-
Stable tag: 1.5.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -165,6 +165,11 @@ function my_move_bootstrap( $args ) {
|
|
165 |
|
166 |
== Changelog ==
|
167 |
|
|
|
|
|
|
|
|
|
|
|
168 |
= 1.5.6 =
|
169 |
* Bug fixed: "undefined" Bootstrap stylesheet link
|
170 |
* Update: Add some custom filters
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=JGUF974QBRKQE
|
4 |
Tags: post, posts, page, pages, query, queries, search, display, show, grid, column, layout, author, blog, categories, category, comment, content, custom, editor, filter, Formatting, image, list, meta, plugin, responsive, shortcode, excerpt, title, tag, term, Taxonomy, thumbnail, pagination, date, scrollable, slider, collapsible
|
5 |
Requires at least: 3.3
|
6 |
+
Tested up to: 4.2.1
|
7 |
+
Stable tag: 1.5.7
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
165 |
|
166 |
== Changelog ==
|
167 |
|
168 |
+
= 1.5.7 =
|
169 |
+
* Update: Show confirm message before leave a View page to prevent missing changes
|
170 |
+
* Update: Some update styles for Scrollable, Collapsible layouts
|
171 |
+
* Tested up to: 4.2.1
|
172 |
+
|
173 |
= 1.5.6 =
|
174 |
* Bug fixed: "undefined" Bootstrap stylesheet link
|
175 |
* Update: Add some custom filters
|
admin/assets/js/admin.js
CHANGED
@@ -8,12 +8,12 @@
|
|
8 |
* @copyright 2014 PT Guy
|
9 |
*/
|
10 |
|
11 |
-
(function ($) {
|
12 |
"use strict";
|
13 |
|
14 |
-
$.PT_CV_Admin = $.PT_CV_Admin || {};
|
15 |
|
16 |
-
$.PT_CV_Admin = function (options) {
|
17 |
this.options = options;
|
18 |
this.options.onload = 1;
|
19 |
this.options.scroll_time = 500;
|
@@ -27,22 +27,22 @@
|
|
27 |
* @param {type} $selector
|
28 |
* @returns {undefined}
|
29 |
*/
|
30 |
-
_toggle_panel: function ($selector) {
|
31 |
-
$('body').on('click', $selector, function (e) {
|
32 |
-
var $heading = $(this);
|
33 |
-
var $span = $heading.find('span.clickable');
|
34 |
var time = 100;
|
35 |
|
36 |
-
if (!$span.hasClass('panel-collapsed')) {
|
37 |
-
$heading.next('.panel-body').slideUp(time);
|
38 |
-
$span.addClass('panel-collapsed');
|
39 |
-
$span.find('i').removeClass('glyphicon-minus').addClass('glyphicon-plus');
|
40 |
} else {
|
41 |
-
$heading.next('.panel-body').slideDown(time);
|
42 |
-
$span.removeClass('panel-collapsed');
|
43 |
-
$span.find('i').removeClass('glyphicon-plus').addClass('glyphicon-minus');
|
44 |
}
|
45 |
-
});
|
46 |
},
|
47 |
/**
|
48 |
* Toggle Taxonomy Relation setting on page load & on change
|
@@ -53,40 +53,40 @@
|
|
53 |
var $self = this;
|
54 |
var _prefix = $self.options._prefix;
|
55 |
|
56 |
-
var $taxonomy_relation = $('.' + _prefix + 'taxonomy-relation').parent().parent('.form-group');
|
57 |
|
58 |
// Taxonomies Settings wrapper div
|
59 |
-
var $wrap_taxonomies = $('#' + _prefix + 'group-taxonomy');
|
60 |
|
61 |
// Get Taxonomy checkbox item
|
62 |
var taxonomy_item = '.' + _prefix + 'taxonomy-item';
|
63 |
|
64 |
// Run on page load
|
65 |
-
$self._do_toggle_taxonomy_relation($taxonomy_relation, $wrap_taxonomies);
|
66 |
|
67 |
// Run on change
|
68 |
-
$(taxonomy_item).change(function () {
|
69 |
-
$self._do_toggle_taxonomy_relation($taxonomy_relation, $wrap_taxonomies);
|
70 |
-
});
|
71 |
},
|
72 |
/**
|
73 |
* Toggle Taxonomy Relation setting by number of selected taxonomies
|
74 |
*
|
75 |
* @returns void
|
76 |
*/
|
77 |
-
_do_toggle_taxonomy_relation: function ($taxonomy_relation, $wrap_taxonomies) {
|
78 |
var $self = this;
|
79 |
var _prefix = $self.options._prefix;
|
80 |
|
81 |
// If there is no taxonomies
|
82 |
-
if ($wrap_taxonomies.find('.' + _prefix + 'taxonomies .checkbox').filter(function () {
|
83 |
-
return !$(this).hasClass('hidden') && $(this).find('input:checked').length;
|
84 |
-
}).length > 1) {
|
85 |
-
$taxonomy_relation.removeClass('hidden');
|
86 |
-
$('.pt-wrap').trigger(_prefix + 'multiple-taxonomies', [1, $self.options.onload]);
|
87 |
} else {
|
88 |
-
$taxonomy_relation.addClass('hidden');
|
89 |
-
$('.pt-wrap').trigger(_prefix + 'multiple-taxonomies', [0, $self.options.onload]);
|
90 |
}
|
91 |
},
|
92 |
/**
|
@@ -95,12 +95,12 @@
|
|
95 |
* @param {type} el : string to selector
|
96 |
* @returns {undefined}
|
97 |
*/
|
98 |
-
_get_field_val: function (el) {
|
99 |
-
var $this = $(el);
|
100 |
-
var value = $(el).val();
|
101 |
|
102 |
-
if ($this.is(':checkbox') || $this.is(':radio')) {
|
103 |
-
value = $(el + ':checked').val();
|
104 |
}
|
105 |
|
106 |
return value;
|
@@ -111,27 +111,27 @@
|
|
111 |
* @param {type} $toggle_data_js_
|
112 |
* @returns {undefined}
|
113 |
*/
|
114 |
-
dependence_do_all: function ($toggle_data_js_) {
|
115 |
var $self = this;
|
116 |
var _prefix = $self.options._prefix;
|
117 |
-
var $toggle_data_js = $.parseJSON($toggle_data_js_);
|
118 |
-
$.each($toggle_data_js, function (idx, obj) {
|
119 |
// Obj_sub: an object contains (dependence_id, operator, expect_val)
|
120 |
-
$.each(obj, function (key, obj_sub) {
|
121 |
// Get name of depended element (which other elements depend on it)
|
122 |
var el_name = _prefix + key;
|
123 |
|
124 |
var el = "[name='" + el_name + "']";
|
125 |
|
126 |
// Run on page load
|
127 |
-
$self._dependence_group($self._get_field_val(el), obj_sub);
|
128 |
|
129 |
// Run on change
|
130 |
-
$(el).change(function () {
|
131 |
-
$self._dependence_group($self._get_field_val(el), obj_sub);
|
132 |
-
});
|
133 |
-
});
|
134 |
-
});
|
135 |
},
|
136 |
/**
|
137 |
* Toggle each dependency group
|
@@ -139,11 +139,11 @@
|
|
139 |
* @param {type} obj_sub : an object contains (dependence_id, expect_val, operator)
|
140 |
* @returns {undefined}
|
141 |
*/
|
142 |
-
_dependence_group: function (this_val, obj_sub) {
|
143 |
var $self = this;
|
144 |
-
$.each(obj_sub, function (key, data) {
|
145 |
-
$self._dependence_element(data[0], this_val, data[2], data[1]);
|
146 |
-
});
|
147 |
},
|
148 |
/**
|
149 |
* Toggle each dependency element
|
@@ -154,48 +154,48 @@
|
|
154 |
* @param {type} expect_val : expect value of B to show A group
|
155 |
* @returns {undefined}
|
156 |
*/
|
157 |
-
_dependence_element: function (dependence_id, this_val, operator, expect_val) {
|
158 |
|
159 |
-
var dependence_el = $("#" + dependence_id);
|
160 |
var pass = 0;
|
161 |
-
switch (operator) {
|
162 |
case "=":
|
163 |
{
|
164 |
-
if (typeof expect_val === 'string')
|
165 |
-
expect_val = [expect_val];
|
166 |
-
pass = ($.inArray(this_val, expect_val) >= 0);
|
167 |
}
|
168 |
break;
|
169 |
case "!=":
|
170 |
{
|
171 |
-
if (typeof expect_val === 'string')
|
172 |
-
expect_val = [expect_val];
|
173 |
-
pass = ($.inArray(this_val, expect_val) < 0);
|
174 |
}
|
175 |
break;
|
176 |
default :
|
177 |
-
if (typeof expect_val !== 'object')
|
178 |
-
pass = eval("this_val " + operator + " expect_val");
|
179 |
break;
|
180 |
|
181 |
}
|
182 |
var action = '';
|
183 |
var result = 0;
|
184 |
-
if (pass) {
|
185 |
-
dependence_el.removeClass('hidden');
|
186 |
|
187 |
action = 'remove';
|
188 |
-
result = !dependence_el.hasClass('hidden');
|
189 |
} else {
|
190 |
-
dependence_el.addClass('hidden');
|
191 |
|
192 |
action = 'add';
|
193 |
-
result = dependence_el.hasClass('hidden');
|
194 |
}
|
195 |
|
196 |
// Log if something is wrong
|
197 |
-
if (!result)
|
198 |
-
console.log(dependence_id, this_val, operator, expect_val, action);
|
199 |
},
|
200 |
/**
|
201 |
* Toggle a group inside Panel group when check/uncheck a checkbox inside checboxes list
|
@@ -204,21 +204,21 @@
|
|
204 |
* @param {type} id_prefix
|
205 |
* @returns {undefined}
|
206 |
*/
|
207 |
-
toggle_group: function (selector, id_prefix) {
|
208 |
var $self = this;
|
209 |
// Run on page load
|
210 |
-
$(selector).each(function () {
|
211 |
-
$self._toggle_each_group($(this), id_prefix);
|
212 |
-
});
|
213 |
// Run on change
|
214 |
-
$(selector).each(function () {
|
215 |
-
$(this).change(function () {
|
216 |
-
var this_ = $(this);
|
217 |
-
setTimeout(function () {
|
218 |
-
$self._toggle_each_group(this_, id_prefix);
|
219 |
-
}, 200);
|
220 |
-
});
|
221 |
-
});
|
222 |
},
|
223 |
/**
|
224 |
* Toggle group depends on selector value
|
@@ -227,46 +227,46 @@
|
|
227 |
* @param {type} id_prefix
|
228 |
* @returns {undefined}
|
229 |
*/
|
230 |
-
_toggle_each_group: function ($this, id_prefix) {
|
231 |
var $self = this;
|
232 |
var _prefix = $self.options._prefix;
|
233 |
-
if ($this.is('select') || (($this.is(':checkbox') || $this.is(':radio')) && $this.is(':checked'))) {
|
234 |
// Get id of element A which needs to toggle
|
235 |
var toggle_id = '#' + id_prefix + $this.val();
|
236 |
|
237 |
// Get siblings groups of A
|
238 |
-
var other_groups = $(toggle_id).parent().children('.' + _prefix + 'group').not(toggle_id);
|
239 |
|
240 |
-
if ($(toggle_id).hasClass(_prefix + 'only-one')) {
|
241 |
// Hide other group in a same Panel group
|
242 |
-
other_groups.addClass('hidden');
|
243 |
} else {
|
244 |
}
|
245 |
|
246 |
// Show group
|
247 |
-
$(toggle_id).removeClass('hidden');
|
248 |
|
249 |
// Show the content
|
250 |
-
$(toggle_id).find('.panel-body').show();
|
251 |
|
252 |
// Scroll to
|
253 |
-
if (!$self.options.onload && !$(toggle_id).hasClass(_prefix + 'no-animation') && $(toggle_id).offset()) {
|
254 |
-
$('html, body').animate({
|
255 |
-
scrollTop: $(toggle_id).offset().top - 40
|
256 |
-
}, $self.options.scroll_time);
|
257 |
}
|
258 |
|
259 |
// Highlight color
|
260 |
var activate_group = _prefix + 'group-activate';
|
261 |
-
$(toggle_id).addClass(activate_group);
|
262 |
|
263 |
// Remove highlight color
|
264 |
-
setTimeout(function () {
|
265 |
-
$(toggle_id).removeClass(activate_group);
|
266 |
-
}, 2000);
|
267 |
|
268 |
} else {
|
269 |
-
$('#' + id_prefix + $this.val()).addClass('hidden');
|
270 |
}
|
271 |
},
|
272 |
/**
|
@@ -279,75 +279,75 @@
|
|
279 |
var _prefix = $self.options._prefix;
|
280 |
|
281 |
// Taxonomies Settings wrapper div
|
282 |
-
var $wrap_taxonomies = $('#' + _prefix + 'group-taxonomy');
|
283 |
|
284 |
// Append <div> : "There is no taxonomy for selected content type" before description of Taxonomies
|
285 |
var no_taxonomy_id = _prefix + 'no-taxonomy';
|
286 |
var no_taxonomy_class = _prefix + 'text';
|
287 |
-
$wrap_taxonomies.find('.text-muted').first().before('<div id="' + no_taxonomy_id + '" class="' + no_taxonomy_class + '">' + PT_CV_ADMIN.text.no_taxonomy + '</div>');
|
288 |
-
var no_taxonomy = $('#' + no_taxonomy_id);
|
289 |
|
290 |
// Hide all Taxonomies at beginning
|
291 |
-
var fn_taxonomy_hide = function (taxonomies) {
|
292 |
-
taxonomies.each(function () {
|
293 |
-
$(this).parents('.checkbox').addClass('hidden');
|
294 |
-
});
|
295 |
// Hide no taxonomy div
|
296 |
-
no_taxonomy.addClass('hidden');
|
297 |
|
298 |
// Hide Terms group
|
299 |
-
$('.panel-group.terms').find('.' + _prefix + 'group').addClass('hidden');
|
300 |
};
|
301 |
-
var $taxonomies = $('.' + _prefix + 'taxonomy-item');
|
302 |
-
fn_taxonomy_hide($taxonomies);
|
303 |
|
304 |
// Create function to handle
|
305 |
-
var fn_content_type = function (this_val, is_change) {
|
306 |
-
if (typeof this_val === 'undefined') {
|
307 |
return;
|
308 |
}
|
309 |
|
310 |
-
if (is_change) {
|
311 |
// Uncheck all checkbox of taxonomies
|
312 |
-
$taxonomies.attr('checked', false);
|
313 |
|
314 |
// Toggle Taxonomy Relation setting
|
315 |
-
var $taxonomy_relation = $('.' + _prefix + 'taxonomy-relation').parent().parent('.form-group');
|
316 |
-
$self._do_toggle_taxonomy_relation($taxonomy_relation, $wrap_taxonomies);
|
317 |
}
|
318 |
|
319 |
// Show taxonomies relates to selected post type
|
320 |
-
if (this_val !== '') {
|
321 |
-
fn_taxonomy_hide($taxonomies);
|
322 |
-
$taxonomies.filter(function () {
|
323 |
-
var val = $(this).val();
|
324 |
var $taxonomies_of_this = PT_CV_ADMIN.data.post_types_vs_taxonomies[this_val] || '';
|
325 |
-
return $.inArray(val, $taxonomies_of_this) >= 0;
|
326 |
-
}).parents('.checkbox').removeClass('hidden');
|
327 |
}
|
328 |
|
329 |
// Show there is no taxonomies
|
330 |
-
if ($wrap_taxonomies.find('.pt-params .checkbox').filter(function () {
|
331 |
-
return !$(this).hasClass('hidden');
|
332 |
-
}).length === 0) {
|
333 |
// Show no taxonomy div
|
334 |
-
no_taxonomy.removeClass('hidden');
|
335 |
}
|
336 |
|
337 |
// Trigger custom actions
|
338 |
-
$('.pt-wrap').trigger('content-type-change', [this_val]);
|
339 |
};
|
340 |
|
341 |
// Get "Content Type" input object
|
342 |
var content_type = '[name="' + _prefix + 'content-type' + '"]';
|
343 |
|
344 |
// Run on page load
|
345 |
-
fn_content_type($(content_type + ':checked').val());
|
346 |
|
347 |
// Run on change
|
348 |
-
$(content_type).change(function () {
|
349 |
-
fn_content_type($(content_type + ':checked').val(), 1);
|
350 |
-
});
|
351 |
},
|
352 |
/**
|
353 |
* Preview handle
|
@@ -355,66 +355,66 @@
|
|
355 |
* @param string _nonce
|
356 |
* @returns {undefined}
|
357 |
*/
|
358 |
-
preview: function (_nonce) {
|
359 |
var $self = this;
|
360 |
var _prefix = $self.options._prefix;
|
361 |
|
362 |
// Store previous offset top position
|
363 |
var offset_top;
|
364 |
|
365 |
-
$('#' + _prefix + 'show-preview').click(function (e) {
|
366 |
e.stopPropagation();
|
367 |
e.preventDefault();
|
368 |
|
369 |
-
var $this_btn = $(this);
|
370 |
|
371 |
// Get Preview box
|
372 |
-
var $preview = $('#' + _prefix + 'preview-box');
|
373 |
|
374 |
// Show/hide Preview box
|
375 |
-
if ($self.options.can_preview) {
|
376 |
-
$preview.addClass('in');
|
377 |
} else {
|
378 |
-
$preview.removeClass('in');
|
379 |
}
|
380 |
|
381 |
/**
|
382 |
* Animation
|
383 |
*/
|
384 |
// Scroll to preview box if want to show it
|
385 |
-
if ($self.options.can_preview) {
|
386 |
// Get current offset top to go back later
|
387 |
-
offset_top = $(document).scrollTop();
|
388 |
|
389 |
// Scroll to preview box
|
390 |
-
$('html, body').animate({
|
391 |
scrollTop: $preview.offset().top - 100
|
392 |
-
}, $self.options.scroll_time);
|
393 |
|
394 |
/// Send request
|
395 |
-
$preview.css('opacity', '0.2');
|
396 |
// Show loading icon
|
397 |
-
$preview.next().removeClass('hidden');
|
398 |
|
399 |
// Get settings data
|
400 |
-
var data = $('#' + _prefix + 'form-view').serialize();
|
401 |
// Call handle function
|
402 |
-
$self._preview_request($preview, data, _nonce, $this_btn);
|
403 |
} else {
|
404 |
// Scroll to previous position
|
405 |
-
$('html, body').animate({
|
406 |
scrollTop: offset_top
|
407 |
-
}, $self.options.scroll_time);
|
408 |
|
409 |
// Toggle text of this button
|
410 |
-
$this_btn.html(PT_CV_ADMIN.btn.preview.show);
|
411 |
|
412 |
// Enable preview
|
413 |
-
setTimeout(function () {
|
414 |
$self.options.can_preview = 1;
|
415 |
-
}, $self.options.scroll_time);
|
416 |
}
|
417 |
-
});
|
418 |
},
|
419 |
/**
|
420 |
* Send preview Ajax request
|
@@ -425,7 +425,7 @@
|
|
425 |
* @param object $this_btn The Show/Hide preview button
|
426 |
* @returns void
|
427 |
*/
|
428 |
-
_preview_request: function (preview_box, _data, _nonce, $this_btn) {
|
429 |
var $self = this;
|
430 |
var _prefix = $self.options._prefix;
|
431 |
|
@@ -437,27 +437,27 @@
|
|
437 |
};
|
438 |
|
439 |
// Sent POST request
|
440 |
-
$.ajax({
|
441 |
type: "POST",
|
442 |
url: ajaxurl,
|
443 |
data: data,
|
444 |
-
}).done(function (response) {
|
445 |
-
preview_box.css('opacity', '1');
|
446 |
// Hide loading icon
|
447 |
-
preview_box.next().addClass('hidden');
|
448 |
|
449 |
// Update content of Preview box
|
450 |
-
preview_box.html(response);
|
451 |
|
452 |
// Toggle text of this button
|
453 |
-
$this_btn.html(PT_CV_ADMIN.btn.preview.hide);
|
454 |
|
455 |
// Disable preview
|
456 |
$self.options.can_preview = 0;
|
457 |
|
458 |
// Trigger action, to recall function such as pagination, pinterest render layout...
|
459 |
-
$('body').trigger(_prefix + 'custom-trigger');
|
460 |
-
});
|
461 |
},
|
462 |
/**
|
463 |
* Toggle 'Thumbnail settings'
|
@@ -474,17 +474,17 @@
|
|
474 |
* @param this_val Layout format value
|
475 |
* @returns void
|
476 |
*/
|
477 |
-
var fn_thumbnail_setting = function (this_val) {
|
478 |
-
|
479 |
-
var $thumbnail_wrapper = $('.' + _prefix + 'thumbnail-setting').parent();
|
480 |
-
if (this_val === '2-col') {
|
481 |
-
_thumbnail_setting_state = $thumbnail_wrapper.hasClass('hidden') ? 0 : 1;
|
482 |
-
$thumbnail_wrapper.removeClass('hidden');
|
483 |
-
} else if (this_val === '1-col') {
|
484 |
-
if (_thumbnail_setting_state) {
|
485 |
-
$thumbnail_wrapper.removeClass('hidden');
|
486 |
} else {
|
487 |
-
$thumbnail_wrapper.addClass('hidden');
|
488 |
}
|
489 |
}
|
490 |
};
|
@@ -492,42 +492,42 @@
|
|
492 |
var layout_format = '[name="' + _prefix + 'layout-format' + '"]';
|
493 |
|
494 |
// Run on page load
|
495 |
-
fn_thumbnail_setting($(layout_format + ':checked').val());
|
496 |
|
497 |
// Run on change
|
498 |
-
$(layout_format).change(function () {
|
499 |
-
fn_thumbnail_setting($(layout_format + ':checked').val());
|
500 |
-
});
|
501 |
|
502 |
/**
|
503 |
* Toggle 'Layout format' when change 'View type'
|
504 |
*/
|
505 |
-
var fn_layout_format = function (this_val, layout_format) {
|
506 |
-
var expect_val = ['scrollable'];
|
507 |
|
508 |
// Add more layouts
|
509 |
-
$('.pt-wrap').trigger('toggle-layout-format', [expect_val]);
|
510 |
|
511 |
-
if ($.inArray(this_val, expect_val) >= 0) {
|
512 |
// Trigger select 1-col
|
513 |
-
$(layout_format + '[value="1-col"]').trigger('click');
|
514 |
// Disable 2-col
|
515 |
-
$(layout_format + '[value="2-col"]').attr('disabled', true);
|
516 |
} else {
|
517 |
// Enable 2-col
|
518 |
-
$(layout_format + '[value="2-col"]').attr('disabled', false);
|
519 |
}
|
520 |
};
|
521 |
|
522 |
var view_type = '[name="' + _prefix + 'view-type' + '"]';
|
523 |
|
524 |
// Run on page load
|
525 |
-
fn_layout_format($(view_type + ':checked').val(), layout_format);
|
526 |
|
527 |
// Run on change
|
528 |
-
$(view_type).change(function () {
|
529 |
-
fn_layout_format($(view_type + ':checked').val(), layout_format);
|
530 |
-
});
|
531 |
},
|
532 |
/**
|
533 |
* Toggle text of Preview button
|
@@ -538,25 +538,25 @@
|
|
538 |
var $self = this;
|
539 |
var _prefix = $self.options._prefix;
|
540 |
|
541 |
-
var _fn = function (is_trigger) {
|
542 |
-
if (!is_trigger) {
|
543 |
$self.options.onload = 0;
|
544 |
}
|
545 |
|
546 |
// Toggle text of this button
|
547 |
-
$('#' + _prefix + 'show-preview').html(PT_CV_ADMIN.btn.preview.update);
|
548 |
|
549 |
// Enable preview
|
550 |
$self.options.can_preview = 1;
|
551 |
};
|
552 |
// Bind on change input after page load
|
553 |
-
$('.pt-wrap .tab-content').on('change', 'input, select, textarea', function (evt, is_trigger) {
|
554 |
-
_fn(is_trigger);
|
555 |
-
});
|
556 |
|
557 |
-
$('body').bind(_prefix + 'preview-btn-toggle', function () {
|
558 |
_fn();
|
559 |
-
});
|
560 |
},
|
561 |
/**
|
562 |
* Do handy toggle for Excerpt settings
|
@@ -567,26 +567,26 @@
|
|
567 |
var _prefix = this.options._prefix;
|
568 |
|
569 |
// For Excerpt Settings
|
570 |
-
var _this_toggle = function (show_content) {
|
571 |
-
if (!show_content) {
|
572 |
-
$('#' + _prefix + 'group-excerpt-settings').addClass('hidden');
|
573 |
} else {
|
574 |
-
$('#' + _prefix + 'group-excerpt-settings').removeClass('hidden');
|
575 |
}
|
576 |
};
|
577 |
|
578 |
var selector = '[name="' + _prefix + 'show-field-content' + '"]';
|
579 |
|
580 |
// Run on page load
|
581 |
-
_this_toggle($(selector).is(':checked'));
|
582 |
|
583 |
// Run on change
|
584 |
-
$(selector).change(function () {
|
585 |
-
_this_toggle($(selector).is(':checked'));
|
586 |
-
});
|
587 |
|
588 |
// Handy do other toggle
|
589 |
-
$('.pt-wrap').trigger(_prefix + 'multi-level-toggle');
|
590 |
},
|
591 |
/**
|
592 |
* Custom js for elements
|
@@ -606,33 +606,47 @@
|
|
606 |
$self._toggle_taxonomy_relation();
|
607 |
|
608 |
// Toggle panel of 'Advanced filters'
|
609 |
-
$self._toggle_panel('.' + _prefix + 'group .panel-heading');
|
610 |
|
611 |
// 'Thumbnail settings' toggle
|
612 |
$self._thumbnail_settings();
|
613 |
|
614 |
// Select 2
|
615 |
-
$('.' + _prefix + 'select2').select2();
|
616 |
|
617 |
// Change class of panel inside panel
|
618 |
-
$('.' + _prefix + 'group .panel .panel').each(function () {
|
619 |
-
$(this).removeClass('panel-primary').addClass('panel-info');
|
620 |
-
});
|
621 |
|
622 |
// Set custom style for 'Thumbnail position' box
|
623 |
-
$('.' + _prefix + 'bg-none').parent().css({'background-color': '#fff', 'padding-bottom': '10px'});
|
624 |
-
$('.' + _prefix + 'bg-none').parent().addClass('unsortable');
|
625 |
|
626 |
// Prevent click on links
|
627 |
-
$('#' + _prefix + 'preview-box').on('click', 'a', function (e) {
|
628 |
e.preventDefault();
|
629 |
-
});
|
630 |
|
631 |
// Handle Pagination actions
|
632 |
-
$('body').bind(_prefix + 'custom-trigger', function () {
|
633 |
-
var $pt_cv_public_js = new $.PT_CV_Public({_prefix: _prefix, _autoload: 0});
|
634 |
$pt_cv_public_js.pagination();
|
635 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
636 |
},
|
637 |
};
|
638 |
-
}(jQuery));
|
8 |
* @copyright 2014 PT Guy
|
9 |
*/
|
10 |
|
11 |
+
( function ( $ ) {
|
12 |
"use strict";
|
13 |
|
14 |
+
$.PT_CV_Admin = $.PT_CV_Admin || { };
|
15 |
|
16 |
+
$.PT_CV_Admin = function ( options ) {
|
17 |
this.options = options;
|
18 |
this.options.onload = 1;
|
19 |
this.options.scroll_time = 500;
|
27 |
* @param {type} $selector
|
28 |
* @returns {undefined}
|
29 |
*/
|
30 |
+
_toggle_panel: function ( $selector ) {
|
31 |
+
$( 'body' ).on( 'click', $selector, function ( e ) {
|
32 |
+
var $heading = $( this );
|
33 |
+
var $span = $heading.find( 'span.clickable' );
|
34 |
var time = 100;
|
35 |
|
36 |
+
if ( !$span.hasClass( 'panel-collapsed' ) ) {
|
37 |
+
$heading.next( '.panel-body' ).slideUp( time );
|
38 |
+
$span.addClass( 'panel-collapsed' );
|
39 |
+
$span.find( 'i' ).removeClass( 'glyphicon-minus' ).addClass( 'glyphicon-plus' );
|
40 |
} else {
|
41 |
+
$heading.next( '.panel-body' ).slideDown( time );
|
42 |
+
$span.removeClass( 'panel-collapsed' );
|
43 |
+
$span.find( 'i' ).removeClass( 'glyphicon-plus' ).addClass( 'glyphicon-minus' );
|
44 |
}
|
45 |
+
} );
|
46 |
},
|
47 |
/**
|
48 |
* Toggle Taxonomy Relation setting on page load & on change
|
53 |
var $self = this;
|
54 |
var _prefix = $self.options._prefix;
|
55 |
|
56 |
+
var $taxonomy_relation = $( '.' + _prefix + 'taxonomy-relation' ).parent().parent( '.form-group' );
|
57 |
|
58 |
// Taxonomies Settings wrapper div
|
59 |
+
var $wrap_taxonomies = $( '#' + _prefix + 'group-taxonomy' );
|
60 |
|
61 |
// Get Taxonomy checkbox item
|
62 |
var taxonomy_item = '.' + _prefix + 'taxonomy-item';
|
63 |
|
64 |
// Run on page load
|
65 |
+
$self._do_toggle_taxonomy_relation( $taxonomy_relation, $wrap_taxonomies );
|
66 |
|
67 |
// Run on change
|
68 |
+
$( taxonomy_item ).change( function () {
|
69 |
+
$self._do_toggle_taxonomy_relation( $taxonomy_relation, $wrap_taxonomies );
|
70 |
+
} );
|
71 |
},
|
72 |
/**
|
73 |
* Toggle Taxonomy Relation setting by number of selected taxonomies
|
74 |
*
|
75 |
* @returns void
|
76 |
*/
|
77 |
+
_do_toggle_taxonomy_relation: function ( $taxonomy_relation, $wrap_taxonomies ) {
|
78 |
var $self = this;
|
79 |
var _prefix = $self.options._prefix;
|
80 |
|
81 |
// If there is no taxonomies
|
82 |
+
if ( $wrap_taxonomies.find( '.' + _prefix + 'taxonomies .checkbox' ).filter( function () {
|
83 |
+
return !$( this ).hasClass( 'hidden' ) && $( this ).find( 'input:checked' ).length;
|
84 |
+
} ).length > 1 ) {
|
85 |
+
$taxonomy_relation.removeClass( 'hidden' );
|
86 |
+
$( '.pt-wrap' ).trigger( _prefix + 'multiple-taxonomies', [ 1, $self.options.onload ] );
|
87 |
} else {
|
88 |
+
$taxonomy_relation.addClass( 'hidden' );
|
89 |
+
$( '.pt-wrap' ).trigger( _prefix + 'multiple-taxonomies', [ 0, $self.options.onload ] );
|
90 |
}
|
91 |
},
|
92 |
/**
|
95 |
* @param {type} el : string to selector
|
96 |
* @returns {undefined}
|
97 |
*/
|
98 |
+
_get_field_val: function ( el ) {
|
99 |
+
var $this = $( el );
|
100 |
+
var value = $( el ).val();
|
101 |
|
102 |
+
if ( $this.is( ':checkbox' ) || $this.is( ':radio' ) ) {
|
103 |
+
value = $( el + ':checked' ).val();
|
104 |
}
|
105 |
|
106 |
return value;
|
111 |
* @param {type} $toggle_data_js_
|
112 |
* @returns {undefined}
|
113 |
*/
|
114 |
+
dependence_do_all: function ( $toggle_data_js_ ) {
|
115 |
var $self = this;
|
116 |
var _prefix = $self.options._prefix;
|
117 |
+
var $toggle_data_js = $.parseJSON( $toggle_data_js_ );
|
118 |
+
$.each( $toggle_data_js, function ( idx, obj ) {
|
119 |
// Obj_sub: an object contains (dependence_id, operator, expect_val)
|
120 |
+
$.each( obj, function ( key, obj_sub ) {
|
121 |
// Get name of depended element (which other elements depend on it)
|
122 |
var el_name = _prefix + key;
|
123 |
|
124 |
var el = "[name='" + el_name + "']";
|
125 |
|
126 |
// Run on page load
|
127 |
+
$self._dependence_group( $self._get_field_val( el ), obj_sub );
|
128 |
|
129 |
// Run on change
|
130 |
+
$( el ).change( function () {
|
131 |
+
$self._dependence_group( $self._get_field_val( el ), obj_sub );
|
132 |
+
} );
|
133 |
+
} );
|
134 |
+
} );
|
135 |
},
|
136 |
/**
|
137 |
* Toggle each dependency group
|
139 |
* @param {type} obj_sub : an object contains (dependence_id, expect_val, operator)
|
140 |
* @returns {undefined}
|
141 |
*/
|
142 |
+
_dependence_group: function ( this_val, obj_sub ) {
|
143 |
var $self = this;
|
144 |
+
$.each( obj_sub, function ( key, data ) {
|
145 |
+
$self._dependence_element( data[0], this_val, data[2], data[1] );
|
146 |
+
} );
|
147 |
},
|
148 |
/**
|
149 |
* Toggle each dependency element
|
154 |
* @param {type} expect_val : expect value of B to show A group
|
155 |
* @returns {undefined}
|
156 |
*/
|
157 |
+
_dependence_element: function ( dependence_id, this_val, operator, expect_val ) {
|
158 |
|
159 |
+
var dependence_el = $( "#" + dependence_id );
|
160 |
var pass = 0;
|
161 |
+
switch ( operator ) {
|
162 |
case "=":
|
163 |
{
|
164 |
+
if ( typeof expect_val === 'string' )
|
165 |
+
expect_val = [ expect_val ];
|
166 |
+
pass = ( $.inArray( this_val, expect_val ) >= 0 );
|
167 |
}
|
168 |
break;
|
169 |
case "!=":
|
170 |
{
|
171 |
+
if ( typeof expect_val === 'string' )
|
172 |
+
expect_val = [ expect_val ];
|
173 |
+
pass = ( $.inArray( this_val, expect_val ) < 0 );
|
174 |
}
|
175 |
break;
|
176 |
default :
|
177 |
+
if ( typeof expect_val !== 'object' )
|
178 |
+
pass = eval( "this_val " + operator + " expect_val" );
|
179 |
break;
|
180 |
|
181 |
}
|
182 |
var action = '';
|
183 |
var result = 0;
|
184 |
+
if ( pass ) {
|
185 |
+
dependence_el.removeClass( 'hidden' );
|
186 |
|
187 |
action = 'remove';
|
188 |
+
result = !dependence_el.hasClass( 'hidden' );
|
189 |
} else {
|
190 |
+
dependence_el.addClass( 'hidden' );
|
191 |
|
192 |
action = 'add';
|
193 |
+
result = dependence_el.hasClass( 'hidden' );
|
194 |
}
|
195 |
|
196 |
// Log if something is wrong
|
197 |
+
if ( !result )
|
198 |
+
console.log( dependence_id, this_val, operator, expect_val, action );
|
199 |
},
|
200 |
/**
|
201 |
* Toggle a group inside Panel group when check/uncheck a checkbox inside checboxes list
|
204 |
* @param {type} id_prefix
|
205 |
* @returns {undefined}
|
206 |
*/
|
207 |
+
toggle_group: function ( selector, id_prefix ) {
|
208 |
var $self = this;
|
209 |
// Run on page load
|
210 |
+
$( selector ).each( function () {
|
211 |
+
$self._toggle_each_group( $( this ), id_prefix );
|
212 |
+
} );
|
213 |
// Run on change
|
214 |
+
$( selector ).each( function () {
|
215 |
+
$( this ).change( function () {
|
216 |
+
var this_ = $( this );
|
217 |
+
setTimeout( function () {
|
218 |
+
$self._toggle_each_group( this_, id_prefix );
|
219 |
+
}, 200 );
|
220 |
+
} );
|
221 |
+
} );
|
222 |
},
|
223 |
/**
|
224 |
* Toggle group depends on selector value
|
227 |
* @param {type} id_prefix
|
228 |
* @returns {undefined}
|
229 |
*/
|
230 |
+
_toggle_each_group: function ( $this, id_prefix ) {
|
231 |
var $self = this;
|
232 |
var _prefix = $self.options._prefix;
|
233 |
+
if ( $this.is( 'select' ) || ( ( $this.is( ':checkbox' ) || $this.is( ':radio' ) ) && $this.is( ':checked' ) ) ) {
|
234 |
// Get id of element A which needs to toggle
|
235 |
var toggle_id = '#' + id_prefix + $this.val();
|
236 |
|
237 |
// Get siblings groups of A
|
238 |
+
var other_groups = $( toggle_id ).parent().children( '.' + _prefix + 'group' ).not( toggle_id );
|
239 |
|
240 |
+
if ( $( toggle_id ).hasClass( _prefix + 'only-one' ) ) {
|
241 |
// Hide other group in a same Panel group
|
242 |
+
other_groups.addClass( 'hidden' );
|
243 |
} else {
|
244 |
}
|
245 |
|
246 |
// Show group
|
247 |
+
$( toggle_id ).removeClass( 'hidden' );
|
248 |
|
249 |
// Show the content
|
250 |
+
$( toggle_id ).find( '.panel-body' ).show();
|
251 |
|
252 |
// Scroll to
|
253 |
+
if ( !$self.options.onload && !$( toggle_id ).hasClass( _prefix + 'no-animation' ) && $( toggle_id ).offset() ) {
|
254 |
+
$( 'html, body' ).animate( {
|
255 |
+
scrollTop: $( toggle_id ).offset().top - 40
|
256 |
+
}, $self.options.scroll_time );
|
257 |
}
|
258 |
|
259 |
// Highlight color
|
260 |
var activate_group = _prefix + 'group-activate';
|
261 |
+
$( toggle_id ).addClass( activate_group );
|
262 |
|
263 |
// Remove highlight color
|
264 |
+
setTimeout( function () {
|
265 |
+
$( toggle_id ).removeClass( activate_group );
|
266 |
+
}, 2000 );
|
267 |
|
268 |
} else {
|
269 |
+
$( '#' + id_prefix + $this.val() ).addClass( 'hidden' );
|
270 |
}
|
271 |
},
|
272 |
/**
|
279 |
var _prefix = $self.options._prefix;
|
280 |
|
281 |
// Taxonomies Settings wrapper div
|
282 |
+
var $wrap_taxonomies = $( '#' + _prefix + 'group-taxonomy' );
|
283 |
|
284 |
// Append <div> : "There is no taxonomy for selected content type" before description of Taxonomies
|
285 |
var no_taxonomy_id = _prefix + 'no-taxonomy';
|
286 |
var no_taxonomy_class = _prefix + 'text';
|
287 |
+
$wrap_taxonomies.find( '.text-muted' ).first().before( '<div id="' + no_taxonomy_id + '" class="' + no_taxonomy_class + '">' + PT_CV_ADMIN.text.no_taxonomy + '</div>' );
|
288 |
+
var no_taxonomy = $( '#' + no_taxonomy_id );
|
289 |
|
290 |
// Hide all Taxonomies at beginning
|
291 |
+
var fn_taxonomy_hide = function ( taxonomies ) {
|
292 |
+
taxonomies.each( function () {
|
293 |
+
$( this ).parents( '.checkbox' ).addClass( 'hidden' );
|
294 |
+
} );
|
295 |
// Hide no taxonomy div
|
296 |
+
no_taxonomy.addClass( 'hidden' );
|
297 |
|
298 |
// Hide Terms group
|
299 |
+
$( '.panel-group.terms' ).find( '.' + _prefix + 'group' ).addClass( 'hidden' );
|
300 |
};
|
301 |
+
var $taxonomies = $( '.' + _prefix + 'taxonomy-item' );
|
302 |
+
fn_taxonomy_hide( $taxonomies );
|
303 |
|
304 |
// Create function to handle
|
305 |
+
var fn_content_type = function ( this_val, is_change ) {
|
306 |
+
if ( typeof this_val === 'undefined' ) {
|
307 |
return;
|
308 |
}
|
309 |
|
310 |
+
if ( is_change ) {
|
311 |
// Uncheck all checkbox of taxonomies
|
312 |
+
$taxonomies.attr( 'checked', false );
|
313 |
|
314 |
// Toggle Taxonomy Relation setting
|
315 |
+
var $taxonomy_relation = $( '.' + _prefix + 'taxonomy-relation' ).parent().parent( '.form-group' );
|
316 |
+
$self._do_toggle_taxonomy_relation( $taxonomy_relation, $wrap_taxonomies );
|
317 |
}
|
318 |
|
319 |
// Show taxonomies relates to selected post type
|
320 |
+
if ( this_val !== '' ) {
|
321 |
+
fn_taxonomy_hide( $taxonomies );
|
322 |
+
$taxonomies.filter( function () {
|
323 |
+
var val = $( this ).val();
|
324 |
var $taxonomies_of_this = PT_CV_ADMIN.data.post_types_vs_taxonomies[this_val] || '';
|
325 |
+
return $.inArray( val, $taxonomies_of_this ) >= 0;
|
326 |
+
} ).parents( '.checkbox' ).removeClass( 'hidden' );
|
327 |
}
|
328 |
|
329 |
// Show there is no taxonomies
|
330 |
+
if ( $wrap_taxonomies.find( '.pt-params .checkbox' ).filter( function () {
|
331 |
+
return !$( this ).hasClass( 'hidden' );
|
332 |
+
} ).length === 0 ) {
|
333 |
// Show no taxonomy div
|
334 |
+
no_taxonomy.removeClass( 'hidden' );
|
335 |
}
|
336 |
|
337 |
// Trigger custom actions
|
338 |
+
$( '.pt-wrap' ).trigger( 'content-type-change', [ this_val ] );
|
339 |
};
|
340 |
|
341 |
// Get "Content Type" input object
|
342 |
var content_type = '[name="' + _prefix + 'content-type' + '"]';
|
343 |
|
344 |
// Run on page load
|
345 |
+
fn_content_type( $( content_type + ':checked' ).val() );
|
346 |
|
347 |
// Run on change
|
348 |
+
$( content_type ).change( function () {
|
349 |
+
fn_content_type( $( content_type + ':checked' ).val(), 1 );
|
350 |
+
} );
|
351 |
},
|
352 |
/**
|
353 |
* Preview handle
|
355 |
* @param string _nonce
|
356 |
* @returns {undefined}
|
357 |
*/
|
358 |
+
preview: function ( _nonce ) {
|
359 |
var $self = this;
|
360 |
var _prefix = $self.options._prefix;
|
361 |
|
362 |
// Store previous offset top position
|
363 |
var offset_top;
|
364 |
|
365 |
+
$( '#' + _prefix + 'show-preview' ).click( function ( e ) {
|
366 |
e.stopPropagation();
|
367 |
e.preventDefault();
|
368 |
|
369 |
+
var $this_btn = $( this );
|
370 |
|
371 |
// Get Preview box
|
372 |
+
var $preview = $( '#' + _prefix + 'preview-box' );
|
373 |
|
374 |
// Show/hide Preview box
|
375 |
+
if ( $self.options.can_preview ) {
|
376 |
+
$preview.addClass( 'in' );
|
377 |
} else {
|
378 |
+
$preview.removeClass( 'in' );
|
379 |
}
|
380 |
|
381 |
/**
|
382 |
* Animation
|
383 |
*/
|
384 |
// Scroll to preview box if want to show it
|
385 |
+
if ( $self.options.can_preview ) {
|
386 |
// Get current offset top to go back later
|
387 |
+
offset_top = $( document ).scrollTop();
|
388 |
|
389 |
// Scroll to preview box
|
390 |
+
$( 'html, body' ).animate( {
|
391 |
scrollTop: $preview.offset().top - 100
|
392 |
+
}, $self.options.scroll_time );
|
393 |
|
394 |
/// Send request
|
395 |
+
$preview.css( 'opacity', '0.2' );
|
396 |
// Show loading icon
|
397 |
+
$preview.next().removeClass( 'hidden' );
|
398 |
|
399 |
// Get settings data
|
400 |
+
var data = $( '#' + _prefix + 'form-view' ).serialize();
|
401 |
// Call handle function
|
402 |
+
$self._preview_request( $preview, data, _nonce, $this_btn );
|
403 |
} else {
|
404 |
// Scroll to previous position
|
405 |
+
$( 'html, body' ).animate( {
|
406 |
scrollTop: offset_top
|
407 |
+
}, $self.options.scroll_time );
|
408 |
|
409 |
// Toggle text of this button
|
410 |
+
$this_btn.html( PT_CV_ADMIN.btn.preview.show );
|
411 |
|
412 |
// Enable preview
|
413 |
+
setTimeout( function () {
|
414 |
$self.options.can_preview = 1;
|
415 |
+
}, $self.options.scroll_time );
|
416 |
}
|
417 |
+
} );
|
418 |
},
|
419 |
/**
|
420 |
* Send preview Ajax request
|
425 |
* @param object $this_btn The Show/Hide preview button
|
426 |
* @returns void
|
427 |
*/
|
428 |
+
_preview_request: function ( preview_box, _data, _nonce, $this_btn ) {
|
429 |
var $self = this;
|
430 |
var _prefix = $self.options._prefix;
|
431 |
|
437 |
};
|
438 |
|
439 |
// Sent POST request
|
440 |
+
$.ajax( {
|
441 |
type: "POST",
|
442 |
url: ajaxurl,
|
443 |
data: data,
|
444 |
+
} ).done( function ( response ) {
|
445 |
+
preview_box.css( 'opacity', '1' );
|
446 |
// Hide loading icon
|
447 |
+
preview_box.next().addClass( 'hidden' );
|
448 |
|
449 |
// Update content of Preview box
|
450 |
+
preview_box.html( response );
|
451 |
|
452 |
// Toggle text of this button
|
453 |
+
$this_btn.html( PT_CV_ADMIN.btn.preview.hide );
|
454 |
|
455 |
// Disable preview
|
456 |
$self.options.can_preview = 0;
|
457 |
|
458 |
// Trigger action, to recall function such as pagination, pinterest render layout...
|
459 |
+
$( 'body' ).trigger( _prefix + 'custom-trigger' );
|
460 |
+
} );
|
461 |
},
|
462 |
/**
|
463 |
* Toggle 'Thumbnail settings'
|
474 |
* @param this_val Layout format value
|
475 |
* @returns void
|
476 |
*/
|
477 |
+
var fn_thumbnail_setting = function ( this_val ) {
|
478 |
+
|
479 |
+
var $thumbnail_wrapper = $( '.' + _prefix + 'thumbnail-setting' ).parent();
|
480 |
+
if ( this_val === '2-col' ) {
|
481 |
+
_thumbnail_setting_state = $thumbnail_wrapper.hasClass( 'hidden' ) ? 0 : 1;
|
482 |
+
$thumbnail_wrapper.removeClass( 'hidden' );
|
483 |
+
} else if ( this_val === '1-col' ) {
|
484 |
+
if ( _thumbnail_setting_state ) {
|
485 |
+
$thumbnail_wrapper.removeClass( 'hidden' );
|
486 |
} else {
|
487 |
+
$thumbnail_wrapper.addClass( 'hidden' );
|
488 |
}
|
489 |
}
|
490 |
};
|
492 |
var layout_format = '[name="' + _prefix + 'layout-format' + '"]';
|
493 |
|
494 |
// Run on page load
|
495 |
+
fn_thumbnail_setting( $( layout_format + ':checked' ).val() );
|
496 |
|
497 |
// Run on change
|
498 |
+
$( layout_format ).change( function () {
|
499 |
+
fn_thumbnail_setting( $( layout_format + ':checked' ).val() );
|
500 |
+
} );
|
501 |
|
502 |
/**
|
503 |
* Toggle 'Layout format' when change 'View type'
|
504 |
*/
|
505 |
+
var fn_layout_format = function ( this_val, layout_format ) {
|
506 |
+
var expect_val = [ 'scrollable' ];
|
507 |
|
508 |
// Add more layouts
|
509 |
+
$( '.pt-wrap' ).trigger( 'toggle-layout-format', [ expect_val ] );
|
510 |
|
511 |
+
if ( $.inArray( this_val, expect_val ) >= 0 ) {
|
512 |
// Trigger select 1-col
|
513 |
+
$( layout_format + '[value="1-col"]' ).trigger( 'click' );
|
514 |
// Disable 2-col
|
515 |
+
$( layout_format + '[value="2-col"]' ).attr( 'disabled', true );
|
516 |
} else {
|
517 |
// Enable 2-col
|
518 |
+
$( layout_format + '[value="2-col"]' ).attr( 'disabled', false );
|
519 |
}
|
520 |
};
|
521 |
|
522 |
var view_type = '[name="' + _prefix + 'view-type' + '"]';
|
523 |
|
524 |
// Run on page load
|
525 |
+
fn_layout_format( $( view_type + ':checked' ).val(), layout_format );
|
526 |
|
527 |
// Run on change
|
528 |
+
$( view_type ).change( function () {
|
529 |
+
fn_layout_format( $( view_type + ':checked' ).val(), layout_format );
|
530 |
+
} );
|
531 |
},
|
532 |
/**
|
533 |
* Toggle text of Preview button
|
538 |
var $self = this;
|
539 |
var _prefix = $self.options._prefix;
|
540 |
|
541 |
+
var _fn = function ( is_trigger ) {
|
542 |
+
if ( !is_trigger ) {
|
543 |
$self.options.onload = 0;
|
544 |
}
|
545 |
|
546 |
// Toggle text of this button
|
547 |
+
$( '#' + _prefix + 'show-preview' ).html( PT_CV_ADMIN.btn.preview.update );
|
548 |
|
549 |
// Enable preview
|
550 |
$self.options.can_preview = 1;
|
551 |
};
|
552 |
// Bind on change input after page load
|
553 |
+
$( '.pt-wrap .tab-content' ).on( 'change', 'input, select, textarea', function ( evt, is_trigger ) {
|
554 |
+
_fn( is_trigger );
|
555 |
+
} );
|
556 |
|
557 |
+
$( 'body' ).bind( _prefix + 'preview-btn-toggle', function () {
|
558 |
_fn();
|
559 |
+
} );
|
560 |
},
|
561 |
/**
|
562 |
* Do handy toggle for Excerpt settings
|
567 |
var _prefix = this.options._prefix;
|
568 |
|
569 |
// For Excerpt Settings
|
570 |
+
var _this_toggle = function ( show_content ) {
|
571 |
+
if ( !show_content ) {
|
572 |
+
$( '#' + _prefix + 'group-excerpt-settings' ).addClass( 'hidden' );
|
573 |
} else {
|
574 |
+
$( '#' + _prefix + 'group-excerpt-settings' ).removeClass( 'hidden' );
|
575 |
}
|
576 |
};
|
577 |
|
578 |
var selector = '[name="' + _prefix + 'show-field-content' + '"]';
|
579 |
|
580 |
// Run on page load
|
581 |
+
_this_toggle( $( selector ).is( ':checked' ) );
|
582 |
|
583 |
// Run on change
|
584 |
+
$( selector ).change( function () {
|
585 |
+
_this_toggle( $( selector ).is( ':checked' ) );
|
586 |
+
} );
|
587 |
|
588 |
// Handy do other toggle
|
589 |
+
$( '.pt-wrap' ).trigger( _prefix + 'multi-level-toggle' );
|
590 |
},
|
591 |
/**
|
592 |
* Custom js for elements
|
606 |
$self._toggle_taxonomy_relation();
|
607 |
|
608 |
// Toggle panel of 'Advanced filters'
|
609 |
+
$self._toggle_panel( '.' + _prefix + 'group .panel-heading' );
|
610 |
|
611 |
// 'Thumbnail settings' toggle
|
612 |
$self._thumbnail_settings();
|
613 |
|
614 |
// Select 2
|
615 |
+
$( '.' + _prefix + 'select2' ).select2();
|
616 |
|
617 |
// Change class of panel inside panel
|
618 |
+
$( '.' + _prefix + 'group .panel .panel' ).each( function () {
|
619 |
+
$( this ).removeClass( 'panel-primary' ).addClass( 'panel-info' );
|
620 |
+
} );
|
621 |
|
622 |
// Set custom style for 'Thumbnail position' box
|
623 |
+
$( '.' + _prefix + 'bg-none' ).parent().css( { 'background-color': '#fff', 'padding-bottom': '10px' } );
|
624 |
+
$( '.' + _prefix + 'bg-none' ).parent().addClass( 'unsortable' );
|
625 |
|
626 |
// Prevent click on links
|
627 |
+
$( '#' + _prefix + 'preview-box' ).on( 'click', 'a', function ( e ) {
|
628 |
e.preventDefault();
|
629 |
+
} );
|
630 |
|
631 |
// Handle Pagination actions
|
632 |
+
$( 'body' ).bind( _prefix + 'custom-trigger', function () {
|
633 |
+
var $pt_cv_public_js = new $.PT_CV_Public( { _prefix: _prefix, _autoload: 0 } );
|
634 |
$pt_cv_public_js.pagination();
|
635 |
+
} );
|
636 |
+
|
637 |
+
// Prevent missing changes
|
638 |
+
window.onbeforeunload = function ( event ) {
|
639 |
+
if ( !$self.options.onload ) {
|
640 |
+
var message = 'The changes you made will be lost if you navigate away from this page.';
|
641 |
+
if ( typeof event === 'undefined' ) {
|
642 |
+
event = window.event;
|
643 |
+
}
|
644 |
+
if ( event ) {
|
645 |
+
event.returnValue = message;
|
646 |
+
}
|
647 |
+
return message;
|
648 |
+
}
|
649 |
+
}
|
650 |
},
|
651 |
};
|
652 |
+
}( jQuery ) );
|
admin/content-views-admin.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Content Views Admin
|
4 |
*
|
@@ -8,7 +9,6 @@
|
|
8 |
* @link http://www.contentviewspro.com/
|
9 |
* @copyright 2014 PT Guy
|
10 |
*/
|
11 |
-
|
12 |
class PT_Content_Views_Admin {
|
13 |
|
14 |
/**
|
@@ -27,8 +27,7 @@ class PT_Content_Views_Admin {
|
|
27 |
*
|
28 |
* @var string
|
29 |
*/
|
30 |
-
protected $plugin_screen_hook_suffix
|
31 |
-
|
32 |
// Slugs for sub menu pages
|
33 |
protected $plugin_sub_screen_hook_suffix = null;
|
34 |
|
@@ -46,14 +45,14 @@ class PT_Content_Views_Admin {
|
|
46 |
* - Uncomment following lines if the admin class should only be available for super admins
|
47 |
*/
|
48 |
/* if( ! is_super_admin() ) {
|
49 |
-
|
50 |
-
|
51 |
|
52 |
/*
|
53 |
* Call $plugin_slug from public plugin class.
|
54 |
*/
|
55 |
-
$plugin
|
56 |
-
$this->plugin_slug
|
57 |
|
58 |
// Fix redirect error
|
59 |
add_action( 'init', array( $this, 'do_output_buffer' ) );
|
@@ -116,8 +115,8 @@ class PT_Content_Views_Admin {
|
|
116 |
* - Uncomment following lines if the admin class should only be available for super admins
|
117 |
*/
|
118 |
/* if( ! is_super_admin() ) {
|
119 |
-
|
120 |
-
|
121 |
|
122 |
// If the single instance hasn't been set, set it now.
|
123 |
if ( null == self::$instance ) {
|
@@ -140,7 +139,7 @@ class PT_Content_Views_Admin {
|
|
140 |
public function redirect_add_new() {
|
141 |
global $pagenow;
|
142 |
if ( $pagenow === 'post-new.php' ) {
|
143 |
-
$post_type = isset( $_GET['post_type'] ) ? $_GET['post_type'] : '';
|
144 |
if ( $post_type === PT_CV_POST_TYPE ) {
|
145 |
wp_redirect( admin_url( 'admin.php?page=' . $this->plugin_slug . '-add' ), 301 );
|
146 |
exit;
|
@@ -157,15 +156,15 @@ class PT_Content_Views_Admin {
|
|
157 |
*/
|
158 |
public function enqueue_admin_styles() {
|
159 |
|
160 |
-
if ( !
|
161 |
return;
|
162 |
}
|
163 |
|
164 |
// Load every Admin pages
|
165 |
PT_CV_Asset::enqueue(
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
);
|
170 |
|
171 |
$screen = get_current_screen();
|
@@ -178,34 +177,34 @@ class PT_Content_Views_Admin {
|
|
178 |
|
179 |
// Main admin style
|
180 |
PT_CV_Asset::enqueue(
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
);
|
185 |
|
186 |
// Fix style of WP
|
187 |
global $wp_version;
|
188 |
if ( version_compare( $wp_version, '3.8.0' ) >= 0 ) {
|
189 |
PT_CV_Asset::enqueue(
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
);
|
195 |
} else {
|
196 |
PT_CV_Asset::enqueue(
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
);
|
202 |
}
|
203 |
|
204 |
// Bootstrap for Admin
|
205 |
PT_CV_Asset::enqueue(
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
);
|
210 |
|
211 |
// For Preview
|
@@ -226,7 +225,7 @@ class PT_Content_Views_Admin {
|
|
226 |
*/
|
227 |
public function enqueue_admin_scripts() {
|
228 |
|
229 |
-
if ( !
|
230 |
return;
|
231 |
}
|
232 |
|
@@ -239,32 +238,32 @@ class PT_Content_Views_Admin {
|
|
239 |
|
240 |
// Main admin script
|
241 |
PT_CV_Asset::enqueue(
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
);
|
247 |
|
248 |
// Localize strings
|
249 |
PT_CV_Asset::localize_script(
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
),
|
263 |
-
),
|
264 |
-
'data' => array(
|
265 |
-
'post_types_vs_taxonomies' => PT_CV_Values::post_types_vs_taxonomies(),
|
266 |
),
|
267 |
-
)
|
|
|
|
|
|
|
|
|
268 |
);
|
269 |
|
270 |
// For Preview
|
@@ -278,7 +277,7 @@ class PT_Content_Views_Admin {
|
|
278 |
* Print script at footer of WP admin
|
279 |
*/
|
280 |
public function print_footer_scripts() {
|
281 |
-
if ( !
|
282 |
return;
|
283 |
}
|
284 |
|
@@ -298,37 +297,20 @@ class PT_Content_Views_Admin {
|
|
298 |
* Add a settings page for this plugin to the Settings menu.
|
299 |
*/
|
300 |
// Get user role settings option
|
301 |
-
$options
|
302 |
-
$user_role
|
303 |
|
304 |
$this->plugin_screen_hook_suffix = add_menu_page(
|
305 |
-
|
306 |
-
__( 'Content View Settings', $this->plugin_slug ),
|
307 |
-
$user_role,
|
308 |
-
$this->plugin_slug,
|
309 |
-
array( $this, 'display_plugin_admin_page' ),
|
310 |
-
'',
|
311 |
-
'45.6'
|
312 |
);
|
313 |
|
314 |
$this->plugin_sub_screen_hook_suffix[] = PT_CV_Functions::menu_add_sub(
|
315 |
-
|
316 |
-
__( 'All Content Views', $this->plugin_slug ),
|
317 |
-
__( 'All Views', $this->plugin_slug ),
|
318 |
-
$user_role,
|
319 |
-
'list',
|
320 |
-
__CLASS__
|
321 |
);
|
322 |
|
323 |
$this->plugin_sub_screen_hook_suffix[] = PT_CV_Functions::menu_add_sub(
|
324 |
-
|
325 |
-
__( 'Add New View', $this->plugin_slug ),
|
326 |
-
__( 'Add New', $this->plugin_slug ),
|
327 |
-
$user_role,
|
328 |
-
'add',
|
329 |
-
__CLASS__
|
330 |
);
|
331 |
-
|
332 |
}
|
333 |
|
334 |
/**
|
@@ -377,11 +359,10 @@ class PT_Content_Views_Admin {
|
|
377 |
public function filter_add_action_links( $links ) {
|
378 |
|
379 |
return array_merge(
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
$links
|
385 |
);
|
386 |
}
|
387 |
|
@@ -403,19 +384,18 @@ class PT_Content_Views_Admin {
|
|
403 |
}
|
404 |
|
405 |
// Remove Quick edit link
|
406 |
-
unset( $actions['inline hide-if-no-js'] );
|
407 |
|
408 |
// Remove View link
|
409 |
-
unset( $actions['view'] );
|
410 |
|
411 |
// Update Edit link
|
412 |
-
|
413 |
// Get View id
|
414 |
$view_id = get_post_meta( $post->ID, PT_CV_META_ID, true );
|
415 |
|
416 |
-
if ( !
|
417 |
-
$edit_link
|
418 |
-
$actions['edit']
|
419 |
}
|
420 |
|
421 |
// Filter actions
|
@@ -426,16 +406,16 @@ class PT_Content_Views_Admin {
|
|
426 |
|
427 |
/**
|
428 |
* Modify column in View list page (Admin)
|
429 |
-
*
|
430 |
* @param type $defaults
|
431 |
*/
|
432 |
public function filter_view_custom_column_header( $defaults ) {
|
433 |
-
unset( $defaults['author'] );
|
434 |
-
unset( $defaults['date'] );
|
435 |
|
436 |
-
$defaults['shortcode'] = __( 'Shortcode' );
|
437 |
-
$defaults['author']
|
438 |
-
$defaults['date']
|
439 |
|
440 |
return $defaults;
|
441 |
}
|
@@ -469,14 +449,14 @@ class PT_Content_Views_Admin {
|
|
469 |
public function filter_admin_title( $admin_title, $title ) {
|
470 |
$screen = get_current_screen();
|
471 |
|
472 |
-
if (
|
473 |
return $admin_title;
|
474 |
}
|
475 |
|
476 |
// If is View page
|
477 |
if ( $this->plugin_screen_hook_suffix == $screen->id || in_array( $screen->id, $this->plugin_sub_screen_hook_suffix ) ) {
|
478 |
// If View id is passed in url
|
479 |
-
if ( !
|
480 |
$admin_title = str_replace( 'Add New', 'Edit', $admin_title );
|
481 |
}
|
482 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Content Views Admin
|
5 |
*
|
9 |
* @link http://www.contentviewspro.com/
|
10 |
* @copyright 2014 PT Guy
|
11 |
*/
|
|
|
12 |
class PT_Content_Views_Admin {
|
13 |
|
14 |
/**
|
27 |
*
|
28 |
* @var string
|
29 |
*/
|
30 |
+
protected $plugin_screen_hook_suffix = null;
|
|
|
31 |
// Slugs for sub menu pages
|
32 |
protected $plugin_sub_screen_hook_suffix = null;
|
33 |
|
45 |
* - Uncomment following lines if the admin class should only be available for super admins
|
46 |
*/
|
47 |
/* if( ! is_super_admin() ) {
|
48 |
+
return;
|
49 |
+
} */
|
50 |
|
51 |
/*
|
52 |
* Call $plugin_slug from public plugin class.
|
53 |
*/
|
54 |
+
$plugin = PT_Content_Views::get_instance();
|
55 |
+
$this->plugin_slug = $plugin->get_plugin_slug();
|
56 |
|
57 |
// Fix redirect error
|
58 |
add_action( 'init', array( $this, 'do_output_buffer' ) );
|
115 |
* - Uncomment following lines if the admin class should only be available for super admins
|
116 |
*/
|
117 |
/* if( ! is_super_admin() ) {
|
118 |
+
return;
|
119 |
+
} */
|
120 |
|
121 |
// If the single instance hasn't been set, set it now.
|
122 |
if ( null == self::$instance ) {
|
139 |
public function redirect_add_new() {
|
140 |
global $pagenow;
|
141 |
if ( $pagenow === 'post-new.php' ) {
|
142 |
+
$post_type = isset( $_GET[ 'post_type' ] ) ? $_GET[ 'post_type' ] : '';
|
143 |
if ( $post_type === PT_CV_POST_TYPE ) {
|
144 |
wp_redirect( admin_url( 'admin.php?page=' . $this->plugin_slug . '-add' ), 301 );
|
145 |
exit;
|
156 |
*/
|
157 |
public function enqueue_admin_styles() {
|
158 |
|
159 |
+
if ( !isset( $this->plugin_screen_hook_suffix ) ) {
|
160 |
return;
|
161 |
}
|
162 |
|
163 |
// Load every Admin pages
|
164 |
PT_CV_Asset::enqueue(
|
165 |
+
'admin-menu', 'style', array(
|
166 |
+
'src' => plugins_url( 'assets/css/menu.css', __FILE__ ),
|
167 |
+
)
|
168 |
);
|
169 |
|
170 |
$screen = get_current_screen();
|
177 |
|
178 |
// Main admin style
|
179 |
PT_CV_Asset::enqueue(
|
180 |
+
'admin', 'style', array(
|
181 |
+
'src' => plugins_url( 'assets/css/admin.css', __FILE__ ),
|
182 |
+
)
|
183 |
);
|
184 |
|
185 |
// Fix style of WP
|
186 |
global $wp_version;
|
187 |
if ( version_compare( $wp_version, '3.8.0' ) >= 0 ) {
|
188 |
PT_CV_Asset::enqueue(
|
189 |
+
'admin-fix', 'style', array(
|
190 |
+
'src' => plugins_url( 'assets/css/wp38.css', __FILE__ ),
|
191 |
+
'ver' => $wp_version,
|
192 |
+
)
|
193 |
);
|
194 |
} else {
|
195 |
PT_CV_Asset::enqueue(
|
196 |
+
'admin-fix', 'style', array(
|
197 |
+
'src' => plugins_url( 'assets/css/wp.css', __FILE__ ),
|
198 |
+
'ver' => $wp_version,
|
199 |
+
)
|
200 |
);
|
201 |
}
|
202 |
|
203 |
// Bootstrap for Admin
|
204 |
PT_CV_Asset::enqueue(
|
205 |
+
'bootstrap-admin', 'style', array(
|
206 |
+
'src' => plugins_url( 'assets/bootstrap/css/bootstrap.admin.css', PT_CV_FILE ),
|
207 |
+
)
|
208 |
);
|
209 |
|
210 |
// For Preview
|
225 |
*/
|
226 |
public function enqueue_admin_scripts() {
|
227 |
|
228 |
+
if ( !isset( $this->plugin_screen_hook_suffix ) ) {
|
229 |
return;
|
230 |
}
|
231 |
|
238 |
|
239 |
// Main admin script
|
240 |
PT_CV_Asset::enqueue(
|
241 |
+
'admin', 'script', array(
|
242 |
+
'src' => plugins_url( 'assets/js/admin.js', __FILE__ ),
|
243 |
+
'deps' => array( 'jquery' ),
|
244 |
+
)
|
245 |
);
|
246 |
|
247 |
// Localize strings
|
248 |
PT_CV_Asset::localize_script(
|
249 |
+
'admin', PT_CV_PREFIX_UPPER . 'ADMIN', array(
|
250 |
+
'supported_version' => PT_CV_Functions::wp_version_compare( '3.5' ),
|
251 |
+
'text' => array(
|
252 |
+
'no_taxonomy' => __( 'There is no taxonomy for selected content type', PT_CV_DOMAIN ),
|
253 |
+
'pagination_disable' => __( 'Pagination is disabled when Limit = -1', PT_CV_DOMAIN ),
|
254 |
+
'prevent_click' => __( 'Opening a link is prevented in preview box', PT_CV_DOMAIN ),
|
255 |
+
),
|
256 |
+
'btn' => array(
|
257 |
+
'preview' => array(
|
258 |
+
'show' => __( 'Show Preview', PT_CV_DOMAIN ),
|
259 |
+
'hide' => __( 'Hide Preview', PT_CV_DOMAIN ),
|
260 |
+
'update' => __( 'Update Preview', PT_CV_DOMAIN ),
|
|
|
|
|
|
|
|
|
261 |
),
|
262 |
+
),
|
263 |
+
'data' => array(
|
264 |
+
'post_types_vs_taxonomies' => PT_CV_Values::post_types_vs_taxonomies(),
|
265 |
+
),
|
266 |
+
)
|
267 |
);
|
268 |
|
269 |
// For Preview
|
277 |
* Print script at footer of WP admin
|
278 |
*/
|
279 |
public function print_footer_scripts() {
|
280 |
+
if ( !isset( $this->plugin_screen_hook_suffix ) ) {
|
281 |
return;
|
282 |
}
|
283 |
|
297 |
* Add a settings page for this plugin to the Settings menu.
|
298 |
*/
|
299 |
// Get user role settings option
|
300 |
+
$options = get_option( PT_CV_OPTION_NAME );
|
301 |
+
$user_role = current_user_can( 'administrator' ) ? 'administrator' : ( isset( $options[ 'access_role' ] ) ? $options[ 'access_role' ] : 'edit_posts' );
|
302 |
|
303 |
$this->plugin_screen_hook_suffix = add_menu_page(
|
304 |
+
__( 'Content View Settings', $this->plugin_slug ), __( 'Content View Settings', $this->plugin_slug ), $user_role, $this->plugin_slug, array( $this, 'display_plugin_admin_page' ), '', '45.6'
|
|
|
|
|
|
|
|
|
|
|
|
|
305 |
);
|
306 |
|
307 |
$this->plugin_sub_screen_hook_suffix[] = PT_CV_Functions::menu_add_sub(
|
308 |
+
$this->plugin_slug, __( 'All Content Views', $this->plugin_slug ), __( 'All Views', $this->plugin_slug ), $user_role, 'list', __CLASS__
|
|
|
|
|
|
|
|
|
|
|
309 |
);
|
310 |
|
311 |
$this->plugin_sub_screen_hook_suffix[] = PT_CV_Functions::menu_add_sub(
|
312 |
+
$this->plugin_slug, __( 'Add New View', $this->plugin_slug ), __( 'Add New', $this->plugin_slug ), $user_role, 'add', __CLASS__
|
|
|
|
|
|
|
|
|
|
|
313 |
);
|
|
|
314 |
}
|
315 |
|
316 |
/**
|
359 |
public function filter_add_action_links( $links ) {
|
360 |
|
361 |
return array_merge(
|
362 |
+
array(
|
363 |
+
'settings' => '<a href="' . admin_url( 'admin.php?page=' . $this->plugin_slug ) . '">' . __( 'Settings', $this->plugin_slug ) . '</a>',
|
364 |
+
'add' => '<a href="' . admin_url( 'admin.php?page=' . $this->plugin_slug . '-add' ) . '">' . __( 'Add View', $this->plugin_slug ) . '</a>',
|
365 |
+
), $links
|
|
|
366 |
);
|
367 |
}
|
368 |
|
384 |
}
|
385 |
|
386 |
// Remove Quick edit link
|
387 |
+
unset( $actions[ 'inline hide-if-no-js' ] );
|
388 |
|
389 |
// Remove View link
|
390 |
+
unset( $actions[ 'view' ] );
|
391 |
|
392 |
// Update Edit link
|
|
|
393 |
// Get View id
|
394 |
$view_id = get_post_meta( $post->ID, PT_CV_META_ID, true );
|
395 |
|
396 |
+
if ( !empty( $view_id ) ) {
|
397 |
+
$edit_link = PT_CV_Functions::view_link( $view_id );
|
398 |
+
$actions[ 'edit' ] = '<a href="' . esc_url( $edit_link ) . '" title="' . esc_attr( __( 'Edit this item' ) ) . '">' . __( 'Edit' ) . '</a>';
|
399 |
}
|
400 |
|
401 |
// Filter actions
|
406 |
|
407 |
/**
|
408 |
* Modify column in View list page (Admin)
|
409 |
+
*
|
410 |
* @param type $defaults
|
411 |
*/
|
412 |
public function filter_view_custom_column_header( $defaults ) {
|
413 |
+
unset( $defaults[ 'author' ] );
|
414 |
+
unset( $defaults[ 'date' ] );
|
415 |
|
416 |
+
$defaults[ 'shortcode' ] = __( 'Shortcode' );
|
417 |
+
$defaults[ 'author' ] = __( 'Author' );
|
418 |
+
$defaults[ 'date' ] = __( 'Date' );
|
419 |
|
420 |
return $defaults;
|
421 |
}
|
449 |
public function filter_admin_title( $admin_title, $title ) {
|
450 |
$screen = get_current_screen();
|
451 |
|
452 |
+
if ( !$this || !isset( $this->plugin_sub_screen_hook_suffix ) ) {
|
453 |
return $admin_title;
|
454 |
}
|
455 |
|
456 |
// If is View page
|
457 |
if ( $this->plugin_screen_hook_suffix == $screen->id || in_array( $screen->id, $this->plugin_sub_screen_hook_suffix ) ) {
|
458 |
// If View id is passed in url
|
459 |
+
if ( !empty( $_GET[ 'id' ] ) ) {
|
460 |
$admin_title = str_replace( 'Add New', 'Edit', $admin_title );
|
461 |
}
|
462 |
}
|
admin/includes/options.php
CHANGED
@@ -10,14 +10,14 @@
|
|
10 |
* @link http://www.contentviewspro.com/
|
11 |
* @copyright 2014 PT Guy
|
12 |
*/
|
13 |
-
|
14 |
-
if ( ! class_exists( 'PT_Options_Framework' ) ) {
|
15 |
|
16 |
class PT_Options_Framework {
|
17 |
|
18 |
private static $dependence_info; // Store dependency information of options
|
19 |
|
20 |
public function __construct() {
|
|
|
21 |
}
|
22 |
|
23 |
/**
|
@@ -29,13 +29,13 @@ if ( ! class_exists( 'PT_Options_Framework' ) ) {
|
|
29 |
* @return string|null
|
30 |
*/
|
31 |
public static function _dependence_check( $param, &$dependence_ ) {
|
32 |
-
if ( isset( $param['dependence'] ) ) {
|
33 |
// Depend array: 3 params in order : name (of param this param depends), value (of param this param depends), operator
|
34 |
-
$dependence
|
35 |
-
$random_id
|
36 |
|
37 |
// Single dependency relationship
|
38 |
-
if ( !
|
39 |
self::_dependence_assign( $dependence, $random_id, $dependence_ );
|
40 |
} else {
|
41 |
// Multiple dependency relationships
|
@@ -57,8 +57,9 @@ if ( ! class_exists( 'PT_Options_Framework' ) ) {
|
|
57 |
* @param string $random_id Random string
|
58 |
* @param array $dependence_ Global dependence array
|
59 |
*/
|
60 |
-
public static function _dependence_assign( $dependence, $random_id,
|
61 |
-
|
|
|
62 |
}
|
63 |
|
64 |
/**
|
@@ -70,8 +71,8 @@ if ( ! class_exists( 'PT_Options_Framework' ) ) {
|
|
70 |
* @return string
|
71 |
*/
|
72 |
public static function do_settings( $options, $data = array() ) {
|
73 |
-
$result
|
74 |
-
if (
|
75 |
return '';
|
76 |
}
|
77 |
|
@@ -95,18 +96,18 @@ if ( ! class_exists( 'PT_Options_Framework' ) ) {
|
|
95 |
* @return string
|
96 |
*/
|
97 |
public static function group( $group, $data, &$dependence_ ) {
|
98 |
-
if ( empty( $group['label'] ) && empty( $group['params'] ) ) {
|
99 |
return '';
|
100 |
}
|
101 |
|
102 |
-
$extra_setting
|
103 |
-
$label
|
104 |
-
$params
|
105 |
-
$random_id
|
106 |
-
$id
|
107 |
if ( $random_id ) {
|
108 |
-
$id
|
109 |
-
$class
|
110 |
}
|
111 |
|
112 |
return "<div class='form-group pt-form-group $class' $id>$label $params</div>";
|
@@ -118,10 +119,10 @@ if ( ! class_exists( 'PT_Options_Framework' ) ) {
|
|
118 |
* @param string $label Text for label
|
119 |
*/
|
120 |
public static function label( $label = array(), $extra_setting = array() ) {
|
121 |
-
$for
|
122 |
-
$width
|
123 |
if ( $width ) {
|
124 |
-
$html = "<label $for class='col-md-$width control-label'>" . __( $label['text'], PT_CV_DOMAIN ) . '</label>';
|
125 |
} else {
|
126 |
$html = '';
|
127 |
}
|
@@ -139,10 +140,10 @@ if ( ! class_exists( 'PT_Options_Framework' ) ) {
|
|
139 |
foreach ( (array) $params as $param ) {
|
140 |
$params_html[] = self::field_type( (array) $param, $data ) . "\n";
|
141 |
}
|
142 |
-
$html
|
143 |
-
$param_wrap_class
|
144 |
-
$param_wrap_id
|
145 |
-
$width
|
146 |
|
147 |
return "<div class='col-md-$width pt-params $param_wrap_class' $param_wrap_id>$html</div>";
|
148 |
}
|
@@ -161,9 +162,9 @@ if ( ! class_exists( 'PT_Options_Framework' ) ) {
|
|
161 |
|
162 |
// Get value of field
|
163 |
if ( $data ) {
|
164 |
-
$value = isset( $data[$single_name] ) ? $data[$single_name] : '';
|
165 |
} else {
|
166 |
-
$value = isset( $param['std'] ) ? $param['std'] : '';
|
167 |
}
|
168 |
|
169 |
return $value;
|
@@ -178,23 +179,23 @@ if ( ! class_exists( 'PT_Options_Framework' ) ) {
|
|
178 |
* @return string
|
179 |
*/
|
180 |
public static function field_type( $param, $data, $value_ = NULL ) {
|
181 |
-
if (
|
182 |
return '';
|
183 |
}
|
184 |
-
$html
|
185 |
-
$class
|
186 |
|
187 |
-
$type
|
188 |
-
$name
|
189 |
-
$id
|
190 |
-
$value
|
191 |
-
$description = isset( $param['desc'] ) ? balanceTags( $param['desc'] ) : '';
|
192 |
|
193 |
// Add extra information of option type
|
194 |
switch ( $type ) {
|
195 |
case 'number':
|
196 |
-
$min
|
197 |
-
$extend
|
198 |
break;
|
199 |
case 'color':
|
200 |
$class .= ' ' . PT_CV_PREFIX . 'color';
|
@@ -202,7 +203,7 @@ if ( ! class_exists( 'PT_Options_Framework' ) ) {
|
|
202 |
case 'checkbox':
|
203 |
case 'radio':
|
204 |
// Remove form-control class in checkbox, radio
|
205 |
-
$class
|
206 |
break;
|
207 |
}
|
208 |
|
@@ -211,15 +212,15 @@ if ( ! class_exists( 'PT_Options_Framework' ) ) {
|
|
211 |
// Show HTML of option type
|
212 |
switch ( $type ) {
|
213 |
case 'group':
|
214 |
-
$html .= self::do_settings( $param['params'], $data );
|
215 |
break;
|
216 |
case 'text':
|
217 |
case 'email':
|
218 |
case 'password':
|
219 |
case 'number':
|
220 |
case 'url':
|
221 |
-
$placeholder = !
|
222 |
-
$append_text = !
|
223 |
|
224 |
$input = "<input type='$type' name='$name' value='$value' class='$class' $id $extend placeholder='$placeholder'>";
|
225 |
if ( empty( $append_text ) ) {
|
@@ -237,17 +238,17 @@ if ( ! class_exists( 'PT_Options_Framework' ) ) {
|
|
237 |
break;
|
238 |
case 'checkbox':
|
239 |
case 'radio':
|
240 |
-
if ( !
|
241 |
break;
|
242 |
}
|
243 |
|
244 |
-
$settings = isset( $param['settings'] ) ? $param['settings'] : array();
|
245 |
-
foreach ( $param['options'] as $key => $text ) {
|
246 |
// Append Html to $text, such as image...
|
247 |
if ( $settings ) {
|
248 |
-
$append = isset( $settings['text-append'] ) ? $settings['text-append'] : '';
|
249 |
if ( $append == 'image' ) {
|
250 |
-
$path = isset( $settings['path'] ) ? $settings['path'] : '';
|
251 |
if ( $path ) {
|
252 |
$text .= "<br> <img src='" . plugins_url( $path . "/$key.png", PT_CV_FILE ) . "' />";
|
253 |
}
|
@@ -260,21 +261,21 @@ if ( ! class_exists( 'PT_Options_Framework' ) ) {
|
|
260 |
|
261 |
break;
|
262 |
case 'select':
|
263 |
-
if ( !
|
264 |
break;
|
265 |
}
|
266 |
|
267 |
$options = '';
|
268 |
-
foreach ( $param['options'] as $key => $text ) {
|
269 |
-
$selected
|
270 |
-
$option_class
|
271 |
$options .= "<option value='$key' $selected $option_class>$text</option>";
|
272 |
}
|
273 |
if ( empty( $options ) ) {
|
274 |
$html .= "<div class='" . PT_CV_PREFIX . "text'>" . __( 'There is no option', PT_CV_DOMAIN ) . '</div>';
|
275 |
} else {
|
276 |
$multiple = '';
|
277 |
-
if ( ( isset( $param['multiple'] ) && $param['multiple'] == '1' ) || $value == 'all' ) {
|
278 |
$multiple = 'multiple';
|
279 |
// Auto add [] to name of select
|
280 |
$name .= substr( $name, - 2 ) == '[]' ? '' : '[]';
|
@@ -283,18 +284,18 @@ if ( ! class_exists( 'PT_Options_Framework' ) ) {
|
|
283 |
}
|
284 |
break;
|
285 |
case 'color_picker':
|
286 |
-
$html .= self::field_type( $param['options'], $data );
|
287 |
break;
|
288 |
case 'html':
|
289 |
-
if ( isset( $param['content'] ) ) {
|
290 |
-
$html .= $param['content'];
|
291 |
}
|
292 |
break;
|
293 |
case 'panel_group':
|
294 |
// In format: key => array of params
|
295 |
-
$parent_id
|
296 |
-
$settings
|
297 |
-
foreach ( $param['params'] as $key => $param_group ) {
|
298 |
$html .= self::sub_panel_group( $key, $param_group, $data, $parent_id, $settings );
|
299 |
}
|
300 |
break;
|
@@ -304,7 +305,7 @@ if ( ! class_exists( 'PT_Options_Framework' ) ) {
|
|
304 |
|
305 |
$description = apply_filters( PT_CV_PREFIX_ . 'options_description', $description, $param );
|
306 |
|
307 |
-
if ( !
|
308 |
$html .= "<p class='text-muted'>$description</p>";
|
309 |
}
|
310 |
|
@@ -322,24 +323,25 @@ if ( ! class_exists( 'PT_Options_Framework' ) ) {
|
|
322 |
*
|
323 |
* @return string
|
324 |
*/
|
325 |
-
static function sub_panel_group( $key, $param_group, $data, $parent_id,
|
|
|
326 |
|
327 |
// Content for body
|
328 |
$content = self::do_settings( $param_group, $data );
|
329 |
// Class for wrapper
|
330 |
-
$class
|
331 |
-
$class .= ( isset( $settings['show_all'] ) ? '' : ' hidden' );
|
332 |
-
$class .= ( isset( $settings['show_only_one'] ) ? ' ' . PT_CV_PREFIX . 'only-one' : '' );
|
333 |
-
$class .= ( isset( $settings['no_panel'] ) ? ' ' . PT_CV_PREFIX . 'no-panel' : '' );
|
334 |
-
$class .= ( isset( $settings['no_animation'] ) ? ' ' . PT_CV_PREFIX . 'no-animation' : '' );
|
335 |
// Id for wrapper
|
336 |
-
$id
|
337 |
|
338 |
-
if ( !
|
339 |
// Heading text
|
340 |
-
$heading = ( isset( $settings['nice_name'] ) && isset( $settings['nice_name'][$key] ) ) ? $settings['nice_name'][$key] : PT_CV_Functions::string_slug_to_text( $key );
|
341 |
$heading = __( $heading, PT_CV_DOMAIN ) . ' ' . __( 'Settings', PT_CV_DOMAIN );
|
342 |
-
$html
|
343 |
} else {
|
344 |
$html = $content;
|
345 |
}
|
@@ -354,37 +356,37 @@ if ( ! class_exists( 'PT_Options_Framework' ) ) {
|
|
354 |
$toggle_data_js = json_encode( self::$dependence_info );
|
355 |
?>
|
356 |
<script>
|
357 |
-
(function ($) {
|
358 |
"use strict";
|
359 |
|
360 |
-
$(function () {
|
361 |
var _prefix = '<?php echo esc_js( PT_CV_PREFIX ); ?>';
|
362 |
-
var $pt_cv_admin_js = new $.PT_CV_Admin({_prefix: _prefix});
|
363 |
var group_prefix = '<?php echo esc_js( PT_CV_Html::html_group_class() ); ?>' + '-';
|
364 |
|
365 |
// Preview actions
|
366 |
-
$pt_cv_admin_js.preview('<?php echo balanceTags( wp_create_nonce(
|
367 |
|
368 |
// Custom js
|
369 |
$pt_cv_admin_js.custom();
|
370 |
|
371 |
// Toggle Panel group of 'Advance Settings'
|
372 |
-
$pt_cv_admin_js.toggle_group('.' + _prefix + 'advanced-settings-item', group_prefix);
|
373 |
// Toggle Panel group of 'Terms' (in "Taxonomy Settings")
|
374 |
-
$pt_cv_admin_js.toggle_group('.' + _prefix + 'taxonomy-item', group_prefix);
|
375 |
// Toggle Panel group of 'Advanced Order by'
|
376 |
-
$pt_cv_admin_js.toggle_group('[name="' + _prefix + 'content-type' + '"]', group_prefix);
|
377 |
// Toggle Panel group of 'View type settings'
|
378 |
-
$pt_cv_admin_js.toggle_group('[name="' + _prefix + 'view-type' + '"]', group_prefix);
|
379 |
|
380 |
// Toggle dependence
|
381 |
-
$pt_cv_admin_js.dependence_do_all('<?php echo balanceTags( $toggle_data_js ); ?>');
|
382 |
|
383 |
$pt_cv_admin_js.multi_level_toggle();
|
384 |
-
});
|
385 |
-
}(jQuery));
|
386 |
</script>
|
387 |
-
|
388 |
}
|
389 |
|
390 |
}
|
10 |
* @link http://www.contentviewspro.com/
|
11 |
* @copyright 2014 PT Guy
|
12 |
*/
|
13 |
+
if ( !class_exists( 'PT_Options_Framework' ) ) {
|
|
|
14 |
|
15 |
class PT_Options_Framework {
|
16 |
|
17 |
private static $dependence_info; // Store dependency information of options
|
18 |
|
19 |
public function __construct() {
|
20 |
+
|
21 |
}
|
22 |
|
23 |
/**
|
29 |
* @return string|null
|
30 |
*/
|
31 |
public static function _dependence_check( $param, &$dependence_ ) {
|
32 |
+
if ( isset( $param[ 'dependence' ] ) ) {
|
33 |
// Depend array: 3 params in order : name (of param this param depends), value (of param this param depends), operator
|
34 |
+
$dependence = (array) $param[ 'dependence' ];
|
35 |
+
$random_id = PT_CV_PREFIX . 'dependence_' . PT_CV_Functions::string_random();
|
36 |
|
37 |
// Single dependency relationship
|
38 |
+
if ( !is_array( $dependence[ 0 ] ) ) {
|
39 |
self::_dependence_assign( $dependence, $random_id, $dependence_ );
|
40 |
} else {
|
41 |
// Multiple dependency relationships
|
57 |
* @param string $random_id Random string
|
58 |
* @param array $dependence_ Global dependence array
|
59 |
*/
|
60 |
+
public static function _dependence_assign( $dependence, $random_id,
|
61 |
+
&$dependence_ ) {
|
62 |
+
$dependence_[ $dependence[ 0 ] ][] = array( $random_id, $dependence[ 1 ], isset( $dependence[ 2 ] ) ? $dependence[ 2 ] : '=' );
|
63 |
}
|
64 |
|
65 |
/**
|
71 |
* @return string
|
72 |
*/
|
73 |
public static function do_settings( $options, $data = array() ) {
|
74 |
+
$result = $dependence_ = array();
|
75 |
+
if ( !$options ) {
|
76 |
return '';
|
77 |
}
|
78 |
|
96 |
* @return string
|
97 |
*/
|
98 |
public static function group( $group, $data, &$dependence_ ) {
|
99 |
+
if ( empty( $group[ 'label' ] ) && empty( $group[ 'params' ] ) ) {
|
100 |
return '';
|
101 |
}
|
102 |
|
103 |
+
$extra_setting = isset( $group[ 'extra_setting' ] ) ? $group[ 'extra_setting' ] : array();
|
104 |
+
$label = self::label( $group[ 'label' ], $extra_setting );
|
105 |
+
$params = self::params( $group[ 'params' ], $data, $extra_setting );
|
106 |
+
$random_id = self::_dependence_check( $group, $dependence_ );
|
107 |
+
$id = $class = '';
|
108 |
if ( $random_id ) {
|
109 |
+
$id = "id='$random_id'";
|
110 |
+
$class = 'hidden';
|
111 |
}
|
112 |
|
113 |
return "<div class='form-group pt-form-group $class' $id>$label $params</div>";
|
119 |
* @param string $label Text for label
|
120 |
*/
|
121 |
public static function label( $label = array(), $extra_setting = array() ) {
|
122 |
+
$for = isset( $label[ 'for' ] ) ? "for='{$label[ 'for' ]}'" : '';
|
123 |
+
$width = 12 - ( isset( $extra_setting[ 'params' ][ 'width' ] ) ? intval( $extra_setting[ 'params' ][ 'width' ] ) : 10 );
|
124 |
if ( $width ) {
|
125 |
+
$html = "<label $for class='col-md-$width control-label'>" . __( $label[ 'text' ], PT_CV_DOMAIN ) . '</label>';
|
126 |
} else {
|
127 |
$html = '';
|
128 |
}
|
140 |
foreach ( (array) $params as $param ) {
|
141 |
$params_html[] = self::field_type( (array) $param, $data ) . "\n";
|
142 |
}
|
143 |
+
$html = implode( '', $params_html );
|
144 |
+
$param_wrap_class = isset( $extra_setting[ 'params' ][ 'wrap-class' ] ) ? esc_attr( $extra_setting[ 'params' ][ 'wrap-class' ] ) : '';
|
145 |
+
$param_wrap_id = isset( $extra_setting[ 'params' ][ 'wrap-id' ] ) ? "id='" . esc_attr( $extra_setting[ 'params' ][ 'wrap-id' ] ) . "'" : '';
|
146 |
+
$width = isset( $extra_setting[ 'params' ][ 'width' ] ) ? intval( $extra_setting[ 'params' ][ 'width' ] ) : 10;
|
147 |
|
148 |
return "<div class='col-md-$width pt-params $param_wrap_class' $param_wrap_id>$html</div>";
|
149 |
}
|
162 |
|
163 |
// Get value of field
|
164 |
if ( $data ) {
|
165 |
+
$value = isset( $data[ $single_name ] ) ? $data[ $single_name ] : '';
|
166 |
} else {
|
167 |
+
$value = isset( $param[ 'std' ] ) ? $param[ 'std' ] : '';
|
168 |
}
|
169 |
|
170 |
return $value;
|
179 |
* @return string
|
180 |
*/
|
181 |
public static function field_type( $param, $data, $value_ = NULL ) {
|
182 |
+
if ( !$param || !isset( $param[ 'type' ] ) ) {
|
183 |
return '';
|
184 |
}
|
185 |
+
$html = $extend = '';
|
186 |
+
$class = 'form-control ' . ( isset( $param[ 'class' ] ) ? ' ' . PT_CV_PREFIX . $param[ 'class' ] : '' );
|
187 |
|
188 |
+
$type = esc_attr( $param[ 'type' ] );
|
189 |
+
$name = !empty( $param[ 'name' ] ) ? PT_CV_PREFIX . esc_attr( $param[ 'name' ] ) : '';
|
190 |
+
$id = !empty( $param[ 'id' ] ) ? "id='" . PT_CV_PREFIX . esc_attr( $param[ 'id' ] ) . "'" : '';
|
191 |
+
$value = isset( $value_ ) ? $value_ : self::field_value( $data, $param, $name );
|
192 |
+
$description = isset( $param[ 'desc' ] ) ? balanceTags( $param[ 'desc' ] ) : '';
|
193 |
|
194 |
// Add extra information of option type
|
195 |
switch ( $type ) {
|
196 |
case 'number':
|
197 |
+
$min = !empty( $param[ 'min' ] ) ? intval( $param[ 'min' ] ) : 0;
|
198 |
+
$extend = 'min="' . $min . '"';
|
199 |
break;
|
200 |
case 'color':
|
201 |
$class .= ' ' . PT_CV_PREFIX . 'color';
|
203 |
case 'checkbox':
|
204 |
case 'radio':
|
205 |
// Remove form-control class in checkbox, radio
|
206 |
+
$class = str_replace( 'form-control', '', $class );
|
207 |
break;
|
208 |
}
|
209 |
|
212 |
// Show HTML of option type
|
213 |
switch ( $type ) {
|
214 |
case 'group':
|
215 |
+
$html .= self::do_settings( $param[ 'params' ], $data );
|
216 |
break;
|
217 |
case 'text':
|
218 |
case 'email':
|
219 |
case 'password':
|
220 |
case 'number':
|
221 |
case 'url':
|
222 |
+
$placeholder = !empty( $param[ 'placeholder' ] ) ? $param[ 'placeholder' ] : '';
|
223 |
+
$append_text = !empty( $param[ 'append_text' ] ) ? $param[ 'append_text' ] : '';
|
224 |
|
225 |
$input = "<input type='$type' name='$name' value='$value' class='$class' $id $extend placeholder='$placeholder'>";
|
226 |
if ( empty( $append_text ) ) {
|
238 |
break;
|
239 |
case 'checkbox':
|
240 |
case 'radio':
|
241 |
+
if ( !isset( $param[ 'options' ] ) ) {
|
242 |
break;
|
243 |
}
|
244 |
|
245 |
+
$settings = isset( $param[ 'settings' ] ) ? $param[ 'settings' ] : array();
|
246 |
+
foreach ( $param[ 'options' ] as $key => $text ) {
|
247 |
// Append Html to $text, such as image...
|
248 |
if ( $settings ) {
|
249 |
+
$append = isset( $settings[ 'text-append' ] ) ? $settings[ 'text-append' ] : '';
|
250 |
if ( $append == 'image' ) {
|
251 |
+
$path = isset( $settings[ 'path' ] ) ? $settings[ 'path' ] : '';
|
252 |
if ( $path ) {
|
253 |
$text .= "<br> <img src='" . plugins_url( $path . "/$key.png", PT_CV_FILE ) . "' />";
|
254 |
}
|
261 |
|
262 |
break;
|
263 |
case 'select':
|
264 |
+
if ( !isset( $param[ 'options' ] ) ) {
|
265 |
break;
|
266 |
}
|
267 |
|
268 |
$options = '';
|
269 |
+
foreach ( $param[ 'options' ] as $key => $text ) {
|
270 |
+
$selected = ( in_array( $key, (array) $value ) || ( $value == 'all' ) ) ? 'selected' : '';
|
271 |
+
$option_class = isset( $param[ 'option_class_prefix' ] ) ? sprintf( "class='%s'", $param[ 'option_class_prefix' ] . esc_attr( sanitize_title( $key ) ) ) : '';
|
272 |
$options .= "<option value='$key' $selected $option_class>$text</option>";
|
273 |
}
|
274 |
if ( empty( $options ) ) {
|
275 |
$html .= "<div class='" . PT_CV_PREFIX . "text'>" . __( 'There is no option', PT_CV_DOMAIN ) . '</div>';
|
276 |
} else {
|
277 |
$multiple = '';
|
278 |
+
if ( ( isset( $param[ 'multiple' ] ) && $param[ 'multiple' ] == '1' ) || $value == 'all' ) {
|
279 |
$multiple = 'multiple';
|
280 |
// Auto add [] to name of select
|
281 |
$name .= substr( $name, - 2 ) == '[]' ? '' : '[]';
|
284 |
}
|
285 |
break;
|
286 |
case 'color_picker':
|
287 |
+
$html .= self::field_type( $param[ 'options' ], $data );
|
288 |
break;
|
289 |
case 'html':
|
290 |
+
if ( isset( $param[ 'content' ] ) ) {
|
291 |
+
$html .= $param[ 'content' ];
|
292 |
}
|
293 |
break;
|
294 |
case 'panel_group':
|
295 |
// In format: key => array of params
|
296 |
+
$parent_id = PT_CV_Functions::string_random( true );
|
297 |
+
$settings = isset( $param[ 'settings' ] ) ? $param[ 'settings' ] : array();
|
298 |
+
foreach ( $param[ 'params' ] as $key => $param_group ) {
|
299 |
$html .= self::sub_panel_group( $key, $param_group, $data, $parent_id, $settings );
|
300 |
}
|
301 |
break;
|
305 |
|
306 |
$description = apply_filters( PT_CV_PREFIX_ . 'options_description', $description, $param );
|
307 |
|
308 |
+
if ( !empty( $description ) ) {
|
309 |
$html .= "<p class='text-muted'>$description</p>";
|
310 |
}
|
311 |
|
323 |
*
|
324 |
* @return string
|
325 |
*/
|
326 |
+
static function sub_panel_group( $key, $param_group, $data, $parent_id,
|
327 |
+
$settings = array() ) {
|
328 |
|
329 |
// Content for body
|
330 |
$content = self::do_settings( $param_group, $data );
|
331 |
// Class for wrapper
|
332 |
+
$class = PT_CV_Html::html_group_class();
|
333 |
+
$class .= ( isset( $settings[ 'show_all' ] ) ? '' : ' hidden' );
|
334 |
+
$class .= ( isset( $settings[ 'show_only_one' ] ) ? ' ' . PT_CV_PREFIX . 'only-one' : '' );
|
335 |
+
$class .= ( isset( $settings[ 'no_panel' ] ) ? ' ' . PT_CV_PREFIX . 'no-panel' : '' );
|
336 |
+
$class .= ( isset( $settings[ 'no_animation' ] ) ? ' ' . PT_CV_PREFIX . 'no-animation' : '' );
|
337 |
// Id for wrapper
|
338 |
+
$id = PT_CV_Html::html_group_id( $key );
|
339 |
|
340 |
+
if ( !isset( $settings[ 'no_panel' ] ) ) {
|
341 |
// Heading text
|
342 |
+
$heading = ( isset( $settings[ 'nice_name' ] ) && isset( $settings[ 'nice_name' ][ $key ] ) ) ? $settings[ 'nice_name' ][ $key ] : PT_CV_Functions::string_slug_to_text( $key );
|
343 |
$heading = __( $heading, PT_CV_DOMAIN ) . ' ' . __( 'Settings', PT_CV_DOMAIN );
|
344 |
+
$html = PT_CV_Html::html_collapse_one( $parent_id, $id . '-child', $heading, $content, true );
|
345 |
} else {
|
346 |
$html = $content;
|
347 |
}
|
356 |
$toggle_data_js = json_encode( self::$dependence_info );
|
357 |
?>
|
358 |
<script>
|
359 |
+
( function ( $ ) {
|
360 |
"use strict";
|
361 |
|
362 |
+
$( function () {
|
363 |
var _prefix = '<?php echo esc_js( PT_CV_PREFIX ); ?>';
|
364 |
+
var $pt_cv_admin_js = new $.PT_CV_Admin( { _prefix: _prefix } );
|
365 |
var group_prefix = '<?php echo esc_js( PT_CV_Html::html_group_class() ); ?>' + '-';
|
366 |
|
367 |
// Preview actions
|
368 |
+
$pt_cv_admin_js.preview( '<?php echo balanceTags( wp_create_nonce( PT_CV_PREFIX_ . 'ajax_nonce' ) ); ?>' );
|
369 |
|
370 |
// Custom js
|
371 |
$pt_cv_admin_js.custom();
|
372 |
|
373 |
// Toggle Panel group of 'Advance Settings'
|
374 |
+
$pt_cv_admin_js.toggle_group( '.' + _prefix + 'advanced-settings-item', group_prefix );
|
375 |
// Toggle Panel group of 'Terms' (in "Taxonomy Settings")
|
376 |
+
$pt_cv_admin_js.toggle_group( '.' + _prefix + 'taxonomy-item', group_prefix );
|
377 |
// Toggle Panel group of 'Advanced Order by'
|
378 |
+
$pt_cv_admin_js.toggle_group( '[name="' + _prefix + 'content-type' + '"]', group_prefix );
|
379 |
// Toggle Panel group of 'View type settings'
|
380 |
+
$pt_cv_admin_js.toggle_group( '[name="' + _prefix + 'view-type' + '"]', group_prefix );
|
381 |
|
382 |
// Toggle dependence
|
383 |
+
$pt_cv_admin_js.dependence_do_all( '<?php echo balanceTags( $toggle_data_js ); ?>' );
|
384 |
|
385 |
$pt_cv_admin_js.multi_level_toggle();
|
386 |
+
} );
|
387 |
+
}( jQuery ) );
|
388 |
</script>
|
389 |
+
<?php
|
390 |
}
|
391 |
|
392 |
}
|
admin/includes/plugin.php
CHANGED
@@ -8,8 +8,7 @@
|
|
8 |
* @link http://www.contentviewspro.com/
|
9 |
* @copyright 2014 PT Guy
|
10 |
*/
|
11 |
-
|
12 |
-
if ( ! class_exists( 'PT_CV_Plugin' ) ) {
|
13 |
|
14 |
/**
|
15 |
* @name PT_CV_Plugin
|
@@ -64,7 +63,7 @@ if ( ! class_exists( 'PT_CV_Plugin' ) ) {
|
|
64 |
public static function settings_page_form() {
|
65 |
ob_start();
|
66 |
|
67 |
-
self::$options
|
68 |
?>
|
69 |
<form method="post" action="options.php">
|
70 |
<?php
|
@@ -75,7 +74,7 @@ if ( ! class_exists( 'PT_CV_Plugin' ) ) {
|
|
75 |
?>
|
76 |
</form>
|
77 |
<?php
|
78 |
-
$text
|
79 |
|
80 |
echo balanceTags( $text );
|
81 |
}
|
@@ -86,25 +85,25 @@ if ( ! class_exists( 'PT_CV_Plugin' ) ) {
|
|
86 |
public static function register_settings() {
|
87 |
|
88 |
register_setting(
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
);
|
93 |
|
94 |
// Common setting Section
|
95 |
$this_section = 'setting_frontend_assets';
|
96 |
add_settings_section(
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
);
|
102 |
|
103 |
// Define Common setting fields
|
104 |
$frontend_assets_fields = array(
|
105 |
array(
|
106 |
-
'id'
|
107 |
-
'title'
|
108 |
),
|
109 |
);
|
110 |
|
@@ -116,7 +115,7 @@ if ( ! class_exists( 'PT_CV_Plugin' ) ) {
|
|
116 |
|
117 |
// Register Common setting fields
|
118 |
foreach ( $frontend_assets_fields as $field ) {
|
119 |
-
$class = ( array_key_exists( $field['id'], $defined_in_class ) ) ? $defined_in_class[$field['id']] : __CLASS__;
|
120 |
self::field_register( $field, $this_section, $class );
|
121 |
}
|
122 |
|
@@ -132,7 +131,7 @@ if ( ! class_exists( 'PT_CV_Plugin' ) ) {
|
|
132 |
$new_input = array();
|
133 |
|
134 |
foreach ( $input as $key => $value ) {
|
135 |
-
$new_input[$key] = sanitize_text_field( $value );
|
136 |
}
|
137 |
|
138 |
return $new_input;
|
@@ -145,17 +144,18 @@ if ( ! class_exists( 'PT_CV_Plugin' ) ) {
|
|
145 |
* @param string $section Id of setting section
|
146 |
* @param string $class Class name to find the callback function
|
147 |
*/
|
148 |
-
public static function field_register( $field_info, $section,
|
149 |
-
|
|
|
150 |
return false;
|
151 |
}
|
152 |
|
153 |
add_settings_field(
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
);
|
160 |
}
|
161 |
|
@@ -166,10 +166,7 @@ if ( ! class_exists( 'PT_CV_Plugin' ) ) {
|
|
166 |
$field_name = 'unload_bootstrap';
|
167 |
|
168 |
self::_field_print(
|
169 |
-
|
170 |
-
'checkbox',
|
171 |
-
__( "Don't load <b>Bootstrap 3</b> style & script (in frontend of website)", PT_CV_DOMAIN ),
|
172 |
-
__( 'Only check this option if Bootstrap has been loaded by active theme or other plugins', PT_CV_DOMAIN )
|
173 |
);
|
174 |
}
|
175 |
|
@@ -181,14 +178,15 @@ if ( ! class_exists( 'PT_CV_Plugin' ) ) {
|
|
181 |
* @param string $text The label of field
|
182 |
* @param string $desc Description text
|
183 |
*/
|
184 |
-
static function _field_print( $field_name, $field_type = 'text', $text = '',
|
|
|
185 |
|
186 |
// Get Saved value
|
187 |
-
$field_value = isset( self::$options[$field_name] ) ? esc_attr( self::$options[$field_name] ) : '';
|
188 |
-
$checked
|
189 |
|
190 |
if ( in_array( $field_type, array( 'checkbox', 'radio' ) ) ) {
|
191 |
-
$checked
|
192 |
// Reassign value for this option
|
193 |
$field_value = 1;
|
194 |
}
|
@@ -196,17 +194,16 @@ if ( ! class_exists( 'PT_CV_Plugin' ) ) {
|
|
196 |
$field_id = esc_attr( $field_name );
|
197 |
|
198 |
printf(
|
199 |
-
|
200 |
-
esc_attr( $field_type ), $field_id, PT_CV_OPTION_NAME, $field_value, $checked
|
201 |
);
|
202 |
|
203 |
// For radio, checkbox field
|
204 |
-
if ( !
|
205 |
printf( '<label for="%s" class="label-for-option">%s</label>', $field_id, $text );
|
206 |
}
|
207 |
|
208 |
// Show description
|
209 |
-
if ( !
|
210 |
printf( '<p class="description">%s</p>', $desc );
|
211 |
}
|
212 |
}
|
@@ -217,6 +214,7 @@ if ( ! class_exists( 'PT_CV_Plugin' ) ) {
|
|
217 |
public static function section_callback_setting_frontend_assets() {
|
218 |
|
219 |
}
|
|
|
220 |
}
|
221 |
|
222 |
}
|
8 |
* @link http://www.contentviewspro.com/
|
9 |
* @copyright 2014 PT Guy
|
10 |
*/
|
11 |
+
if ( !class_exists( 'PT_CV_Plugin' ) ) {
|
|
|
12 |
|
13 |
/**
|
14 |
* @name PT_CV_Plugin
|
63 |
public static function settings_page_form() {
|
64 |
ob_start();
|
65 |
|
66 |
+
self::$options = get_option( PT_CV_OPTION_NAME );
|
67 |
?>
|
68 |
<form method="post" action="options.php">
|
69 |
<?php
|
74 |
?>
|
75 |
</form>
|
76 |
<?php
|
77 |
+
$text = ob_get_clean();
|
78 |
|
79 |
echo balanceTags( $text );
|
80 |
}
|
85 |
public static function register_settings() {
|
86 |
|
87 |
register_setting(
|
88 |
+
PT_CV_OPTION_NAME . '_group', // Option group
|
89 |
+
PT_CV_OPTION_NAME, // Option name
|
90 |
+
array( __CLASS__, 'field_sanitize' ) // Sanitize
|
91 |
);
|
92 |
|
93 |
// Common setting Section
|
94 |
$this_section = 'setting_frontend_assets';
|
95 |
add_settings_section(
|
96 |
+
$this_section, // ID
|
97 |
+
'', // Title
|
98 |
+
array( __CLASS__, 'section_callback_setting_frontend_assets' ), // Callback
|
99 |
+
PT_CV_DOMAIN // Page
|
100 |
);
|
101 |
|
102 |
// Define Common setting fields
|
103 |
$frontend_assets_fields = array(
|
104 |
array(
|
105 |
+
'id' => 'unload_bootstrap',
|
106 |
+
'title' => '<strong>' . __( 'Frontend assets', PT_CV_DOMAIN ) . '</strong>',
|
107 |
),
|
108 |
);
|
109 |
|
115 |
|
116 |
// Register Common setting fields
|
117 |
foreach ( $frontend_assets_fields as $field ) {
|
118 |
+
$class = ( array_key_exists( $field[ 'id' ], $defined_in_class ) ) ? $defined_in_class[ $field[ 'id' ] ] : __CLASS__;
|
119 |
self::field_register( $field, $this_section, $class );
|
120 |
}
|
121 |
|
131 |
$new_input = array();
|
132 |
|
133 |
foreach ( $input as $key => $value ) {
|
134 |
+
$new_input[ $key ] = sanitize_text_field( $value );
|
135 |
}
|
136 |
|
137 |
return $new_input;
|
144 |
* @param string $section Id of setting section
|
145 |
* @param string $class Class name to find the callback function
|
146 |
*/
|
147 |
+
public static function field_register( $field_info, $section,
|
148 |
+
$class = __CLASS__ ) {
|
149 |
+
if ( !$field_info ) {
|
150 |
return false;
|
151 |
}
|
152 |
|
153 |
add_settings_field(
|
154 |
+
$field_info[ 'id' ], // ID
|
155 |
+
$field_info[ 'title' ], // Title
|
156 |
+
array( $class, 'field_callback_' . $field_info[ 'id' ] ), // Callback
|
157 |
+
PT_CV_DOMAIN, // Page
|
158 |
+
$section // Section
|
159 |
);
|
160 |
}
|
161 |
|
166 |
$field_name = 'unload_bootstrap';
|
167 |
|
168 |
self::_field_print(
|
169 |
+
$field_name, 'checkbox', __( "Don't load <b>Bootstrap 3</b> style & script (in frontend of website)", PT_CV_DOMAIN ), __( 'Only check this option if Bootstrap has been loaded by active theme or other plugins', PT_CV_DOMAIN )
|
|
|
|
|
|
|
170 |
);
|
171 |
}
|
172 |
|
178 |
* @param string $text The label of field
|
179 |
* @param string $desc Description text
|
180 |
*/
|
181 |
+
static function _field_print( $field_name, $field_type = 'text', $text = '',
|
182 |
+
$desc = '' ) {
|
183 |
|
184 |
// Get Saved value
|
185 |
+
$field_value = isset( self::$options[ $field_name ] ) ? esc_attr( self::$options[ $field_name ] ) : '';
|
186 |
+
$checked = '';
|
187 |
|
188 |
if ( in_array( $field_type, array( 'checkbox', 'radio' ) ) ) {
|
189 |
+
$checked = checked( 1, $field_value, false );
|
190 |
// Reassign value for this option
|
191 |
$field_value = 1;
|
192 |
}
|
194 |
$field_id = esc_attr( $field_name );
|
195 |
|
196 |
printf(
|
197 |
+
'<input type="%1$s" id="%2$s" name="%3$s[%2$s]" value="%4$s" %5$s /> ', esc_attr( $field_type ), $field_id, PT_CV_OPTION_NAME, $field_value, $checked
|
|
|
198 |
);
|
199 |
|
200 |
// For radio, checkbox field
|
201 |
+
if ( !empty( $text ) ) {
|
202 |
printf( '<label for="%s" class="label-for-option">%s</label>', $field_id, $text );
|
203 |
}
|
204 |
|
205 |
// Show description
|
206 |
+
if ( !empty( $desc ) ) {
|
207 |
printf( '<p class="description">%s</p>', $desc );
|
208 |
}
|
209 |
}
|
214 |
public static function section_callback_setting_frontend_assets() {
|
215 |
|
216 |
}
|
217 |
+
|
218 |
}
|
219 |
|
220 |
}
|
admin/includes/templates/settings-section-two.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
#pt-cv-features {padding-right: 0; margin-bottom: 30px;}
|
3 |
#pt-cv-features * {font-size: 14px;}
|
4 |
#pt-cv-features h3 {font-size: 18px;}
|
5 |
-
#pt-cv-features .col-md-6 {padding: 0;}
|
6 |
</style>
|
7 |
|
8 |
<h3>⇒ <a style="font-size: 18px;" href="http://www.contentviewspro.com/docs/?utm_source=settings_page" target="_blank">Content Views Documentation</a></h3>
|
@@ -26,14 +26,14 @@
|
|
26 |
</ul>
|
27 |
</div>
|
28 |
</div>
|
29 |
-
|
30 |
<div class="col-md-6">
|
31 |
<h3>
|
32 |
Query custom post types
|
33 |
</h3>
|
34 |
<div>
|
35 |
<p>Content Views Pro allows you to query any custom post types.</p>
|
36 |
-
<p>And of course, It supports below well-known plugins:</p>
|
37 |
<ul style="list-style: circle; margin-left: 20px;">
|
38 |
<li>WooCommerce</li>
|
39 |
<li>Easy Digital Downloads</li>
|
@@ -41,7 +41,7 @@
|
|
41 |
</ul>
|
42 |
</div>
|
43 |
</div>
|
44 |
-
|
45 |
<h3>» <a style="font-size: 18px;" href="http://sample.contentviewspro.com/?utm_source=settings_page" target="_blank">See all features</a></h3>
|
46 |
<br>
|
47 |
</div>
|
2 |
#pt-cv-features {padding-right: 0; margin-bottom: 30px;}
|
3 |
#pt-cv-features * {font-size: 14px;}
|
4 |
#pt-cv-features h3 {font-size: 18px;}
|
5 |
+
#pt-cv-features .col-md-6 {padding: 0;}
|
6 |
</style>
|
7 |
|
8 |
<h3>⇒ <a style="font-size: 18px;" href="http://www.contentviewspro.com/docs/?utm_source=settings_page" target="_blank">Content Views Documentation</a></h3>
|
26 |
</ul>
|
27 |
</div>
|
28 |
</div>
|
29 |
+
|
30 |
<div class="col-md-6">
|
31 |
<h3>
|
32 |
Query custom post types
|
33 |
</h3>
|
34 |
<div>
|
35 |
<p>Content Views Pro allows you to query any custom post types.</p>
|
36 |
+
<p>And of course, It supports below well-known plugins:</p>
|
37 |
<ul style="list-style: circle; margin-left: 20px;">
|
38 |
<li>WooCommerce</li>
|
39 |
<li>Easy Digital Downloads</li>
|
41 |
</ul>
|
42 |
</div>
|
43 |
</div>
|
44 |
+
|
45 |
<h3>» <a style="font-size: 18px;" href="http://sample.contentviewspro.com/?utm_source=settings_page" target="_blank">See all features</a></h3>
|
46 |
<br>
|
47 |
</div>
|
admin/views/admin.php
CHANGED
@@ -8,7 +8,6 @@
|
|
8 |
* @link http://www.contentviewspro.com/
|
9 |
* @copyright 2014 PT Guy
|
10 |
*/
|
11 |
-
|
12 |
?>
|
13 |
|
14 |
<div class="wrap">
|
8 |
* @link http://www.contentviewspro.com/
|
9 |
* @copyright 2014 PT Guy
|
10 |
*/
|
|
|
11 |
?>
|
12 |
|
13 |
<div class="wrap">
|
admin/views/list.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* List all Content Views
|
4 |
*
|
@@ -8,7 +9,6 @@
|
|
8 |
* @link http://www.contentviewspro.com/
|
9 |
* @copyright 2014 PT Guy
|
10 |
*/
|
11 |
-
|
12 |
// Redirect to edit.php page of Content Views post type
|
13 |
wp_redirect( admin_url( 'edit.php?post_type=' . PT_CV_POST_TYPE ) );
|
14 |
-
exit;
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* List all Content Views
|
5 |
*
|
9 |
* @link http://www.contentviewspro.com/
|
10 |
* @copyright 2014 PT Guy
|
11 |
*/
|
|
|
12 |
// Redirect to edit.php page of Content Views post type
|
13 |
wp_redirect( admin_url( 'edit.php?post_type=' . PT_CV_POST_TYPE ) );
|
14 |
+
exit;
|
admin/views/view.php
CHANGED
@@ -8,7 +8,6 @@
|
|
8 |
* @link http://www.contentviewspro.com/
|
9 |
* @copyright 2014 PT Guy
|
10 |
*/
|
11 |
-
|
12 |
// Check if using Wordpress version 3.7 or higher
|
13 |
$version_gt_37 = PT_CV_Functions::wp_version_compare( '3.7' );
|
14 |
|
@@ -18,603 +17,571 @@ $settings = array();
|
|
18 |
$id = 0;
|
19 |
|
20 |
// Check if this is edit View page
|
21 |
-
if ( !
|
22 |
|
23 |
-
$id = esc_sql( $_GET['id'] );
|
24 |
|
25 |
if ( $id ) {
|
26 |
|
27 |
// Get View settings
|
28 |
global $pt_cv_admin_settings;
|
29 |
-
$pt_cv_admin_settings
|
30 |
}
|
31 |
}
|
32 |
|
33 |
// Submit handle
|
34 |
PT_CV_Functions::view_submit();
|
35 |
-
|
36 |
?>
|
37 |
|
38 |
<div class="wrap form-horizontal pt-wrap">
|
39 |
|
40 |
-
<h2><?php echo esc_html( $id ? __( 'Edit View', PT_CV_DOMAIN ) : get_admin_page_title()
|
41 |
|
42 |
-
<?php
|
43 |
-
if ( $id ) {
|
44 |
-
|
45 |
-
}
|
46 |
-
?>
|
47 |
|
48 |
-
<?php PT_CV_Functions::util_show_promo_view(); ?>
|
49 |
|
50 |
-
<div class="preview-wrapper">
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
|
|
64 |
),
|
65 |
),
|
66 |
-
)
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
</div>
|
71 |
|
72 |
-
<!-- Show Preview -->
|
73 |
-
<a class="btn btn-success" id="<?php echo esc_attr( PT_CV_PREFIX ); ?>show-preview"><?php _e( 'Show Preview', PT_CV_DOMAIN ); ?></a>
|
74 |
|
75 |
-
<br>
|
76 |
|
77 |
-
<!-- Settings form -->
|
78 |
-
<form action="" method="POST" id="<?php echo esc_attr( PT_CV_PREFIX . 'form-view' ); ?>">
|
79 |
|
80 |
-
<?php
|
81 |
// Add nonce field
|
82 |
-
wp_nonce_field( PT_CV_PREFIX_ . 'view_submit', PT_CV_PREFIX_ . 'form_nonce' );
|
83 |
|
84 |
// Get post ID of this View
|
85 |
-
$post_id
|
86 |
-
$view_object = $post_id ? get_post( $post_id ) : null;
|
87 |
-
?>
|
88 |
-
<!-- add hidden field -->
|
89 |
-
<input type="hidden" name="<?php echo esc_attr( PT_CV_PREFIX . 'post-id' ); ?>" value="<?php echo esc_attr( $post_id ); ?>" />
|
90 |
-
<input type="hidden" name="<?php echo esc_attr( PT_CV_PREFIX . 'view-id' ); ?>" value="<?php echo esc_attr( $id ); ?>" />
|
91 |
-
|
92 |
-
<?php
|
93 |
// View title
|
94 |
-
$options
|
95 |
-
array(
|
96 |
-
'label' => array(
|
97 |
-
'text' => __( 'View title', PT_CV_DOMAIN ),
|
98 |
-
),
|
99 |
-
'params' => array(
|
100 |
-
array(
|
101 |
-
'type' => 'text',
|
102 |
-
'name' => 'view-title',
|
103 |
-
'std' => isset( $view_object->post_title ) ? $view_object->post_title : '',
|
104 |
-
'desc' => __( 'Enter a name to identify your views easily', PT_CV_DOMAIN ),
|
105 |
-
),
|
106 |
-
),
|
107 |
-
),
|
108 |
-
);
|
109 |
-
echo balanceTags( PT_Options_Framework::do_settings( $options, $settings ) );
|
110 |
-
?>
|
111 |
-
<br>
|
112 |
-
|
113 |
-
<!-- Save -->
|
114 |
-
<input type="submit" class="btn btn-primary pull-right <?php echo esc_attr( PT_CV_PREFIX ); ?>save-view" value="<?php _e( 'Save', PT_CV_DOMAIN ); ?>">
|
115 |
-
|
116 |
-
<!-- Nav tabs -->
|
117 |
-
<ul class="nav nav-tabs">
|
118 |
-
<li class="active">
|
119 |
-
<a href="#<?php echo esc_attr( PT_CV_PREFIX ); ?>filter-settings" data-toggle="tab"><span class="glyphicon glyphicon-search"></span><?php _e( 'Filter Settings', PT_CV_DOMAIN ); ?>
|
120 |
-
</a>
|
121 |
-
</li>
|
122 |
-
<li>
|
123 |
-
<a href="#<?php echo esc_attr( PT_CV_PREFIX ); ?>display-settings" data-toggle="tab"><span class="glyphicon glyphicon-th-large"></span><?php _e( 'Display Settings', PT_CV_DOMAIN ); ?>
|
124 |
-
</a>
|
125 |
-
</li>
|
126 |
-
<?php do_action( PT_CV_PREFIX_ . 'setting_tabs_header', $settings ); ?>
|
127 |
-
</ul>
|
128 |
-
|
129 |
-
<!-- Tab panes -->
|
130 |
-
<div class="tab-content">
|
131 |
-
<!-- Filter Settings -->
|
132 |
-
<div class="tab-pane active" id="<?php echo esc_attr( PT_CV_PREFIX ); ?>filter-settings">
|
133 |
-
<?php
|
134 |
-
$options = array(
|
135 |
-
// Content type
|
136 |
-
array(
|
137 |
-
'label' => array(
|
138 |
-
'text' => __( 'Content type', PT_CV_DOMAIN ),
|
139 |
-
),
|
140 |
-
'params' => array(
|
141 |
array(
|
142 |
-
'
|
143 |
-
|
144 |
-
|
145 |
-
'std' => 'post',
|
146 |
-
),
|
147 |
-
),
|
148 |
-
),
|
149 |
-
|
150 |
-
// Upgrade to Pro
|
151 |
-
! get_option( 'pt_cv_version_pro' ) ? array(
|
152 |
-
'label' => array(
|
153 |
-
'text' => '',
|
154 |
-
),
|
155 |
-
'extra_setting' => array(
|
156 |
-
'params' => array(
|
157 |
-
'width' => 10,
|
158 |
-
),
|
159 |
-
),
|
160 |
-
'params' => array(
|
161 |
-
array(
|
162 |
-
'type' => 'html',
|
163 |
-
'content' => sprintf( '<p class="text-muted">→ %s</p>', __( 'Filter custom content type (or post type) ?', PT_CV_DOMAIN ) . sprintf( ' <a href="%s" target="_blank">%s</a>', esc_url( 'http://www.contentviewspro.com/pricing/?utm_source=client&utm_medium=view' ), __( 'Please upgrade to Pro', PT_CV_DOMAIN ) ) ),
|
164 |
-
),
|
165 |
-
),
|
166 |
-
) : '',
|
167 |
-
|
168 |
-
apply_filters( PT_CV_PREFIX_ . 'custom_filters', array() ),
|
169 |
-
|
170 |
-
// Common Filters
|
171 |
-
array(
|
172 |
-
'label' => array(
|
173 |
-
'text' => __( 'Common filters', PT_CV_DOMAIN ),
|
174 |
-
),
|
175 |
-
'extra_setting' => array(
|
176 |
-
'params' => array(
|
177 |
-
'wrap-class' => PT_CV_Html::html_group_class(),
|
178 |
-
),
|
179 |
-
),
|
180 |
-
'params' => array(
|
181 |
-
array(
|
182 |
-
'type' => 'group',
|
183 |
'params' => array(
|
184 |
-
|
185 |
-
apply_filters( PT_CV_PREFIX_ . 'sticky_posts_setting', array() ),
|
186 |
-
|
187 |
-
// Includes
|
188 |
array(
|
189 |
-
'
|
190 |
-
|
191 |
-
),
|
192 |
-
'
|
193 |
-
array(
|
194 |
-
'type' => 'text',
|
195 |
-
'name' => 'post__in',
|
196 |
-
'std' => '',
|
197 |
-
'desc' => __( 'List of post ids to retrieve (comma-separated values, e.g. 1,2,3)<br>A post is displayed only if its ID is equal to any of the values IN this list', PT_CV_DOMAIN ),
|
198 |
-
),
|
199 |
-
),
|
200 |
),
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
205 |
array(
|
206 |
-
'label'
|
207 |
-
'text' => __( '
|
208 |
),
|
209 |
'params' => array(
|
210 |
array(
|
211 |
-
'type'
|
212 |
-
'name'
|
213 |
-
'
|
214 |
-
'
|
215 |
),
|
216 |
),
|
217 |
),
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
array(
|
223 |
-
'label' => array(
|
224 |
-
'text' => __( 'Parent page', PT_CV_DOMAIN ),
|
225 |
),
|
226 |
-
'
|
227 |
-
array(
|
228 |
-
'
|
229 |
-
'name' => 'post_parent',
|
230 |
-
'std' => '',
|
231 |
-
'desc' => __( 'Enter ID of parent page to query child pages', PT_CV_DOMAIN ),
|
232 |
),
|
233 |
),
|
234 |
-
'
|
235 |
-
),
|
236 |
-
|
237 |
-
apply_filters( PT_CV_PREFIX_ . 'post_parent_settings', array() ),
|
238 |
-
|
239 |
-
// Limit
|
240 |
-
array(
|
241 |
-
'label' => array(
|
242 |
-
'text' => __( 'Limit', PT_CV_DOMAIN ),
|
243 |
-
),
|
244 |
-
'params' => array(
|
245 |
array(
|
246 |
-
'type'
|
247 |
-
'
|
248 |
-
'std' => '10',
|
249 |
-
'min' => '1',
|
250 |
-
'append_text' => '1 → 999',
|
251 |
-
'desc' => __( 'The number of posts to show. Set empty to show all found posts (which match all filter settings)', PT_CV_DOMAIN ),
|
252 |
),
|
253 |
),
|
254 |
-
),
|
255 |
-
|
256 |
-
|
257 |
-
),
|
258 |
-
),
|
259 |
-
),
|
260 |
-
), // End Common Filters
|
261 |
-
|
262 |
-
// Advanced Filters
|
263 |
-
array(
|
264 |
-
'label' => array(
|
265 |
-
'text' => __( 'Advanced filters', PT_CV_DOMAIN ),
|
266 |
-
),
|
267 |
-
'extra_setting' => array(
|
268 |
-
'params' => array(
|
269 |
-
'wrap-class' => PT_CV_Html::html_group_class(),
|
270 |
-
'wrap-id' => PT_CV_Html::html_group_id( 'advanced-params' ),
|
271 |
-
),
|
272 |
-
),
|
273 |
-
'params' => array(
|
274 |
-
array(
|
275 |
-
'type' => 'group',
|
276 |
-
'params' => array(
|
277 |
array(
|
278 |
-
'label'
|
279 |
-
'text' => '',
|
280 |
),
|
281 |
-
'extra_setting'
|
282 |
'params' => array(
|
283 |
-
'
|
284 |
),
|
285 |
),
|
286 |
-
'params'
|
287 |
-
array(
|
288 |
-
'type' => 'checkbox',
|
289 |
-
'name' => 'advanced-settings[]',
|
290 |
-
'options' => PT_CV_Values::advanced_settings(),
|
291 |
-
'std' => '',
|
292 |
-
'class' => 'advanced-settings-item',
|
293 |
-
),
|
294 |
-
),
|
295 |
-
),
|
296 |
-
),
|
297 |
-
),
|
298 |
-
),
|
299 |
-
), // End Advanced Filters
|
300 |
-
|
301 |
-
// Settings of Advanced Filters options
|
302 |
-
array(
|
303 |
-
'label' => array(
|
304 |
-
'text' => '',
|
305 |
-
),
|
306 |
-
'extra_setting' => array(
|
307 |
-
'params' => array(
|
308 |
-
'wrap-class' => PT_CV_Html::html_panel_group_class(),
|
309 |
-
'wrap-id' => PT_CV_Html::html_panel_group_id( PT_CV_Functions::string_random() ),
|
310 |
-
),
|
311 |
-
),
|
312 |
-
'params' => array(
|
313 |
-
array(
|
314 |
-
'type' => 'panel_group',
|
315 |
-
'params' => apply_filters( PT_CV_PREFIX_ . 'advanced_settings_panel',
|
316 |
-
array(
|
317 |
-
|
318 |
-
// Taxonomies Settings
|
319 |
-
'taxonomy' => array(
|
320 |
-
|
321 |
-
// Taxonomies list
|
322 |
array(
|
323 |
-
'
|
324 |
-
'text' => __( 'Taxonomies', PT_CV_DOMAIN ),
|
325 |
-
),
|
326 |
-
'extra_setting' => array(
|
327 |
-
'params' => array(
|
328 |
-
'wrap-class' => PT_CV_PREFIX . 'taxonomies',
|
329 |
-
),
|
330 |
-
),
|
331 |
'params' => array(
|
|
|
|
|
332 |
array(
|
333 |
-
'
|
334 |
-
|
335 |
-
|
336 |
-
'
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
array(
|
345 |
-
'label' => array(
|
346 |
-
'text' => __( 'Terms', PT_CV_DOMAIN ),
|
347 |
-
),
|
348 |
-
'extra_setting' => array(
|
349 |
-
'params' => array(
|
350 |
-
'wrap-class' => PT_CV_Html::html_panel_group_class() . ' terms',
|
351 |
-
'wrap-id' => PT_CV_Html::html_panel_group_id( PT_CV_Functions::string_random() ),
|
352 |
),
|
353 |
-
|
354 |
-
|
355 |
array(
|
356 |
-
'
|
357 |
-
|
358 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
359 |
),
|
360 |
-
'params' => PT_CV_Settings::terms_of_taxonomies(),
|
361 |
),
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
// Relation of taxonomies
|
366 |
-
array(
|
367 |
-
'label' => array(
|
368 |
-
'text' => __( 'Relation', PT_CV_DOMAIN ),
|
369 |
-
),
|
370 |
-
'params' => array(
|
371 |
array(
|
372 |
-
'
|
373 |
-
|
374 |
-
|
375 |
-
'
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
// Order by Settings
|
386 |
-
'order' => array(
|
387 |
-
array(
|
388 |
-
'label' => array(
|
389 |
-
'text' => __( 'Order by', PT_CV_DOMAIN ),
|
390 |
-
),
|
391 |
-
'extra_setting' => array(
|
392 |
-
'params' => array(
|
393 |
-
'width' => 12,
|
394 |
),
|
395 |
-
|
396 |
-
|
397 |
array(
|
398 |
-
'
|
399 |
-
|
400 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
401 |
),
|
402 |
-
'params' => PT_CV_Settings::orderby(),
|
403 |
),
|
|
|
404 |
),
|
405 |
),
|
406 |
-
),
|
407 |
-
|
408 |
-
|
409 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
410 |
array(
|
411 |
-
'
|
412 |
-
'text' => __( 'Written by', PT_CV_DOMAIN ),
|
413 |
-
),
|
414 |
'params' => array(
|
415 |
array(
|
416 |
-
'
|
417 |
-
|
418 |
-
|
419 |
-
'
|
420 |
-
|
421 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
422 |
),
|
423 |
),
|
424 |
),
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
431 |
array(
|
432 |
-
'
|
433 |
-
|
434 |
-
|
435 |
-
'
|
436 |
-
|
437 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
438 |
),
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
459 |
),
|
460 |
),
|
461 |
-
),
|
462 |
-
|
463 |
-
|
464 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
465 |
array(
|
466 |
-
'
|
467 |
-
|
468 |
-
),
|
469 |
-
'
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
476 |
),
|
|
|
477 |
),
|
478 |
-
),
|
479 |
-
)
|
480 |
-
),
|
481 |
-
),
|
482 |
-
),
|
483 |
-
),
|
484 |
-
);
|
485 |
-
echo balanceTags( PT_Options_Framework::do_settings( $options, $settings ) );
|
486 |
-
?>
|
487 |
-
</div>
|
488 |
-
<!-- end Filter Settings -->
|
489 |
-
|
490 |
-
<!-- Display Settings -->
|
491 |
-
<div class="tab-pane" id="<?php echo esc_attr( PT_CV_PREFIX ); ?>display-settings">
|
492 |
-
<?php
|
493 |
-
$options = array(
|
494 |
-
|
495 |
-
// View Type
|
496 |
-
array(
|
497 |
-
'label' => array(
|
498 |
-
'text' => __( 'View type', PT_CV_DOMAIN ),
|
499 |
-
),
|
500 |
-
'params' => array(
|
501 |
-
array(
|
502 |
-
'type' => 'radio',
|
503 |
-
'name' => 'view-type',
|
504 |
-
'options' => PT_CV_Values::view_type(),
|
505 |
-
'std' => PT_CV_Functions::array_get_first_key( PT_CV_Values::view_type() ),
|
506 |
-
),
|
507 |
-
),
|
508 |
-
),
|
509 |
-
|
510 |
-
// View settings
|
511 |
-
array(
|
512 |
-
'label' => array(
|
513 |
-
'text' => __( 'View type settings', PT_CV_DOMAIN ),
|
514 |
-
),
|
515 |
-
'params' => array(
|
516 |
-
array(
|
517 |
-
'type' => 'panel_group',
|
518 |
-
'settings' => array(
|
519 |
-
'no_panel' => 1,
|
520 |
-
'no_animation' => 1,
|
521 |
-
'show_only_one' => 1,
|
522 |
),
|
523 |
-
'
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
)
|
592 |
-
),
|
593 |
-
'params' => array(
|
594 |
-
array(
|
595 |
-
'type' => 'group',
|
596 |
-
'params' => PT_CV_Settings::settings_other(),
|
597 |
-
),
|
598 |
-
),
|
599 |
-
),
|
600 |
-
|
601 |
-
);
|
602 |
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
</div>
|
607 |
-
<!-- end Display Settings -->
|
608 |
|
609 |
-
<?php
|
610 |
-
do_action( PT_CV_PREFIX_ . 'setting_tabs_content', $settings );
|
611 |
-
?>
|
612 |
|
613 |
-
</div>
|
614 |
|
615 |
-
<div class="clearfix"></div>
|
616 |
-
<hr>
|
617 |
-
<!-- Save -->
|
618 |
-
<input type="submit" class="btn btn-primary pull-right <?php echo esc_attr( PT_CV_PREFIX ); ?>save-view" value="<?php _e( 'Save', PT_CV_DOMAIN ); ?>">
|
619 |
-
</form>
|
620 |
</div>
|
8 |
* @link http://www.contentviewspro.com/
|
9 |
* @copyright 2014 PT Guy
|
10 |
*/
|
|
|
11 |
// Check if using Wordpress version 3.7 or higher
|
12 |
$version_gt_37 = PT_CV_Functions::wp_version_compare( '3.7' );
|
13 |
|
17 |
$id = 0;
|
18 |
|
19 |
// Check if this is edit View page
|
20 |
+
if ( !empty( $_GET[ 'id' ] ) ) {
|
21 |
|
22 |
+
$id = esc_sql( $_GET[ 'id' ] );
|
23 |
|
24 |
if ( $id ) {
|
25 |
|
26 |
// Get View settings
|
27 |
global $pt_cv_admin_settings;
|
28 |
+
$pt_cv_admin_settings = $settings = PT_CV_Functions::view_get_settings( $id );
|
29 |
}
|
30 |
}
|
31 |
|
32 |
// Submit handle
|
33 |
PT_CV_Functions::view_submit();
|
|
|
34 |
?>
|
35 |
|
36 |
<div class="wrap form-horizontal pt-wrap">
|
37 |
|
38 |
+
<h2><?php echo esc_html( $id ? __( 'Edit View', PT_CV_DOMAIN ) : get_admin_page_title() ); ?></h2>
|
39 |
|
40 |
+
<?php
|
41 |
+
if ( $id ) {
|
42 |
+
echo balanceTags( sprintf( '<div><input id="view-shortcode" type="text" value="[pt_view id="%s"]" onclick="this.select()" readonly="" class="form-control">%s</div><div class="clear"></div>', $id, apply_filters( PT_CV_PREFIX_ . 'view_actions', '', $id ) ) );
|
43 |
+
}
|
44 |
+
?>
|
45 |
|
46 |
+
<?php PT_CV_Functions::util_show_promo_view(); ?>
|
47 |
|
48 |
+
<div class="preview-wrapper">
|
49 |
+
<?php
|
50 |
+
// Preview
|
51 |
+
$options = array(
|
52 |
+
array(
|
53 |
+
'label' => array(
|
54 |
+
'text' => __( 'Preview', PT_CV_DOMAIN ),
|
55 |
+
),
|
56 |
+
'params' => array(
|
57 |
+
array(
|
58 |
+
'type' => 'html',
|
59 |
+
'name' => 'preview',
|
60 |
+
'content' => PT_CV_Html::html_preview_box(),
|
61 |
+
'desc' => __( 'Click "Show Preview" or "Update Preview" button to show, "Hide Preview" button to hide the output', PT_CV_DOMAIN ),
|
62 |
+
),
|
63 |
),
|
64 |
),
|
65 |
+
);
|
66 |
+
echo balanceTags( PT_Options_Framework::do_settings( $options, $settings ) );
|
67 |
+
?>
|
68 |
+
</div>
|
|
|
69 |
|
70 |
+
<!-- Show Preview -->
|
71 |
+
<a class="btn btn-success" id="<?php echo esc_attr( PT_CV_PREFIX ); ?>show-preview"><?php _e( 'Show Preview', PT_CV_DOMAIN ); ?></a>
|
72 |
|
73 |
+
<br>
|
74 |
|
75 |
+
<!-- Settings form -->
|
76 |
+
<form action="" method="POST" id="<?php echo esc_attr( PT_CV_PREFIX . 'form-view' ); ?>">
|
77 |
|
78 |
+
<?php
|
79 |
// Add nonce field
|
80 |
+
wp_nonce_field( PT_CV_PREFIX_ . 'view_submit', PT_CV_PREFIX_ . 'form_nonce' );
|
81 |
|
82 |
// Get post ID of this View
|
83 |
+
$post_id = PT_CV_Functions::post_id_from_meta_id( $id );
|
84 |
+
$view_object = $post_id ? get_post( $post_id ) : null;
|
85 |
+
?>
|
86 |
+
<!-- add hidden field -->
|
87 |
+
<input type="hidden" name="<?php echo esc_attr( PT_CV_PREFIX . 'post-id' ); ?>" value="<?php echo esc_attr( $post_id ); ?>" />
|
88 |
+
<input type="hidden" name="<?php echo esc_attr( PT_CV_PREFIX . 'view-id' ); ?>" value="<?php echo esc_attr( $id ); ?>" />
|
89 |
+
|
90 |
+
<?php
|
91 |
// View title
|
92 |
+
$options = array(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
array(
|
94 |
+
'label' => array(
|
95 |
+
'text' => __( 'View title', PT_CV_DOMAIN ),
|
96 |
+
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
'params' => array(
|
|
|
|
|
|
|
|
|
98 |
array(
|
99 |
+
'type' => 'text',
|
100 |
+
'name' => 'view-title',
|
101 |
+
'std' => isset( $view_object->post_title ) ? $view_object->post_title : '',
|
102 |
+
'desc' => __( 'Enter a name to identify your views easily', PT_CV_DOMAIN ),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
),
|
104 |
+
),
|
105 |
+
),
|
106 |
+
);
|
107 |
+
echo balanceTags( PT_Options_Framework::do_settings( $options, $settings ) );
|
108 |
+
?>
|
109 |
+
<br>
|
110 |
+
|
111 |
+
<!-- Save -->
|
112 |
+
<input type="submit" class="btn btn-primary pull-right <?php echo esc_attr( PT_CV_PREFIX ); ?>save-view" value="<?php _e( 'Save', PT_CV_DOMAIN ); ?>">
|
113 |
+
<?php do_action( PT_CV_PREFIX_ . 'admin_more_buttons' ); ?>
|
114 |
+
|
115 |
+
<!-- Nav tabs -->
|
116 |
+
<ul class="nav nav-tabs">
|
117 |
+
<li class="active">
|
118 |
+
<a href="#<?php echo esc_attr( PT_CV_PREFIX ); ?>filter-settings" data-toggle="tab"><span class="glyphicon glyphicon-search"></span><?php _e( 'Filter Settings', PT_CV_DOMAIN ); ?>
|
119 |
+
</a>
|
120 |
+
</li>
|
121 |
+
<li>
|
122 |
+
<a href="#<?php echo esc_attr( PT_CV_PREFIX ); ?>display-settings" data-toggle="tab"><span class="glyphicon glyphicon-th-large"></span><?php _e( 'Display Settings', PT_CV_DOMAIN ); ?>
|
123 |
+
</a>
|
124 |
+
</li>
|
125 |
+
<?php do_action( PT_CV_PREFIX_ . 'setting_tabs_header', $settings ); ?>
|
126 |
+
</ul>
|
127 |
+
|
128 |
+
<!-- Tab panes -->
|
129 |
+
<div class="tab-content">
|
130 |
+
<!-- Filter Settings -->
|
131 |
+
<div class="tab-pane active" id="<?php echo esc_attr( PT_CV_PREFIX ); ?>filter-settings">
|
132 |
+
<?php
|
133 |
+
$options = array(
|
134 |
+
// Content type
|
135 |
array(
|
136 |
+
'label' => array(
|
137 |
+
'text' => __( 'Content type', PT_CV_DOMAIN ),
|
138 |
),
|
139 |
'params' => array(
|
140 |
array(
|
141 |
+
'type' => 'radio',
|
142 |
+
'name' => 'content-type',
|
143 |
+
'options' => PT_CV_Values::post_types(),
|
144 |
+
'std' => 'post',
|
145 |
),
|
146 |
),
|
147 |
),
|
148 |
+
// Upgrade to Pro
|
149 |
+
!get_option( 'pt_cv_version_pro' ) ? array(
|
150 |
+
'label' => array(
|
151 |
+
'text' => '',
|
|
|
|
|
|
|
152 |
),
|
153 |
+
'extra_setting' => array(
|
154 |
+
'params' => array(
|
155 |
+
'width' => 10,
|
|
|
|
|
|
|
156 |
),
|
157 |
),
|
158 |
+
'params' => array(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
159 |
array(
|
160 |
+
'type' => 'html',
|
161 |
+
'content' => sprintf( '<p class="text-muted">→ %s</p>', __( 'Filter custom content type (or post type) ?', PT_CV_DOMAIN ) . sprintf( ' <a href="%s" target="_blank">%s</a>', esc_url( 'http://www.contentviewspro.com/pricing/?utm_source=client&utm_medium=view' ), __( 'Please upgrade to Pro', PT_CV_DOMAIN ) ) ),
|
|
|
|
|
|
|
|
|
162 |
),
|
163 |
),
|
164 |
+
) : '',
|
165 |
+
apply_filters( PT_CV_PREFIX_ . 'custom_filters', array() ),
|
166 |
+
// Common Filters
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
array(
|
168 |
+
'label' => array(
|
169 |
+
'text' => __( 'Common filters', PT_CV_DOMAIN ),
|
170 |
),
|
171 |
+
'extra_setting' => array(
|
172 |
'params' => array(
|
173 |
+
'wrap-class' => PT_CV_Html::html_group_class(),
|
174 |
),
|
175 |
),
|
176 |
+
'params' => array(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
177 |
array(
|
178 |
+
'type' => 'group',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
179 |
'params' => array(
|
180 |
+
apply_filters( PT_CV_PREFIX_ . 'sticky_posts_setting', array() ),
|
181 |
+
// Includes
|
182 |
array(
|
183 |
+
'label' => array(
|
184 |
+
'text' => __( 'In list', PT_CV_DOMAIN ),
|
185 |
+
),
|
186 |
+
'params' => array(
|
187 |
+
array(
|
188 |
+
'type' => 'text',
|
189 |
+
'name' => 'post__in',
|
190 |
+
'std' => '',
|
191 |
+
'desc' => __( 'List of post ids to retrieve (comma-separated values, e.g. 1,2,3)<br>A post is displayed only if its ID is equal to any of the values IN this list', PT_CV_DOMAIN ),
|
192 |
+
),
|
193 |
+
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
194 |
),
|
195 |
+
apply_filters( PT_CV_PREFIX_ . 'include_extra_settings', array() ),
|
196 |
+
// Excludes
|
197 |
array(
|
198 |
+
'label' => array(
|
199 |
+
'text' => __( 'Excludes', PT_CV_DOMAIN ),
|
200 |
+
),
|
201 |
+
'params' => array(
|
202 |
+
array(
|
203 |
+
'type' => 'text',
|
204 |
+
'name' => 'post__not_in',
|
205 |
+
'std' => '',
|
206 |
+
'desc' => __( 'List of post ids to exclude (comma-separated values, e.g. 1,2,3)', PT_CV_DOMAIN ),
|
207 |
+
),
|
208 |
),
|
|
|
209 |
),
|
210 |
+
apply_filters( PT_CV_PREFIX_ . 'exclude_extra_settings', array() ),
|
211 |
+
// Parent page
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
212 |
array(
|
213 |
+
'label' => array(
|
214 |
+
'text' => __( 'Parent page', PT_CV_DOMAIN ),
|
215 |
+
),
|
216 |
+
'params' => array(
|
217 |
+
array(
|
218 |
+
'type' => 'number',
|
219 |
+
'name' => 'post_parent',
|
220 |
+
'std' => '',
|
221 |
+
'desc' => __( 'Enter ID of parent page to query child pages', PT_CV_DOMAIN ),
|
222 |
+
),
|
223 |
+
),
|
224 |
+
'dependence' => array( 'content-type', 'page' ),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
225 |
),
|
226 |
+
apply_filters( PT_CV_PREFIX_ . 'post_parent_settings', array() ),
|
227 |
+
// Limit
|
228 |
array(
|
229 |
+
'label' => array(
|
230 |
+
'text' => __( 'Limit', PT_CV_DOMAIN ),
|
231 |
+
),
|
232 |
+
'params' => array(
|
233 |
+
array(
|
234 |
+
'type' => 'number',
|
235 |
+
'name' => 'limit',
|
236 |
+
'std' => '10',
|
237 |
+
'min' => '1',
|
238 |
+
'append_text' => '1 → 999',
|
239 |
+
'desc' => __( 'The number of posts to show. Set empty to show all found posts (which match all filter settings)', PT_CV_DOMAIN ),
|
240 |
+
),
|
241 |
),
|
|
|
242 |
),
|
243 |
+
apply_filters( PT_CV_PREFIX_ . 'after_limit_option', array() ),
|
244 |
),
|
245 |
),
|
246 |
+
),
|
247 |
+
), // End Common Filters
|
248 |
+
// Advanced Filters
|
249 |
+
array(
|
250 |
+
'label' => array(
|
251 |
+
'text' => __( 'Advanced filters', PT_CV_DOMAIN ),
|
252 |
+
),
|
253 |
+
'extra_setting' => array(
|
254 |
+
'params' => array(
|
255 |
+
'wrap-class' => PT_CV_Html::html_group_class(),
|
256 |
+
'wrap-id' => PT_CV_Html::html_group_id( 'advanced-params' ),
|
257 |
+
),
|
258 |
+
),
|
259 |
+
'params' => array(
|
260 |
array(
|
261 |
+
'type' => 'group',
|
|
|
|
|
262 |
'params' => array(
|
263 |
array(
|
264 |
+
'label' => array(
|
265 |
+
'text' => '',
|
266 |
+
),
|
267 |
+
'extra_setting' => array(
|
268 |
+
'params' => array(
|
269 |
+
'width' => 12,
|
270 |
+
),
|
271 |
+
),
|
272 |
+
'params' => array(
|
273 |
+
array(
|
274 |
+
'type' => 'checkbox',
|
275 |
+
'name' => 'advanced-settings[]',
|
276 |
+
'options' => PT_CV_Values::advanced_settings(),
|
277 |
+
'std' => '',
|
278 |
+
'class' => 'advanced-settings-item',
|
279 |
+
),
|
280 |
+
),
|
281 |
),
|
282 |
),
|
283 |
),
|
284 |
+
),
|
285 |
+
), // End Advanced Filters
|
286 |
+
// Settings of Advanced Filters options
|
287 |
+
array(
|
288 |
+
'label' => array(
|
289 |
+
'text' => '',
|
290 |
+
),
|
291 |
+
'extra_setting' => array(
|
292 |
+
'params' => array(
|
293 |
+
'wrap-class' => PT_CV_Html::html_panel_group_class(),
|
294 |
+
'wrap-id' => PT_CV_Html::html_panel_group_id( PT_CV_Functions::string_random() ),
|
295 |
+
),
|
296 |
+
),
|
297 |
+
'params' => array(
|
298 |
+
array(
|
299 |
+
'type' => 'panel_group',
|
300 |
+
'params' => apply_filters( PT_CV_PREFIX_ . 'advanced_settings_panel', array(
|
301 |
+
// Taxonomies Settings
|
302 |
+
'taxonomy' => array(
|
303 |
+
// Taxonomies list
|
304 |
array(
|
305 |
+
'label' => array(
|
306 |
+
'text' => __( 'Taxonomies', PT_CV_DOMAIN ),
|
307 |
+
),
|
308 |
+
'extra_setting' => array(
|
309 |
+
'params' => array(
|
310 |
+
'wrap-class' => PT_CV_PREFIX . 'taxonomies',
|
311 |
+
),
|
312 |
+
),
|
313 |
+
'params' => array(
|
314 |
+
array(
|
315 |
+
'type' => 'checkbox',
|
316 |
+
'name' => 'taxonomy[]',
|
317 |
+
'options' => PT_CV_Values::taxonomy_list(),
|
318 |
+
'std' => '',
|
319 |
+
'class' => 'taxonomy-item',
|
320 |
+
'desc' => __( 'Check checkbox of taxonomies to filter posts by their terms', PT_CV_DOMAIN ),
|
321 |
+
),
|
322 |
+
),
|
323 |
),
|
324 |
+
// Terms list
|
325 |
+
array(
|
326 |
+
'label' => array(
|
327 |
+
'text' => __( 'Terms', PT_CV_DOMAIN ),
|
328 |
+
),
|
329 |
+
'extra_setting' => array(
|
330 |
+
'params' => array(
|
331 |
+
'wrap-class' => PT_CV_Html::html_panel_group_class() . ' terms',
|
332 |
+
'wrap-id' => PT_CV_Html::html_panel_group_id( PT_CV_Functions::string_random() ),
|
333 |
+
),
|
334 |
+
),
|
335 |
+
'params' => array(
|
336 |
+
array(
|
337 |
+
'type' => 'panel_group',
|
338 |
+
'settings' => array(
|
339 |
+
'nice_name' => PT_CV_Values::taxonomy_list(),
|
340 |
+
),
|
341 |
+
'params' => PT_CV_Settings::terms_of_taxonomies(),
|
342 |
+
),
|
343 |
+
),
|
344 |
+
),
|
345 |
+
// Relation of taxonomies
|
346 |
+
array(
|
347 |
+
'label' => array(
|
348 |
+
'text' => __( 'Relation', PT_CV_DOMAIN ),
|
349 |
+
),
|
350 |
+
'params' => array(
|
351 |
+
array(
|
352 |
+
'type' => 'select',
|
353 |
+
'name' => 'taxonomy-relation',
|
354 |
+
'options' => PT_CV_Values::taxonomy_relation(),
|
355 |
+
'std' => PT_CV_Functions::array_get_first_key( PT_CV_Values::taxonomy_relation() ),
|
356 |
+
'class' => 'taxonomy-relation',
|
357 |
+
'desc' => __( 'Select AND to show posts which match ALL settings of selected taxonomies<br>Select OR to show posts which match settings of at least one selected taxonomy', PT_CV_DOMAIN ),
|
358 |
+
),
|
359 |
+
),
|
360 |
+
),
|
361 |
+
apply_filters( PT_CV_PREFIX_ . 'taxonomies_custom_settings', array() ),
|
362 |
+
), // End Taxonomies Settings
|
363 |
+
// Order by Settings
|
364 |
+
'order' => array(
|
365 |
+
array(
|
366 |
+
'label' => array(
|
367 |
+
'text' => __( 'Order by', PT_CV_DOMAIN ),
|
368 |
+
),
|
369 |
+
'extra_setting' => array(
|
370 |
+
'params' => array(
|
371 |
+
'width' => 12,
|
372 |
+
),
|
373 |
+
),
|
374 |
+
'params' => array(
|
375 |
+
array(
|
376 |
+
'type' => 'panel_group',
|
377 |
+
'settings' => array(
|
378 |
+
'show_all' => 1,
|
379 |
+
),
|
380 |
+
'params' => PT_CV_Settings::orderby(),
|
381 |
+
),
|
382 |
+
),
|
383 |
+
),
|
384 |
+
), // End Order by Settings
|
385 |
+
// Author Settings
|
386 |
+
'author' => apply_filters( PT_CV_PREFIX_ . 'author_settings', array(
|
387 |
+
array(
|
388 |
+
'label' => array(
|
389 |
+
'text' => __( 'Written by', PT_CV_DOMAIN ),
|
390 |
+
),
|
391 |
+
'params' => array(
|
392 |
+
array(
|
393 |
+
'type' => 'select',
|
394 |
+
'name' => 'author__in[]',
|
395 |
+
'options' => PT_CV_Values::user_list(),
|
396 |
+
'std' => '',
|
397 |
+
'class' => 'select2',
|
398 |
+
'multiple' => $version_gt_37 ? '1' : '0',
|
399 |
+
),
|
400 |
+
),
|
401 |
+
),
|
402 |
+
$version_gt_37 ?
|
403 |
+
array(
|
404 |
+
'label' => array(
|
405 |
+
'text' => __( 'Not written by', PT_CV_DOMAIN ),
|
406 |
+
),
|
407 |
+
'params' => array(
|
408 |
+
array(
|
409 |
+
'type' => 'select',
|
410 |
+
'name' => 'author__not_in[]',
|
411 |
+
'options' => PT_CV_Values::user_list(),
|
412 |
+
'std' => '',
|
413 |
+
'class' => 'select2',
|
414 |
+
'multiple' => $version_gt_37 ? '1' : '0',
|
415 |
+
),
|
416 |
+
),
|
417 |
+
) : array(),
|
418 |
+
) ), // End Author Settings
|
419 |
+
// Status Settings
|
420 |
+
'status' => array(
|
421 |
+
array(
|
422 |
+
'label' => array(
|
423 |
+
'text' => __( 'Status', PT_CV_DOMAIN ),
|
424 |
+
),
|
425 |
+
'params' => array(
|
426 |
+
array(
|
427 |
+
'type' => 'select',
|
428 |
+
'name' => 'post_status',
|
429 |
+
'options' => PT_CV_Values::post_statuses(),
|
430 |
+
'std' => 'publish',
|
431 |
+
'class' => 'select2',
|
432 |
+
'multiple' => '1',
|
433 |
+
'desc' => __( 'Select status of posts', PT_CV_DOMAIN ),
|
434 |
+
),
|
435 |
+
),
|
436 |
+
),
|
437 |
+
), // End Status Settings
|
438 |
+
// Keyword Settings
|
439 |
+
'search' => array(
|
440 |
+
array(
|
441 |
+
'label' => array(
|
442 |
+
'text' => __( 'Keyword', PT_CV_DOMAIN ),
|
443 |
+
),
|
444 |
+
'params' => array(
|
445 |
+
array(
|
446 |
+
'type' => 'text',
|
447 |
+
'name' => 's',
|
448 |
+
'std' => '',
|
449 |
+
'desc' => __( 'Enter the keyword to searching for posts', PT_CV_DOMAIN ) . apply_filters( PT_CV_PREFIX_ . 'searchby_keyword_desc', '' ),
|
450 |
+
),
|
451 |
+
),
|
452 |
+
),
|
453 |
+
), // End Keyword Settings
|
454 |
+
)
|
455 |
),
|
456 |
),
|
457 |
+
),
|
458 |
+
),
|
459 |
+
);
|
460 |
+
echo balanceTags( PT_Options_Framework::do_settings( $options, $settings ) );
|
461 |
+
?>
|
462 |
+
</div>
|
463 |
+
<!-- end Filter Settings -->
|
464 |
+
|
465 |
+
<!-- Display Settings -->
|
466 |
+
<div class="tab-pane" id="<?php echo esc_attr( PT_CV_PREFIX ); ?>display-settings">
|
467 |
+
<?php
|
468 |
+
$options = array(
|
469 |
+
// View Type
|
470 |
+
array(
|
471 |
+
'label' => array(
|
472 |
+
'text' => __( 'View type', PT_CV_DOMAIN ),
|
473 |
+
),
|
474 |
+
'params' => array(
|
475 |
array(
|
476 |
+
'type' => 'radio',
|
477 |
+
'name' => 'view-type',
|
478 |
+
'options' => PT_CV_Values::view_type(),
|
479 |
+
'std' => PT_CV_Functions::array_get_first_key( PT_CV_Values::view_type() ),
|
480 |
+
),
|
481 |
+
),
|
482 |
+
),
|
483 |
+
// View settings
|
484 |
+
array(
|
485 |
+
'label' => array(
|
486 |
+
'text' => __( 'View type settings', PT_CV_DOMAIN ),
|
487 |
+
),
|
488 |
+
'params' => array(
|
489 |
+
array(
|
490 |
+
'type' => 'panel_group',
|
491 |
+
'settings' => array(
|
492 |
+
'no_panel' => 1,
|
493 |
+
'no_animation' => 1,
|
494 |
+
'show_only_one' => 1,
|
495 |
),
|
496 |
+
'params' => PT_CV_Values::view_type_settings(),
|
497 |
),
|
498 |
+
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
499 |
),
|
500 |
+
apply_filters( PT_CV_PREFIX_ . 'responsive_settings', array() ),
|
501 |
+
// Layout format of output item
|
502 |
+
array(
|
503 |
+
'label' => array(
|
504 |
+
'text' => __( 'Layout format', PT_CV_DOMAIN ),
|
505 |
+
),
|
506 |
+
'params' => array(
|
507 |
+
array(
|
508 |
+
'type' => 'radio',
|
509 |
+
'name' => 'layout-format',
|
510 |
+
'options' => PT_CV_Values::layout_format(),
|
511 |
+
'std' => PT_CV_Functions::array_get_first_key( PT_CV_Values::layout_format() ),
|
512 |
+
'desc' => __( 'This is layout format of output for each post', PT_CV_DOMAIN ),
|
513 |
+
),
|
514 |
+
),
|
515 |
+
),
|
516 |
+
// Fields settings
|
517 |
+
array(
|
518 |
+
'label' => array(
|
519 |
+
'text' => __( 'Fields settings', PT_CV_DOMAIN ),
|
520 |
+
),
|
521 |
+
'extra_setting' => array(
|
522 |
+
'params' => array(
|
523 |
+
'wrap-class' => PT_CV_Html::html_group_class(),
|
524 |
+
'wrap-id' => PT_CV_Html::html_group_id( 'field-settings' ),
|
525 |
+
),
|
526 |
+
),
|
527 |
+
'params' => array(
|
528 |
+
array(
|
529 |
+
'type' => 'group',
|
530 |
+
'params' => PT_CV_Settings::field_settings(),
|
531 |
+
),
|
532 |
+
),
|
533 |
+
),
|
534 |
+
// Pagination settings
|
535 |
+
array(
|
536 |
+
'label' => array(
|
537 |
+
'text' => __( 'Pagination settings', PT_CV_DOMAIN ),
|
538 |
+
),
|
539 |
+
'extra_setting' => array(
|
540 |
+
'params' => array(
|
541 |
+
'wrap-class' => PT_CV_Html::html_group_class(),
|
542 |
+
),
|
543 |
+
),
|
544 |
+
'params' => array(
|
545 |
+
array(
|
546 |
+
'type' => 'group',
|
547 |
+
'params' => PT_CV_Settings::settings_pagination(),
|
548 |
+
),
|
549 |
+
),
|
550 |
+
),
|
551 |
+
// Other settings
|
552 |
+
array(
|
553 |
+
'label' => array(
|
554 |
+
'text' => __( 'Other settings', PT_CV_DOMAIN ),
|
555 |
+
),
|
556 |
+
'extra_setting' => array(
|
557 |
+
'params' => array(
|
558 |
+
'wrap-class' => PT_CV_Html::html_group_class(),
|
559 |
+
),
|
560 |
+
),
|
561 |
+
'params' => array(
|
562 |
+
array(
|
563 |
+
'type' => 'group',
|
564 |
+
'params' => PT_CV_Settings::settings_other(),
|
565 |
+
),
|
566 |
+
),
|
567 |
+
),
|
568 |
+
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
569 |
|
570 |
+
$options = apply_filters( PT_CV_PREFIX_ . 'display_settings', $options );
|
571 |
+
echo balanceTags( PT_Options_Framework::do_settings( $options, $settings ) );
|
572 |
+
?>
|
573 |
+
</div>
|
574 |
+
<!-- end Display Settings -->
|
575 |
|
576 |
+
<?php
|
577 |
+
do_action( PT_CV_PREFIX_ . 'setting_tabs_content', $settings );
|
578 |
+
?>
|
579 |
|
580 |
+
</div>
|
581 |
|
582 |
+
<div class="clearfix"></div>
|
583 |
+
<hr>
|
584 |
+
<!-- Save -->
|
585 |
+
<input type="submit" class="btn btn-primary pull-right <?php echo esc_attr( PT_CV_PREFIX ); ?>save-view" value="<?php _e( 'Save', PT_CV_DOMAIN ); ?>">
|
586 |
+
</form>
|
587 |
</div>
|
content-views.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* @package PT_Content_Views
|
4 |
* @author PT Guy <palaceofthemes@gmail.com>
|
@@ -10,7 +11,7 @@
|
|
10 |
* Plugin Name: Content Views
|
11 |
* Plugin URI: http://wordpress.org/plugins/content-views-query-and-display-post-page/
|
12 |
* Description: Query and display <strong>posts, pages</strong> in awesome layouts (<strong>grid, scrollable list, collapsible list</strong>) easier than ever, without coding!
|
13 |
-
* Version: 1.5.
|
14 |
* Author: PT Guy
|
15 |
* Author URI: http://profiles.wordpress.org/pt-guy
|
16 |
* Text Domain: content-views
|
@@ -19,15 +20,14 @@
|
|
19 |
* Domain Path: /languages
|
20 |
* GitHub Plugin URI: https://github.com/<owner>/<repo>
|
21 |
*/
|
22 |
-
|
23 |
// If this file is called directly, abort.
|
24 |
-
if ( !
|
25 |
die;
|
26 |
}
|
27 |
/*
|
28 |
* Define Constant
|
29 |
*/
|
30 |
-
define( 'PT_CV_VERSION', '1.5.
|
31 |
define( 'PT_CV_FILE', __FILE__ );
|
32 |
$pt_cv_path = plugin_dir_path( __FILE__ );
|
33 |
include_once( $pt_cv_path . 'includes/defines.php' );
|
@@ -44,9 +44,9 @@ include_once( $pt_cv_path . 'includes/settings.php' );
|
|
44 |
include_once( $pt_cv_path . 'includes/update.php' );
|
45 |
include_once( $pt_cv_path . 'includes/values.php' );
|
46 |
|
47 |
-
|
48 |
* Public-Facing Functionality
|
49 |
-
|
50 |
|
51 |
/*
|
52 |
* the plugin's class file
|
@@ -62,9 +62,9 @@ register_deactivation_hook( __FILE__, array( 'PT_Content_Views', 'deactivate' )
|
|
62 |
|
63 |
add_action( 'plugins_loaded', array( 'PT_Content_Views', 'get_instance' ) );
|
64 |
|
65 |
-
|
66 |
* Dashboard and Administrative Functionality
|
67 |
-
|
68 |
|
69 |
/*
|
70 |
* the plugin's admin file
|
@@ -92,4 +92,4 @@ add_theme_support( 'post-thumbnails' );
|
|
92 |
add_filter( 'the_content', 'do_shortcode', 15 );
|
93 |
|
94 |
// Enable shortcodes in text widgets.
|
95 |
-
add_filter( 'widget_text', 'do_shortcode', 15 );
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* @package PT_Content_Views
|
5 |
* @author PT Guy <palaceofthemes@gmail.com>
|
11 |
* Plugin Name: Content Views
|
12 |
* Plugin URI: http://wordpress.org/plugins/content-views-query-and-display-post-page/
|
13 |
* Description: Query and display <strong>posts, pages</strong> in awesome layouts (<strong>grid, scrollable list, collapsible list</strong>) easier than ever, without coding!
|
14 |
+
* Version: 1.5.7
|
15 |
* Author: PT Guy
|
16 |
* Author URI: http://profiles.wordpress.org/pt-guy
|
17 |
* Text Domain: content-views
|
20 |
* Domain Path: /languages
|
21 |
* GitHub Plugin URI: https://github.com/<owner>/<repo>
|
22 |
*/
|
|
|
23 |
// If this file is called directly, abort.
|
24 |
+
if ( !defined( 'WPINC' ) ) {
|
25 |
die;
|
26 |
}
|
27 |
/*
|
28 |
* Define Constant
|
29 |
*/
|
30 |
+
define( 'PT_CV_VERSION', '1.5.7' );
|
31 |
define( 'PT_CV_FILE', __FILE__ );
|
32 |
$pt_cv_path = plugin_dir_path( __FILE__ );
|
33 |
include_once( $pt_cv_path . 'includes/defines.php' );
|
44 |
include_once( $pt_cv_path . 'includes/update.php' );
|
45 |
include_once( $pt_cv_path . 'includes/values.php' );
|
46 |
|
47 |
+
/* ----------------------------------------------------------------------------*
|
48 |
* Public-Facing Functionality
|
49 |
+
* ---------------------------------------------------------------------------- */
|
50 |
|
51 |
/*
|
52 |
* the plugin's class file
|
62 |
|
63 |
add_action( 'plugins_loaded', array( 'PT_Content_Views', 'get_instance' ) );
|
64 |
|
65 |
+
/* ----------------------------------------------------------------------------*
|
66 |
* Dashboard and Administrative Functionality
|
67 |
+
* ---------------------------------------------------------------------------- */
|
68 |
|
69 |
/*
|
70 |
* the plugin's admin file
|
92 |
add_filter( 'the_content', 'do_shortcode', 15 );
|
93 |
|
94 |
// Enable shortcodes in text widgets.
|
95 |
+
add_filter( 'widget_text', 'do_shortcode', 15 );
|
includes/assets.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Asset management
|
4 |
*
|
@@ -10,8 +11,7 @@
|
|
10 |
* @link http://www.contentviewspro.com/
|
11 |
* @copyright 2014 PT Guy
|
12 |
*/
|
13 |
-
|
14 |
-
if ( ! class_exists( 'PT_CV_Asset' ) ) {
|
15 |
|
16 |
/**
|
17 |
* @name PT_CV_Asset
|
@@ -20,26 +20,27 @@ if ( ! class_exists( 'PT_CV_Asset' ) ) {
|
|
20 |
class PT_CV_Asset {
|
21 |
|
22 |
// Prefix for handle of all assets
|
23 |
-
static $prefix
|
24 |
// Array of style & script
|
25 |
-
static $assets
|
|
|
26 |
/**
|
27 |
* version of assets
|
28 |
* if an asset doesn't have configed version, it will get plugin version as asset version
|
29 |
*/
|
30 |
static $version = array(
|
31 |
-
'bootstrap'
|
32 |
-
'bootstrap-paginator'
|
33 |
-
'select2'
|
34 |
-
'select2-bootstrap'
|
35 |
);
|
36 |
|
37 |
/**
|
38 |
* Register assets to enqueue later
|
39 |
*/
|
40 |
static function register() {
|
41 |
-
self::$assets['style']
|
42 |
-
self::$assets['script']
|
43 |
}
|
44 |
|
45 |
/**
|
@@ -53,8 +54,8 @@ if ( ! class_exists( 'PT_CV_Asset' ) ) {
|
|
53 |
static function enqueue( $name, $type = 'script', $data = '', $prefix = '' ) {
|
54 |
|
55 |
// If asset is registered, get handle information $data
|
56 |
-
if ( array_key_exists( $name, self::$assets[$type] ) ) {
|
57 |
-
$data = self::$assets[$type][$name];
|
58 |
}
|
59 |
|
60 |
// Do action
|
@@ -68,13 +69,13 @@ if ( ! class_exists( 'PT_CV_Asset' ) ) {
|
|
68 |
*/
|
69 |
static function style() {
|
70 |
return array(
|
71 |
-
'bootstrap'
|
72 |
'src' => plugins_url( 'assets/bootstrap/css/bootstrap.min.css', PT_CV_FILE ),
|
73 |
),
|
74 |
-
'select2'
|
75 |
'src' => plugins_url( 'assets/select2/select2.min.css', PT_CV_FILE ),
|
76 |
),
|
77 |
-
'select2-bootstrap'
|
78 |
'src' => plugins_url( 'assets/select2/select2-bootstrap.min.css', PT_CV_FILE ),
|
79 |
),
|
80 |
);
|
@@ -87,17 +88,17 @@ if ( ! class_exists( 'PT_CV_Asset' ) ) {
|
|
87 |
*/
|
88 |
static function script() {
|
89 |
return array(
|
90 |
-
'bootstrap'
|
91 |
-
'src'
|
92 |
-
'deps'
|
93 |
),
|
94 |
-
'bootstrap-paginator'
|
95 |
'src' => plugins_url( 'assets/bootstrap-paginator/bootstrap-paginator.min.js', PT_CV_FILE ),
|
96 |
-
|
97 |
),
|
98 |
-
'select2'
|
99 |
-
'src'
|
100 |
-
'deps'
|
101 |
),
|
102 |
);
|
103 |
}
|
@@ -112,12 +113,12 @@ if ( ! class_exists( 'PT_CV_Asset' ) ) {
|
|
112 |
*/
|
113 |
static function get_version( $name, $data ) {
|
114 |
|
115 |
-
if ( isset( $data['ver'] ) ) {
|
116 |
-
return $data['ver'];
|
117 |
}
|
118 |
|
119 |
if ( array_key_exists( $name, self::$version ) ) {
|
120 |
-
return self::$version[$name];
|
121 |
}
|
122 |
|
123 |
return PT_CV_Functions::plugin_info( PT_CV_FILE, 'Version' );
|
@@ -133,17 +134,17 @@ if ( ! class_exists( 'PT_CV_Asset' ) ) {
|
|
133 |
* @param string $prefix Prefix string for asset
|
134 |
*/
|
135 |
static function action( $name, $data, $type, $action, $prefix ) {
|
136 |
-
$prefix_ = !
|
137 |
-
$handle
|
138 |
-
$src
|
139 |
-
$deps
|
140 |
-
$ver
|
141 |
|
142 |
if ( $type == 'style' ) {
|
143 |
-
$last_param = isset( $data['media'] ) ? $data['media'] : 'all';
|
144 |
} else {
|
145 |
// Auto enqueue script in footer
|
146 |
-
$last_param = isset( $data['in_footer'] ) ? $data['in_footer'] : true;
|
147 |
}
|
148 |
$function = "wp_{$action}_{$type}";
|
149 |
if ( function_exists( $function ) ) {
|
@@ -159,10 +160,11 @@ if ( ! class_exists( 'PT_CV_Asset' ) ) {
|
|
159 |
* @param string $translation_array Array of translation strings
|
160 |
* @param string $prefix Prefix string for asset
|
161 |
*/
|
162 |
-
static function localize_script( $name, $object_name, $translation_array,
|
163 |
-
|
164 |
-
$
|
165 |
-
$
|
|
|
166 |
|
167 |
wp_localize_script( $handle, $object_name, $translation_array );
|
168 |
}
|
@@ -176,8 +178,8 @@ if ( ! class_exists( 'PT_CV_Asset' ) ) {
|
|
176 |
* @param string $prefix Prefix string for asset
|
177 |
*/
|
178 |
static function include_inline( $name, $src, $type, $prefix = '' ) {
|
179 |
-
$prefix_ = !
|
180 |
-
$handle
|
181 |
|
182 |
switch ( $type ) {
|
183 |
case 'js':
|
@@ -191,7 +193,8 @@ if ( ! class_exists( 'PT_CV_Asset' ) ) {
|
|
191 |
}
|
192 |
|
193 |
}
|
|
|
194 |
}
|
195 |
|
196 |
// Call to run
|
197 |
-
PT_CV_Asset::register();
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Asset management
|
5 |
*
|
11 |
* @link http://www.contentviewspro.com/
|
12 |
* @copyright 2014 PT Guy
|
13 |
*/
|
14 |
+
if ( !class_exists( 'PT_CV_Asset' ) ) {
|
|
|
15 |
|
16 |
/**
|
17 |
* @name PT_CV_Asset
|
20 |
class PT_CV_Asset {
|
21 |
|
22 |
// Prefix for handle of all assets
|
23 |
+
static $prefix = PT_CV_PREFIX;
|
24 |
// Array of style & script
|
25 |
+
static $assets = array();
|
26 |
+
|
27 |
/**
|
28 |
* version of assets
|
29 |
* if an asset doesn't have configed version, it will get plugin version as asset version
|
30 |
*/
|
31 |
static $version = array(
|
32 |
+
'bootstrap' => '3.3.0',
|
33 |
+
'bootstrap-paginator' => '0.5',
|
34 |
+
'select2' => '3.4.5',
|
35 |
+
'select2-bootstrap' => '3.4.5',
|
36 |
);
|
37 |
|
38 |
/**
|
39 |
* Register assets to enqueue later
|
40 |
*/
|
41 |
static function register() {
|
42 |
+
self::$assets[ 'style' ] = self::style();
|
43 |
+
self::$assets[ 'script' ] = self::script();
|
44 |
}
|
45 |
|
46 |
/**
|
54 |
static function enqueue( $name, $type = 'script', $data = '', $prefix = '' ) {
|
55 |
|
56 |
// If asset is registered, get handle information $data
|
57 |
+
if ( array_key_exists( $name, self::$assets[ $type ] ) ) {
|
58 |
+
$data = self::$assets[ $type ][ $name ];
|
59 |
}
|
60 |
|
61 |
// Do action
|
69 |
*/
|
70 |
static function style() {
|
71 |
return array(
|
72 |
+
'bootstrap' => array(
|
73 |
'src' => plugins_url( 'assets/bootstrap/css/bootstrap.min.css', PT_CV_FILE ),
|
74 |
),
|
75 |
+
'select2' => array(
|
76 |
'src' => plugins_url( 'assets/select2/select2.min.css', PT_CV_FILE ),
|
77 |
),
|
78 |
+
'select2-bootstrap' => array(
|
79 |
'src' => plugins_url( 'assets/select2/select2-bootstrap.min.css', PT_CV_FILE ),
|
80 |
),
|
81 |
);
|
88 |
*/
|
89 |
static function script() {
|
90 |
return array(
|
91 |
+
'bootstrap' => array(
|
92 |
+
'src' => plugins_url( 'assets/bootstrap/js/bootstrap.min.js', PT_CV_FILE ),
|
93 |
+
'deps' => array( 'jquery' ),
|
94 |
),
|
95 |
+
'bootstrap-paginator' => array(
|
96 |
'src' => plugins_url( 'assets/bootstrap-paginator/bootstrap-paginator.min.js', PT_CV_FILE ),
|
97 |
+
// 'deps' => array( PT_CV_PREFIX . 'bootstrap' . '-' . 'script' ),
|
98 |
),
|
99 |
+
'select2' => array(
|
100 |
+
'src' => plugins_url( 'assets/select2/select2.min.js', PT_CV_FILE ),
|
101 |
+
'deps' => array( 'jquery' ),
|
102 |
),
|
103 |
);
|
104 |
}
|
113 |
*/
|
114 |
static function get_version( $name, $data ) {
|
115 |
|
116 |
+
if ( isset( $data[ 'ver' ] ) ) {
|
117 |
+
return $data[ 'ver' ];
|
118 |
}
|
119 |
|
120 |
if ( array_key_exists( $name, self::$version ) ) {
|
121 |
+
return self::$version[ $name ];
|
122 |
}
|
123 |
|
124 |
return PT_CV_Functions::plugin_info( PT_CV_FILE, 'Version' );
|
134 |
* @param string $prefix Prefix string for asset
|
135 |
*/
|
136 |
static function action( $name, $data, $type, $action, $prefix ) {
|
137 |
+
$prefix_ = !empty( $prefix ) ? $prefix : self::$prefix;
|
138 |
+
$handle = $prefix_ . $name . '-' . $type;
|
139 |
+
$src = isset( $data[ 'src' ] ) ? $data[ 'src' ] : '';
|
140 |
+
$deps = isset( $data[ 'deps' ] ) ? $data[ 'deps' ] : '';
|
141 |
+
$ver = self::get_version( $name, $data );
|
142 |
|
143 |
if ( $type == 'style' ) {
|
144 |
+
$last_param = isset( $data[ 'media' ] ) ? $data[ 'media' ] : 'all';
|
145 |
} else {
|
146 |
// Auto enqueue script in footer
|
147 |
+
$last_param = isset( $data[ 'in_footer' ] ) ? $data[ 'in_footer' ] : true;
|
148 |
}
|
149 |
$function = "wp_{$action}_{$type}";
|
150 |
if ( function_exists( $function ) ) {
|
160 |
* @param string $translation_array Array of translation strings
|
161 |
* @param string $prefix Prefix string for asset
|
162 |
*/
|
163 |
+
static function localize_script( $name, $object_name, $translation_array,
|
164 |
+
$prefix = '' ) {
|
165 |
+
$type = 'script';
|
166 |
+
$prefix_ = !empty( $prefix ) ? $prefix : self::$prefix;
|
167 |
+
$handle = $prefix_ . $name . '-' . $type;
|
168 |
|
169 |
wp_localize_script( $handle, $object_name, $translation_array );
|
170 |
}
|
178 |
* @param string $prefix Prefix string for asset
|
179 |
*/
|
180 |
static function include_inline( $name, $src, $type, $prefix = '' ) {
|
181 |
+
$prefix_ = !empty( $prefix ) ? $prefix : self::$prefix;
|
182 |
+
$handle = $prefix_ . $name . '-' . $type;
|
183 |
|
184 |
switch ( $type ) {
|
185 |
case 'js':
|
193 |
}
|
194 |
|
195 |
}
|
196 |
+
|
197 |
}
|
198 |
|
199 |
// Call to run
|
200 |
+
PT_CV_Asset::register();
|
includes/defines.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Defines common constant
|
4 |
*
|
@@ -8,7 +9,6 @@
|
|
8 |
* @link http://www.contentviewspro.com/
|
9 |
* @copyright 2014 PT Guy
|
10 |
*/
|
11 |
-
|
12 |
define( 'PT_CV_DOMAIN', 'content-views' );
|
13 |
define( 'PT_CV_PREFIX', 'pt-cv-' );
|
14 |
define( 'PT_CV_PREFIX_', 'pt_cv_' );
|
@@ -33,4 +33,4 @@ define( 'PT_CV_PUBLIC_ASSETS', plugin_dir_path( PT_CV_FILE ) . 'public/assets/'
|
|
33 |
define( 'PT_CV_PUBLIC_ASSETS_URI', plugins_url( 'public/assets/', PT_CV_FILE ) );
|
34 |
|
35 |
// View type directory (HTML + CSS + JS)
|
36 |
-
define( 'PT_CV_VIEW_TYPE_OUTPUT', plugin_dir_path( PT_CV_FILE ) . 'public/templates/' );
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Defines common constant
|
5 |
*
|
9 |
* @link http://www.contentviewspro.com/
|
10 |
* @copyright 2014 PT Guy
|
11 |
*/
|
|
|
12 |
define( 'PT_CV_DOMAIN', 'content-views' );
|
13 |
define( 'PT_CV_PREFIX', 'pt-cv-' );
|
14 |
define( 'PT_CV_PREFIX_', 'pt_cv_' );
|
33 |
define( 'PT_CV_PUBLIC_ASSETS_URI', plugins_url( 'public/assets/', PT_CV_FILE ) );
|
34 |
|
35 |
// View type directory (HTML + CSS + JS)
|
36 |
+
define( 'PT_CV_VIEW_TYPE_OUTPUT', plugin_dir_path( PT_CV_FILE ) . 'public/templates/' );
|
includes/functions.php
CHANGED
@@ -8,11 +8,10 @@
|
|
8 |
* @link http://www.contentviewspro.com/
|
9 |
* @copyright 2014 PT Guy
|
10 |
*/
|
11 |
-
|
12 |
-
if ( ! function_exists( 'get_plugin_data' ) ) {
|
13 |
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
14 |
}
|
15 |
-
if ( !
|
16 |
|
17 |
/**
|
18 |
* @name PT_CV_Functions
|
@@ -60,8 +59,8 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
60 |
* @since 1.5.3
|
61 |
*/
|
62 |
global $q_config;
|
63 |
-
if ( $q_config && !
|
64 |
-
$language = $q_config['language'];
|
65 |
}
|
66 |
|
67 |
return $language;
|
@@ -74,8 +73,8 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
74 |
* @param string $language Current language
|
75 |
*/
|
76 |
static function switch_language( $language ) {
|
77 |
-
if(
|
78 |
-
return
|
79 |
|
80 |
// WPML
|
81 |
global $sitepress;
|
@@ -89,7 +88,7 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
89 |
*/
|
90 |
global $q_config;
|
91 |
if ( $q_config ) {
|
92 |
-
$q_config['language'] = $language;
|
93 |
}
|
94 |
}
|
95 |
|
@@ -104,7 +103,7 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
104 |
static function plugin_info( $file, $data = '' ) {
|
105 |
$plugin_data = get_plugin_data( $file );
|
106 |
|
107 |
-
return isset( $plugin_data[$data] ) ? $plugin_data[$data] : NULL;
|
108 |
}
|
109 |
|
110 |
/**
|
@@ -117,9 +116,10 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
117 |
* @param string $sub_page Slug of sub menu
|
118 |
* @param string $class Class name which contains function to output content of page created by this menu
|
119 |
*/
|
120 |
-
static function menu_add_sub( $parent_slug, $page_title, $menu_title,
|
|
|
121 |
return add_submenu_page(
|
122 |
-
|
123 |
);
|
124 |
}
|
125 |
|
@@ -218,7 +218,7 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
218 |
do_action( PT_CV_PREFIX_ . 'before_strip_shortcodes' );
|
219 |
|
220 |
// Strip all shortcodes
|
221 |
-
$text
|
222 |
|
223 |
// Recovery global $shortcode_tags
|
224 |
do_action( PT_CV_PREFIX_ . 'after_strip_shortcodes' );
|
@@ -227,11 +227,10 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
227 |
$result = self::pt_strip_tags( $text );
|
228 |
|
229 |
// Split words
|
230 |
-
$array
|
231 |
|
232 |
// Already short enough, return the whole thing
|
233 |
-
if ( count( $array ) > $num_words )
|
234 |
-
{
|
235 |
array_splice( $array, $num_words );
|
236 |
$result = implode( ' ', $array );
|
237 |
}
|
@@ -252,9 +251,9 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
252 |
# allow some tags
|
253 |
global $dargs;
|
254 |
# predefined allowable HTML tags
|
255 |
-
$allowable_tags
|
256 |
-
$allowed_tags
|
257 |
-
if ( !
|
258 |
$allowed_tags = implode( '', $allowable_tags );
|
259 |
|
260 |
// Changes double line-breaks in the text into HTML paragraphs (<p>, <br>)
|
@@ -263,7 +262,7 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
263 |
}
|
264 |
}
|
265 |
|
266 |
-
$string
|
267 |
|
268 |
return trim( $string );
|
269 |
}
|
@@ -276,7 +275,7 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
276 |
* @return array
|
277 |
*/
|
278 |
static function field_thumbnail_dimensions( $fargs ) {
|
279 |
-
$size = $fargs['size'];
|
280 |
|
281 |
return (array) explode( '×', str_replace( ' ', '', $size ) );
|
282 |
}
|
@@ -289,7 +288,7 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
289 |
* @param mixed|null $assign The value to assign if setting is not found
|
290 |
*/
|
291 |
static function setting_value( $field, $array_to_get, $assign = NULL ) {
|
292 |
-
return isset( $array_to_get[$field] ) ? $array_to_get[$field] : $assign;
|
293 |
}
|
294 |
|
295 |
/**
|
@@ -300,9 +299,10 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
300 |
* @param array $array_to_get Array to get values of wanted setting fields
|
301 |
* @param string $prefix Prefix string to looking for fields in $array_to_get
|
302 |
*/
|
303 |
-
static function settings_values( $fields, &$array_to_save, $array_to_get,
|
|
|
304 |
foreach ( $fields as $tsetting ) {
|
305 |
-
$array_to_save[$tsetting] = PT_CV_Functions::setting_value( $prefix . $tsetting, $array_to_get );
|
306 |
}
|
307 |
}
|
308 |
|
@@ -315,11 +315,11 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
315 |
static function settings_keys( $prefix, $options ) {
|
316 |
$result = array();
|
317 |
foreach ( $options as $option ) {
|
318 |
-
if ( isset( $option['params'] ) ) {
|
319 |
-
foreach ( $option['params'] as $params ) {
|
320 |
// If name of setting match with prefix string, got it name
|
321 |
-
if ( isset( $params['name'] ) && substr( $params['name'], 0, strlen( $prefix ) ) === $prefix ) {
|
322 |
-
$result[] = substr( $params['name'], strlen( $prefix ) );
|
323 |
}
|
324 |
}
|
325 |
}
|
@@ -337,7 +337,7 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
337 |
static function settings_values_by_prefix( $prefix, $backend = FALSE ) {
|
338 |
global $pt_view_settings;
|
339 |
|
340 |
-
if (
|
341 |
global $pt_cv_admin_settings;
|
342 |
$pt_view_settings = $pt_cv_admin_settings;
|
343 |
}
|
@@ -347,7 +347,7 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
347 |
foreach ( (array) $pt_view_settings as $name => $value ) {
|
348 |
// If name of setting match with prefix string, got it name
|
349 |
if ( substr( $name, 0, strlen( $prefix ) ) === $prefix ) {
|
350 |
-
$result[substr( $name, strlen( $prefix ) )] = $value;
|
351 |
}
|
352 |
}
|
353 |
|
@@ -381,16 +381,13 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
381 |
|
382 |
foreach ( $terms as $term ) {
|
383 |
$links[] = sprintf(
|
384 |
-
|
385 |
-
esc_url( get_term_link( $term, $term->taxonomy ) ),
|
386 |
-
__( 'View all posts in', PT_CV_DOMAIN ),
|
387 |
-
$term->name
|
388 |
);
|
389 |
|
390 |
-
if ( !
|
391 |
-
$pt_post_terms[$post_id] = array();
|
392 |
}
|
393 |
-
$pt_post_terms[$post_id][$term->slug] = $term->name;
|
394 |
}
|
395 |
|
396 |
return implode( ', ', $links );
|
@@ -402,9 +399,9 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
402 |
* @param string $post_id ID of post
|
403 |
*/
|
404 |
static function post_update_view_count( $post_id ) {
|
405 |
-
$meta_key
|
406 |
-
$count
|
407 |
-
if (
|
408 |
$count = 0;
|
409 |
}
|
410 |
$count ++;
|
@@ -417,9 +414,9 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
417 |
* @param string $post_id ID of post
|
418 |
*/
|
419 |
static function post_get_view_count( $post_id ) {
|
420 |
-
$meta_key
|
421 |
-
$count
|
422 |
-
if (
|
423 |
$count = 1;
|
424 |
}
|
425 |
|
@@ -432,16 +429,16 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
432 |
* @param string $arr Array of post data
|
433 |
*/
|
434 |
static function post_insert( $arr ) {
|
435 |
-
if (
|
436 |
return;
|
437 |
}
|
438 |
// Create post object
|
439 |
$my_post = array(
|
440 |
-
'ID'
|
441 |
-
'post_type'
|
442 |
-
'post_content'
|
443 |
-
'post_title'
|
444 |
-
'post_status'
|
445 |
);
|
446 |
|
447 |
// Insert the post into the database
|
@@ -458,18 +455,18 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
458 |
static function post_id_from_meta_id( $meta_id ) {
|
459 |
|
460 |
$post_id = 0;
|
461 |
-
if (
|
462 |
return $post_id;
|
463 |
}
|
464 |
|
465 |
// Query view which has view id = $meta_id
|
466 |
$pt_query = new WP_Query(
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
);
|
474 |
if ( $pt_query->have_posts() ) :
|
475 |
while ( $pt_query->have_posts() ):
|
@@ -503,7 +500,7 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
503 |
*/
|
504 |
static function _nonce_check( $nonce_name, $action_name ) {
|
505 |
$nonce_name = PT_CV_PREFIX_ . $nonce_name;
|
506 |
-
if ( !
|
507 |
print esc_html( __( 'Sorry, your nonce did not verify.', PT_CV_DOMAIN ) );
|
508 |
exit;
|
509 |
}
|
@@ -517,7 +514,7 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
517 |
* @return array
|
518 |
*/
|
519 |
static function view_get_settings( $meta_id ) {
|
520 |
-
if (
|
521 |
return;
|
522 |
}
|
523 |
|
@@ -544,20 +541,20 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
544 |
* @param type $view_settings
|
545 |
*/
|
546 |
static function view_backward_comp( &$view_settings ) {
|
547 |
-
if (
|
548 |
return $view_settings;
|
549 |
}
|
550 |
|
551 |
// Taxonomy In, Not in
|
552 |
-
$taxonomies = isset( $view_settings[PT_CV_PREFIX . 'taxonomy'] ) ? $view_settings[PT_CV_PREFIX . 'taxonomy'] : array();
|
553 |
if ( is_array( $taxonomies ) ) {
|
554 |
$list = array( '__in', '__not_in' );
|
555 |
foreach ( $taxonomies as $taxonomy ) {
|
556 |
// Check if IN/NOT IN list has values. NOT IN list will overwite IN list
|
557 |
foreach ( $list as $ltype ) {
|
558 |
-
if ( isset( $view_settings[PT_CV_PREFIX . $taxonomy . $ltype] ) ) {
|
559 |
-
$view_settings[PT_CV_PREFIX . $taxonomy . '-terms']
|
560 |
-
$view_settings[PT_CV_PREFIX . $taxonomy . '-operator'] = ( $ltype == '__in' ) ? 'IN' : 'NOT IN';
|
561 |
}
|
562 |
}
|
563 |
}
|
@@ -588,32 +585,32 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
588 |
global $processed_views, $pt_cv_shortcode_params;
|
589 |
// Same View but has different shortcode parameters => consider as 2 different Views
|
590 |
$vid = $id . '-' . md5( serialize( $pt_cv_shortcode_params ) );
|
591 |
-
if ( !
|
592 |
return '';
|
593 |
}
|
594 |
-
$processed_views[$vid] = 1;
|
595 |
|
596 |
// Escaped value appropriate for use in a SQL query
|
597 |
global $pt_view_settings;
|
598 |
|
599 |
$pt_view_settings = array();
|
600 |
foreach ( $settings as $key => $value ) {
|
601 |
-
$pt_view_settings[$key] = esc_sql( $value );
|
602 |
}
|
603 |
|
604 |
// Get content type
|
605 |
global $pt_content_type;
|
606 |
-
$pt_content_type = $content_type
|
607 |
-
$content_type
|
608 |
|
609 |
// Get view type
|
610 |
global $pt_view_type;
|
611 |
-
$pt_view_type
|
612 |
|
613 |
// Store display settings
|
614 |
global $dargs, $pt_query_args, $pt_view_sid;
|
615 |
|
616 |
-
$session_id = ( $pargs && isset( $pargs['session_id'] ) ) ? $pargs['session_id'] : 0;
|
617 |
|
618 |
// If is pagination request
|
619 |
if ( $session_id ) {
|
@@ -621,36 +618,34 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
621 |
$pt_view_sid = $session_id;
|
622 |
}
|
623 |
|
624 |
-
$session_data
|
625 |
-
|
626 |
-
( false === ( $saved_settings = get_transient( PT_CV_PREFIX . 'view-data-' . $session_id ) ) ) ? array() : $saved_settings
|
627 |
);
|
628 |
|
629 |
-
$args
|
630 |
-
$dargs
|
631 |
} else {
|
632 |
// If id is passed, assign it to session id, otherwise, generate random number
|
633 |
-
$pt_view_sid = $session_id
|
634 |
|
635 |
// Store settings
|
636 |
set_transient( PT_CV_PREFIX . 'view-settings-' . $session_id, $settings, 7 * DAY_IN_SECONDS );
|
637 |
}
|
638 |
|
639 |
if ( empty( $args ) || empty( $dargs ) ) {
|
640 |
-
$args
|
641 |
-
$dargs
|
642 |
|
643 |
// Filter
|
644 |
-
$dargs
|
645 |
-
$args
|
646 |
|
647 |
// Store view data
|
648 |
set_transient(
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
), 7 * DAY_IN_SECONDS
|
654 |
);
|
655 |
}
|
656 |
|
@@ -688,20 +683,20 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
688 |
/**
|
689 |
* Output Pagination
|
690 |
*/
|
691 |
-
$current_page
|
692 |
-
$html
|
693 |
|
694 |
// Append Pagination HTML if this is first page, or not Ajax calling
|
695 |
-
$type
|
696 |
-
if ( $pt_query && $args['posts_per_page'] > 0 && ( ( $type == 'ajax' && $current_page === 1 ) || $type == 'normal' ) ) {
|
697 |
// Total post founds
|
698 |
$found_posts = apply_filters( PT_CV_PREFIX_ . 'found_posts', $pt_query->found_posts );
|
699 |
|
700 |
// Total number of items
|
701 |
-
$total_items = ( $args['limit'] > 0 && $found_posts > $args['limit'] ) ? $args['limit'] : $found_posts;
|
702 |
|
703 |
// Total number of pages
|
704 |
-
$max_num_pages = ceil( $total_items / $args['posts_per_page'] );
|
705 |
|
706 |
// Output pagination
|
707 |
$html .= "\n" . PT_CV_Html::pagination_output( $max_num_pages, $current_page, $session_id );
|
@@ -738,7 +733,7 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
738 |
// Output HTML for this item
|
739 |
$post_id = apply_filters( PT_CV_PREFIX_ . 'show_this_post', $post->ID );
|
740 |
if ( $post_id ) {
|
741 |
-
$content_items[$post->ID] = PT_CV_Html::view_type_output( $view_type, $post );
|
742 |
}
|
743 |
}
|
744 |
} else {
|
@@ -775,30 +770,30 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
775 |
* Set default values
|
776 |
*/
|
777 |
$args = array(
|
778 |
-
'post_type'
|
779 |
-
'post_status'
|
780 |
-
'ignore_sticky_posts'
|
781 |
);
|
782 |
|
783 |
// Post in
|
784 |
if ( PT_CV_Functions::setting_value( PT_CV_PREFIX . 'post__in', $pt_view_settings ) ) {
|
785 |
-
$post_in
|
786 |
-
$args['post__in']
|
787 |
}
|
788 |
|
789 |
// Post not in
|
790 |
if ( PT_CV_Functions::setting_value( PT_CV_PREFIX . 'post__not_in', $pt_view_settings ) ) {
|
791 |
-
$post_not_in
|
792 |
-
$args['post__not_in']
|
793 |
}
|
794 |
|
795 |
-
$args['post__not_in'] = apply_filters( PT_CV_PREFIX_ . 'post__not_in', isset( $args['post__not_in'] ) ? $args['post__not_in'] : array(), $pt_view_settings );
|
796 |
|
797 |
// Parent page
|
798 |
if ( $content_type == 'page' ) {
|
799 |
$post_parent = apply_filters( PT_CV_PREFIX_ . 'post_parent_id', PT_CV_Functions::setting_value( PT_CV_PREFIX . 'post_parent', $pt_view_settings ) );
|
800 |
-
if ( !
|
801 |
-
$args['post_parent'] = (int) $post_parent;
|
802 |
}
|
803 |
}
|
804 |
|
@@ -821,7 +816,7 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
821 |
*/
|
822 |
$dargs = array();
|
823 |
|
824 |
-
$dargs['view-type'] = $view_type;
|
825 |
|
826 |
// Field settings of a item
|
827 |
PT_CV_Functions::view_get_display_settings( $dargs );
|
@@ -830,7 +825,7 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
830 |
PT_CV_Functions::view_get_other_settings( $dargs );
|
831 |
|
832 |
// View type settings
|
833 |
-
$dargs['view-type-settings'] = PT_CV_Functions::settings_values_by_prefix( PT_CV_PREFIX . $view_type . '-' );
|
834 |
|
835 |
return $dargs;
|
836 |
}
|
@@ -860,29 +855,29 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
860 |
$author_not_in = PT_CV_Functions::string_to_array( PT_CV_Functions::setting_value( PT_CV_PREFIX . 'author__not_in', $pt_view_settings ) );
|
861 |
|
862 |
// Author in
|
863 |
-
if ( !
|
864 |
$args = array_merge(
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
);
|
869 |
}
|
870 |
|
871 |
// Author not in
|
872 |
-
if ( !
|
873 |
$args = array_merge(
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
);
|
878 |
}
|
879 |
} else {
|
880 |
// Author = ID
|
881 |
-
if ( !
|
882 |
$args = array_merge(
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
);
|
887 |
}
|
888 |
}
|
@@ -892,9 +887,9 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
892 |
// Status
|
893 |
case 'status':
|
894 |
$args = array_merge(
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
);
|
899 |
break;
|
900 |
|
@@ -902,9 +897,9 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
902 |
case 'search':
|
903 |
if ( PT_CV_Functions::setting_value( PT_CV_PREFIX . 's', $pt_view_settings ) ) {
|
904 |
$args = array_merge(
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
);
|
909 |
}
|
910 |
break;
|
@@ -912,7 +907,7 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
912 |
// Taxonomy
|
913 |
case 'taxonomy':
|
914 |
// No taxonomy found
|
915 |
-
if ( !
|
916 |
break;
|
917 |
}
|
918 |
|
@@ -929,18 +924,18 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
929 |
$operator = PT_CV_Functions::setting_value( PT_CV_PREFIX . $taxonomy . '-operator', $pt_view_settings, 'IN' );
|
930 |
|
931 |
$taxonomy_setting[] = array(
|
932 |
-
'taxonomy'
|
933 |
-
'field'
|
934 |
-
'terms'
|
935 |
-
'operator'
|
936 |
-
'include_children'
|
937 |
);
|
938 |
}
|
939 |
}
|
940 |
|
941 |
// Get Taxonomy relation if there are more than 1 selected taxonomies | set In & Not in of a taxonomy
|
942 |
if ( count( $taxonomies ) > 1 || count( $taxonomy_setting ) > 1 ) {
|
943 |
-
$taxonomy_setting['relation'] = PT_CV_Functions::setting_value( PT_CV_PREFIX . 'taxonomy-relation', $pt_view_settings, 'AND' );
|
944 |
}
|
945 |
|
946 |
// Filter taxonomy with Custom post types
|
@@ -952,11 +947,10 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
952 |
// Order
|
953 |
case 'order':
|
954 |
$order_settings = apply_filters(
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
)
|
960 |
);
|
961 |
|
962 |
$args = array_merge( $args, $order_settings );
|
@@ -977,70 +971,70 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
977 |
static function view_get_display_settings( &$dargs ) {
|
978 |
global $pt_view_settings;
|
979 |
|
980 |
-
$view_type = $dargs['view-type'];
|
981 |
|
982 |
/**
|
983 |
* Layout format
|
984 |
*/
|
985 |
-
$dargs['layout-format'] = PT_CV_Functions::setting_value( PT_CV_PREFIX . 'layout-format', $pt_view_settings );
|
986 |
|
987 |
/**
|
988 |
* Columns count & Rows count
|
989 |
*/
|
990 |
-
$dargs['number-columns']
|
991 |
-
$dargs['number-rows']
|
992 |
|
993 |
/**
|
994 |
* Fields settings
|
995 |
*/
|
996 |
-
$cfields_settings
|
997 |
-
$cfields
|
998 |
foreach ( $cfields as $field ) {
|
999 |
// If show this field
|
1000 |
if ( PT_CV_Functions::setting_value( PT_CV_PREFIX . 'show-field-' . $field, $pt_view_settings ) ) {
|
1001 |
// Add this field to display fields list
|
1002 |
-
$dargs['fields'][] = $field;
|
1003 |
|
1004 |
// Get field settings
|
1005 |
switch ( $field ) {
|
1006 |
|
1007 |
// Get title settings
|
1008 |
case 'title':
|
1009 |
-
$prefix
|
1010 |
-
$field_setting
|
1011 |
|
1012 |
-
$dargs['field-settings'][$field] = apply_filters( PT_CV_PREFIX_ . 'field_title_setting_values', $field_setting, $prefix );
|
1013 |
|
1014 |
break;
|
1015 |
|
1016 |
// Get thumbnail settings
|
1017 |
case 'thumbnail':
|
1018 |
-
$prefix
|
1019 |
-
$field_setting
|
1020 |
|
1021 |
-
$dargs['field-settings'][$field] = apply_filters( PT_CV_PREFIX_ . 'field_thumbnail_setting_values', $field_setting, $prefix );
|
1022 |
|
1023 |
break;
|
1024 |
|
1025 |
// Get meta fields settings
|
1026 |
case 'meta-fields':
|
1027 |
-
$prefix
|
1028 |
-
$field_setting
|
1029 |
|
1030 |
-
$dargs['field-settings'][$field] = apply_filters( PT_CV_PREFIX_ . 'field_meta_fields_setting_values', $field_setting, $prefix );
|
1031 |
|
1032 |
break;
|
1033 |
|
1034 |
// Get content settings
|
1035 |
case 'content':
|
1036 |
-
$prefix
|
1037 |
-
$field_setting
|
1038 |
|
1039 |
-
if ( $field_setting['show'] == 'excerpt' ) {
|
1040 |
$field_setting = array_merge( $field_setting, PT_CV_Functions::settings_values_by_prefix( PT_CV_PREFIX . 'field-excerpt-' ) );
|
1041 |
}
|
1042 |
|
1043 |
-
$dargs['field-settings'][$field] = apply_filters( PT_CV_PREFIX_ . 'field_content_setting_values', $field_setting, $prefix );
|
1044 |
|
1045 |
break;
|
1046 |
|
@@ -1062,28 +1056,28 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
1062 |
global $pt_view_settings;
|
1063 |
|
1064 |
// Get Limit value
|
1065 |
-
$limit
|
1066 |
-
$limit
|
1067 |
-
$args['limit']
|
1068 |
-
$offset
|
1069 |
|
1070 |
// Get pagination enable/disable
|
1071 |
$pagination = PT_CV_Functions::setting_value( PT_CV_PREFIX . 'enable-pagination', $pt_view_settings );
|
1072 |
if ( $pagination ) {
|
1073 |
-
$prefix
|
1074 |
-
$field_setting
|
1075 |
|
1076 |
-
$dargs['pagination-settings'] = apply_filters( PT_CV_PREFIX_ . 'pagination_settings', $field_setting, $prefix );
|
1077 |
|
1078 |
// If Items per page is set, get its value
|
1079 |
-
$posts_per_page = isset( $dargs['pagination-settings']['items-per-page'] ) ? (int) $dargs['pagination-settings']['items-per-page'] : $limit;
|
1080 |
|
1081 |
if ( $posts_per_page > $limit ) {
|
1082 |
$posts_per_page = $limit;
|
1083 |
}
|
1084 |
|
1085 |
// Set 'posts_per_page' parameter
|
1086 |
-
$args['posts_per_page'] = $posts_per_page;
|
1087 |
|
1088 |
// Get offset
|
1089 |
$paged = self::get_current_page( $pargs );
|
@@ -1091,15 +1085,15 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
1091 |
$offset = $posts_per_page * ( (int) $paged - 1 );
|
1092 |
|
1093 |
// Update posts_per_page
|
1094 |
-
if ( intval( $args['posts_per_page'] ) > $limit - $offset ) {
|
1095 |
-
$args['posts_per_page'] = $limit - $offset;
|
1096 |
}
|
1097 |
}
|
1098 |
|
1099 |
$offset = apply_filters( PT_CV_PREFIX_ . 'settings_args_offset', $offset );
|
1100 |
|
1101 |
// Set 'offset' parameter
|
1102 |
-
$args['offset'] = $offset;
|
1103 |
}
|
1104 |
|
1105 |
/**
|
@@ -1108,10 +1102,10 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
1108 |
* @param array $dargs The settings array of Fields
|
1109 |
*/
|
1110 |
static function view_get_other_settings( &$dargs ) {
|
1111 |
-
$prefix
|
1112 |
-
$field_setting
|
1113 |
|
1114 |
-
$dargs['other-settings'] = apply_filters( PT_CV_PREFIX_ . 'other_settings', $field_setting );
|
1115 |
}
|
1116 |
|
1117 |
/**
|
@@ -1130,13 +1124,13 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
1130 |
* INSERT VIEW
|
1131 |
*/
|
1132 |
// View title
|
1133 |
-
$title = esc_sql( $_POST[PT_CV_PREFIX . 'view-title'] );
|
1134 |
|
1135 |
// Current post id ( 0 if new view )
|
1136 |
-
$cur_post_id = esc_sql( $_POST[PT_CV_PREFIX . 'post-id'] );
|
1137 |
|
1138 |
// Insert post
|
1139 |
-
if (
|
1140 |
$post_id = PT_CV_Functions::post_insert( array( 'ID' => $cur_post_id, 'title' => $title ) );
|
1141 |
} else {
|
1142 |
$post_id = $cur_post_id;
|
@@ -1146,8 +1140,8 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
1146 |
* ADD/UPDATE CUSTOM FIELDS
|
1147 |
*/
|
1148 |
// Get current view id, = 0 if it is new view
|
1149 |
-
$cur_view_id = esc_sql( $_POST[PT_CV_PREFIX . 'view-id'] );
|
1150 |
-
$view_id
|
1151 |
update_post_meta( $post_id, PT_CV_META_ID, $view_id );
|
1152 |
update_post_meta( $post_id, PT_CV_META_SETTINGS, (array) $_POST );
|
1153 |
|
@@ -1172,20 +1166,18 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
1172 |
*/
|
1173 |
static function view_output( $atts, $content = '' ) {
|
1174 |
$atts = shortcode_atts(
|
1175 |
-
|
1176 |
-
|
1177 |
-
|
1178 |
-
|
1179 |
-
|
1180 |
-
),
|
1181 |
-
$atts
|
1182 |
);
|
1183 |
|
1184 |
global $pt_cv_shortcode_params;
|
1185 |
$pt_cv_shortcode_params = $atts;
|
1186 |
|
1187 |
// View meta id
|
1188 |
-
$id = esc_sql( $atts['id'] );
|
1189 |
|
1190 |
// Get View settings
|
1191 |
$settings = PT_CV_Functions::view_get_settings( $id );
|
@@ -1221,9 +1213,9 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
1221 |
public static function view_link( $view_id, $action = array() ) {
|
1222 |
|
1223 |
$edit_link = admin_url( 'admin.php?page=' . PT_CV_DOMAIN . '-add' );
|
1224 |
-
if ( !
|
1225 |
-
$query_args
|
1226 |
-
$edit_link
|
1227 |
}
|
1228 |
|
1229 |
return $edit_link;
|
@@ -1241,7 +1233,7 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
1241 |
|
1242 |
// Request handle
|
1243 |
$settings = array();
|
1244 |
-
parse_str( $_POST['data'], $settings );
|
1245 |
|
1246 |
// Show View output
|
1247 |
echo balanceTags( PT_CV_Functions::view_process_settings( null, $settings ) );
|
@@ -1260,21 +1252,21 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
1260 |
check_ajax_referer( PT_CV_PREFIX_ . 'ajax_nonce', 'ajax_nonce' );
|
1261 |
|
1262 |
// Session id
|
1263 |
-
$session_id = empty( $_POST['sid'] ) ? '' : esc_sql( $_POST['sid'] );
|
1264 |
|
1265 |
// Get saved $settings
|
1266 |
$settings = get_transient( PT_CV_PREFIX . 'view-settings-' . $session_id );
|
1267 |
|
1268 |
// If empty, get settings by ID
|
1269 |
-
if (
|
1270 |
$settings = PT_CV_Functions::view_get_settings( $session_id );
|
1271 |
}
|
1272 |
|
1273 |
// Pagination settings
|
1274 |
-
$pargs = array( 'session_id' => $session_id, 'page' => (int) esc_sql( $_POST['page'] ) );
|
1275 |
|
1276 |
// Switch language
|
1277 |
-
$language = empty( $_POST['lang'] ) ? '' : esc_sql( $_POST['lang'] );
|
1278 |
self::switch_language( $language );
|
1279 |
|
1280 |
// Show View output
|
@@ -1289,14 +1281,14 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
1289 |
*/
|
1290 |
static function util_show_promo_view() {
|
1291 |
$pro_installed = get_option( 'pt_cv_version_pro' );
|
1292 |
-
if (
|
1293 |
?>
|
1294 |
<div class="pull-right" style="margin-top: -54px;">
|
1295 |
<a class="btn btn-success" target="_blank" href="http://www.contentviewspro.com/pricing/?utm_source=client&utm_medium=view">» Get Pro version</a>
|
1296 |
or
|
1297 |
<a class="btn btn-info" target="_blank" href="http://sample.contentviewspro.com/?utm_source=client&utm_medium=view">Check demo site</a>
|
1298 |
</div>
|
1299 |
-
|
1300 |
}
|
1301 |
}
|
1302 |
|
@@ -1309,13 +1301,13 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
1309 |
static function pagination_generate_link( $class, $this_page, $label = '' ) {
|
1310 |
$data_page = '';
|
1311 |
|
1312 |
-
if (
|
1313 |
-
$label
|
1314 |
-
$data_page
|
1315 |
}
|
1316 |
|
1317 |
-
$html
|
1318 |
-
$class
|
1319 |
|
1320 |
return sprintf( '<li%s>%s</li>', $class, $html );
|
1321 |
}
|
@@ -1327,7 +1319,8 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
1327 |
* @param int $current_page Current page number
|
1328 |
* @param int $pages_to_show Number of page to show
|
1329 |
*/
|
1330 |
-
static function pagination( $total_pages, $current_page = 1,
|
|
|
1331 |
if ( $total_pages == 1 )
|
1332 |
return '';
|
1333 |
|
@@ -1335,39 +1328,39 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
1335 |
|
1336 |
// Define labels
|
1337 |
$labels = apply_filters( PT_CV_PREFIX_ . 'pagination_label', array(
|
1338 |
-
'prev'
|
1339 |
-
'next'
|
1340 |
-
'first'
|
1341 |
-
'last'
|
1342 |
) );
|
1343 |
|
1344 |
-
$start
|
1345 |
-
$end
|
1346 |
|
1347 |
-
$html
|
1348 |
|
1349 |
$compared_page = 1;
|
1350 |
// First
|
1351 |
if ( $start > $compared_page ) {
|
1352 |
-
$html .= self::pagination_generate_link( '', $compared_page, $labels['first'] );
|
1353 |
}
|
1354 |
// Prev
|
1355 |
if ( $current_page > $compared_page ) {
|
1356 |
-
$html
|
1357 |
}
|
1358 |
|
1359 |
-
for ( $i = $start
|
1360 |
$html .= self::pagination_generate_link( ( $current_page == $i ) ? 'active' : '', $i );
|
1361 |
}
|
1362 |
|
1363 |
$compared_page = $total_pages;
|
1364 |
// Next
|
1365 |
if ( $current_page < $total_pages ) {
|
1366 |
-
$html
|
1367 |
}
|
1368 |
// Last
|
1369 |
if ( $end < $compared_page ) {
|
1370 |
-
$html .= self::pagination_generate_link( '', $compared_page, $labels['last'] );
|
1371 |
}
|
1372 |
|
1373 |
return $html;
|
@@ -1379,12 +1372,12 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
1379 |
static function get_current_page( $pargs ) {
|
1380 |
$paged = 1;
|
1381 |
|
1382 |
-
if ( !
|
1383 |
-
$paged = intval( $pargs['page'] );
|
1384 |
}
|
1385 |
|
1386 |
-
if ( !
|
1387 |
-
$paged = intval( $_GET['vpage'] );
|
1388 |
}
|
1389 |
|
1390 |
return $paged;
|
8 |
* @link http://www.contentviewspro.com/
|
9 |
* @copyright 2014 PT Guy
|
10 |
*/
|
11 |
+
if ( !function_exists( 'get_plugin_data' ) ) {
|
|
|
12 |
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
13 |
}
|
14 |
+
if ( !class_exists( 'PT_CV_Functions' ) ) {
|
15 |
|
16 |
/**
|
17 |
* @name PT_CV_Functions
|
59 |
* @since 1.5.3
|
60 |
*/
|
61 |
global $q_config;
|
62 |
+
if ( $q_config && !empty( $q_config[ 'language' ] ) ) {
|
63 |
+
$language = $q_config[ 'language' ];
|
64 |
}
|
65 |
|
66 |
return $language;
|
73 |
* @param string $language Current language
|
74 |
*/
|
75 |
static function switch_language( $language ) {
|
76 |
+
if ( !$language )
|
77 |
+
return;
|
78 |
|
79 |
// WPML
|
80 |
global $sitepress;
|
88 |
*/
|
89 |
global $q_config;
|
90 |
if ( $q_config ) {
|
91 |
+
$q_config[ 'language' ] = $language;
|
92 |
}
|
93 |
}
|
94 |
|
103 |
static function plugin_info( $file, $data = '' ) {
|
104 |
$plugin_data = get_plugin_data( $file );
|
105 |
|
106 |
+
return isset( $plugin_data[ $data ] ) ? $plugin_data[ $data ] : NULL;
|
107 |
}
|
108 |
|
109 |
/**
|
116 |
* @param string $sub_page Slug of sub menu
|
117 |
* @param string $class Class name which contains function to output content of page created by this menu
|
118 |
*/
|
119 |
+
static function menu_add_sub( $parent_slug, $page_title, $menu_title,
|
120 |
+
$user_role, $sub_page, $class ) {
|
121 |
return add_submenu_page(
|
122 |
+
$parent_slug, $page_title, $menu_title, $user_role, $parent_slug . '-' . $sub_page, array( $class, 'display_sub_page_' . $sub_page )
|
123 |
);
|
124 |
}
|
125 |
|
218 |
do_action( PT_CV_PREFIX_ . 'before_strip_shortcodes' );
|
219 |
|
220 |
// Strip all shortcodes
|
221 |
+
$text = strip_shortcodes( $text );
|
222 |
|
223 |
// Recovery global $shortcode_tags
|
224 |
do_action( PT_CV_PREFIX_ . 'after_strip_shortcodes' );
|
227 |
$result = self::pt_strip_tags( $text );
|
228 |
|
229 |
// Split words
|
230 |
+
$array = preg_split( "/[\n\r\t ]+/", $result, $num_words + 1, PREG_SPLIT_NO_EMPTY );
|
231 |
|
232 |
// Already short enough, return the whole thing
|
233 |
+
if ( count( $array ) > $num_words ) {
|
|
|
234 |
array_splice( $array, $num_words );
|
235 |
$result = implode( ' ', $array );
|
236 |
}
|
251 |
# allow some tags
|
252 |
global $dargs;
|
253 |
# predefined allowable HTML tags
|
254 |
+
$allowable_tags = (array) apply_filters( PT_CV_PREFIX_ . 'allowable_tags', array( '<a>', '<br>', '<strong>', '<em>', '<strike>', '<i>', '<ul>', '<ol>', '<li>' ) );
|
255 |
+
$allowed_tags = '';
|
256 |
+
if ( !empty( $dargs[ 'field-settings' ][ 'content' ][ 'allow_html' ] ) ) {
|
257 |
$allowed_tags = implode( '', $allowable_tags );
|
258 |
|
259 |
// Changes double line-breaks in the text into HTML paragraphs (<p>, <br>)
|
262 |
}
|
263 |
}
|
264 |
|
265 |
+
$string = strip_tags( $string, $allowed_tags );
|
266 |
|
267 |
return trim( $string );
|
268 |
}
|
275 |
* @return array
|
276 |
*/
|
277 |
static function field_thumbnail_dimensions( $fargs ) {
|
278 |
+
$size = $fargs[ 'size' ];
|
279 |
|
280 |
return (array) explode( '×', str_replace( ' ', '', $size ) );
|
281 |
}
|
288 |
* @param mixed|null $assign The value to assign if setting is not found
|
289 |
*/
|
290 |
static function setting_value( $field, $array_to_get, $assign = NULL ) {
|
291 |
+
return isset( $array_to_get[ $field ] ) ? $array_to_get[ $field ] : $assign;
|
292 |
}
|
293 |
|
294 |
/**
|
299 |
* @param array $array_to_get Array to get values of wanted setting fields
|
300 |
* @param string $prefix Prefix string to looking for fields in $array_to_get
|
301 |
*/
|
302 |
+
static function settings_values( $fields, &$array_to_save, $array_to_get,
|
303 |
+
$prefix ) {
|
304 |
foreach ( $fields as $tsetting ) {
|
305 |
+
$array_to_save[ $tsetting ] = PT_CV_Functions::setting_value( $prefix . $tsetting, $array_to_get );
|
306 |
}
|
307 |
}
|
308 |
|
315 |
static function settings_keys( $prefix, $options ) {
|
316 |
$result = array();
|
317 |
foreach ( $options as $option ) {
|
318 |
+
if ( isset( $option[ 'params' ] ) ) {
|
319 |
+
foreach ( $option[ 'params' ] as $params ) {
|
320 |
// If name of setting match with prefix string, got it name
|
321 |
+
if ( isset( $params[ 'name' ] ) && substr( $params[ 'name' ], 0, strlen( $prefix ) ) === $prefix ) {
|
322 |
+
$result[] = substr( $params[ 'name' ], strlen( $prefix ) );
|
323 |
}
|
324 |
}
|
325 |
}
|
337 |
static function settings_values_by_prefix( $prefix, $backend = FALSE ) {
|
338 |
global $pt_view_settings;
|
339 |
|
340 |
+
if ( !$pt_view_settings && $backend ) {
|
341 |
global $pt_cv_admin_settings;
|
342 |
$pt_view_settings = $pt_cv_admin_settings;
|
343 |
}
|
347 |
foreach ( (array) $pt_view_settings as $name => $value ) {
|
348 |
// If name of setting match with prefix string, got it name
|
349 |
if ( substr( $name, 0, strlen( $prefix ) ) === $prefix ) {
|
350 |
+
$result[ substr( $name, strlen( $prefix ) ) ] = $value;
|
351 |
}
|
352 |
}
|
353 |
|
381 |
|
382 |
foreach ( $terms as $term ) {
|
383 |
$links[] = sprintf(
|
384 |
+
'<a href="%1$s" title="%2$s %3$s">%3$s</a>', esc_url( get_term_link( $term, $term->taxonomy ) ), __( 'View all posts in', PT_CV_DOMAIN ), $term->name
|
|
|
|
|
|
|
385 |
);
|
386 |
|
387 |
+
if ( !isset( $pt_post_terms[ $post_id ] ) ) {
|
388 |
+
$pt_post_terms[ $post_id ] = array();
|
389 |
}
|
390 |
+
$pt_post_terms[ $post_id ][ $term->slug ] = $term->name;
|
391 |
}
|
392 |
|
393 |
return implode( ', ', $links );
|
399 |
* @param string $post_id ID of post
|
400 |
*/
|
401 |
static function post_update_view_count( $post_id ) {
|
402 |
+
$meta_key = PT_CV_META_VIEW_COUNT;
|
403 |
+
$count = get_post_meta( $post_id, $meta_key, true );
|
404 |
+
if ( !$count ) {
|
405 |
$count = 0;
|
406 |
}
|
407 |
$count ++;
|
414 |
* @param string $post_id ID of post
|
415 |
*/
|
416 |
static function post_get_view_count( $post_id ) {
|
417 |
+
$meta_key = PT_CV_META_VIEW_COUNT;
|
418 |
+
$count = get_post_meta( $post_id, $meta_key, true );
|
419 |
+
if ( !$count ) {
|
420 |
$count = 1;
|
421 |
}
|
422 |
|
429 |
* @param string $arr Array of post data
|
430 |
*/
|
431 |
static function post_insert( $arr ) {
|
432 |
+
if ( !$arr ) {
|
433 |
return;
|
434 |
}
|
435 |
// Create post object
|
436 |
$my_post = array(
|
437 |
+
'ID' => (int) $arr[ 'ID' ],
|
438 |
+
'post_type' => PT_CV_POST_TYPE,
|
439 |
+
'post_content' => '',
|
440 |
+
'post_title' => !empty( $arr[ 'title' ] ) ? $arr[ 'title' ] : __( '(no title)', PT_CV_DOMAIN ),
|
441 |
+
'post_status' => 'publish',
|
442 |
);
|
443 |
|
444 |
// Insert the post into the database
|
455 |
static function post_id_from_meta_id( $meta_id ) {
|
456 |
|
457 |
$post_id = 0;
|
458 |
+
if ( !$meta_id ) {
|
459 |
return $post_id;
|
460 |
}
|
461 |
|
462 |
// Query view which has view id = $meta_id
|
463 |
$pt_query = new WP_Query(
|
464 |
+
array(
|
465 |
+
'post_type' => PT_CV_POST_TYPE,
|
466 |
+
'post_status' => 'publish',
|
467 |
+
'meta_key' => PT_CV_META_ID,
|
468 |
+
'meta_value' => esc_sql( $meta_id ),
|
469 |
+
)
|
470 |
);
|
471 |
if ( $pt_query->have_posts() ) :
|
472 |
while ( $pt_query->have_posts() ):
|
500 |
*/
|
501 |
static function _nonce_check( $nonce_name, $action_name ) {
|
502 |
$nonce_name = PT_CV_PREFIX_ . $nonce_name;
|
503 |
+
if ( !isset( $_POST[ $nonce_name ] ) || !wp_verify_nonce( $_POST[ $nonce_name ], PT_CV_PREFIX_ . $action_name ) ) {
|
504 |
print esc_html( __( 'Sorry, your nonce did not verify.', PT_CV_DOMAIN ) );
|
505 |
exit;
|
506 |
}
|
514 |
* @return array
|
515 |
*/
|
516 |
static function view_get_settings( $meta_id ) {
|
517 |
+
if ( !$meta_id ) {
|
518 |
return;
|
519 |
}
|
520 |
|
541 |
* @param type $view_settings
|
542 |
*/
|
543 |
static function view_backward_comp( &$view_settings ) {
|
544 |
+
if ( !$view_settings ) {
|
545 |
return $view_settings;
|
546 |
}
|
547 |
|
548 |
// Taxonomy In, Not in
|
549 |
+
$taxonomies = isset( $view_settings[ PT_CV_PREFIX . 'taxonomy' ] ) ? $view_settings[ PT_CV_PREFIX . 'taxonomy' ] : array();
|
550 |
if ( is_array( $taxonomies ) ) {
|
551 |
$list = array( '__in', '__not_in' );
|
552 |
foreach ( $taxonomies as $taxonomy ) {
|
553 |
// Check if IN/NOT IN list has values. NOT IN list will overwite IN list
|
554 |
foreach ( $list as $ltype ) {
|
555 |
+
if ( isset( $view_settings[ PT_CV_PREFIX . $taxonomy . $ltype ] ) ) {
|
556 |
+
$view_settings[ PT_CV_PREFIX . $taxonomy . '-terms' ] = $view_settings[ PT_CV_PREFIX . $taxonomy . $ltype ];
|
557 |
+
$view_settings[ PT_CV_PREFIX . $taxonomy . '-operator' ] = ( $ltype == '__in' ) ? 'IN' : 'NOT IN';
|
558 |
}
|
559 |
}
|
560 |
}
|
585 |
global $processed_views, $pt_cv_shortcode_params;
|
586 |
// Same View but has different shortcode parameters => consider as 2 different Views
|
587 |
$vid = $id . '-' . md5( serialize( $pt_cv_shortcode_params ) );
|
588 |
+
if ( !empty( $processed_views[ $vid ] ) ) {
|
589 |
return '';
|
590 |
}
|
591 |
+
$processed_views[ $vid ] = 1;
|
592 |
|
593 |
// Escaped value appropriate for use in a SQL query
|
594 |
global $pt_view_settings;
|
595 |
|
596 |
$pt_view_settings = array();
|
597 |
foreach ( $settings as $key => $value ) {
|
598 |
+
$pt_view_settings[ $key ] = esc_sql( $value );
|
599 |
}
|
600 |
|
601 |
// Get content type
|
602 |
global $pt_content_type;
|
603 |
+
$pt_content_type = $content_type = PT_CV_Functions::setting_value( PT_CV_PREFIX . 'content-type', $pt_view_settings );
|
604 |
+
$content_type = apply_filters( PT_CV_PREFIX_ . 'content_type', $content_type, $id );
|
605 |
|
606 |
// Get view type
|
607 |
global $pt_view_type;
|
608 |
+
$pt_view_type = $view_type = PT_CV_Functions::setting_value( PT_CV_PREFIX . 'view-type', $pt_view_settings );
|
609 |
|
610 |
// Store display settings
|
611 |
global $dargs, $pt_query_args, $pt_view_sid;
|
612 |
|
613 |
+
$session_id = ( $pargs && isset( $pargs[ 'session_id' ] ) ) ? $pargs[ 'session_id' ] : 0;
|
614 |
|
615 |
// If is pagination request
|
616 |
if ( $session_id ) {
|
618 |
$pt_view_sid = $session_id;
|
619 |
}
|
620 |
|
621 |
+
$session_data = array_merge(
|
622 |
+
array( '$args' => '', '$dargs' => '' ), ( false === ( $saved_settings = get_transient( PT_CV_PREFIX . 'view-data-' . $session_id ) ) ) ? array() : $saved_settings
|
|
|
623 |
);
|
624 |
|
625 |
+
$args = $session_data[ '$args' ];
|
626 |
+
$dargs = $session_data[ '$dargs' ];
|
627 |
} else {
|
628 |
// If id is passed, assign it to session id, otherwise, generate random number
|
629 |
+
$pt_view_sid = $session_id = $id ? $id : PT_CV_Functions::string_random();
|
630 |
|
631 |
// Store settings
|
632 |
set_transient( PT_CV_PREFIX . 'view-settings-' . $session_id, $settings, 7 * DAY_IN_SECONDS );
|
633 |
}
|
634 |
|
635 |
if ( empty( $args ) || empty( $dargs ) ) {
|
636 |
+
$args = PT_CV_Functions::view_filter_settings( $content_type, $pt_view_settings );
|
637 |
+
$dargs = PT_CV_Functions::view_display_settings( $view_type );
|
638 |
|
639 |
// Filter
|
640 |
+
$dargs = apply_filters( PT_CV_PREFIX_ . 'all_display_settings', $dargs );
|
641 |
+
$args = apply_filters( PT_CV_PREFIX_ . 'query_parameters', $args );
|
642 |
|
643 |
// Store view data
|
644 |
set_transient(
|
645 |
+
PT_CV_PREFIX . 'view-data-' . $session_id, array(
|
646 |
+
'$args' => $args,
|
647 |
+
'$dargs' => $dargs,
|
648 |
+
), 7 * DAY_IN_SECONDS
|
|
|
649 |
);
|
650 |
}
|
651 |
|
683 |
/**
|
684 |
* Output Pagination
|
685 |
*/
|
686 |
+
$current_page = self::get_current_page( $pargs );
|
687 |
+
$html = PT_CV_Html::content_items_wrap( $content_items, $current_page, $args[ 'posts_per_page' ], $id );
|
688 |
|
689 |
// Append Pagination HTML if this is first page, or not Ajax calling
|
690 |
+
$type = isset( $dargs[ 'pagination-settings' ][ 'type' ] ) ? $dargs[ 'pagination-settings' ][ 'type' ] : 'ajax';
|
691 |
+
if ( $pt_query && $args[ 'posts_per_page' ] > 0 && ( ( $type == 'ajax' && $current_page === 1 ) || $type == 'normal' ) ) {
|
692 |
// Total post founds
|
693 |
$found_posts = apply_filters( PT_CV_PREFIX_ . 'found_posts', $pt_query->found_posts );
|
694 |
|
695 |
// Total number of items
|
696 |
+
$total_items = ( $args[ 'limit' ] > 0 && $found_posts > $args[ 'limit' ] ) ? $args[ 'limit' ] : $found_posts;
|
697 |
|
698 |
// Total number of pages
|
699 |
+
$max_num_pages = ceil( $total_items / $args[ 'posts_per_page' ] );
|
700 |
|
701 |
// Output pagination
|
702 |
$html .= "\n" . PT_CV_Html::pagination_output( $max_num_pages, $current_page, $session_id );
|
733 |
// Output HTML for this item
|
734 |
$post_id = apply_filters( PT_CV_PREFIX_ . 'show_this_post', $post->ID );
|
735 |
if ( $post_id ) {
|
736 |
+
$content_items[ $post->ID ] = PT_CV_Html::view_type_output( $view_type, $post );
|
737 |
}
|
738 |
}
|
739 |
} else {
|
770 |
* Set default values
|
771 |
*/
|
772 |
$args = array(
|
773 |
+
'post_type' => $content_type,
|
774 |
+
'post_status' => 'publish',
|
775 |
+
'ignore_sticky_posts' => apply_filters( PT_CV_PREFIX_ . 'ignore_sticky_posts', 1 ),
|
776 |
);
|
777 |
|
778 |
// Post in
|
779 |
if ( PT_CV_Functions::setting_value( PT_CV_PREFIX . 'post__in', $pt_view_settings ) ) {
|
780 |
+
$post_in = PT_CV_Functions::string_to_array( PT_CV_Functions::setting_value( PT_CV_PREFIX . 'post__in', $pt_view_settings ) );
|
781 |
+
$args[ 'post__in' ] = array_map( 'intval', array_filter( $post_in ) );
|
782 |
}
|
783 |
|
784 |
// Post not in
|
785 |
if ( PT_CV_Functions::setting_value( PT_CV_PREFIX . 'post__not_in', $pt_view_settings ) ) {
|
786 |
+
$post_not_in = PT_CV_Functions::string_to_array( PT_CV_Functions::setting_value( PT_CV_PREFIX . 'post__not_in', $pt_view_settings ) );
|
787 |
+
$args[ 'post__not_in' ] = array_map( 'intval', array_filter( $post_not_in ) );
|
788 |
}
|
789 |
|
790 |
+
$args[ 'post__not_in' ] = apply_filters( PT_CV_PREFIX_ . 'post__not_in', isset( $args[ 'post__not_in' ] ) ? $args[ 'post__not_in' ] : array(), $pt_view_settings );
|
791 |
|
792 |
// Parent page
|
793 |
if ( $content_type == 'page' ) {
|
794 |
$post_parent = apply_filters( PT_CV_PREFIX_ . 'post_parent_id', PT_CV_Functions::setting_value( PT_CV_PREFIX . 'post_parent', $pt_view_settings ) );
|
795 |
+
if ( !empty( $post_parent ) ) {
|
796 |
+
$args[ 'post_parent' ] = (int) $post_parent;
|
797 |
}
|
798 |
}
|
799 |
|
816 |
*/
|
817 |
$dargs = array();
|
818 |
|
819 |
+
$dargs[ 'view-type' ] = $view_type;
|
820 |
|
821 |
// Field settings of a item
|
822 |
PT_CV_Functions::view_get_display_settings( $dargs );
|
825 |
PT_CV_Functions::view_get_other_settings( $dargs );
|
826 |
|
827 |
// View type settings
|
828 |
+
$dargs[ 'view-type-settings' ] = PT_CV_Functions::settings_values_by_prefix( PT_CV_PREFIX . $view_type . '-' );
|
829 |
|
830 |
return $dargs;
|
831 |
}
|
855 |
$author_not_in = PT_CV_Functions::string_to_array( PT_CV_Functions::setting_value( PT_CV_PREFIX . 'author__not_in', $pt_view_settings ) );
|
856 |
|
857 |
// Author in
|
858 |
+
if ( !empty( $author_in[ 0 ] ) ) {
|
859 |
$args = array_merge(
|
860 |
+
$args, array(
|
861 |
+
'author__in' => array_map( 'intval', $author_in ),
|
862 |
+
)
|
863 |
);
|
864 |
}
|
865 |
|
866 |
// Author not in
|
867 |
+
if ( !empty( $author_not_in[ 0 ] ) ) {
|
868 |
$args = array_merge(
|
869 |
+
$args, array(
|
870 |
+
'author__not_in' => array_map( 'intval', $author_not_in ),
|
871 |
+
)
|
872 |
);
|
873 |
}
|
874 |
} else {
|
875 |
// Author = ID
|
876 |
+
if ( !empty( $author_in[ 0 ] ) ) {
|
877 |
$args = array_merge(
|
878 |
+
$args, array(
|
879 |
+
'author' => intval( $author_in[ 0 ] ),
|
880 |
+
)
|
881 |
);
|
882 |
}
|
883 |
}
|
887 |
// Status
|
888 |
case 'status':
|
889 |
$args = array_merge(
|
890 |
+
$args, array(
|
891 |
+
'post_status' => PT_CV_Functions::string_to_array( PT_CV_Functions::setting_value( PT_CV_PREFIX . 'post_status', $pt_view_settings, 'publish' ) ),
|
892 |
+
)
|
893 |
);
|
894 |
break;
|
895 |
|
897 |
case 'search':
|
898 |
if ( PT_CV_Functions::setting_value( PT_CV_PREFIX . 's', $pt_view_settings ) ) {
|
899 |
$args = array_merge(
|
900 |
+
$args, array(
|
901 |
+
's' => PT_CV_Functions::setting_value( PT_CV_PREFIX . 's', $pt_view_settings ),
|
902 |
+
)
|
903 |
);
|
904 |
}
|
905 |
break;
|
907 |
// Taxonomy
|
908 |
case 'taxonomy':
|
909 |
// No taxonomy found
|
910 |
+
if ( !PT_CV_Functions::setting_value( PT_CV_PREFIX . 'taxonomy', $pt_view_settings ) ) {
|
911 |
break;
|
912 |
}
|
913 |
|
924 |
$operator = PT_CV_Functions::setting_value( PT_CV_PREFIX . $taxonomy . '-operator', $pt_view_settings, 'IN' );
|
925 |
|
926 |
$taxonomy_setting[] = array(
|
927 |
+
'taxonomy' => $taxonomy,
|
928 |
+
'field' => 'slug',
|
929 |
+
'terms' => (array) PT_CV_Functions::setting_value( PT_CV_PREFIX . $taxonomy . '-terms', $pt_view_settings ),
|
930 |
+
'operator' => $operator,
|
931 |
+
'include_children' => apply_filters( PT_CV_PREFIX_ . 'include_children', true )
|
932 |
);
|
933 |
}
|
934 |
}
|
935 |
|
936 |
// Get Taxonomy relation if there are more than 1 selected taxonomies | set In & Not in of a taxonomy
|
937 |
if ( count( $taxonomies ) > 1 || count( $taxonomy_setting ) > 1 ) {
|
938 |
+
$taxonomy_setting[ 'relation' ] = PT_CV_Functions::setting_value( PT_CV_PREFIX . 'taxonomy-relation', $pt_view_settings, 'AND' );
|
939 |
}
|
940 |
|
941 |
// Filter taxonomy with Custom post types
|
947 |
// Order
|
948 |
case 'order':
|
949 |
$order_settings = apply_filters(
|
950 |
+
PT_CV_PREFIX_ . 'order_setting', array(
|
951 |
+
'orderby' => PT_CV_Functions::setting_value( PT_CV_PREFIX . 'orderby', $pt_view_settings ),
|
952 |
+
'order' => PT_CV_Functions::setting_value( PT_CV_PREFIX . 'order', $pt_view_settings ),
|
953 |
+
)
|
|
|
954 |
);
|
955 |
|
956 |
$args = array_merge( $args, $order_settings );
|
971 |
static function view_get_display_settings( &$dargs ) {
|
972 |
global $pt_view_settings;
|
973 |
|
974 |
+
$view_type = $dargs[ 'view-type' ];
|
975 |
|
976 |
/**
|
977 |
* Layout format
|
978 |
*/
|
979 |
+
$dargs[ 'layout-format' ] = PT_CV_Functions::setting_value( PT_CV_PREFIX . 'layout-format', $pt_view_settings );
|
980 |
|
981 |
/**
|
982 |
* Columns count & Rows count
|
983 |
*/
|
984 |
+
$dargs[ 'number-columns' ] = apply_filters( PT_CV_PREFIX_ . 'item_per_row', PT_CV_Functions::setting_value( PT_CV_PREFIX . $view_type . '-' . 'number-columns', $pt_view_settings, 1 ) );
|
985 |
+
$dargs[ 'number-rows' ] = PT_CV_Functions::setting_value( PT_CV_PREFIX . $view_type . '-' . 'number-rows', $pt_view_settings, 1 );
|
986 |
|
987 |
/**
|
988 |
* Fields settings
|
989 |
*/
|
990 |
+
$cfields_settings = PT_CV_Functions::settings_values_by_prefix( PT_CV_PREFIX . 'show-field-' );
|
991 |
+
$cfields = (array) array_keys( (array) $cfields_settings );
|
992 |
foreach ( $cfields as $field ) {
|
993 |
// If show this field
|
994 |
if ( PT_CV_Functions::setting_value( PT_CV_PREFIX . 'show-field-' . $field, $pt_view_settings ) ) {
|
995 |
// Add this field to display fields list
|
996 |
+
$dargs[ 'fields' ][] = $field;
|
997 |
|
998 |
// Get field settings
|
999 |
switch ( $field ) {
|
1000 |
|
1001 |
// Get title settings
|
1002 |
case 'title':
|
1003 |
+
$prefix = PT_CV_PREFIX . 'field-title-';
|
1004 |
+
$field_setting = PT_CV_Functions::settings_values_by_prefix( $prefix );
|
1005 |
|
1006 |
+
$dargs[ 'field-settings' ][ $field ] = apply_filters( PT_CV_PREFIX_ . 'field_title_setting_values', $field_setting, $prefix );
|
1007 |
|
1008 |
break;
|
1009 |
|
1010 |
// Get thumbnail settings
|
1011 |
case 'thumbnail':
|
1012 |
+
$prefix = PT_CV_PREFIX . 'field-thumbnail-';
|
1013 |
+
$field_setting = PT_CV_Functions::settings_values_by_prefix( $prefix );
|
1014 |
|
1015 |
+
$dargs[ 'field-settings' ][ $field ] = apply_filters( PT_CV_PREFIX_ . 'field_thumbnail_setting_values', $field_setting, $prefix );
|
1016 |
|
1017 |
break;
|
1018 |
|
1019 |
// Get meta fields settings
|
1020 |
case 'meta-fields':
|
1021 |
+
$prefix = PT_CV_PREFIX . 'meta-fields-';
|
1022 |
+
$field_setting = PT_CV_Functions::settings_values_by_prefix( $prefix );
|
1023 |
|
1024 |
+
$dargs[ 'field-settings' ][ $field ] = apply_filters( PT_CV_PREFIX_ . 'field_meta_fields_setting_values', $field_setting, $prefix );
|
1025 |
|
1026 |
break;
|
1027 |
|
1028 |
// Get content settings
|
1029 |
case 'content':
|
1030 |
+
$prefix = PT_CV_PREFIX . 'field-content-';
|
1031 |
+
$field_setting = PT_CV_Functions::settings_values_by_prefix( $prefix );
|
1032 |
|
1033 |
+
if ( $field_setting[ 'show' ] == 'excerpt' ) {
|
1034 |
$field_setting = array_merge( $field_setting, PT_CV_Functions::settings_values_by_prefix( PT_CV_PREFIX . 'field-excerpt-' ) );
|
1035 |
}
|
1036 |
|
1037 |
+
$dargs[ 'field-settings' ][ $field ] = apply_filters( PT_CV_PREFIX_ . 'field_content_setting_values', $field_setting, $prefix );
|
1038 |
|
1039 |
break;
|
1040 |
|
1056 |
global $pt_view_settings;
|
1057 |
|
1058 |
// Get Limit value
|
1059 |
+
$limit = trim( PT_CV_Functions::setting_value( PT_CV_PREFIX . 'limit', $pt_view_settings ) );
|
1060 |
+
$limit = ( empty( $limit ) || $limit === '-1' ) ? 10000000 : (int) $limit;
|
1061 |
+
$args[ 'limit' ] = $args[ 'posts_per_page' ] = $limit;
|
1062 |
+
$offset = 0;
|
1063 |
|
1064 |
// Get pagination enable/disable
|
1065 |
$pagination = PT_CV_Functions::setting_value( PT_CV_PREFIX . 'enable-pagination', $pt_view_settings );
|
1066 |
if ( $pagination ) {
|
1067 |
+
$prefix = PT_CV_PREFIX . 'pagination-';
|
1068 |
+
$field_setting = PT_CV_Functions::settings_values_by_prefix( $prefix );
|
1069 |
|
1070 |
+
$dargs[ 'pagination-settings' ] = apply_filters( PT_CV_PREFIX_ . 'pagination_settings', $field_setting, $prefix );
|
1071 |
|
1072 |
// If Items per page is set, get its value
|
1073 |
+
$posts_per_page = isset( $dargs[ 'pagination-settings' ][ 'items-per-page' ] ) ? (int) $dargs[ 'pagination-settings' ][ 'items-per-page' ] : $limit;
|
1074 |
|
1075 |
if ( $posts_per_page > $limit ) {
|
1076 |
$posts_per_page = $limit;
|
1077 |
}
|
1078 |
|
1079 |
// Set 'posts_per_page' parameter
|
1080 |
+
$args[ 'posts_per_page' ] = $posts_per_page;
|
1081 |
|
1082 |
// Get offset
|
1083 |
$paged = self::get_current_page( $pargs );
|
1085 |
$offset = $posts_per_page * ( (int) $paged - 1 );
|
1086 |
|
1087 |
// Update posts_per_page
|
1088 |
+
if ( intval( $args[ 'posts_per_page' ] ) > $limit - $offset ) {
|
1089 |
+
$args[ 'posts_per_page' ] = $limit - $offset;
|
1090 |
}
|
1091 |
}
|
1092 |
|
1093 |
$offset = apply_filters( PT_CV_PREFIX_ . 'settings_args_offset', $offset );
|
1094 |
|
1095 |
// Set 'offset' parameter
|
1096 |
+
$args[ 'offset' ] = $offset;
|
1097 |
}
|
1098 |
|
1099 |
/**
|
1102 |
* @param array $dargs The settings array of Fields
|
1103 |
*/
|
1104 |
static function view_get_other_settings( &$dargs ) {
|
1105 |
+
$prefix = PT_CV_PREFIX . 'other-';
|
1106 |
+
$field_setting = PT_CV_Functions::settings_values_by_prefix( $prefix );
|
1107 |
|
1108 |
+
$dargs[ 'other-settings' ] = apply_filters( PT_CV_PREFIX_ . 'other_settings', $field_setting );
|
1109 |
}
|
1110 |
|
1111 |
/**
|
1124 |
* INSERT VIEW
|
1125 |
*/
|
1126 |
// View title
|
1127 |
+
$title = esc_sql( $_POST[ PT_CV_PREFIX . 'view-title' ] );
|
1128 |
|
1129 |
// Current post id ( 0 if new view )
|
1130 |
+
$cur_post_id = esc_sql( $_POST[ PT_CV_PREFIX . 'post-id' ] );
|
1131 |
|
1132 |
// Insert post
|
1133 |
+
if ( !$cur_post_id ) {
|
1134 |
$post_id = PT_CV_Functions::post_insert( array( 'ID' => $cur_post_id, 'title' => $title ) );
|
1135 |
} else {
|
1136 |
$post_id = $cur_post_id;
|
1140 |
* ADD/UPDATE CUSTOM FIELDS
|
1141 |
*/
|
1142 |
// Get current view id, = 0 if it is new view
|
1143 |
+
$cur_view_id = esc_sql( $_POST[ PT_CV_PREFIX . 'view-id' ] );
|
1144 |
+
$view_id = empty( $cur_view_id ) ? PT_CV_Functions::string_random() : $cur_view_id;
|
1145 |
update_post_meta( $post_id, PT_CV_META_ID, $view_id );
|
1146 |
update_post_meta( $post_id, PT_CV_META_SETTINGS, (array) $_POST );
|
1147 |
|
1166 |
*/
|
1167 |
static function view_output( $atts, $content = '' ) {
|
1168 |
$atts = shortcode_atts(
|
1169 |
+
apply_filters(
|
1170 |
+
PT_CV_PREFIX_ . 'shortcode_params', array(
|
1171 |
+
'id' => 0,
|
1172 |
+
)
|
1173 |
+
), $atts
|
|
|
|
|
1174 |
);
|
1175 |
|
1176 |
global $pt_cv_shortcode_params;
|
1177 |
$pt_cv_shortcode_params = $atts;
|
1178 |
|
1179 |
// View meta id
|
1180 |
+
$id = esc_sql( $atts[ 'id' ] );
|
1181 |
|
1182 |
// Get View settings
|
1183 |
$settings = PT_CV_Functions::view_get_settings( $id );
|
1213 |
public static function view_link( $view_id, $action = array() ) {
|
1214 |
|
1215 |
$edit_link = admin_url( 'admin.php?page=' . PT_CV_DOMAIN . '-add' );
|
1216 |
+
if ( !empty( $view_id ) ) {
|
1217 |
+
$query_args = array( 'id' => $view_id ) + $action;
|
1218 |
+
$edit_link = add_query_arg( $query_args, $edit_link );
|
1219 |
}
|
1220 |
|
1221 |
return $edit_link;
|
1233 |
|
1234 |
// Request handle
|
1235 |
$settings = array();
|
1236 |
+
parse_str( $_POST[ 'data' ], $settings );
|
1237 |
|
1238 |
// Show View output
|
1239 |
echo balanceTags( PT_CV_Functions::view_process_settings( null, $settings ) );
|
1252 |
check_ajax_referer( PT_CV_PREFIX_ . 'ajax_nonce', 'ajax_nonce' );
|
1253 |
|
1254 |
// Session id
|
1255 |
+
$session_id = empty( $_POST[ 'sid' ] ) ? '' : esc_sql( $_POST[ 'sid' ] );
|
1256 |
|
1257 |
// Get saved $settings
|
1258 |
$settings = get_transient( PT_CV_PREFIX . 'view-settings-' . $session_id );
|
1259 |
|
1260 |
// If empty, get settings by ID
|
1261 |
+
if ( !$settings ) {
|
1262 |
$settings = PT_CV_Functions::view_get_settings( $session_id );
|
1263 |
}
|
1264 |
|
1265 |
// Pagination settings
|
1266 |
+
$pargs = array( 'session_id' => $session_id, 'page' => (int) esc_sql( $_POST[ 'page' ] ) );
|
1267 |
|
1268 |
// Switch language
|
1269 |
+
$language = empty( $_POST[ 'lang' ] ) ? '' : esc_sql( $_POST[ 'lang' ] );
|
1270 |
self::switch_language( $language );
|
1271 |
|
1272 |
// Show View output
|
1281 |
*/
|
1282 |
static function util_show_promo_view() {
|
1283 |
$pro_installed = get_option( 'pt_cv_version_pro' );
|
1284 |
+
if ( !$pro_installed ) {
|
1285 |
?>
|
1286 |
<div class="pull-right" style="margin-top: -54px;">
|
1287 |
<a class="btn btn-success" target="_blank" href="http://www.contentviewspro.com/pricing/?utm_source=client&utm_medium=view">» Get Pro version</a>
|
1288 |
or
|
1289 |
<a class="btn btn-info" target="_blank" href="http://sample.contentviewspro.com/?utm_source=client&utm_medium=view">Check demo site</a>
|
1290 |
</div>
|
1291 |
+
<?php
|
1292 |
}
|
1293 |
}
|
1294 |
|
1301 |
static function pagination_generate_link( $class, $this_page, $label = '' ) {
|
1302 |
$data_page = '';
|
1303 |
|
1304 |
+
if ( !$label ) {
|
1305 |
+
$label = $this_page;
|
1306 |
+
$data_page = sprintf( ' data-page="%s"', $this_page );
|
1307 |
}
|
1308 |
|
1309 |
+
$html = sprintf( '<a%s href="%s">%s</a>', $data_page, add_query_arg( 'vpage', $this_page ), $label );
|
1310 |
+
$class = $class ? sprintf( ' class="%s"', esc_attr( $class ) ) : '';
|
1311 |
|
1312 |
return sprintf( '<li%s>%s</li>', $class, $html );
|
1313 |
}
|
1319 |
* @param int $current_page Current page number
|
1320 |
* @param int $pages_to_show Number of page to show
|
1321 |
*/
|
1322 |
+
static function pagination( $total_pages, $current_page = 1,
|
1323 |
+
$pages_to_show = 4 ) {
|
1324 |
if ( $total_pages == 1 )
|
1325 |
return '';
|
1326 |
|
1328 |
|
1329 |
// Define labels
|
1330 |
$labels = apply_filters( PT_CV_PREFIX_ . 'pagination_label', array(
|
1331 |
+
'prev' => '‹',
|
1332 |
+
'next' => '›',
|
1333 |
+
'first' => '«',
|
1334 |
+
'last' => '»',
|
1335 |
) );
|
1336 |
|
1337 |
+
$start = ( ( $current_page - $pages_to_show ) > 0 ) ? $current_page - $pages_to_show : 1;
|
1338 |
+
$end = ( ( $current_page + $pages_to_show ) < $total_pages ) ? $current_page + $pages_to_show : $total_pages;
|
1339 |
|
1340 |
+
$html = '';
|
1341 |
|
1342 |
$compared_page = 1;
|
1343 |
// First
|
1344 |
if ( $start > $compared_page ) {
|
1345 |
+
$html .= self::pagination_generate_link( '', $compared_page, $labels[ 'first' ] );
|
1346 |
}
|
1347 |
// Prev
|
1348 |
if ( $current_page > $compared_page ) {
|
1349 |
+
$html .= self::pagination_generate_link( '', $current_page - 1, $labels[ 'prev' ] );
|
1350 |
}
|
1351 |
|
1352 |
+
for ( $i = $start; $i <= $end; $i++ ) {
|
1353 |
$html .= self::pagination_generate_link( ( $current_page == $i ) ? 'active' : '', $i );
|
1354 |
}
|
1355 |
|
1356 |
$compared_page = $total_pages;
|
1357 |
// Next
|
1358 |
if ( $current_page < $total_pages ) {
|
1359 |
+
$html .= self::pagination_generate_link( '', $current_page + 1, $labels[ 'next' ] );
|
1360 |
}
|
1361 |
// Last
|
1362 |
if ( $end < $compared_page ) {
|
1363 |
+
$html .= self::pagination_generate_link( '', $compared_page, $labels[ 'last' ] );
|
1364 |
}
|
1365 |
|
1366 |
return $html;
|
1372 |
static function get_current_page( $pargs ) {
|
1373 |
$paged = 1;
|
1374 |
|
1375 |
+
if ( !empty( $pargs[ 'page' ] ) ) {
|
1376 |
+
$paged = intval( $pargs[ 'page' ] );
|
1377 |
}
|
1378 |
|
1379 |
+
if ( !empty( $_GET[ 'vpage' ] ) ) {
|
1380 |
+
$paged = intval( $_GET[ 'vpage' ] );
|
1381 |
}
|
1382 |
|
1383 |
return $paged;
|
includes/hooks.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Custom filters/actions
|
4 |
*
|
@@ -8,8 +9,7 @@
|
|
8 |
* @link http://www.contentviewspro.com/
|
9 |
* @copyright 2014 PT Guy
|
10 |
*/
|
11 |
-
|
12 |
-
if ( ! class_exists( 'PT_CV_Hooks' ) ) {
|
13 |
|
14 |
/**
|
15 |
* @name PT_CV_Hooks
|
@@ -38,66 +38,62 @@ if ( ! class_exists( 'PT_CV_Hooks' ) ) {
|
|
38 |
// echo "<pre>";
|
39 |
// var_dump( 'query args', $args );
|
40 |
// echo "</pre>";
|
41 |
-
|
42 |
// echo "<pre>";
|
43 |
// var_dump( 'display args', $dargs );
|
44 |
// echo "</pre>";
|
45 |
-
|
46 |
// Prefix string for error message
|
47 |
$messages = array(
|
48 |
-
'field'
|
49 |
'select' => __( 'Please select an option in : ', PT_CV_DOMAIN ),
|
50 |
-
'text'
|
51 |
),
|
52 |
-
'tab'
|
53 |
-
'filter'
|
54 |
-
'display'
|
55 |
),
|
56 |
);
|
57 |
|
58 |
/**
|
59 |
* Validate Query parameters
|
60 |
*/
|
61 |
-
|
62 |
// Post type
|
63 |
-
if ( empty( $args['post_type'] ) ) {
|
64 |
-
$errors[] = $messages['field']['select'] . $messages['tab']['filter'] . ' > ' . __( 'Content type', PT_CV_DOMAIN );
|
65 |
}
|
66 |
|
67 |
/**
|
68 |
* Validate common Display parameters
|
69 |
*/
|
70 |
-
|
71 |
// View type
|
72 |
-
if ( empty( $dargs['view-type'] ) ) {
|
73 |
-
$errors[] = $messages['field']['select'] . $messages['tab']['display'] . ' > ' . __( 'View type', PT_CV_DOMAIN );
|
74 |
}
|
75 |
|
76 |
// Layout format
|
77 |
-
if ( empty( $dargs['layout-format'] ) ) {
|
78 |
-
$errors[] = $messages['field']['select'] . $messages['tab']['display'] . ' > ' . __( 'Layout format', PT_CV_DOMAIN );
|
79 |
}
|
80 |
|
81 |
// Field settings
|
82 |
-
if ( !
|
83 |
-
$errors[] = $messages['field']['select'] . $messages['tab']['display'] . ' > ' . __( 'Fields settings', PT_CV_DOMAIN ) . ' > ' . __( 'Fields display', PT_CV_DOMAIN );
|
84 |
}
|
85 |
|
86 |
// Item per page
|
87 |
-
if ( isset( $dargs['pagination-settings'] ) ) {
|
88 |
-
if ( empty( $dargs['pagination-settings']['items-per-page'] ) ) {
|
89 |
-
$errors[] = $messages['field']['text'] . $messages['tab']['display'] . ' > ' . __( 'Pagination settings', PT_CV_DOMAIN ) . ' > ' . __( 'Items per page', PT_CV_DOMAIN );
|
90 |
}
|
91 |
}
|
92 |
|
93 |
/**
|
94 |
* Validate Display parameters of view types
|
95 |
*/
|
96 |
-
if ( !
|
97 |
-
switch ( $dargs['view-type'] ) {
|
98 |
case 'grid':
|
99 |
-
if ( empty( $dargs['number-columns'] ) ) {
|
100 |
-
$errors[] = $messages['field']['text'] . $messages['tab']['display'] . ' > ' . __( 'View type settings', PT_CV_DOMAIN ) . ' > ' . __( 'Items per row', PT_CV_DOMAIN );
|
101 |
}
|
102 |
break;
|
103 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Custom filters/actions
|
5 |
*
|
9 |
* @link http://www.contentviewspro.com/
|
10 |
* @copyright 2014 PT Guy
|
11 |
*/
|
12 |
+
if ( !class_exists( 'PT_CV_Hooks' ) ) {
|
|
|
13 |
|
14 |
/**
|
15 |
* @name PT_CV_Hooks
|
38 |
// echo "<pre>";
|
39 |
// var_dump( 'query args', $args );
|
40 |
// echo "</pre>";
|
|
|
41 |
// echo "<pre>";
|
42 |
// var_dump( 'display args', $dargs );
|
43 |
// echo "</pre>";
|
|
|
44 |
// Prefix string for error message
|
45 |
$messages = array(
|
46 |
+
'field' => array(
|
47 |
'select' => __( 'Please select an option in : ', PT_CV_DOMAIN ),
|
48 |
+
'text' => __( 'Please set value in : ', PT_CV_DOMAIN ),
|
49 |
),
|
50 |
+
'tab' => array(
|
51 |
+
'filter' => __( 'Filter Settings', PT_CV_DOMAIN ),
|
52 |
+
'display' => __( 'Display Settings', PT_CV_DOMAIN ),
|
53 |
),
|
54 |
);
|
55 |
|
56 |
/**
|
57 |
* Validate Query parameters
|
58 |
*/
|
|
|
59 |
// Post type
|
60 |
+
if ( empty( $args[ 'post_type' ] ) ) {
|
61 |
+
$errors[] = $messages[ 'field' ][ 'select' ] . $messages[ 'tab' ][ 'filter' ] . ' > ' . __( 'Content type', PT_CV_DOMAIN );
|
62 |
}
|
63 |
|
64 |
/**
|
65 |
* Validate common Display parameters
|
66 |
*/
|
|
|
67 |
// View type
|
68 |
+
if ( empty( $dargs[ 'view-type' ] ) ) {
|
69 |
+
$errors[] = $messages[ 'field' ][ 'select' ] . $messages[ 'tab' ][ 'display' ] . ' > ' . __( 'View type', PT_CV_DOMAIN );
|
70 |
}
|
71 |
|
72 |
// Layout format
|
73 |
+
if ( empty( $dargs[ 'layout-format' ] ) ) {
|
74 |
+
$errors[] = $messages[ 'field' ][ 'select' ] . $messages[ 'tab' ][ 'display' ] . ' > ' . __( 'Layout format', PT_CV_DOMAIN );
|
75 |
}
|
76 |
|
77 |
// Field settings
|
78 |
+
if ( !isset( $dargs[ 'fields' ] ) ) {
|
79 |
+
$errors[] = $messages[ 'field' ][ 'select' ] . $messages[ 'tab' ][ 'display' ] . ' > ' . __( 'Fields settings', PT_CV_DOMAIN ) . ' > ' . __( 'Fields display', PT_CV_DOMAIN );
|
80 |
}
|
81 |
|
82 |
// Item per page
|
83 |
+
if ( isset( $dargs[ 'pagination-settings' ] ) ) {
|
84 |
+
if ( empty( $dargs[ 'pagination-settings' ][ 'items-per-page' ] ) ) {
|
85 |
+
$errors[] = $messages[ 'field' ][ 'text' ] . $messages[ 'tab' ][ 'display' ] . ' > ' . __( 'Pagination settings', PT_CV_DOMAIN ) . ' > ' . __( 'Items per page', PT_CV_DOMAIN );
|
86 |
}
|
87 |
}
|
88 |
|
89 |
/**
|
90 |
* Validate Display parameters of view types
|
91 |
*/
|
92 |
+
if ( !empty( $dargs[ 'view-type' ] ) ) {
|
93 |
+
switch ( $dargs[ 'view-type' ] ) {
|
94 |
case 'grid':
|
95 |
+
if ( empty( $dargs[ 'number-columns' ] ) ) {
|
96 |
+
$errors[] = $messages[ 'field' ][ 'text' ] . $messages[ 'tab' ][ 'display' ] . ' > ' . __( 'View type settings', PT_CV_DOMAIN ) . ' > ' . __( 'Items per row', PT_CV_DOMAIN );
|
97 |
}
|
98 |
break;
|
99 |
}
|
includes/html-viewtype.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* HTML output for specific View types
|
4 |
*
|
@@ -8,8 +9,7 @@
|
|
8 |
* @link http://www.contentviewspro.com/
|
9 |
* @copyright 2014 PT Guy
|
10 |
*/
|
11 |
-
|
12 |
-
if ( ! class_exists( 'PT_CV_Html_ViewType' ) ) {
|
13 |
|
14 |
/**
|
15 |
* @name PT_CV_Html_ViewType
|
@@ -31,12 +31,12 @@ if ( ! class_exists( 'PT_CV_Html_ViewType' ) ) {
|
|
31 |
|
32 |
// -- Get column span
|
33 |
|
34 |
-
$columns = (int) $dargs['number-columns'];
|
35 |
-
if (
|
36 |
$columns = 1;
|
37 |
}
|
38 |
|
39 |
-
$span_width_last = $span_width
|
40 |
|
41 |
// Get span for the last column on row
|
42 |
if ( 12 % $columns ) {
|
@@ -47,10 +47,9 @@ if ( ! class_exists( 'PT_CV_Html_ViewType' ) ) {
|
|
47 |
$span_class = apply_filters( PT_CV_PREFIX_ . 'span_class', 'col-md-' );
|
48 |
|
49 |
// -- Row output
|
50 |
-
|
51 |
// Get wrapper class of a row
|
52 |
$row_classes = apply_filters( PT_CV_PREFIX_ . 'row_class', array( 'row', PT_CV_PREFIX . 'row' ) );
|
53 |
-
$row_class
|
54 |
|
55 |
return array( $columns, $span_width_last, $span_width, $span_class, $row_class );
|
56 |
}
|
@@ -80,9 +79,9 @@ if ( ! class_exists( 'PT_CV_Html_ViewType' ) ) {
|
|
80 |
$_span_width = ( $idx == count( $items_per_row ) - 1 ) ? $span_width_last : $span_width;
|
81 |
|
82 |
// Wrap content of item
|
83 |
-
$item_classes
|
84 |
-
$item_class
|
85 |
-
$row_html[]
|
86 |
|
87 |
$idx ++;
|
88 |
}
|
@@ -113,8 +112,8 @@ if ( ! class_exists( 'PT_CV_Html_ViewType' ) ) {
|
|
113 |
$collapsible_list = array();
|
114 |
foreach ( $content_items as $idx => $content_item ) {
|
115 |
// Replace class in body of collapsible item, to show one (now is the first item)
|
116 |
-
$class
|
117 |
-
$content_item
|
118 |
|
119 |
// Replace id in {data-parent="#ID"} of each item by generated id
|
120 |
$collapsible_list[] = str_replace( PT_CV_PREFIX_UPPER . 'ID', $random_id, $content_item );
|
@@ -149,12 +148,12 @@ if ( ! class_exists( 'PT_CV_Html_ViewType' ) ) {
|
|
149 |
$scrollable_html = array();
|
150 |
|
151 |
$scrollable_content_data = self::scrollable_content( $content_items );
|
152 |
-
$count_slides
|
153 |
-
$scrollable_content
|
154 |
|
155 |
// Js code
|
156 |
-
$interval
|
157 |
-
$js
|
158 |
|
159 |
$scrollable_html[] = PT_CV_Html::inline_script( $js );
|
160 |
|
@@ -162,19 +161,19 @@ if ( ! class_exists( 'PT_CV_Html_ViewType' ) ) {
|
|
162 |
$enable = apply_filters( PT_CV_PREFIX_ . 'scrollable_fields_enable', 1 );
|
163 |
|
164 |
// Indicator html
|
165 |
-
$show_indicator
|
166 |
-
$scrollable_html[]
|
167 |
|
168 |
// Content html
|
169 |
$scrollable_html[] = $scrollable_content;
|
170 |
|
171 |
// Control html
|
172 |
-
$show_navigation
|
173 |
-
$scrollable_html[]
|
174 |
|
175 |
// Get wrapper class scrollable
|
176 |
-
$scrollable_class
|
177 |
-
$content[]
|
178 |
}
|
179 |
|
180 |
/**
|
@@ -190,7 +189,7 @@ if ( ! class_exists( 'PT_CV_Html_ViewType' ) ) {
|
|
190 |
// Store content of a Scrollable list
|
191 |
$scrollable_content = array();
|
192 |
|
193 |
-
$rows = ( $dargs['number-rows'] ) ? (int) $dargs['number-rows'] : 1;
|
194 |
|
195 |
list( $columns, $span_width_last, $span_width, $span_class, $row_class ) = self::process_column_width( $content_items );
|
196 |
|
@@ -215,26 +214,26 @@ if ( ! class_exists( 'PT_CV_Html_ViewType' ) ) {
|
|
215 |
$_span_width = ( $idx == count( $items_per_row ) - 1 ) ? $span_width_last : $span_width;
|
216 |
|
217 |
// Wrap content of item
|
218 |
-
$item_classes
|
219 |
-
$item_class
|
220 |
-
$row_html[]
|
221 |
}
|
222 |
|
223 |
$slide_html[] = sprintf( '<div class="%1$s">%2$s</div>', esc_attr( $row_class ), implode( "\n", $row_html ) );
|
224 |
}
|
225 |
|
226 |
// Show first slide
|
227 |
-
$this_class
|
228 |
-
$scrollable_content[]
|
229 |
}
|
230 |
|
231 |
// Get class of wrapper of content of scrollable list
|
232 |
-
$content_class
|
233 |
-
$content
|
234 |
|
235 |
return array(
|
236 |
'scrollable_content' => $content,
|
237 |
-
'count_slides'
|
238 |
);
|
239 |
}
|
240 |
|
@@ -246,7 +245,7 @@ if ( ! class_exists( 'PT_CV_Html_ViewType' ) ) {
|
|
246 |
* @param int $count_slides The amount of items
|
247 |
*/
|
248 |
static function scrollable_indicator( $show, $wrapper_id, $count_slides ) {
|
249 |
-
if (
|
250 |
return '';
|
251 |
}
|
252 |
|
@@ -254,8 +253,8 @@ if ( ! class_exists( 'PT_CV_Html_ViewType' ) ) {
|
|
254 |
if ( $count_slides > 1 ) {
|
255 |
$li = array();
|
256 |
for ( $index = 0; $index < $count_slides; $index ++ ) {
|
257 |
-
$class
|
258 |
-
$li[]
|
259 |
}
|
260 |
|
261 |
$output = '<ol class="carousel-indicators">' . implode( "\n", $li ) . '</ol>';
|
@@ -272,24 +271,24 @@ if ( ! class_exists( 'PT_CV_Html_ViewType' ) ) {
|
|
272 |
* @param int $count_slides The amount of items
|
273 |
*/
|
274 |
static function scrollable_control( $show, $wrapper_id, $count_slides ) {
|
275 |
-
if (
|
276 |
return '';
|
277 |
}
|
278 |
$output = '';
|
279 |
if ( $count_slides > 1 ) {
|
280 |
$output = sprintf(
|
281 |
-
|
282 |
<span class="glyphicon glyphicon-chevron-left"></span>
|
283 |
</a>
|
284 |
<a class="right carousel-control" href="#%1$s" data-slide="next">
|
285 |
<span class="glyphicon glyphicon-chevron-right"></span>
|
286 |
-
</a>',
|
287 |
-
esc_attr( $wrapper_id )
|
288 |
);
|
289 |
}
|
290 |
|
291 |
return $output;
|
292 |
}
|
|
|
293 |
}
|
294 |
|
295 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* HTML output for specific View types
|
5 |
*
|
9 |
* @link http://www.contentviewspro.com/
|
10 |
* @copyright 2014 PT Guy
|
11 |
*/
|
12 |
+
if ( !class_exists( 'PT_CV_Html_ViewType' ) ) {
|
|
|
13 |
|
14 |
/**
|
15 |
* @name PT_CV_Html_ViewType
|
31 |
|
32 |
// -- Get column span
|
33 |
|
34 |
+
$columns = (int) $dargs[ 'number-columns' ];
|
35 |
+
if ( !$columns ) {
|
36 |
$columns = 1;
|
37 |
}
|
38 |
|
39 |
+
$span_width_last = $span_width = (int) ( 12 / $columns );
|
40 |
|
41 |
// Get span for the last column on row
|
42 |
if ( 12 % $columns ) {
|
47 |
$span_class = apply_filters( PT_CV_PREFIX_ . 'span_class', 'col-md-' );
|
48 |
|
49 |
// -- Row output
|
|
|
50 |
// Get wrapper class of a row
|
51 |
$row_classes = apply_filters( PT_CV_PREFIX_ . 'row_class', array( 'row', PT_CV_PREFIX . 'row' ) );
|
52 |
+
$row_class = implode( ' ', array_filter( $row_classes ) );
|
53 |
|
54 |
return array( $columns, $span_width_last, $span_width, $span_class, $row_class );
|
55 |
}
|
79 |
$_span_width = ( $idx == count( $items_per_row ) - 1 ) ? $span_width_last : $span_width;
|
80 |
|
81 |
// Wrap content of item
|
82 |
+
$item_classes = apply_filters( PT_CV_PREFIX_ . 'item_col_class', array( $span_class . $_span_width ), $_span_width );
|
83 |
+
$item_class = implode( ' ', array_filter( $item_classes ) );
|
84 |
+
$row_html[] = PT_CV_Html::content_item_wrap( $content_item, $item_class, $post_id );
|
85 |
|
86 |
$idx ++;
|
87 |
}
|
112 |
$collapsible_list = array();
|
113 |
foreach ( $content_items as $idx => $content_item ) {
|
114 |
// Replace class in body of collapsible item, to show one (now is the first item)
|
115 |
+
$class = ( $idx == 0 ) ? 'in' : '';
|
116 |
+
$content_item = str_replace( PT_CV_PREFIX_UPPER . 'CLASS', $class, $content_item );
|
117 |
|
118 |
// Replace id in {data-parent="#ID"} of each item by generated id
|
119 |
$collapsible_list[] = str_replace( PT_CV_PREFIX_UPPER . 'ID', $random_id, $content_item );
|
148 |
$scrollable_html = array();
|
149 |
|
150 |
$scrollable_content_data = self::scrollable_content( $content_items );
|
151 |
+
$count_slides = $scrollable_content_data[ 'count_slides' ];
|
152 |
+
$scrollable_content = $scrollable_content_data[ 'scrollable_content' ];
|
153 |
|
154 |
// Js code
|
155 |
+
$interval = apply_filters( PT_CV_PREFIX_ . 'scrollable_interval', 'false' );
|
156 |
+
$js = "$('#$wrapper_id').carousel({ interval : $interval })";
|
157 |
|
158 |
$scrollable_html[] = PT_CV_Html::inline_script( $js );
|
159 |
|
161 |
$enable = apply_filters( PT_CV_PREFIX_ . 'scrollable_fields_enable', 1 );
|
162 |
|
163 |
// Indicator html
|
164 |
+
$show_indicator = isset( $dargs[ 'view-type-settings' ][ 'indicator' ] ) ? $dargs[ 'view-type-settings' ][ 'indicator' ] : $enable;
|
165 |
+
$scrollable_html[] = self::scrollable_indicator( $show_indicator, $wrapper_id, $count_slides );
|
166 |
|
167 |
// Content html
|
168 |
$scrollable_html[] = $scrollable_content;
|
169 |
|
170 |
// Control html
|
171 |
+
$show_navigation = isset( $dargs[ 'view-type-settings' ][ 'navigation' ] ) ? $dargs[ 'view-type-settings' ][ 'navigation' ] : $enable;
|
172 |
+
$scrollable_html[] = self::scrollable_control( $show_navigation, $wrapper_id, $count_slides );
|
173 |
|
174 |
// Get wrapper class scrollable
|
175 |
+
$scrollable_class = apply_filters( PT_CV_PREFIX_ . 'scrollable_class', 'carousel slide' );
|
176 |
+
$content[] = sprintf( '<div id="%s" class="%s" data-ride="carousel">%s</div>', esc_attr( $wrapper_id ), esc_attr( $scrollable_class ), implode( "\n", $scrollable_html ) );
|
177 |
}
|
178 |
|
179 |
/**
|
189 |
// Store content of a Scrollable list
|
190 |
$scrollable_content = array();
|
191 |
|
192 |
+
$rows = ( $dargs[ 'number-rows' ] ) ? (int) $dargs[ 'number-rows' ] : 1;
|
193 |
|
194 |
list( $columns, $span_width_last, $span_width, $span_class, $row_class ) = self::process_column_width( $content_items );
|
195 |
|
214 |
$_span_width = ( $idx == count( $items_per_row ) - 1 ) ? $span_width_last : $span_width;
|
215 |
|
216 |
// Wrap content of item
|
217 |
+
$item_classes = apply_filters( PT_CV_PREFIX_ . 'item_col_class', array( $span_class . $_span_width ), $_span_width );
|
218 |
+
$item_class = implode( ' ', array_filter( $item_classes ) );
|
219 |
+
$row_html[] = PT_CV_Html::content_item_wrap( $content_item, $item_class );
|
220 |
}
|
221 |
|
222 |
$slide_html[] = sprintf( '<div class="%1$s">%2$s</div>', esc_attr( $row_class ), implode( "\n", $row_html ) );
|
223 |
}
|
224 |
|
225 |
// Show first slide
|
226 |
+
$this_class = $slide_class . ( ( $s_idx == 0 ) ? ' active' : '' );
|
227 |
+
$scrollable_content[] = sprintf( '<div class="%s">%s</div>', esc_attr( $this_class ), implode( "\n", $slide_html ) );
|
228 |
}
|
229 |
|
230 |
// Get class of wrapper of content of scrollable list
|
231 |
+
$content_class = apply_filters( PT_CV_PREFIX_ . 'scrollable_content_class', 'carousel-inner' );
|
232 |
+
$content = sprintf( '<div class="%s">%s</div>', esc_attr( $content_class ), implode( "\n", $scrollable_content ) );
|
233 |
|
234 |
return array(
|
235 |
'scrollable_content' => $content,
|
236 |
+
'count_slides' => count( $slides_item ),
|
237 |
);
|
238 |
}
|
239 |
|
245 |
* @param int $count_slides The amount of items
|
246 |
*/
|
247 |
static function scrollable_indicator( $show, $wrapper_id, $count_slides ) {
|
248 |
+
if ( !$show ) {
|
249 |
return '';
|
250 |
}
|
251 |
|
253 |
if ( $count_slides > 1 ) {
|
254 |
$li = array();
|
255 |
for ( $index = 0; $index < $count_slides; $index ++ ) {
|
256 |
+
$class = ( $index == 0 ) ? 'active' : '';
|
257 |
+
$li[] = sprintf( '<li data-target="#%s" data-slide-to="%s" class="%s"></li>', esc_attr( $wrapper_id ), esc_attr( $index ), $class );
|
258 |
}
|
259 |
|
260 |
$output = '<ol class="carousel-indicators">' . implode( "\n", $li ) . '</ol>';
|
271 |
* @param int $count_slides The amount of items
|
272 |
*/
|
273 |
static function scrollable_control( $show, $wrapper_id, $count_slides ) {
|
274 |
+
if ( !$show ) {
|
275 |
return '';
|
276 |
}
|
277 |
$output = '';
|
278 |
if ( $count_slides > 1 ) {
|
279 |
$output = sprintf(
|
280 |
+
'<a class="left carousel-control" href="#%1$s" data-slide="prev">
|
281 |
<span class="glyphicon glyphicon-chevron-left"></span>
|
282 |
</a>
|
283 |
<a class="right carousel-control" href="#%1$s" data-slide="next">
|
284 |
<span class="glyphicon glyphicon-chevron-right"></span>
|
285 |
+
</a>', esc_attr( $wrapper_id )
|
|
|
286 |
);
|
287 |
}
|
288 |
|
289 |
return $output;
|
290 |
}
|
291 |
+
|
292 |
}
|
293 |
|
294 |
}
|
includes/html.php
CHANGED
@@ -8,8 +8,7 @@
|
|
8 |
* @link http://www.contentviewspro.com/
|
9 |
* @copyright 2014 PT Guy
|
10 |
*/
|
11 |
-
|
12 |
-
if ( ! class_exists( 'PT_CV_Html' ) ) {
|
13 |
|
14 |
/**
|
15 |
* @name PT_CV_Html
|
@@ -18,9 +17,9 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
18 |
class PT_CV_Html {
|
19 |
|
20 |
// Store directory of selected view_types
|
21 |
-
static $view_type_dir
|
22 |
// Store all selected styles
|
23 |
-
static $style
|
24 |
|
25 |
/**
|
26 |
* return class for Panel (Group of) group of params
|
@@ -80,7 +79,8 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
80 |
* @param string $content Content
|
81 |
* @param bool $show Show/hide the content
|
82 |
*/
|
83 |
-
static function html_collapse_one( $parent_id, $id, $heading, $content = '',
|
|
|
84 |
$class = $show ? 'in' : '';
|
85 |
ob_start();
|
86 |
?>
|
@@ -155,7 +155,8 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
155 |
*
|
156 |
* @return string
|
157 |
*/
|
158 |
-
static function link_button( $link, $style, $text = 'Button', $class = '',
|
|
|
159 |
return sprintf( '<a href="%s" class="btn btn-%s %s %s">%s</a>', $link, $style, $class, $size, $text );
|
160 |
}
|
161 |
|
@@ -182,19 +183,19 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
182 |
|
183 |
if ( is_dir( $view_type_dir ) ) {
|
184 |
// Store view type & asset information
|
185 |
-
self::$view_type_dir[]
|
186 |
-
self::$style[]
|
187 |
|
188 |
// Generate HTML output of all content fields
|
189 |
$fields_html = array();
|
190 |
-
foreach ( $dargs['fields'] as $field_name ) {
|
191 |
// Get settings of fields
|
192 |
-
$fargs = isset( $dargs['field-settings'] ) ? $dargs['field-settings'] : array();
|
193 |
|
194 |
-
$fargs['layout-format'] = $dargs['layout-format'];
|
195 |
|
196 |
// Get HTML output of field
|
197 |
-
$fields_html[$field_name] = self::field_item_html( $field_name, $post, $fargs );
|
198 |
}
|
199 |
|
200 |
$fields_html = apply_filters( PT_CV_PREFIX_ . 'fields_html', $fields_html, $post );
|
@@ -231,14 +232,14 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
231 |
|
232 |
if ( is_array( $dargs ) ) {
|
233 |
// If only show Title
|
234 |
-
if ( isset( $dargs['fields'] ) && count( (array) $dargs['fields'] ) == 1 && $dargs['fields'][0] === 'title' ) {
|
235 |
$class .= ' ' . PT_CV_PREFIX . 'only-title';
|
236 |
}
|
237 |
}
|
238 |
|
239 |
// Get wrapper class of a item
|
240 |
-
$layout
|
241 |
-
$item_class
|
242 |
|
243 |
$item_filter = apply_filters( PT_CV_PREFIX_ . 'content_item_filter_value', '', $post_id );
|
244 |
|
@@ -262,7 +263,8 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
262 |
*
|
263 |
* @return string Full HTML output for Content View
|
264 |
*/
|
265 |
-
static function content_items_wrap( $content_items, $current_page,
|
|
|
266 |
global $dargs, $pt_cv_content_items;
|
267 |
|
268 |
if ( empty( $content_items ) ) {
|
@@ -272,15 +274,15 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
272 |
// Assign as global variable
|
273 |
$pt_cv_content_items = $content_items;
|
274 |
|
275 |
-
$type
|
276 |
$display = ( $type == 'ajax' && $current_page === 1 ) || $type == 'normal';
|
277 |
|
278 |
// 1. Before output
|
279 |
$before_output = $display ? apply_filters( PT_CV_PREFIX_ . 'before_output_html', '' ) : '';
|
280 |
|
281 |
// 2. Output content
|
282 |
-
$content
|
283 |
-
$view_type
|
284 |
|
285 |
// Separate items by row, column
|
286 |
switch ( $view_type ) {
|
@@ -321,16 +323,16 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
321 |
$content_list = balanceTags( implode( "\n", $content ) );
|
322 |
|
323 |
// Custom attribute of a page
|
324 |
-
$page_attr_
|
325 |
-
$page_attr
|
326 |
|
327 |
// Wrap items in 'page' wrapper
|
328 |
$wrap_in_page = apply_filters( PT_CV_PREFIX_ . 'wrap_in_page', true );
|
329 |
if ( $wrap_in_page ) {
|
330 |
// Wrap in page wrapper
|
331 |
-
$html
|
332 |
// Remove page attribute value
|
333 |
-
$page_attr
|
334 |
} else {
|
335 |
$html = $content_list;
|
336 |
}
|
@@ -371,14 +373,14 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
371 |
$html = '';
|
372 |
|
373 |
// Get other settings
|
374 |
-
$oargs = isset( $dargs['other-settings'] ) ? $dargs['other-settings'] : array();
|
375 |
|
376 |
switch ( $field_name ) {
|
377 |
|
378 |
// Thumbnail
|
379 |
case 'thumbnail':
|
380 |
|
381 |
-
if ( empty( $fargs['thumbnail'] ) ) {
|
382 |
break;
|
383 |
}
|
384 |
|
@@ -396,7 +398,7 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
396 |
// Content
|
397 |
case 'content':
|
398 |
|
399 |
-
if ( empty( $fargs['content'] ) ) {
|
400 |
break;
|
401 |
}
|
402 |
|
@@ -407,11 +409,11 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
407 |
// Meta fields
|
408 |
case 'meta-fields':
|
409 |
|
410 |
-
if ( empty( $fargs['meta-fields'] ) ) {
|
411 |
break;
|
412 |
}
|
413 |
|
414 |
-
$html = self::_field_meta( $post, $fargs['meta-fields'] );
|
415 |
|
416 |
break;
|
417 |
|
@@ -446,8 +448,7 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
446 |
$title = apply_filters( PT_CV_PREFIX_ . 'field_title_result', $title, $fargs );
|
447 |
|
448 |
$html = sprintf(
|
449 |
-
|
450 |
-
$tag, esc_attr( $title_class ), self::_field_href( $oargs, $post, $title )
|
451 |
);
|
452 |
|
453 |
return $html;
|
@@ -465,7 +466,7 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
465 |
global $dargs;
|
466 |
|
467 |
// Get other settings
|
468 |
-
$oargs = isset( $dargs['other-settings'] ) ? $dargs['other-settings'] : array();
|
469 |
|
470 |
// Sets up global post data
|
471 |
setup_postdata( $post );
|
@@ -481,30 +482,30 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
481 |
|
482 |
// Get full content/exceprt
|
483 |
$content = '';
|
484 |
-
switch ( $fargs['content']['show'] ) {
|
485 |
case 'excerpt':
|
486 |
-
$length
|
487 |
-
$readmore_btn
|
488 |
-
$dots
|
489 |
-
$readmore_html
|
490 |
|
491 |
// Read more button
|
492 |
-
if ( apply_filters( PT_CV_PREFIX_ . 'field_content_readmore_enable', 1, $fargs['content'] ) ) {
|
493 |
-
$text
|
494 |
-
$btn_class
|
495 |
$readmore_btn .= self::_field_href( $oargs, $post, $text, PT_CV_PREFIX . 'readmore ' . $btn_class );
|
496 |
$readmore_html .= apply_filters( PT_CV_PREFIX_ . 'field_content_readmore_seperated', '<br/>', $fargs ) . $readmore_btn;
|
497 |
}
|
498 |
|
499 |
// Get excerpt
|
500 |
if ( $length > 0 ) {
|
501 |
-
$content_to_extract
|
502 |
// Extract excerpt from content
|
503 |
-
$excerpt
|
504 |
// Get manual excerpt
|
505 |
-
$excerpt
|
506 |
// Append readmore button
|
507 |
-
$content
|
508 |
} else {
|
509 |
// Display only readmore button if length <= 0
|
510 |
$content = $readmore_btn;
|
@@ -526,8 +527,7 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
526 |
$content = apply_filters( PT_CV_PREFIX_ . 'field_content_final', $content, $post );
|
527 |
|
528 |
$html = rtrim( $content, '.' ) ? sprintf(
|
529 |
-
|
530 |
-
$tag, esc_attr( $content_class ), force_balance_tags( $content )
|
531 |
) : '';
|
532 |
|
533 |
return $html;
|
@@ -543,7 +543,7 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
543 |
static function _field_href( $oargs, $post, $content, $defined_class = '' ) {
|
544 |
|
545 |
// Open in
|
546 |
-
$open_in = isset( $oargs['open-in'] ) ? $oargs['open-in'] : '_blank';
|
547 |
|
548 |
// Class of href
|
549 |
$href_class = apply_filters( PT_CV_PREFIX_ . 'field_href_class', array( $open_in, $defined_class ), $oargs );
|
@@ -563,8 +563,7 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
563 |
|
564 |
// Generate a tag
|
565 |
$html = sprintf(
|
566 |
-
|
567 |
-
$href, implode( ' ', array_filter( $href_class ) ), $open_in, implode( ' ', array_filter( $custom_attr ) ), balanceTags( $content )
|
568 |
);
|
569 |
|
570 |
return $html;
|
@@ -582,10 +581,10 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
582 |
global $dargs;
|
583 |
|
584 |
// Get layout format
|
585 |
-
$layout_format = $fargs['layout-format'];
|
586 |
|
587 |
// Get thumbnail settings
|
588 |
-
$fargs = $fargs['thumbnail'];
|
589 |
|
590 |
$html = '';
|
591 |
|
@@ -593,33 +592,33 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
593 |
$post_id = $post->ID;
|
594 |
|
595 |
// Custom args for get_the_post_thumbnail function
|
596 |
-
$thumbnail_class
|
597 |
-
$thumbnail_class[]
|
598 |
-
$thumbnail_class[]
|
599 |
if ( $layout_format === '2-col' ) {
|
600 |
-
$thumbnail_class[] = isset( $fargs['position'] ) ? 'pull-' . $fargs['position'] : 'pull-left';
|
601 |
}
|
602 |
$gargs = array(
|
603 |
'class' => apply_filters( PT_CV_PREFIX_ . 'field_thumbnail_class', implode( ' ', array_filter( $thumbnail_class ) ) ),
|
604 |
);
|
605 |
|
606 |
// Get thumbnail dimensions
|
607 |
-
$dimensions
|
608 |
-
$dimensions
|
609 |
|
610 |
// Check if has thumbnail ( has_post_thumbnail doesn't works )
|
611 |
$has_thumbnail = get_the_post_thumbnail( $post_id );
|
612 |
-
if ( !
|
613 |
-
$thumbnail_size
|
614 |
-
$html
|
615 |
-
$html
|
616 |
} else {
|
617 |
$html = apply_filters( PT_CV_PREFIX_ . 'field_thumbnail_not_found', $html, $post, $dimensions, $gargs );
|
618 |
}
|
619 |
|
620 |
// Add link to thumbnail
|
621 |
-
$oargs
|
622 |
-
$html
|
623 |
|
624 |
return $html;
|
625 |
}
|
@@ -640,54 +639,54 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
640 |
setup_postdata( $post );
|
641 |
|
642 |
foreach ( $fargs as $meta => $val ) {
|
643 |
-
if (
|
644 |
continue;
|
645 |
}
|
646 |
|
647 |
switch ( $meta ) {
|
648 |
case 'date':
|
649 |
// Get date wrapper class
|
650 |
-
$date_class
|
651 |
$prefix_text = apply_filters( PT_CV_PREFIX_ . 'field_meta_prefix_text', '', 'date' );
|
652 |
-
$date
|
653 |
|
654 |
-
$html['date'] = sprintf( '<span class="%s">%s <time datetime="%s">%s</time></span>', esc_html( $date_class ), balanceTags( $prefix_text ), esc_attr( get_the_date( 'c' ) ), esc_html( $date ) );
|
655 |
break;
|
656 |
|
657 |
case 'taxonomy':
|
658 |
|
659 |
// Get terms wrapper class
|
660 |
-
$term_class
|
661 |
$prefix_text = apply_filters( PT_CV_PREFIX_ . 'field_meta_prefix_text', __( 'in', PT_CV_DOMAIN ), 'terms' );
|
662 |
|
663 |
$terms = PT_CV_Functions::post_terms( $post );
|
664 |
-
if ( !
|
665 |
-
$term_html
|
666 |
-
$html['taxonomy']
|
667 |
}
|
668 |
break;
|
669 |
|
670 |
case 'comment':
|
671 |
-
if ( !
|
672 |
// Get comment wrapper class
|
673 |
-
$comment_class
|
674 |
-
$prefix_text
|
675 |
|
676 |
ob_start();
|
677 |
comments_popup_link( __( 'Leave a comment', PT_CV_DOMAIN ), __( '1 Comment', PT_CV_DOMAIN ), __( '% Comments', PT_CV_DOMAIN ) );
|
678 |
-
$comment_content
|
679 |
-
$html['comment']
|
680 |
endif;
|
681 |
break;
|
682 |
|
683 |
case 'author':
|
684 |
|
685 |
// Get author wrapper class
|
686 |
-
$author_class
|
687 |
-
$prefix_text
|
688 |
|
689 |
-
$author_html
|
690 |
-
$html['author']
|
691 |
break;
|
692 |
|
693 |
default:
|
@@ -717,7 +716,7 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
717 |
*/
|
718 |
static function _field_meta_wrap( $meta_html, $seperator = NULL ) {
|
719 |
|
720 |
-
if (
|
721 |
return '';
|
722 |
}
|
723 |
|
@@ -731,8 +730,7 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
731 |
|
732 |
// Define wrapper
|
733 |
$wrapper = sprintf(
|
734 |
-
|
735 |
-
$tag, esc_attr( $meta_fields_class ), '%s'
|
736 |
);
|
737 |
|
738 |
// Join fields
|
@@ -756,14 +754,14 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
756 |
static function pagination_output( $max_num_pages, $current_page, $session_id ) {
|
757 |
global $dargs;
|
758 |
|
759 |
-
if (
|
760 |
return '';
|
761 |
}
|
762 |
|
763 |
$pagination_btn = '';
|
764 |
|
765 |
-
$type
|
766 |
-
$style
|
767 |
|
768 |
if ( $type == 'normal' || $style == 'regular' ) {
|
769 |
$pagination_btn = sprintf( '<ul class="%s" data-totalpages="%s" data-sid="%s">%s</ul>', PT_CV_PREFIX . 'pagination' . ' ' . PT_CV_PREFIX . $type . ' pagination', esc_attr( $max_num_pages ), esc_attr( $session_id ), PT_CV_Functions::pagination( $max_num_pages, $current_page ) );
|
@@ -773,8 +771,8 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
773 |
// Add loading icon
|
774 |
$pagination_btn .= self::html_loading_img( 12, PT_CV_PREFIX . 'spinner' );
|
775 |
|
776 |
-
$wrapper_class
|
777 |
-
$output
|
778 |
|
779 |
return $output;
|
780 |
}
|
@@ -787,34 +785,34 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
787 |
global $processed_view_assets, $pt_view_sid;
|
788 |
|
789 |
// If already processed | have no View on this page -> return
|
790 |
-
if ( ( $processed_view_assets && isset( $processed_view_assets[$pt_view_sid] ) ) ||
|
791 |
return;
|
792 |
}
|
793 |
// Mark as processed
|
794 |
-
if (
|
795 |
$processed_view_assets = array();
|
796 |
}
|
797 |
-
$processed_view_assets[$pt_view_sid] = 1;
|
798 |
|
799 |
// Get settings option
|
800 |
$options = get_option( PT_CV_OPTION_NAME );
|
801 |
|
802 |
// Print inline view styles & scripts
|
803 |
if ( apply_filters( PT_CV_PREFIX_ . 'assets_verbose_loading', 1 ) ) {
|
804 |
-
$assets
|
805 |
-
$assets_output
|
806 |
|
807 |
// Get content of asset files in directory of view type
|
808 |
foreach ( self::$view_type_dir as $idx => $view_type_dir ) {
|
809 |
// Get selected style of current view type
|
810 |
-
$style = self::$style[$idx];
|
811 |
|
812 |
// With each type of asset (css, js), looking for suit file of selected style
|
813 |
foreach ( $assets as $type ) {
|
814 |
-
$file_path
|
815 |
-
$content
|
816 |
if ( $content ) {
|
817 |
-
$assets_output[$type][] = $content;
|
818 |
}
|
819 |
}
|
820 |
}
|
@@ -847,8 +845,8 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
847 |
// Enqueue merged asset contents
|
848 |
foreach ( $assets_files as $type => $srcs ) {
|
849 |
foreach ( $srcs as $src ) {
|
850 |
-
$type
|
851 |
-
$function
|
852 |
|
853 |
if ( function_exists( $function ) ) {
|
854 |
$function( PT_CV_PREFIX . $type, $src );
|
@@ -873,7 +871,7 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
873 |
// Get settings option
|
874 |
$options = get_option( PT_CV_OPTION_NAME );
|
875 |
|
876 |
-
if ( $is_admin || !
|
877 |
// Load bootstrap js
|
878 |
PT_CV_Asset::enqueue( 'bootstrap' );
|
879 |
}
|
@@ -883,39 +881,39 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
883 |
|
884 |
// Public script
|
885 |
PT_CV_Asset::enqueue(
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
);
|
891 |
|
892 |
// Localize for Public script
|
893 |
PT_CV_Asset::localize_script(
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
);
|
904 |
|
905 |
// Localize for Pagination script
|
906 |
PT_CV_Asset::localize_script(
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
);
|
920 |
}
|
921 |
|
@@ -929,30 +927,30 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
929 |
// Get settings option
|
930 |
$options = get_option( PT_CV_OPTION_NAME );
|
931 |
|
932 |
-
if ( !
|
933 |
PT_CV_Asset::enqueue( 'bootstrap', 'style' );
|
934 |
}
|
935 |
|
936 |
PT_CV_Asset::enqueue(
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
);
|
941 |
|
942 |
// Fix bootstrap error in IE
|
943 |
global $is_IE;
|
944 |
if ( $is_IE ) {
|
945 |
PT_CV_Asset::enqueue(
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
);
|
951 |
PT_CV_Asset::enqueue(
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
);
|
957 |
}
|
958 |
}
|
@@ -971,10 +969,10 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
971 |
ob_start();
|
972 |
?>
|
973 |
<script type="text/javascript" id="<?php echo esc_attr( PT_CV_PREFIX . 'inline-script-' . $random_id ); ?>">
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
</script>
|
979 |
<?php
|
980 |
return ob_get_clean();
|
@@ -997,6 +995,7 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
997 |
<?php
|
998 |
return ob_get_clean();
|
999 |
}
|
|
|
1000 |
}
|
1001 |
|
1002 |
}
|
8 |
* @link http://www.contentviewspro.com/
|
9 |
* @copyright 2014 PT Guy
|
10 |
*/
|
11 |
+
if ( !class_exists( 'PT_CV_Html' ) ) {
|
|
|
12 |
|
13 |
/**
|
14 |
* @name PT_CV_Html
|
17 |
class PT_CV_Html {
|
18 |
|
19 |
// Store directory of selected view_types
|
20 |
+
static $view_type_dir = array();
|
21 |
// Store all selected styles
|
22 |
+
static $style = array();
|
23 |
|
24 |
/**
|
25 |
* return class for Panel (Group of) group of params
|
79 |
* @param string $content Content
|
80 |
* @param bool $show Show/hide the content
|
81 |
*/
|
82 |
+
static function html_collapse_one( $parent_id, $id, $heading, $content = '',
|
83 |
+
$show = true ) {
|
84 |
$class = $show ? 'in' : '';
|
85 |
ob_start();
|
86 |
?>
|
155 |
*
|
156 |
* @return string
|
157 |
*/
|
158 |
+
static function link_button( $link, $style, $text = 'Button', $class = '',
|
159 |
+
$size = '' ) {
|
160 |
return sprintf( '<a href="%s" class="btn btn-%s %s %s">%s</a>', $link, $style, $class, $size, $text );
|
161 |
}
|
162 |
|
183 |
|
184 |
if ( is_dir( $view_type_dir ) ) {
|
185 |
// Store view type & asset information
|
186 |
+
self::$view_type_dir[] = $view_type_assets_dir;
|
187 |
+
self::$style[] = $style;
|
188 |
|
189 |
// Generate HTML output of all content fields
|
190 |
$fields_html = array();
|
191 |
+
foreach ( $dargs[ 'fields' ] as $field_name ) {
|
192 |
// Get settings of fields
|
193 |
+
$fargs = isset( $dargs[ 'field-settings' ] ) ? $dargs[ 'field-settings' ] : array();
|
194 |
|
195 |
+
$fargs[ 'layout-format' ] = $dargs[ 'layout-format' ];
|
196 |
|
197 |
// Get HTML output of field
|
198 |
+
$fields_html[ $field_name ] = self::field_item_html( $field_name, $post, $fargs );
|
199 |
}
|
200 |
|
201 |
$fields_html = apply_filters( PT_CV_PREFIX_ . 'fields_html', $fields_html, $post );
|
232 |
|
233 |
if ( is_array( $dargs ) ) {
|
234 |
// If only show Title
|
235 |
+
if ( isset( $dargs[ 'fields' ] ) && count( (array) $dargs[ 'fields' ] ) == 1 && $dargs[ 'fields' ][ 0 ] === 'title' ) {
|
236 |
$class .= ' ' . PT_CV_PREFIX . 'only-title';
|
237 |
}
|
238 |
}
|
239 |
|
240 |
// Get wrapper class of a item
|
241 |
+
$layout = $dargs[ 'layout-format' ];
|
242 |
+
$item_class = apply_filters( PT_CV_PREFIX_ . 'content_item_class', array( $class, PT_CV_PREFIX . 'content-item', PT_CV_PREFIX . $layout ) );
|
243 |
|
244 |
$item_filter = apply_filters( PT_CV_PREFIX_ . 'content_item_filter_value', '', $post_id );
|
245 |
|
263 |
*
|
264 |
* @return string Full HTML output for Content View
|
265 |
*/
|
266 |
+
static function content_items_wrap( $content_items, $current_page,
|
267 |
+
$post_per_page, $id ) {
|
268 |
global $dargs, $pt_cv_content_items;
|
269 |
|
270 |
if ( empty( $content_items ) ) {
|
274 |
// Assign as global variable
|
275 |
$pt_cv_content_items = $content_items;
|
276 |
|
277 |
+
$type = isset( $dargs[ 'pagination-settings' ][ 'type' ] ) ? $dargs[ 'pagination-settings' ][ 'type' ] : 'ajax';
|
278 |
$display = ( $type == 'ajax' && $current_page === 1 ) || $type == 'normal';
|
279 |
|
280 |
// 1. Before output
|
281 |
$before_output = $display ? apply_filters( PT_CV_PREFIX_ . 'before_output_html', '' ) : '';
|
282 |
|
283 |
// 2. Output content
|
284 |
+
$content = array();
|
285 |
+
$view_type = $dargs[ 'view-type' ];
|
286 |
|
287 |
// Separate items by row, column
|
288 |
switch ( $view_type ) {
|
323 |
$content_list = balanceTags( implode( "\n", $content ) );
|
324 |
|
325 |
// Custom attribute of a page
|
326 |
+
$page_attr_ = apply_filters( PT_CV_PREFIX_ . 'page_attr', '', $view_type, $content_items );
|
327 |
+
$page_attr = strip_tags( $page_attr_ );
|
328 |
|
329 |
// Wrap items in 'page' wrapper
|
330 |
$wrap_in_page = apply_filters( PT_CV_PREFIX_ . 'wrap_in_page', true );
|
331 |
if ( $wrap_in_page ) {
|
332 |
// Wrap in page wrapper
|
333 |
+
$html = sprintf( '<div id="%s" class="%s" %s>%s</div>', esc_attr( PT_CV_PREFIX . 'page' . '-' . $current_page ), esc_attr( PT_CV_PREFIX . 'page' ), $page_attr, $content_list );
|
334 |
// Remove page attribute value
|
335 |
+
$page_attr = '';
|
336 |
} else {
|
337 |
$html = $content_list;
|
338 |
}
|
373 |
$html = '';
|
374 |
|
375 |
// Get other settings
|
376 |
+
$oargs = isset( $dargs[ 'other-settings' ] ) ? $dargs[ 'other-settings' ] : array();
|
377 |
|
378 |
switch ( $field_name ) {
|
379 |
|
380 |
// Thumbnail
|
381 |
case 'thumbnail':
|
382 |
|
383 |
+
if ( empty( $fargs[ 'thumbnail' ] ) ) {
|
384 |
break;
|
385 |
}
|
386 |
|
398 |
// Content
|
399 |
case 'content':
|
400 |
|
401 |
+
if ( empty( $fargs[ 'content' ] ) ) {
|
402 |
break;
|
403 |
}
|
404 |
|
409 |
// Meta fields
|
410 |
case 'meta-fields':
|
411 |
|
412 |
+
if ( empty( $fargs[ 'meta-fields' ] ) ) {
|
413 |
break;
|
414 |
}
|
415 |
|
416 |
+
$html = self::_field_meta( $post, $fargs[ 'meta-fields' ] );
|
417 |
|
418 |
break;
|
419 |
|
448 |
$title = apply_filters( PT_CV_PREFIX_ . 'field_title_result', $title, $fargs );
|
449 |
|
450 |
$html = sprintf(
|
451 |
+
'<%1$s class="%2$s">%3$s</%1$s>', $tag, esc_attr( $title_class ), self::_field_href( $oargs, $post, $title )
|
|
|
452 |
);
|
453 |
|
454 |
return $html;
|
466 |
global $dargs;
|
467 |
|
468 |
// Get other settings
|
469 |
+
$oargs = isset( $dargs[ 'other-settings' ] ) ? $dargs[ 'other-settings' ] : array();
|
470 |
|
471 |
// Sets up global post data
|
472 |
setup_postdata( $post );
|
482 |
|
483 |
// Get full content/exceprt
|
484 |
$content = '';
|
485 |
+
switch ( $fargs[ 'content' ][ 'show' ] ) {
|
486 |
case 'excerpt':
|
487 |
+
$length = (int) $fargs[ 'content' ][ 'length' ];
|
488 |
+
$readmore_btn = '';
|
489 |
+
$dots = ' ...';
|
490 |
+
$readmore_html = apply_filters( PT_CV_PREFIX_ . 'field_excerpt_dots', 1, $fargs ) ? $dots : '';
|
491 |
|
492 |
// Read more button
|
493 |
+
if ( apply_filters( PT_CV_PREFIX_ . 'field_content_readmore_enable', 1, $fargs[ 'content' ] ) ) {
|
494 |
+
$text = apply_filters( PT_CV_PREFIX_ . 'field_content_readmore_text', __( 'Read More', PT_CV_DOMAIN ), $fargs[ 'content' ] );
|
495 |
+
$btn_class = apply_filters( PT_CV_PREFIX_ . 'field_content_readmore_class', 'btn btn-success btn-sm', $fargs );
|
496 |
$readmore_btn .= self::_field_href( $oargs, $post, $text, PT_CV_PREFIX . 'readmore ' . $btn_class );
|
497 |
$readmore_html .= apply_filters( PT_CV_PREFIX_ . 'field_content_readmore_seperated', '<br/>', $fargs ) . $readmore_btn;
|
498 |
}
|
499 |
|
500 |
// Get excerpt
|
501 |
if ( $length > 0 ) {
|
502 |
+
$content_to_extract = apply_filters( PT_CV_PREFIX_ . 'field_content_to_extract', get_the_content(), $post );
|
503 |
// Extract excerpt from content
|
504 |
+
$excerpt = PT_CV_Functions::wp_trim_words( $content_to_extract, $length );
|
505 |
// Get manual excerpt
|
506 |
+
$excerpt = apply_filters( PT_CV_PREFIX_ . 'field_content_excerpt', $excerpt, $fargs, $post );
|
507 |
// Append readmore button
|
508 |
+
$content = $excerpt . $readmore_html;
|
509 |
} else {
|
510 |
// Display only readmore button if length <= 0
|
511 |
$content = $readmore_btn;
|
527 |
$content = apply_filters( PT_CV_PREFIX_ . 'field_content_final', $content, $post );
|
528 |
|
529 |
$html = rtrim( $content, '.' ) ? sprintf(
|
530 |
+
'<%1$s class="%2$s">%3$s</%1$s>', $tag, esc_attr( $content_class ), force_balance_tags( $content )
|
|
|
531 |
) : '';
|
532 |
|
533 |
return $html;
|
543 |
static function _field_href( $oargs, $post, $content, $defined_class = '' ) {
|
544 |
|
545 |
// Open in
|
546 |
+
$open_in = isset( $oargs[ 'open-in' ] ) ? $oargs[ 'open-in' ] : '_blank';
|
547 |
|
548 |
// Class of href
|
549 |
$href_class = apply_filters( PT_CV_PREFIX_ . 'field_href_class', array( $open_in, $defined_class ), $oargs );
|
563 |
|
564 |
// Generate a tag
|
565 |
$html = sprintf(
|
566 |
+
'<a href="%s" class="%s" target="%s" %s>%s</a>', $href, implode( ' ', array_filter( $href_class ) ), $open_in, implode( ' ', array_filter( $custom_attr ) ), balanceTags( $content )
|
|
|
567 |
);
|
568 |
|
569 |
return $html;
|
581 |
global $dargs;
|
582 |
|
583 |
// Get layout format
|
584 |
+
$layout_format = $fargs[ 'layout-format' ];
|
585 |
|
586 |
// Get thumbnail settings
|
587 |
+
$fargs = $fargs[ 'thumbnail' ];
|
588 |
|
589 |
$html = '';
|
590 |
|
592 |
$post_id = $post->ID;
|
593 |
|
594 |
// Custom args for get_the_post_thumbnail function
|
595 |
+
$thumbnail_class = array();
|
596 |
+
$thumbnail_class[] = PT_CV_PREFIX . 'thumbnail';
|
597 |
+
$thumbnail_class[] = isset( $fargs[ 'style' ] ) ? $fargs[ 'style' ] : '';
|
598 |
if ( $layout_format === '2-col' ) {
|
599 |
+
$thumbnail_class[] = isset( $fargs[ 'position' ] ) ? 'pull-' . $fargs[ 'position' ] : 'pull-left';
|
600 |
}
|
601 |
$gargs = array(
|
602 |
'class' => apply_filters( PT_CV_PREFIX_ . 'field_thumbnail_class', implode( ' ', array_filter( $thumbnail_class ) ) ),
|
603 |
);
|
604 |
|
605 |
// Get thumbnail dimensions
|
606 |
+
$dimensions = PT_CV_Functions::field_thumbnail_dimensions( $fargs );
|
607 |
+
$dimensions = (array) apply_filters( PT_CV_PREFIX_ . 'field_thumbnail_dimension_output', $dimensions, $fargs );
|
608 |
|
609 |
// Check if has thumbnail ( has_post_thumbnail doesn't works )
|
610 |
$has_thumbnail = get_the_post_thumbnail( $post_id );
|
611 |
+
if ( !empty( $has_thumbnail ) ) {
|
612 |
+
$thumbnail_size = count( $dimensions ) > 1 ? $dimensions : $dimensions[ 0 ];
|
613 |
+
$html = get_the_post_thumbnail( $post_id, $thumbnail_size, $gargs );
|
614 |
+
$html = apply_filters( PT_CV_PREFIX_ . 'field_thumbnail_image', $html, $post_id, $dimensions, $fargs );
|
615 |
} else {
|
616 |
$html = apply_filters( PT_CV_PREFIX_ . 'field_thumbnail_not_found', $html, $post, $dimensions, $gargs );
|
617 |
}
|
618 |
|
619 |
// Add link to thumbnail
|
620 |
+
$oargs = isset( $dargs[ 'other-settings' ] ) ? $dargs[ 'other-settings' ] : array();
|
621 |
+
$html = self::_field_href( $oargs, $post, $html );
|
622 |
|
623 |
return $html;
|
624 |
}
|
639 |
setup_postdata( $post );
|
640 |
|
641 |
foreach ( $fargs as $meta => $val ) {
|
642 |
+
if ( !$val ) {
|
643 |
continue;
|
644 |
}
|
645 |
|
646 |
switch ( $meta ) {
|
647 |
case 'date':
|
648 |
// Get date wrapper class
|
649 |
+
$date_class = apply_filters( PT_CV_PREFIX_ . 'field_meta_class', 'entry-date', 'date' );
|
650 |
$prefix_text = apply_filters( PT_CV_PREFIX_ . 'field_meta_prefix_text', '', 'date' );
|
651 |
+
$date = apply_filters( PT_CV_PREFIX_ . 'field_meta_date_final', get_the_date(), get_the_time( 'U' ) );
|
652 |
|
653 |
+
$html[ 'date' ] = sprintf( '<span class="%s">%s <time datetime="%s">%s</time></span>', esc_html( $date_class ), balanceTags( $prefix_text ), esc_attr( get_the_date( 'c' ) ), esc_html( $date ) );
|
654 |
break;
|
655 |
|
656 |
case 'taxonomy':
|
657 |
|
658 |
// Get terms wrapper class
|
659 |
+
$term_class = apply_filters( PT_CV_PREFIX_ . 'field_meta_class', 'terms', 'terms' );
|
660 |
$prefix_text = apply_filters( PT_CV_PREFIX_ . 'field_meta_prefix_text', __( 'in', PT_CV_DOMAIN ), 'terms' );
|
661 |
|
662 |
$terms = PT_CV_Functions::post_terms( $post );
|
663 |
+
if ( !empty( $terms ) ) {
|
664 |
+
$term_html = sprintf( '<span class="%s">%s %s</span>', esc_attr( $term_class ), balanceTags( $prefix_text ), balanceTags( $terms ) );
|
665 |
+
$html[ 'taxonomy' ] = apply_filters( PT_CV_PREFIX_ . 'field_term_html', $term_html, $terms );
|
666 |
}
|
667 |
break;
|
668 |
|
669 |
case 'comment':
|
670 |
+
if ( !post_password_required() && ( comments_open() || get_comments_number() ) ) :
|
671 |
// Get comment wrapper class
|
672 |
+
$comment_class = apply_filters( PT_CV_PREFIX_ . 'field_meta_class', 'comments-link', 'comment' );
|
673 |
+
$prefix_text = apply_filters( PT_CV_PREFIX_ . 'field_meta_prefix_text', '', 'comment' );
|
674 |
|
675 |
ob_start();
|
676 |
comments_popup_link( __( 'Leave a comment', PT_CV_DOMAIN ), __( '1 Comment', PT_CV_DOMAIN ), __( '% Comments', PT_CV_DOMAIN ) );
|
677 |
+
$comment_content = ob_get_clean();
|
678 |
+
$html[ 'comment' ] = sprintf( '<span class="%s">%s %s</span>', esc_attr( $comment_class ), balanceTags( $prefix_text ), $comment_content );
|
679 |
endif;
|
680 |
break;
|
681 |
|
682 |
case 'author':
|
683 |
|
684 |
// Get author wrapper class
|
685 |
+
$author_class = apply_filters( PT_CV_PREFIX_ . 'field_meta_class', 'author', 'author' );
|
686 |
+
$prefix_text = apply_filters( PT_CV_PREFIX_ . 'field_meta_prefix_text', __( 'by', PT_CV_DOMAIN ), 'author' );
|
687 |
|
688 |
+
$author_html = sprintf( '<span class="%s">%s <a href="%s" rel="author">%s</a></span>', esc_attr( $author_class ), balanceTags( $prefix_text ), esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), get_the_author() );
|
689 |
+
$html[ 'author' ] = apply_filters( PT_CV_PREFIX_ . 'field_meta_author_html', $author_html, $post );
|
690 |
break;
|
691 |
|
692 |
default:
|
716 |
*/
|
717 |
static function _field_meta_wrap( $meta_html, $seperator = NULL ) {
|
718 |
|
719 |
+
if ( !$meta_html ) {
|
720 |
return '';
|
721 |
}
|
722 |
|
730 |
|
731 |
// Define wrapper
|
732 |
$wrapper = sprintf(
|
733 |
+
'<%1$s class="%2$s">%3$s</%1$s>', $tag, esc_attr( $meta_fields_class ), '%s'
|
|
|
734 |
);
|
735 |
|
736 |
// Join fields
|
754 |
static function pagination_output( $max_num_pages, $current_page, $session_id ) {
|
755 |
global $dargs;
|
756 |
|
757 |
+
if ( !$max_num_pages || (int) $max_num_pages === 1 ) {
|
758 |
return '';
|
759 |
}
|
760 |
|
761 |
$pagination_btn = '';
|
762 |
|
763 |
+
$type = isset( $dargs[ 'pagination-settings' ][ 'type' ] ) ? $dargs[ 'pagination-settings' ][ 'type' ] : 'ajax';
|
764 |
+
$style = isset( $dargs[ 'pagination-settings' ][ 'style' ] ) ? $dargs[ 'pagination-settings' ][ 'style' ] : 'regular';
|
765 |
|
766 |
if ( $type == 'normal' || $style == 'regular' ) {
|
767 |
$pagination_btn = sprintf( '<ul class="%s" data-totalpages="%s" data-sid="%s">%s</ul>', PT_CV_PREFIX . 'pagination' . ' ' . PT_CV_PREFIX . $type . ' pagination', esc_attr( $max_num_pages ), esc_attr( $session_id ), PT_CV_Functions::pagination( $max_num_pages, $current_page ) );
|
771 |
// Add loading icon
|
772 |
$pagination_btn .= self::html_loading_img( 12, PT_CV_PREFIX . 'spinner' );
|
773 |
|
774 |
+
$wrapper_class = apply_filters( PT_CV_PREFIX_ . 'pagination_class', '' );
|
775 |
+
$output = apply_filters( PT_CV_PREFIX_ . 'pagination_output', sprintf( '<div class="%s">%s</div>', $wrapper_class . ' ' . PT_CV_PREFIX . 'pagination-wrapper', $pagination_btn ) );
|
776 |
|
777 |
return $output;
|
778 |
}
|
785 |
global $processed_view_assets, $pt_view_sid;
|
786 |
|
787 |
// If already processed | have no View on this page -> return
|
788 |
+
if ( ( $processed_view_assets && isset( $processed_view_assets[ $pt_view_sid ] ) ) || !$pt_view_sid ) {
|
789 |
return;
|
790 |
}
|
791 |
// Mark as processed
|
792 |
+
if ( !$processed_view_assets ) {
|
793 |
$processed_view_assets = array();
|
794 |
}
|
795 |
+
$processed_view_assets[ $pt_view_sid ] = 1;
|
796 |
|
797 |
// Get settings option
|
798 |
$options = get_option( PT_CV_OPTION_NAME );
|
799 |
|
800 |
// Print inline view styles & scripts
|
801 |
if ( apply_filters( PT_CV_PREFIX_ . 'assets_verbose_loading', 1 ) ) {
|
802 |
+
$assets = array( 'css', 'js' );
|
803 |
+
$assets_output = $assets_files = array();
|
804 |
|
805 |
// Get content of asset files in directory of view type
|
806 |
foreach ( self::$view_type_dir as $idx => $view_type_dir ) {
|
807 |
// Get selected style of current view type
|
808 |
+
$style = self::$style[ $idx ];
|
809 |
|
810 |
// With each type of asset (css, js), looking for suit file of selected style
|
811 |
foreach ( $assets as $type ) {
|
812 |
+
$file_path = $view_type_dir . '/' . $type . '/' . $style . '.' . $type;
|
813 |
+
$content = PT_CV_Functions::file_include_content( $file_path );
|
814 |
if ( $content ) {
|
815 |
+
$assets_output[ $type ][] = $content;
|
816 |
}
|
817 |
}
|
818 |
}
|
845 |
// Enqueue merged asset contents
|
846 |
foreach ( $assets_files as $type => $srcs ) {
|
847 |
foreach ( $srcs as $src ) {
|
848 |
+
$type = ( $type == 'js' ) ? 'script' : 'style';
|
849 |
+
$function = "wp_enqueue_{$type}";
|
850 |
|
851 |
if ( function_exists( $function ) ) {
|
852 |
$function( PT_CV_PREFIX . $type, $src );
|
871 |
// Get settings option
|
872 |
$options = get_option( PT_CV_OPTION_NAME );
|
873 |
|
874 |
+
if ( $is_admin || !isset( $options[ 'unload_bootstrap' ] ) ) {
|
875 |
// Load bootstrap js
|
876 |
PT_CV_Asset::enqueue( 'bootstrap' );
|
877 |
}
|
881 |
|
882 |
// Public script
|
883 |
PT_CV_Asset::enqueue(
|
884 |
+
'public', 'script', array(
|
885 |
+
'src' => plugins_url( 'public/assets/js/public.js', PT_CV_FILE ),
|
886 |
+
'deps' => array( 'jquery' ),
|
887 |
+
)
|
888 |
);
|
889 |
|
890 |
// Localize for Public script
|
891 |
PT_CV_Asset::localize_script(
|
892 |
+
'public', PT_CV_PREFIX_UPPER . 'PUBLIC', array(
|
893 |
+
'is_admin' => is_admin(),
|
894 |
+
'is_mobile' => wp_is_mobile(),
|
895 |
+
'_prefix' => PT_CV_PREFIX,
|
896 |
+
'ajaxurl' => admin_url( 'admin-ajax.php' ),
|
897 |
+
'_nonce' => wp_create_nonce( PT_CV_PREFIX_ . 'ajax_nonce' ),
|
898 |
+
'lang' => PT_CV_Functions::get_language(), #Get current language of site
|
899 |
+
'move_bootstrap' => apply_filters( PT_CV_PREFIX_ . 'move_bootstrap', 1 ), #Should I move Bootstrap to top of all styles
|
900 |
+
)
|
901 |
);
|
902 |
|
903 |
// Localize for Pagination script
|
904 |
PT_CV_Asset::localize_script(
|
905 |
+
'bootstrap-paginator', PT_CV_PREFIX_UPPER . 'PAGINATION', array(
|
906 |
+
'first' => apply_filters( PT_CV_PREFIX_ . 'pagination_first', '«' ),
|
907 |
+
'prev' => apply_filters( PT_CV_PREFIX_ . 'pagination_prev', '‹' ),
|
908 |
+
'next' => apply_filters( PT_CV_PREFIX_ . 'pagination_next', '›' ),
|
909 |
+
'last' => apply_filters( PT_CV_PREFIX_ . 'pagination_last', '»' ),
|
910 |
+
'goto_first' => apply_filters( PT_CV_PREFIX_ . 'goto_first', __( 'Go to first page', PT_CV_DOMAIN ) ),
|
911 |
+
'goto_prev' => apply_filters( PT_CV_PREFIX_ . 'goto_prev', __( 'Go to previous page', PT_CV_DOMAIN ) ),
|
912 |
+
'goto_next' => apply_filters( PT_CV_PREFIX_ . 'goto_next', __( 'Go to next page', PT_CV_DOMAIN ) ),
|
913 |
+
'goto_last' => apply_filters( PT_CV_PREFIX_ . 'goto_last', __( 'Go to last page', PT_CV_DOMAIN ) ),
|
914 |
+
'current_page' => apply_filters( PT_CV_PREFIX_ . 'current_page', __( 'Current page is', PT_CV_DOMAIN ) ),
|
915 |
+
'goto_page' => apply_filters( PT_CV_PREFIX_ . 'goto_page', __( 'Go to page', PT_CV_DOMAIN ) ),
|
916 |
+
)
|
917 |
);
|
918 |
}
|
919 |
|
927 |
// Get settings option
|
928 |
$options = get_option( PT_CV_OPTION_NAME );
|
929 |
|
930 |
+
if ( !is_admin() && !isset( $options[ 'unload_bootstrap' ] ) ) {
|
931 |
PT_CV_Asset::enqueue( 'bootstrap', 'style' );
|
932 |
}
|
933 |
|
934 |
PT_CV_Asset::enqueue(
|
935 |
+
'public', 'style', array(
|
936 |
+
'src' => plugins_url( 'public/assets/css/public.css', PT_CV_FILE ),
|
937 |
+
)
|
938 |
);
|
939 |
|
940 |
// Fix bootstrap error in IE
|
941 |
global $is_IE;
|
942 |
if ( $is_IE ) {
|
943 |
PT_CV_Asset::enqueue(
|
944 |
+
'html5shiv', 'script', array(
|
945 |
+
'src' => plugins_url( 'assets/ie-fix/html5shiv.min.js', PT_CV_FILE ),
|
946 |
+
'ver' => '3.7.0',
|
947 |
+
)
|
948 |
);
|
949 |
PT_CV_Asset::enqueue(
|
950 |
+
'respond', 'script', array(
|
951 |
+
'src' => plugins_url( 'assets/ie-fix/respond.js', PT_CV_FILE ),
|
952 |
+
'ver' => '1.4.2',
|
953 |
+
)
|
954 |
);
|
955 |
}
|
956 |
}
|
969 |
ob_start();
|
970 |
?>
|
971 |
<script type="text/javascript" id="<?php echo esc_attr( PT_CV_PREFIX . 'inline-script-' . $random_id ); ?>">
|
972 |
+
<?php
|
973 |
+
$format = $wrap ? "(function ($) {\n $(function () { %s }); \n}(jQuery));" : '%s';
|
974 |
+
printf( $format, $js );
|
975 |
+
?>
|
976 |
</script>
|
977 |
<?php
|
978 |
return ob_get_clean();
|
995 |
<?php
|
996 |
return ob_get_clean();
|
997 |
}
|
998 |
+
|
999 |
}
|
1000 |
|
1001 |
}
|
includes/settings.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Define settings for options
|
4 |
*
|
@@ -8,8 +9,7 @@
|
|
8 |
* @link http://www.contentviewspro.com/
|
9 |
* @copyright 2014 PT Guy
|
10 |
*/
|
11 |
-
|
12 |
-
if ( ! class_exists( 'PT_CV_Settings' ) ) {
|
13 |
|
14 |
/**
|
15 |
* @name PT_CV_Settings
|
@@ -24,11 +24,11 @@ if ( ! class_exists( 'PT_CV_Settings' ) ) {
|
|
24 |
* @param array $args Array of query parameters
|
25 |
*/
|
26 |
static function terms_of_taxonomies( $taxonomies = array(), $args = array() ) {
|
27 |
-
$terms_of_taxonomies = $result
|
28 |
// Get taxonomies
|
29 |
-
$taxonomies
|
30 |
// Get slug list of taxonomies
|
31 |
-
$taxonomies_slug
|
32 |
|
33 |
foreach ( $taxonomies_slug as $taxonomy_slug ) {
|
34 |
PT_CV_Values::term_of_taxonomy( $taxonomy_slug, $terms_of_taxonomies, $args );
|
@@ -36,39 +36,36 @@ if ( ! class_exists( 'PT_CV_Settings' ) ) {
|
|
36 |
|
37 |
foreach ( $terms_of_taxonomies as $taxonomy_slug => $terms ) {
|
38 |
|
39 |
-
$result[$taxonomy_slug] = array(
|
40 |
-
|
41 |
// Select term to filter
|
42 |
array(
|
43 |
-
'label'
|
44 |
'text' => __( 'Select terms', PT_CV_DOMAIN ),
|
45 |
),
|
46 |
'params' => array(
|
47 |
array(
|
48 |
-
'type'
|
49 |
-
'name'
|
50 |
-
'options'
|
51 |
-
'std'
|
52 |
-
'class'
|
53 |
-
'multiple'
|
54 |
),
|
55 |
),
|
56 |
),
|
57 |
-
|
58 |
// Quick filter
|
59 |
apply_filters( PT_CV_PREFIX_ . 'term_quick_filter', array() ),
|
60 |
-
|
61 |
//Operator
|
62 |
array(
|
63 |
-
'label'
|
64 |
'text' => __( 'Operator', PT_CV_DOMAIN ),
|
65 |
),
|
66 |
'params' => array(
|
67 |
array(
|
68 |
-
'type'
|
69 |
-
'name'
|
70 |
-
'options'
|
71 |
-
'std'
|
72 |
),
|
73 |
),
|
74 |
),
|
@@ -86,33 +83,33 @@ if ( ! class_exists( 'PT_CV_Settings' ) ) {
|
|
86 |
static function orderby() {
|
87 |
$result = array();
|
88 |
|
89 |
-
$result['common'] = array(
|
90 |
// Order By
|
91 |
array(
|
92 |
-
'label'
|
93 |
'text' => __( 'Order by', PT_CV_DOMAIN ),
|
94 |
),
|
95 |
'params' => array(
|
96 |
array(
|
97 |
-
'type'
|
98 |
-
'name'
|
99 |
-
'options'
|
100 |
-
'std'
|
101 |
-
'desc'
|
102 |
),
|
103 |
),
|
104 |
),
|
105 |
// Order
|
106 |
array(
|
107 |
-
'label'
|
108 |
'text' => __( 'Order', PT_CV_DOMAIN ),
|
109 |
),
|
110 |
'params' => array(
|
111 |
array(
|
112 |
-
'type'
|
113 |
-
'name'
|
114 |
-
'options'
|
115 |
-
'std'
|
116 |
),
|
117 |
),
|
118 |
),
|
@@ -133,81 +130,77 @@ if ( ! class_exists( 'PT_CV_Settings' ) ) {
|
|
133 |
$prefix = 'pagination-';
|
134 |
|
135 |
$result = array(
|
136 |
-
|
137 |
// Pagination
|
138 |
array(
|
139 |
-
'label'
|
140 |
'text' => __( 'Pagination', PT_CV_DOMAIN ),
|
141 |
),
|
142 |
'params' => array(
|
143 |
array(
|
144 |
-
'type'
|
145 |
-
'name'
|
146 |
-
'options'
|
147 |
-
'std'
|
148 |
),
|
149 |
),
|
150 |
),
|
151 |
-
|
152 |
// Items per page
|
153 |
array(
|
154 |
-
'label'
|
155 |
'text' => __( 'Items per page', PT_CV_DOMAIN ),
|
156 |
),
|
157 |
-
'params'
|
158 |
array(
|
159 |
-
'type'
|
160 |
-
'name'
|
161 |
-
'std'
|
162 |
-
'placeholder'
|
163 |
-
'append_text'
|
164 |
-
'desc'
|
165 |
),
|
166 |
),
|
167 |
'dependence' => array( 'enable-pagination', 'yes' ),
|
168 |
),
|
169 |
-
|
170 |
// Pagination Type
|
171 |
array(
|
172 |
-
'label'
|
173 |
'text' => __( 'Pagination type', PT_CV_DOMAIN ),
|
174 |
),
|
175 |
-
'params'
|
176 |
array(
|
177 |
-
'type'
|
178 |
-
'name'
|
179 |
-
'options'
|
180 |
-
'std'
|
181 |
),
|
182 |
),
|
183 |
'dependence' => array( 'enable-pagination', 'yes' ),
|
184 |
),
|
185 |
-
|
186 |
// Pagination Style
|
187 |
array(
|
188 |
-
'label'
|
189 |
'text' => '',
|
190 |
),
|
191 |
-
'extra_setting'
|
192 |
'params' => array(
|
193 |
-
'width'
|
194 |
),
|
195 |
),
|
196 |
-
'params'
|
197 |
array(
|
198 |
-
'type'
|
199 |
'params' => array(
|
200 |
array(
|
201 |
-
'label'
|
202 |
'text' => __( 'Pagination style', PT_CV_DOMAIN ),
|
203 |
),
|
204 |
-
'params'
|
205 |
array(
|
206 |
-
'type'
|
207 |
-
'name'
|
208 |
-
'options'
|
209 |
-
'std'
|
210 |
-
'desc'
|
211 |
),
|
212 |
),
|
213 |
'dependence' => array( $prefix . 'type', 'normal', '!=' ),
|
@@ -215,7 +208,7 @@ if ( ! class_exists( 'PT_CV_Settings' ) ) {
|
|
215 |
),
|
216 |
),
|
217 |
),
|
218 |
-
'dependence'
|
219 |
),
|
220 |
);
|
221 |
|
@@ -234,16 +227,16 @@ if ( ! class_exists( 'PT_CV_Settings' ) ) {
|
|
234 |
$result = array(
|
235 |
// Open an item in
|
236 |
array(
|
237 |
-
'label'
|
238 |
'text' => __( 'Open item in', PT_CV_DOMAIN ),
|
239 |
),
|
240 |
'params' => array(
|
241 |
array(
|
242 |
-
'type'
|
243 |
-
'name'
|
244 |
-
'options'
|
245 |
-
'std'
|
246 |
-
'desc'
|
247 |
),
|
248 |
),
|
249 |
),
|
@@ -259,176 +252,165 @@ if ( ! class_exists( 'PT_CV_Settings' ) ) {
|
|
259 |
*/
|
260 |
static function field_settings() {
|
261 |
|
262 |
-
$prefix
|
263 |
$prefix2 = 'show-' . $prefix;
|
264 |
|
265 |
$result = array(
|
266 |
-
|
267 |
// Fields display
|
268 |
array(
|
269 |
-
'label'
|
270 |
'text' => '',
|
271 |
),
|
272 |
-
'extra_setting'
|
273 |
'params' => array(
|
274 |
'wrap-class' => PT_CV_Html::html_group_class(),
|
275 |
-
'width'
|
276 |
),
|
277 |
),
|
278 |
-
'params'
|
279 |
array(
|
280 |
-
'type'
|
281 |
'params' => PT_CV_Settings::field_display_settings(),
|
282 |
),
|
283 |
),
|
284 |
),
|
285 |
-
|
286 |
// Upgrade to Pro
|
287 |
-
!
|
288 |
-
'label'
|
289 |
'text' => '',
|
290 |
),
|
291 |
-
'extra_setting'
|
292 |
'params' => array(
|
293 |
-
'width'
|
294 |
),
|
295 |
),
|
296 |
-
'params'
|
297 |
array(
|
298 |
-
'type'
|
299 |
-
'content'
|
300 |
),
|
301 |
),
|
302 |
) : '',
|
303 |
-
|
304 |
// Title settings
|
305 |
apply_filters( PT_CV_PREFIX_ . 'settings_title_display', array(), $prefix, $prefix2 ),
|
306 |
-
|
307 |
// Thumbnail settings
|
308 |
array(
|
309 |
-
'label'
|
310 |
'text' => __( 'Thumbnail settings', PT_CV_DOMAIN ),
|
311 |
),
|
312 |
-
'extra_setting'
|
313 |
'params' => array(
|
314 |
'wrap-class' => PT_CV_Html::html_group_class() . ' ' . PT_CV_PREFIX . 'thumbnail-setting' . ' ' . PT_CV_PREFIX . 'w50',
|
315 |
),
|
316 |
),
|
317 |
-
'params'
|
318 |
array(
|
319 |
-
'type'
|
320 |
'params' => PT_CV_Settings::field_thumbnail_settings( $prefix ),
|
321 |
),
|
322 |
),
|
323 |
-
'dependence'
|
324 |
),
|
325 |
-
|
326 |
// Content settings
|
327 |
array(
|
328 |
-
'label'
|
329 |
'text' => __( 'Content settings', PT_CV_DOMAIN ),
|
330 |
),
|
331 |
-
'params'
|
332 |
array(
|
333 |
-
'type'
|
334 |
-
'name'
|
335 |
-
'options'
|
336 |
-
'full'
|
337 |
-
'excerpt'
|
338 |
),
|
339 |
-
'std'
|
340 |
),
|
341 |
),
|
342 |
'dependence' => array( $prefix2 . 'content', 'yes' ),
|
343 |
),
|
344 |
-
|
345 |
// Excerpt settings
|
346 |
array(
|
347 |
-
'label'
|
348 |
'text' => '',
|
349 |
),
|
350 |
-
'extra_setting'
|
351 |
'params' => array(
|
352 |
'wrap-id' => PT_CV_Html::html_group_id( 'excerpt-settings' ),
|
353 |
),
|
354 |
),
|
355 |
-
'params'
|
356 |
array(
|
357 |
-
'type'
|
358 |
'params' => apply_filters(
|
359 |
-
|
|
|
360 |
array(
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
'params' => array(
|
368 |
-
'width' => 9,
|
369 |
-
),
|
370 |
-
),
|
371 |
-
'params' => array(
|
372 |
-
array(
|
373 |
-
'type' => 'number',
|
374 |
-
'name' => $prefix . 'excerpt-length',
|
375 |
-
'std' => '20',
|
376 |
-
'placeholder' => 'e.g. 20',
|
377 |
-
'append_text' => 'words',
|
378 |
-
'desc' => __( 'Generating excerpt by selecting the first X words of the content', PT_CV_DOMAIN ),
|
379 |
-
),
|
380 |
),
|
381 |
),
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
'
|
|
|
|
|
|
|
387 |
),
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
393 |
),
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
),
|
402 |
),
|
403 |
),
|
404 |
),
|
405 |
-
|
406 |
),
|
407 |
),
|
408 |
),
|
409 |
-
'dependence'
|
410 |
),
|
411 |
-
|
412 |
// Meta fields settings
|
413 |
array(
|
414 |
-
'label'
|
415 |
'text' => __( 'Meta fields settings', PT_CV_DOMAIN ),
|
416 |
),
|
417 |
-
'extra_setting'
|
418 |
'params' => array(
|
419 |
'wrap-class' => PT_CV_Html::html_group_class() . ' ' . PT_CV_PREFIX . 'meta-fields-settings',
|
420 |
),
|
421 |
),
|
422 |
-
'params'
|
423 |
array(
|
424 |
-
'type'
|
425 |
'params' => PT_CV_Settings::field_meta_fields( 'meta-fields-' ),
|
426 |
-
'desc'
|
427 |
),
|
428 |
),
|
429 |
-
'dependence'
|
430 |
),
|
431 |
-
|
432 |
// Taxonomies settings
|
433 |
apply_filters( PT_CV_PREFIX_ . 'settings_taxonomies_display', array(), 'meta-fields-' ),
|
434 |
);
|
@@ -447,20 +429,20 @@ if ( ! class_exists( 'PT_CV_Settings' ) ) {
|
|
447 |
|
448 |
$field_display_settings = array(
|
449 |
array(
|
450 |
-
'label'
|
451 |
'text' => '',
|
452 |
),
|
453 |
-
'extra_setting'
|
454 |
'params' => array(
|
455 |
-
'width'
|
456 |
'wrap-class' => PT_CV_PREFIX . 'field-display',
|
457 |
),
|
458 |
),
|
459 |
-
'params'
|
460 |
array(
|
461 |
-
'type'
|
462 |
'params' => PT_CV_Settings::field_display(),
|
463 |
-
'desc'
|
464 |
),
|
465 |
),
|
466 |
),
|
@@ -481,105 +463,100 @@ if ( ! class_exists( 'PT_CV_Settings' ) ) {
|
|
481 |
$prefix = 'show-field-';
|
482 |
|
483 |
$result = array(
|
484 |
-
|
485 |
// Thumbnail position
|
486 |
array(
|
487 |
-
'label'
|
488 |
'text' => __( 'Thumbnail position', PT_CV_DOMAIN ),
|
489 |
),
|
490 |
-
'extra_setting'
|
491 |
'params' => array(
|
492 |
'wrap-class' => PT_CV_PREFIX . 'bg-none' . ' ' . PT_CV_PREFIX . 'w200',
|
493 |
),
|
494 |
),
|
495 |
-
'params'
|
496 |
array(
|
497 |
-
'type'
|
498 |
-
'name'
|
499 |
-
'options'
|
500 |
-
'std'
|
501 |
),
|
502 |
),
|
503 |
-
'dependence'
|
504 |
),
|
505 |
-
|
506 |
// Show Thumbnail
|
507 |
array(
|
508 |
-
'label'
|
509 |
'text' => '',
|
510 |
),
|
511 |
-
'extra_setting'
|
512 |
'params' => array(
|
513 |
'width' => 12,
|
514 |
),
|
515 |
),
|
516 |
-
'params'
|
517 |
array(
|
518 |
-
'type'
|
519 |
-
'name'
|
520 |
-
'options'
|
521 |
-
'std'
|
522 |
),
|
523 |
),
|
524 |
-
'dependence'
|
525 |
),
|
526 |
-
|
527 |
// Show Title
|
528 |
array(
|
529 |
-
'label'
|
530 |
'text' => '',
|
531 |
),
|
532 |
-
'extra_setting'
|
533 |
'params' => array(
|
534 |
'width' => 12,
|
535 |
),
|
536 |
),
|
537 |
-
'params'
|
538 |
array(
|
539 |
-
'type'
|
540 |
-
'name'
|
541 |
-
'options'
|
542 |
-
'std'
|
543 |
),
|
544 |
),
|
545 |
),
|
546 |
-
|
547 |
// Show Content
|
548 |
array(
|
549 |
-
'label'
|
550 |
'text' => '',
|
551 |
),
|
552 |
-
'extra_setting'
|
553 |
'params' => array(
|
554 |
'width' => 12,
|
555 |
),
|
556 |
),
|
557 |
-
'params'
|
558 |
array(
|
559 |
-
'type'
|
560 |
-
'name'
|
561 |
-
'options'
|
562 |
-
'std'
|
563 |
),
|
564 |
),
|
565 |
),
|
566 |
-
|
567 |
// Show Meta fields
|
568 |
array(
|
569 |
-
'label'
|
570 |
'text' => '',
|
571 |
),
|
572 |
-
'extra_setting'
|
573 |
'params' => array(
|
574 |
'width' => 12,
|
575 |
),
|
576 |
),
|
577 |
-
'params'
|
578 |
array(
|
579 |
-
'type'
|
580 |
-
'name'
|
581 |
-
'options'
|
582 |
-
'std'
|
583 |
),
|
584 |
),
|
585 |
),
|
@@ -602,20 +579,20 @@ if ( ! class_exists( 'PT_CV_Settings' ) ) {
|
|
602 |
$result = array(
|
603 |
// Size
|
604 |
array(
|
605 |
-
'label'
|
606 |
'text' => __( 'Thumbnail size', PT_CV_DOMAIN ),
|
607 |
),
|
608 |
-
'extra_setting'
|
609 |
'params' => array(
|
610 |
'width' => 9,
|
611 |
),
|
612 |
),
|
613 |
-
'params'
|
614 |
array(
|
615 |
-
'type'
|
616 |
-
'name'
|
617 |
-
'options'
|
618 |
-
'std'
|
619 |
),
|
620 |
),
|
621 |
),
|
@@ -632,88 +609,83 @@ if ( ! class_exists( 'PT_CV_Settings' ) ) {
|
|
632 |
static function field_meta_fields( $prefix ) {
|
633 |
|
634 |
$result = array(
|
635 |
-
|
636 |
// Date
|
637 |
array(
|
638 |
-
'label'
|
639 |
'text' => '',
|
640 |
),
|
641 |
-
'extra_setting'
|
642 |
'params' => array(
|
643 |
'width' => 12,
|
644 |
),
|
645 |
),
|
646 |
-
'params'
|
647 |
array(
|
648 |
-
'type'
|
649 |
-
'name'
|
650 |
-
'options'
|
651 |
-
'std'
|
652 |
),
|
653 |
),
|
654 |
),
|
655 |
-
|
656 |
// Author
|
657 |
array(
|
658 |
-
'label'
|
659 |
'text' => '',
|
660 |
),
|
661 |
-
'extra_setting'
|
662 |
'params' => array(
|
663 |
'width' => 12,
|
664 |
),
|
665 |
),
|
666 |
-
'params'
|
667 |
array(
|
668 |
-
'type'
|
669 |
-
'name'
|
670 |
-
'options'
|
671 |
-
'std'
|
672 |
),
|
673 |
),
|
674 |
),
|
675 |
-
|
676 |
// Taxonomy
|
677 |
array(
|
678 |
-
'label'
|
679 |
'text' => '',
|
680 |
),
|
681 |
-
'extra_setting'
|
682 |
'params' => array(
|
683 |
'width' => 12,
|
684 |
),
|
685 |
),
|
686 |
-
'params'
|
687 |
array(
|
688 |
-
'type'
|
689 |
-
'name'
|
690 |
-
'options'
|
691 |
-
'std'
|
692 |
),
|
693 |
),
|
694 |
-
'dependence'
|
695 |
),
|
696 |
-
|
697 |
// Comment
|
698 |
array(
|
699 |
-
'label'
|
700 |
'text' => '',
|
701 |
),
|
702 |
-
'extra_setting'
|
703 |
'params' => array(
|
704 |
'width' => 12,
|
705 |
),
|
706 |
),
|
707 |
-
'params'
|
708 |
array(
|
709 |
-
'type'
|
710 |
-
'name'
|
711 |
-
'options'
|
712 |
-
'std'
|
713 |
),
|
714 |
),
|
715 |
),
|
716 |
-
|
717 |
);
|
718 |
|
719 |
// Sort array of params by saved order
|
@@ -734,16 +706,16 @@ if ( ! class_exists( 'PT_CV_Settings' ) ) {
|
|
734 |
$result = array(
|
735 |
// Number of columns
|
736 |
array(
|
737 |
-
'label'
|
738 |
'text' => __( 'Items per row', PT_CV_DOMAIN ),
|
739 |
),
|
740 |
-
'params'
|
741 |
array(
|
742 |
-
'type'
|
743 |
-
'name'
|
744 |
-
'std'
|
745 |
-
'append_text'
|
746 |
-
'desc'
|
747 |
),
|
748 |
),
|
749 |
'dependence' => array( 'view-type', 'grid' ),
|
@@ -799,22 +771,23 @@ if ( ! class_exists( 'PT_CV_Settings' ) ) {
|
|
799 |
static function setting_no_option() {
|
800 |
|
801 |
return array(
|
802 |
-
'label'
|
803 |
'text' => '',
|
804 |
),
|
805 |
-
'extra_setting'
|
806 |
'params' => array(
|
807 |
'width' => 12,
|
808 |
),
|
809 |
),
|
810 |
-
'params'
|
811 |
array(
|
812 |
-
'type'
|
813 |
-
'content'
|
814 |
),
|
815 |
),
|
816 |
);
|
817 |
}
|
|
|
818 |
}
|
819 |
|
820 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Define settings for options
|
5 |
*
|
9 |
* @link http://www.contentviewspro.com/
|
10 |
* @copyright 2014 PT Guy
|
11 |
*/
|
12 |
+
if ( !class_exists( 'PT_CV_Settings' ) ) {
|
|
|
13 |
|
14 |
/**
|
15 |
* @name PT_CV_Settings
|
24 |
* @param array $args Array of query parameters
|
25 |
*/
|
26 |
static function terms_of_taxonomies( $taxonomies = array(), $args = array() ) {
|
27 |
+
$terms_of_taxonomies = $result = array();
|
28 |
// Get taxonomies
|
29 |
+
$taxonomies = PT_CV_Values::taxonomy_list();
|
30 |
// Get slug list of taxonomies
|
31 |
+
$taxonomies_slug = array_keys( $taxonomies );
|
32 |
|
33 |
foreach ( $taxonomies_slug as $taxonomy_slug ) {
|
34 |
PT_CV_Values::term_of_taxonomy( $taxonomy_slug, $terms_of_taxonomies, $args );
|
36 |
|
37 |
foreach ( $terms_of_taxonomies as $taxonomy_slug => $terms ) {
|
38 |
|
39 |
+
$result[ $taxonomy_slug ] = array(
|
|
|
40 |
// Select term to filter
|
41 |
array(
|
42 |
+
'label' => array(
|
43 |
'text' => __( 'Select terms', PT_CV_DOMAIN ),
|
44 |
),
|
45 |
'params' => array(
|
46 |
array(
|
47 |
+
'type' => 'select',
|
48 |
+
'name' => $taxonomy_slug . '-terms[]',
|
49 |
+
'options' => $terms,
|
50 |
+
'std' => '',
|
51 |
+
'class' => apply_filters( PT_CV_PREFIX_ . 'select_term_class', 'select2' ),
|
52 |
+
'multiple' => '1',
|
53 |
),
|
54 |
),
|
55 |
),
|
|
|
56 |
// Quick filter
|
57 |
apply_filters( PT_CV_PREFIX_ . 'term_quick_filter', array() ),
|
|
|
58 |
//Operator
|
59 |
array(
|
60 |
+
'label' => array(
|
61 |
'text' => __( 'Operator', PT_CV_DOMAIN ),
|
62 |
),
|
63 |
'params' => array(
|
64 |
array(
|
65 |
+
'type' => 'select',
|
66 |
+
'name' => $taxonomy_slug . '-operator',
|
67 |
+
'options' => PT_CV_Values::taxonomy_operators(),
|
68 |
+
'std' => 'IN',
|
69 |
),
|
70 |
),
|
71 |
),
|
83 |
static function orderby() {
|
84 |
$result = array();
|
85 |
|
86 |
+
$result[ 'common' ] = array(
|
87 |
// Order By
|
88 |
array(
|
89 |
+
'label' => array(
|
90 |
'text' => __( 'Order by', PT_CV_DOMAIN ),
|
91 |
),
|
92 |
'params' => array(
|
93 |
array(
|
94 |
+
'type' => 'select',
|
95 |
+
'name' => 'orderby',
|
96 |
+
'options' => PT_CV_Values::post_regular_orderby(),
|
97 |
+
'std' => '',
|
98 |
+
'desc' => __( 'Select a criteria to sort by', PT_CV_DOMAIN ),
|
99 |
),
|
100 |
),
|
101 |
),
|
102 |
// Order
|
103 |
array(
|
104 |
+
'label' => array(
|
105 |
'text' => __( 'Order', PT_CV_DOMAIN ),
|
106 |
),
|
107 |
'params' => array(
|
108 |
array(
|
109 |
+
'type' => 'radio',
|
110 |
+
'name' => 'order',
|
111 |
+
'options' => PT_CV_Values::orders(),
|
112 |
+
'std' => 'asc',
|
113 |
),
|
114 |
),
|
115 |
),
|
130 |
$prefix = 'pagination-';
|
131 |
|
132 |
$result = array(
|
|
|
133 |
// Pagination
|
134 |
array(
|
135 |
+
'label' => array(
|
136 |
'text' => __( 'Pagination', PT_CV_DOMAIN ),
|
137 |
),
|
138 |
'params' => array(
|
139 |
array(
|
140 |
+
'type' => 'checkbox',
|
141 |
+
'name' => 'enable-pagination',
|
142 |
+
'options' => PT_CV_Values::yes_no( 'yes', __( 'Enable', PT_CV_DOMAIN ) ),
|
143 |
+
'std' => '',
|
144 |
),
|
145 |
),
|
146 |
),
|
|
|
147 |
// Items per page
|
148 |
array(
|
149 |
+
'label' => array(
|
150 |
'text' => __( 'Items per page', PT_CV_DOMAIN ),
|
151 |
),
|
152 |
+
'params' => array(
|
153 |
array(
|
154 |
+
'type' => 'number',
|
155 |
+
'name' => $prefix . 'items-per-page',
|
156 |
+
'std' => '5',
|
157 |
+
'placeholder' => 'e.g. 5',
|
158 |
+
'append_text' => '1 → 100',
|
159 |
+
'desc' => __( 'The number of items per page<br>If value of "Limit" option is not blank (empty), this value should be smaller than "Limit" value', PT_CV_DOMAIN ),
|
160 |
),
|
161 |
),
|
162 |
'dependence' => array( 'enable-pagination', 'yes' ),
|
163 |
),
|
|
|
164 |
// Pagination Type
|
165 |
array(
|
166 |
+
'label' => array(
|
167 |
'text' => __( 'Pagination type', PT_CV_DOMAIN ),
|
168 |
),
|
169 |
+
'params' => array(
|
170 |
array(
|
171 |
+
'type' => 'radio',
|
172 |
+
'name' => $prefix . 'type',
|
173 |
+
'options' => PT_CV_Values::pagination_types(),
|
174 |
+
'std' => 'ajax',
|
175 |
),
|
176 |
),
|
177 |
'dependence' => array( 'enable-pagination', 'yes' ),
|
178 |
),
|
|
|
179 |
// Pagination Style
|
180 |
array(
|
181 |
+
'label' => array(
|
182 |
'text' => '',
|
183 |
),
|
184 |
+
'extra_setting' => array(
|
185 |
'params' => array(
|
186 |
+
'width' => 12,
|
187 |
),
|
188 |
),
|
189 |
+
'params' => array(
|
190 |
array(
|
191 |
+
'type' => 'group',
|
192 |
'params' => array(
|
193 |
array(
|
194 |
+
'label' => array(
|
195 |
'text' => __( 'Pagination style', PT_CV_DOMAIN ),
|
196 |
),
|
197 |
+
'params' => array(
|
198 |
array(
|
199 |
+
'type' => 'radio',
|
200 |
+
'name' => $prefix . 'style',
|
201 |
+
'options' => PT_CV_Values::pagination_styles(),
|
202 |
+
'std' => PT_CV_Functions::array_get_first_key( PT_CV_Values::pagination_styles() ),
|
203 |
+
'desc' => __( 'Output style for Ajax pagination', PT_CV_DOMAIN ),
|
204 |
),
|
205 |
),
|
206 |
'dependence' => array( $prefix . 'type', 'normal', '!=' ),
|
208 |
),
|
209 |
),
|
210 |
),
|
211 |
+
'dependence' => array( 'enable-pagination', 'yes' ),
|
212 |
),
|
213 |
);
|
214 |
|
227 |
$result = array(
|
228 |
// Open an item in
|
229 |
array(
|
230 |
+
'label' => array(
|
231 |
'text' => __( 'Open item in', PT_CV_DOMAIN ),
|
232 |
),
|
233 |
'params' => array(
|
234 |
array(
|
235 |
+
'type' => 'radio',
|
236 |
+
'name' => $prefix . 'open-in',
|
237 |
+
'options' => PT_CV_Values::open_in(),
|
238 |
+
'std' => PT_CV_Functions::array_get_first_key( PT_CV_Values::open_in() ),
|
239 |
+
'desc' => __( 'How to open an item when click on Title, Thumbnail, Read more button', PT_CV_DOMAIN ),
|
240 |
),
|
241 |
),
|
242 |
),
|
252 |
*/
|
253 |
static function field_settings() {
|
254 |
|
255 |
+
$prefix = 'field-';
|
256 |
$prefix2 = 'show-' . $prefix;
|
257 |
|
258 |
$result = array(
|
|
|
259 |
// Fields display
|
260 |
array(
|
261 |
+
'label' => array(
|
262 |
'text' => '',
|
263 |
),
|
264 |
+
'extra_setting' => array(
|
265 |
'params' => array(
|
266 |
'wrap-class' => PT_CV_Html::html_group_class(),
|
267 |
+
'width' => 12,
|
268 |
),
|
269 |
),
|
270 |
+
'params' => array(
|
271 |
array(
|
272 |
+
'type' => 'group',
|
273 |
'params' => PT_CV_Settings::field_display_settings(),
|
274 |
),
|
275 |
),
|
276 |
),
|
|
|
277 |
// Upgrade to Pro
|
278 |
+
!get_option( 'pt_cv_version_pro' ) ? array(
|
279 |
+
'label' => array(
|
280 |
'text' => '',
|
281 |
),
|
282 |
+
'extra_setting' => array(
|
283 |
'params' => array(
|
284 |
+
'width' => 12,
|
285 |
),
|
286 |
),
|
287 |
+
'params' => array(
|
288 |
array(
|
289 |
+
'type' => 'html',
|
290 |
+
'content' => sprintf( '<p class="text-muted" style="margin-top: -10px; margin-bottom: 15px;">→ %s</p>', __( 'Customize display order of above fields by a simple drag-and-drop ?', PT_CV_DOMAIN ) . sprintf( ' <a href="%s" target="_blank">%s</a>', esc_url( 'http://www.contentviewspro.com/pricing/?utm_source=client&utm_medium=view' ), __( 'Please upgrade to Pro', PT_CV_DOMAIN ) ) ),
|
291 |
),
|
292 |
),
|
293 |
) : '',
|
|
|
294 |
// Title settings
|
295 |
apply_filters( PT_CV_PREFIX_ . 'settings_title_display', array(), $prefix, $prefix2 ),
|
|
|
296 |
// Thumbnail settings
|
297 |
array(
|
298 |
+
'label' => array(
|
299 |
'text' => __( 'Thumbnail settings', PT_CV_DOMAIN ),
|
300 |
),
|
301 |
+
'extra_setting' => array(
|
302 |
'params' => array(
|
303 |
'wrap-class' => PT_CV_Html::html_group_class() . ' ' . PT_CV_PREFIX . 'thumbnail-setting' . ' ' . PT_CV_PREFIX . 'w50',
|
304 |
),
|
305 |
),
|
306 |
+
'params' => array(
|
307 |
array(
|
308 |
+
'type' => 'group',
|
309 |
'params' => PT_CV_Settings::field_thumbnail_settings( $prefix ),
|
310 |
),
|
311 |
),
|
312 |
+
'dependence' => array( $prefix2 . 'thumbnail', 'yes' ),
|
313 |
),
|
|
|
314 |
// Content settings
|
315 |
array(
|
316 |
+
'label' => array(
|
317 |
'text' => __( 'Content settings', PT_CV_DOMAIN ),
|
318 |
),
|
319 |
+
'params' => array(
|
320 |
array(
|
321 |
+
'type' => 'radio',
|
322 |
+
'name' => $prefix . 'content-show',
|
323 |
+
'options' => array(
|
324 |
+
'full' => __( 'Show Full Content', PT_CV_DOMAIN ),
|
325 |
+
'excerpt' => __( 'Show Excerpt', PT_CV_DOMAIN ),
|
326 |
),
|
327 |
+
'std' => 'excerpt',
|
328 |
),
|
329 |
),
|
330 |
'dependence' => array( $prefix2 . 'content', 'yes' ),
|
331 |
),
|
|
|
332 |
// Excerpt settings
|
333 |
array(
|
334 |
+
'label' => array(
|
335 |
'text' => '',
|
336 |
),
|
337 |
+
'extra_setting' => array(
|
338 |
'params' => array(
|
339 |
'wrap-id' => PT_CV_Html::html_group_id( 'excerpt-settings' ),
|
340 |
),
|
341 |
),
|
342 |
+
'params' => array(
|
343 |
array(
|
344 |
+
'type' => 'group',
|
345 |
'params' => apply_filters(
|
346 |
+
PT_CV_PREFIX_ . 'excerpt_settings', array(
|
347 |
+
// Excerpt length
|
348 |
array(
|
349 |
+
'label' => array(
|
350 |
+
'text' => __( 'Excerpt settings', PT_CV_DOMAIN ),
|
351 |
+
),
|
352 |
+
'extra_setting' => array(
|
353 |
+
'params' => array(
|
354 |
+
'width' => 9,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
355 |
),
|
356 |
),
|
357 |
+
'params' => array(
|
358 |
+
array(
|
359 |
+
'type' => 'number',
|
360 |
+
'name' => $prefix . 'excerpt-length',
|
361 |
+
'std' => '20',
|
362 |
+
'placeholder' => 'e.g. 20',
|
363 |
+
'append_text' => 'words',
|
364 |
+
'desc' => __( 'Generating excerpt by selecting the first X words of the content', PT_CV_DOMAIN ),
|
365 |
),
|
366 |
+
),
|
367 |
+
),
|
368 |
+
// Allow HTML tags
|
369 |
+
array(
|
370 |
+
'label' => array(
|
371 |
+
'text' => '',
|
372 |
+
),
|
373 |
+
'extra_setting' => array(
|
374 |
+
'params' => array(
|
375 |
+
'wrap-class' => PT_CV_PREFIX . 'full-fields',
|
376 |
+
'width' => 9,
|
377 |
),
|
378 |
+
),
|
379 |
+
'params' => array(
|
380 |
+
array(
|
381 |
+
'type' => 'checkbox',
|
382 |
+
'name' => $prefix . 'excerpt-allow_html',
|
383 |
+
'options' => PT_CV_Values::yes_no( 'yes', __( 'Allow HTML tags (a, br, strong, em, strike, i, ul, ol, li) in excerpt', PT_CV_DOMAIN ) ),
|
384 |
+
'std' => '',
|
385 |
+
'desc' => __( 'This option can cause broken HTML output. Please be careful when check it', PT_CV_DOMAIN ),
|
386 |
),
|
387 |
),
|
388 |
),
|
389 |
+
), $prefix . 'excerpt-'
|
390 |
),
|
391 |
),
|
392 |
),
|
393 |
+
'dependence' => array( array( $prefix . 'content-show', 'excerpt' ) ),
|
394 |
),
|
|
|
395 |
// Meta fields settings
|
396 |
array(
|
397 |
+
'label' => array(
|
398 |
'text' => __( 'Meta fields settings', PT_CV_DOMAIN ),
|
399 |
),
|
400 |
+
'extra_setting' => array(
|
401 |
'params' => array(
|
402 |
'wrap-class' => PT_CV_Html::html_group_class() . ' ' . PT_CV_PREFIX . 'meta-fields-settings',
|
403 |
),
|
404 |
),
|
405 |
+
'params' => array(
|
406 |
array(
|
407 |
+
'type' => 'group',
|
408 |
'params' => PT_CV_Settings::field_meta_fields( 'meta-fields-' ),
|
409 |
+
'desc' => apply_filters( PT_CV_PREFIX_ . 'settings_sort_text', '' ),
|
410 |
),
|
411 |
),
|
412 |
+
'dependence' => array( $prefix2 . 'meta-fields', 'yes' ),
|
413 |
),
|
|
|
414 |
// Taxonomies settings
|
415 |
apply_filters( PT_CV_PREFIX_ . 'settings_taxonomies_display', array(), 'meta-fields-' ),
|
416 |
);
|
429 |
|
430 |
$field_display_settings = array(
|
431 |
array(
|
432 |
+
'label' => array(
|
433 |
'text' => '',
|
434 |
),
|
435 |
+
'extra_setting' => array(
|
436 |
'params' => array(
|
437 |
+
'width' => 12,
|
438 |
'wrap-class' => PT_CV_PREFIX . 'field-display',
|
439 |
),
|
440 |
),
|
441 |
+
'params' => array(
|
442 |
array(
|
443 |
+
'type' => 'group',
|
444 |
'params' => PT_CV_Settings::field_display(),
|
445 |
+
'desc' => apply_filters( PT_CV_PREFIX_ . 'settings_sort_text', '' ),
|
446 |
),
|
447 |
),
|
448 |
),
|
463 |
$prefix = 'show-field-';
|
464 |
|
465 |
$result = array(
|
|
|
466 |
// Thumbnail position
|
467 |
array(
|
468 |
+
'label' => array(
|
469 |
'text' => __( 'Thumbnail position', PT_CV_DOMAIN ),
|
470 |
),
|
471 |
+
'extra_setting' => array(
|
472 |
'params' => array(
|
473 |
'wrap-class' => PT_CV_PREFIX . 'bg-none' . ' ' . PT_CV_PREFIX . 'w200',
|
474 |
),
|
475 |
),
|
476 |
+
'params' => array(
|
477 |
array(
|
478 |
+
'type' => 'select',
|
479 |
+
'name' => 'field-' . 'thumbnail-position',
|
480 |
+
'options' => PT_CV_Values::thumbnail_position(),
|
481 |
+
'std' => PT_CV_Functions::array_get_first_key( PT_CV_Values::thumbnail_position() ),
|
482 |
),
|
483 |
),
|
484 |
+
'dependence' => array( 'layout-format', '2-col' ),
|
485 |
),
|
|
|
486 |
// Show Thumbnail
|
487 |
array(
|
488 |
+
'label' => array(
|
489 |
'text' => '',
|
490 |
),
|
491 |
+
'extra_setting' => array(
|
492 |
'params' => array(
|
493 |
'width' => 12,
|
494 |
),
|
495 |
),
|
496 |
+
'params' => array(
|
497 |
array(
|
498 |
+
'type' => 'checkbox',
|
499 |
+
'name' => $prefix . 'thumbnail',
|
500 |
+
'options' => PT_CV_Values::yes_no( 'yes', __( 'Show Thumbnail', PT_CV_DOMAIN ) ),
|
501 |
+
'std' => 'yes',
|
502 |
),
|
503 |
),
|
504 |
+
'dependence' => array( 'layout-format', '1-col' ),
|
505 |
),
|
|
|
506 |
// Show Title
|
507 |
array(
|
508 |
+
'label' => array(
|
509 |
'text' => '',
|
510 |
),
|
511 |
+
'extra_setting' => array(
|
512 |
'params' => array(
|
513 |
'width' => 12,
|
514 |
),
|
515 |
),
|
516 |
+
'params' => array(
|
517 |
array(
|
518 |
+
'type' => 'checkbox',
|
519 |
+
'name' => $prefix . 'title',
|
520 |
+
'options' => PT_CV_Values::yes_no( 'yes', __( 'Show Title', PT_CV_DOMAIN ) ),
|
521 |
+
'std' => 'yes',
|
522 |
),
|
523 |
),
|
524 |
),
|
|
|
525 |
// Show Content
|
526 |
array(
|
527 |
+
'label' => array(
|
528 |
'text' => '',
|
529 |
),
|
530 |
+
'extra_setting' => array(
|
531 |
'params' => array(
|
532 |
'width' => 12,
|
533 |
),
|
534 |
),
|
535 |
+
'params' => array(
|
536 |
array(
|
537 |
+
'type' => 'checkbox',
|
538 |
+
'name' => $prefix . 'content',
|
539 |
+
'options' => PT_CV_Values::yes_no( 'yes', __( 'Show Content', PT_CV_DOMAIN ) ),
|
540 |
+
'std' => 'yes',
|
541 |
),
|
542 |
),
|
543 |
),
|
|
|
544 |
// Show Meta fields
|
545 |
array(
|
546 |
+
'label' => array(
|
547 |
'text' => '',
|
548 |
),
|
549 |
+
'extra_setting' => array(
|
550 |
'params' => array(
|
551 |
'width' => 12,
|
552 |
),
|
553 |
),
|
554 |
+
'params' => array(
|
555 |
array(
|
556 |
+
'type' => 'checkbox',
|
557 |
+
'name' => $prefix . 'meta-fields',
|
558 |
+
'options' => PT_CV_Values::yes_no( 'yes', __( 'Show Meta Fields (Author, Date, Comment...)', PT_CV_DOMAIN ) ),
|
559 |
+
'std' => '',
|
560 |
),
|
561 |
),
|
562 |
),
|
579 |
$result = array(
|
580 |
// Size
|
581 |
array(
|
582 |
+
'label' => array(
|
583 |
'text' => __( 'Thumbnail size', PT_CV_DOMAIN ),
|
584 |
),
|
585 |
+
'extra_setting' => array(
|
586 |
'params' => array(
|
587 |
'width' => 9,
|
588 |
),
|
589 |
),
|
590 |
+
'params' => array(
|
591 |
array(
|
592 |
+
'type' => 'select',
|
593 |
+
'name' => $prefix . 'thumbnail-size',
|
594 |
+
'options' => PT_CV_Values::field_thumbnail_sizes(),
|
595 |
+
'std' => 'medium',
|
596 |
),
|
597 |
),
|
598 |
),
|
609 |
static function field_meta_fields( $prefix ) {
|
610 |
|
611 |
$result = array(
|
|
|
612 |
// Date
|
613 |
array(
|
614 |
+
'label' => array(
|
615 |
'text' => '',
|
616 |
),
|
617 |
+
'extra_setting' => array(
|
618 |
'params' => array(
|
619 |
'width' => 12,
|
620 |
),
|
621 |
),
|
622 |
+
'params' => array(
|
623 |
array(
|
624 |
+
'type' => 'checkbox',
|
625 |
+
'name' => $prefix . 'date',
|
626 |
+
'options' => PT_CV_Values::yes_no( 'yes', __( 'Show Date', PT_CV_DOMAIN ) ),
|
627 |
+
'std' => 'yes',
|
628 |
),
|
629 |
),
|
630 |
),
|
|
|
631 |
// Author
|
632 |
array(
|
633 |
+
'label' => array(
|
634 |
'text' => '',
|
635 |
),
|
636 |
+
'extra_setting' => array(
|
637 |
'params' => array(
|
638 |
'width' => 12,
|
639 |
),
|
640 |
),
|
641 |
+
'params' => array(
|
642 |
array(
|
643 |
+
'type' => 'checkbox',
|
644 |
+
'name' => $prefix . 'author',
|
645 |
+
'options' => PT_CV_Values::yes_no( 'yes', __( 'Show Author', PT_CV_DOMAIN ) ),
|
646 |
+
'std' => 'yes',
|
647 |
),
|
648 |
),
|
649 |
),
|
|
|
650 |
// Taxonomy
|
651 |
array(
|
652 |
+
'label' => array(
|
653 |
'text' => '',
|
654 |
),
|
655 |
+
'extra_setting' => array(
|
656 |
'params' => array(
|
657 |
'width' => 12,
|
658 |
),
|
659 |
),
|
660 |
+
'params' => array(
|
661 |
array(
|
662 |
+
'type' => 'checkbox',
|
663 |
+
'name' => $prefix . 'taxonomy',
|
664 |
+
'options' => PT_CV_Values::yes_no( 'yes', __( 'Show Taxonomies (categories, tags...)', PT_CV_DOMAIN ) ),
|
665 |
+
'std' => 'yes',
|
666 |
),
|
667 |
),
|
668 |
+
'dependence' => array( 'content-type', 'page', '!=' ),
|
669 |
),
|
|
|
670 |
// Comment
|
671 |
array(
|
672 |
+
'label' => array(
|
673 |
'text' => '',
|
674 |
),
|
675 |
+
'extra_setting' => array(
|
676 |
'params' => array(
|
677 |
'width' => 12,
|
678 |
),
|
679 |
),
|
680 |
+
'params' => array(
|
681 |
array(
|
682 |
+
'type' => 'checkbox',
|
683 |
+
'name' => $prefix . 'comment',
|
684 |
+
'options' => PT_CV_Values::yes_no( 'yes', __( 'Show Comment Count', PT_CV_DOMAIN ) ),
|
685 |
+
'std' => 'yes',
|
686 |
),
|
687 |
),
|
688 |
),
|
|
|
689 |
);
|
690 |
|
691 |
// Sort array of params by saved order
|
706 |
$result = array(
|
707 |
// Number of columns
|
708 |
array(
|
709 |
+
'label' => array(
|
710 |
'text' => __( 'Items per row', PT_CV_DOMAIN ),
|
711 |
),
|
712 |
+
'params' => array(
|
713 |
array(
|
714 |
+
'type' => 'number',
|
715 |
+
'name' => $prefix . 'number-columns',
|
716 |
+
'std' => '2',
|
717 |
+
'append_text' => '1 → 4',
|
718 |
+
'desc' => __( 'The number of items per row of grid', PT_CV_DOMAIN ),
|
719 |
),
|
720 |
),
|
721 |
'dependence' => array( 'view-type', 'grid' ),
|
771 |
static function setting_no_option() {
|
772 |
|
773 |
return array(
|
774 |
+
'label' => array(
|
775 |
'text' => '',
|
776 |
),
|
777 |
+
'extra_setting' => array(
|
778 |
'params' => array(
|
779 |
'width' => 12,
|
780 |
),
|
781 |
),
|
782 |
+
'params' => array(
|
783 |
array(
|
784 |
+
'type' => 'html',
|
785 |
+
'content' => "<div class='" . PT_CV_PREFIX . "text'>" . __( 'There is no option', PT_CV_DOMAIN ) . '</div>',
|
786 |
),
|
787 |
),
|
788 |
);
|
789 |
}
|
790 |
+
|
791 |
}
|
792 |
|
793 |
}
|
includes/update.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Check update, do update
|
4 |
*
|
@@ -8,12 +9,10 @@
|
|
8 |
* @link http://www.contentviewspro.com/
|
9 |
* @copyright 2014 PT Guy
|
10 |
*/
|
11 |
-
|
12 |
// Compare stored version and current version
|
13 |
$stored_version = get_option( PT_CV_OPTION_VERSION );
|
14 |
if ( $stored_version && version_compare( $stored_version, PT_CV_VERSION, '<' ) ) {
|
15 |
// Do update
|
16 |
-
|
17 |
// Update version
|
18 |
update_option( PT_CV_OPTION_VERSION, PT_CV_VERSION );
|
19 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Check update, do update
|
5 |
*
|
9 |
* @link http://www.contentviewspro.com/
|
10 |
* @copyright 2014 PT Guy
|
11 |
*/
|
|
|
12 |
// Compare stored version and current version
|
13 |
$stored_version = get_option( PT_CV_OPTION_VERSION );
|
14 |
if ( $stored_version && version_compare( $stored_version, PT_CV_VERSION, '<' ) ) {
|
15 |
// Do update
|
|
|
16 |
// Update version
|
17 |
update_option( PT_CV_OPTION_VERSION, PT_CV_VERSION );
|
18 |
}
|
includes/values.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Define values for input, select...
|
4 |
*
|
@@ -8,8 +9,7 @@
|
|
8 |
* @link http://www.contentviewspro.com/
|
9 |
* @copyright 2014 PT Guy
|
10 |
*/
|
11 |
-
|
12 |
-
if ( ! class_exists( 'PT_CV_Values' ) ) {
|
13 |
|
14 |
/**
|
15 |
* @name PT_CV_Values
|
@@ -26,17 +26,17 @@ if ( ! class_exists( 'PT_CV_Values' ) ) {
|
|
26 |
* @return array
|
27 |
*/
|
28 |
static function post_types( $args = array(), $excludes_ = array() ) {
|
29 |
-
$excludes
|
30 |
-
$result
|
31 |
-
$args
|
32 |
-
$args
|
33 |
-
$post_types
|
34 |
|
35 |
foreach ( $post_types as $post_type ) {
|
36 |
if ( in_array( $post_type->name, $excludes ) ) {
|
37 |
continue;
|
38 |
}
|
39 |
-
$result[$post_type->name] = __( $post_type->labels->singular_name, PT_CV_DOMAIN );
|
40 |
}
|
41 |
|
42 |
return $result;
|
@@ -49,15 +49,15 @@ if ( ! class_exists( 'PT_CV_Values' ) ) {
|
|
49 |
*/
|
50 |
static function post_types_vs_taxonomies() {
|
51 |
// Get post types
|
52 |
-
$args
|
53 |
-
$post_types
|
54 |
|
55 |
// Get taxonomies of post types
|
56 |
$result = array();
|
57 |
|
58 |
foreach ( $post_types as $post_type ) {
|
59 |
-
$taxonomy_names
|
60 |
-
$result[$post_type]
|
61 |
}
|
62 |
|
63 |
return $result;
|
@@ -71,13 +71,13 @@ if ( ! class_exists( 'PT_CV_Values' ) ) {
|
|
71 |
* @return array
|
72 |
*/
|
73 |
static function taxonomy_list( $args = array() ) {
|
74 |
-
$result
|
75 |
-
$args
|
76 |
-
$args
|
77 |
-
$taxonomies
|
78 |
|
79 |
foreach ( $taxonomies as $taxonomy ) {
|
80 |
-
$result[$taxonomy->name] = __( $taxonomy->labels->singular_name, PT_CV_DOMAIN );
|
81 |
}
|
82 |
|
83 |
return $result;
|
@@ -90,8 +90,8 @@ if ( ! class_exists( 'PT_CV_Values' ) ) {
|
|
90 |
*/
|
91 |
static function taxonomy_relation() {
|
92 |
return array(
|
93 |
-
'AND'
|
94 |
-
'OR'
|
95 |
);
|
96 |
}
|
97 |
|
@@ -101,9 +101,9 @@ if ( ! class_exists( 'PT_CV_Values' ) ) {
|
|
101 |
*/
|
102 |
static function taxonomy_operators() {
|
103 |
return array(
|
104 |
-
'IN'
|
105 |
'NOT IN' => __( 'NOT IN', PT_CV_DOMAIN ) . ' — ' . __( 'A post is displayed only if it did NOT associated with any values in terms list', PT_CV_DOMAIN ),
|
106 |
-
'AND'
|
107 |
);
|
108 |
}
|
109 |
|
@@ -116,11 +116,11 @@ if ( ! class_exists( 'PT_CV_Values' ) ) {
|
|
116 |
* @return array
|
117 |
*/
|
118 |
static function taxonomy_by_post_type( $object, $output = 'names' ) {
|
119 |
-
$data
|
120 |
-
$result
|
121 |
|
122 |
foreach ( (array) $data as $taxonomy ) {
|
123 |
-
$result[$taxonomy] = self::taxonomy_info( $taxonomy, 'singular_name' );
|
124 |
}
|
125 |
|
126 |
return $result;
|
@@ -155,16 +155,20 @@ if ( ! class_exists( 'PT_CV_Values' ) ) {
|
|
155 |
* @param string $terms_of_taxonomies Array of terms of taxonomies
|
156 |
* @param array $args Array of query parameters
|
157 |
*/
|
158 |
-
static function term_of_taxonomy( $taxonomy, &$terms_of_taxonomies,
|
159 |
-
|
160 |
-
$args
|
161 |
-
$terms
|
162 |
|
163 |
$term_slug_name = array();
|
164 |
foreach ( $terms as $term ) {
|
165 |
-
$term_slug_name[$term->slug] = $term->name;
|
166 |
}
|
167 |
-
|
|
|
|
|
|
|
|
|
168 |
}
|
169 |
|
170 |
/**
|
@@ -174,11 +178,11 @@ if ( ! class_exists( 'PT_CV_Values' ) ) {
|
|
174 |
*/
|
175 |
static function yes_no( $key = '', $value = '' ) {
|
176 |
$result = array(
|
177 |
-
'yes'
|
178 |
-
'no'
|
179 |
);
|
180 |
-
if ( !
|
181 |
-
return array( $key => empty( $value ) ? $result[$key] : $value );
|
182 |
}
|
183 |
|
184 |
return $result;
|
@@ -191,8 +195,8 @@ if ( ! class_exists( 'PT_CV_Values' ) ) {
|
|
191 |
*/
|
192 |
static function show_hide() {
|
193 |
return array(
|
194 |
-
'show'
|
195 |
-
'hide'
|
196 |
);
|
197 |
}
|
198 |
|
@@ -203,7 +207,7 @@ if ( ! class_exists( 'PT_CV_Values' ) ) {
|
|
203 |
*/
|
204 |
static function pagination_types() {
|
205 |
$result = array(
|
206 |
-
'ajax'
|
207 |
'normal' => __( 'Normal', PT_CV_DOMAIN ),
|
208 |
);
|
209 |
|
@@ -234,8 +238,8 @@ if ( ! class_exists( 'PT_CV_Values' ) ) {
|
|
234 |
*/
|
235 |
static function orders() {
|
236 |
return array(
|
237 |
-
'asc'
|
238 |
-
'desc'
|
239 |
);
|
240 |
}
|
241 |
|
@@ -244,14 +248,14 @@ if ( ! class_exists( 'PT_CV_Values' ) ) {
|
|
244 |
*/
|
245 |
static function post_statuses() {
|
246 |
return array(
|
247 |
-
'publish'
|
248 |
-
'pending'
|
249 |
-
'draft'
|
250 |
'auto-draft' => __( 'Auto draft', PT_CV_DOMAIN ),
|
251 |
-
'future'
|
252 |
-
'private'
|
253 |
-
'inherit'
|
254 |
-
'trash'
|
255 |
);
|
256 |
}
|
257 |
|
@@ -262,14 +266,13 @@ if ( ! class_exists( 'PT_CV_Values' ) ) {
|
|
262 |
*/
|
263 |
static function advanced_settings() {
|
264 |
return apply_filters(
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
)
|
273 |
);
|
274 |
}
|
275 |
|
@@ -279,8 +282,8 @@ if ( ! class_exists( 'PT_CV_Values' ) ) {
|
|
279 |
* @return array
|
280 |
*/
|
281 |
static function post_author( $name = 'author', $data = array() ) {
|
282 |
-
$field_name
|
283 |
-
$selected
|
284 |
|
285 |
return wp_dropdown_users( array( 'name' => $field_name, 'selected' => $selected, 'class' => 'form-control', 'show_option_none' => __( '— Select —', PT_CV_DOMAIN ), 'echo' => false ) );
|
286 |
}
|
@@ -292,21 +295,21 @@ if ( ! class_exists( 'PT_CV_Values' ) ) {
|
|
292 |
*/
|
293 |
static function user_list() {
|
294 |
|
295 |
-
$result
|
296 |
-
$show
|
297 |
|
298 |
$args = array(
|
299 |
-
'fields'
|
300 |
-
'orderby'
|
301 |
-
'order'
|
302 |
);
|
303 |
|
304 |
$users = get_users( $args );
|
305 |
foreach ( (array) $users as $user ) {
|
306 |
-
$user->ID
|
307 |
-
$display
|
308 |
|
309 |
-
$result[$user->ID] = esc_html( $display );
|
310 |
}
|
311 |
|
312 |
return $result;
|
@@ -317,11 +320,11 @@ if ( ! class_exists( 'PT_CV_Values' ) ) {
|
|
317 |
*/
|
318 |
static function post_regular_orderby() {
|
319 |
$regular_orderby = array(
|
320 |
-
''
|
321 |
-
'ID'
|
322 |
-
'title'
|
323 |
-
'date'
|
324 |
-
'modified'
|
325 |
);
|
326 |
|
327 |
$result = apply_filters( PT_CV_PREFIX_ . 'regular_orderby', $regular_orderby );
|
@@ -337,9 +340,9 @@ if ( ! class_exists( 'PT_CV_Values' ) ) {
|
|
337 |
static function view_type() {
|
338 |
|
339 |
$view_type = array(
|
340 |
-
'grid'
|
341 |
-
'collapsible'
|
342 |
-
'scrollable'
|
343 |
);
|
344 |
|
345 |
$result = apply_filters( PT_CV_PREFIX_ . 'view_type', $view_type );
|
@@ -357,13 +360,13 @@ if ( ! class_exists( 'PT_CV_Values' ) ) {
|
|
357 |
$view_type_settings = array();
|
358 |
|
359 |
// Settings of Grid type
|
360 |
-
$view_type_settings['grid'] = PT_CV_Settings::view_type_settings_grid();
|
361 |
|
362 |
// Settings of Collapsible type
|
363 |
-
$view_type_settings['collapsible'] = PT_CV_Settings::view_type_settings_collapsible();
|
364 |
|
365 |
// Settings of Scrollable type
|
366 |
-
$view_type_settings['scrollable'] = PT_CV_Settings::view_type_settings_scrollable();
|
367 |
|
368 |
$result = apply_filters( PT_CV_PREFIX_ . 'view_type_settings', $view_type_settings );
|
369 |
|
@@ -378,8 +381,8 @@ if ( ! class_exists( 'PT_CV_Values' ) ) {
|
|
378 |
static function layout_format() {
|
379 |
|
380 |
$result = array(
|
381 |
-
'1-col'
|
382 |
-
'2-col'
|
383 |
);
|
384 |
|
385 |
$result = apply_filters( PT_CV_PREFIX_ . 'layout_format', $result );
|
@@ -393,7 +396,7 @@ if ( ! class_exists( 'PT_CV_Values' ) ) {
|
|
393 |
static function open_in() {
|
394 |
|
395 |
$open_in = array(
|
396 |
-
'_self'
|
397 |
'_blank' => __( 'New tab', PT_CV_DOMAIN ),
|
398 |
);
|
399 |
|
@@ -409,47 +412,47 @@ if ( ! class_exists( 'PT_CV_Values' ) ) {
|
|
409 |
// All available thumbnail sizes
|
410 |
global $_wp_additional_image_sizes;
|
411 |
|
412 |
-
$result
|
413 |
|
414 |
foreach ( get_intermediate_image_sizes() as $size_name ) {
|
415 |
if ( in_array( $size_name, array( 'thumbnail', 'medium', 'large' ) ) ) {
|
416 |
-
$this_size
|
417 |
$this_size[] = get_option( $size_name . '_size_w' );
|
418 |
$this_size[] = get_option( $size_name . '_size_h' );
|
419 |
|
420 |
// Add official sizes to result
|
421 |
-
$result[$size_name] = ucfirst( $size_name ) . ' (' . implode( ' × ', $this_size ) . ')';
|
422 |
} else {
|
423 |
-
if ( isset( $_wp_additional_image_sizes ) && isset( $_wp_additional_image_sizes[$size_name] ) ) {
|
424 |
|
425 |
-
$this_size
|
426 |
-
$this_size['width']
|
427 |
-
$this_size['height']
|
428 |
|
429 |
// Calculate sizes value for sorting
|
430 |
-
$sizes_value = intval( $this_size['width'] ) * intval( $this_size['height'] ) + rand( 1, 10 );
|
431 |
|
432 |
-
$dimensions_to_sort[$sizes_value] = $size_name;
|
433 |
} else {
|
434 |
$this_size = array( 0, 0 );
|
435 |
}
|
436 |
|
437 |
-
$sizes_to_sort[$size_name] = ucfirst( preg_replace( '/[\-_]/', ' ', $size_name ) ) . ' (' . implode( ' × ', $this_size ) . ')';
|
438 |
}
|
439 |
|
440 |
-
if ( !
|
441 |
return $this_size;
|
442 |
}
|
443 |
}
|
444 |
// Add full sizes
|
445 |
-
$result['full'] = __( 'Original resolution (But resize automatically to fit its container)', PT_CV_DOMAIN );
|
446 |
|
447 |
// Sort custom sizes by index (width * height)
|
448 |
krsort( $dimensions_to_sort );
|
449 |
|
450 |
// Get array element in ASC sorted order
|
451 |
foreach ( array_reverse( $dimensions_to_sort ) as $size_name ) {
|
452 |
-
$result[$size_name] = $sizes_to_sort[$size_name];
|
453 |
}
|
454 |
|
455 |
$result = apply_filters( PT_CV_PREFIX_ . 'field_thumbnail_sizes', $result );
|
@@ -465,16 +468,15 @@ if ( ! class_exists( 'PT_CV_Values' ) ) {
|
|
465 |
static function tab_position() {
|
466 |
|
467 |
$tab_position = array(
|
468 |
-
'top'
|
469 |
-
'left'
|
470 |
'bottom' => __( 'Bottom', PT_CV_DOMAIN ),
|
471 |
-
'right'
|
472 |
);
|
473 |
|
474 |
$result = apply_filters( PT_CV_PREFIX_ . 'tab_position', $tab_position );
|
475 |
|
476 |
return $result;
|
477 |
-
|
478 |
}
|
479 |
|
480 |
/**
|
@@ -485,14 +487,13 @@ if ( ! class_exists( 'PT_CV_Values' ) ) {
|
|
485 |
static function thumbnail_position() {
|
486 |
|
487 |
$thumbnail_position = array(
|
488 |
-
'left'
|
489 |
-
'right'
|
490 |
);
|
491 |
|
492 |
$result = apply_filters( PT_CV_PREFIX_ . 'thumbnail_position', $thumbnail_position );
|
493 |
|
494 |
return $result;
|
495 |
-
|
496 |
}
|
497 |
|
498 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Define values for input, select...
|
5 |
*
|
9 |
* @link http://www.contentviewspro.com/
|
10 |
* @copyright 2014 PT Guy
|
11 |
*/
|
12 |
+
if ( !class_exists( 'PT_CV_Values' ) ) {
|
|
|
13 |
|
14 |
/**
|
15 |
* @name PT_CV_Values
|
26 |
* @return array
|
27 |
*/
|
28 |
static function post_types( $args = array(), $excludes_ = array() ) {
|
29 |
+
$excludes = array_merge( array( 'attachment' ), $excludes_ );
|
30 |
+
$result = array();
|
31 |
+
$args = array_merge( array( 'public' => true, 'show_ui' => true, '_builtin' => true ), $args );
|
32 |
+
$args = apply_filters( PT_CV_PREFIX_ . 'post_types', $args );
|
33 |
+
$post_types = get_post_types( $args, 'objects' );
|
34 |
|
35 |
foreach ( $post_types as $post_type ) {
|
36 |
if ( in_array( $post_type->name, $excludes ) ) {
|
37 |
continue;
|
38 |
}
|
39 |
+
$result[ $post_type->name ] = __( $post_type->labels->singular_name, PT_CV_DOMAIN );
|
40 |
}
|
41 |
|
42 |
return $result;
|
49 |
*/
|
50 |
static function post_types_vs_taxonomies() {
|
51 |
// Get post types
|
52 |
+
$args = apply_filters( PT_CV_PREFIX_ . 'post_types', array( 'public' => true, 'show_ui' => true, '_builtin' => true ) );
|
53 |
+
$post_types = get_post_types( $args );
|
54 |
|
55 |
// Get taxonomies of post types
|
56 |
$result = array();
|
57 |
|
58 |
foreach ( $post_types as $post_type ) {
|
59 |
+
$taxonomy_names = get_object_taxonomies( $post_type );
|
60 |
+
$result[ $post_type ] = $taxonomy_names;
|
61 |
}
|
62 |
|
63 |
return $result;
|
71 |
* @return array
|
72 |
*/
|
73 |
static function taxonomy_list( $args = array() ) {
|
74 |
+
$result = array();
|
75 |
+
$args = array_merge( array( 'public' => true, 'show_ui' => true, '_builtin' => true ), $args );
|
76 |
+
$args = apply_filters( PT_CV_PREFIX_ . 'taxonomy_query_args', $args );
|
77 |
+
$taxonomies = get_taxonomies( $args, 'objects' );
|
78 |
|
79 |
foreach ( $taxonomies as $taxonomy ) {
|
80 |
+
$result[ $taxonomy->name ] = __( $taxonomy->labels->singular_name, PT_CV_DOMAIN );
|
81 |
}
|
82 |
|
83 |
return $result;
|
90 |
*/
|
91 |
static function taxonomy_relation() {
|
92 |
return array(
|
93 |
+
'AND' => __( 'AND', PT_CV_DOMAIN ),
|
94 |
+
'OR' => __( 'OR', PT_CV_DOMAIN ),
|
95 |
);
|
96 |
}
|
97 |
|
101 |
*/
|
102 |
static function taxonomy_operators() {
|
103 |
return array(
|
104 |
+
'IN' => __( 'IN', PT_CV_DOMAIN ) . ' — ' . __( 'A post is displayed only if it associated with at least one value in terms list', PT_CV_DOMAIN ),
|
105 |
'NOT IN' => __( 'NOT IN', PT_CV_DOMAIN ) . ' — ' . __( 'A post is displayed only if it did NOT associated with any values in terms list', PT_CV_DOMAIN ),
|
106 |
+
'AND' => __( 'AND', PT_CV_DOMAIN ) . ' — ' . __( 'A post is displayed only if it associated with all values in terms list', PT_CV_DOMAIN ),
|
107 |
);
|
108 |
}
|
109 |
|
116 |
* @return array
|
117 |
*/
|
118 |
static function taxonomy_by_post_type( $object, $output = 'names' ) {
|
119 |
+
$data = get_object_taxonomies( $object, $output );
|
120 |
+
$result = array();
|
121 |
|
122 |
foreach ( (array) $data as $taxonomy ) {
|
123 |
+
$result[ $taxonomy ] = self::taxonomy_info( $taxonomy, 'singular_name' );
|
124 |
}
|
125 |
|
126 |
return $result;
|
155 |
* @param string $terms_of_taxonomies Array of terms of taxonomies
|
156 |
* @param array $args Array of query parameters
|
157 |
*/
|
158 |
+
static function term_of_taxonomy( $taxonomy, &$terms_of_taxonomies,
|
159 |
+
$args = array() ) {
|
160 |
+
$args = array_merge( array( 'hide_empty' => false ), $args );
|
161 |
+
$terms = get_terms( array( $taxonomy ), $args );
|
162 |
|
163 |
$term_slug_name = array();
|
164 |
foreach ( $terms as $term ) {
|
165 |
+
$term_slug_name[ $term->slug ] = $term->name;
|
166 |
}
|
167 |
+
|
168 |
+
// Sort values of param by saved order
|
169 |
+
$term_slug_name = apply_filters( PT_CV_PREFIX_ . 'settings_sort_single', $term_slug_name, $taxonomy . '-' . 'terms' );
|
170 |
+
|
171 |
+
$terms_of_taxonomies[ $taxonomy ] = $term_slug_name;
|
172 |
}
|
173 |
|
174 |
/**
|
178 |
*/
|
179 |
static function yes_no( $key = '', $value = '' ) {
|
180 |
$result = array(
|
181 |
+
'yes' => __( 'Yes', PT_CV_DOMAIN ),
|
182 |
+
'no' => __( 'No', PT_CV_DOMAIN ),
|
183 |
);
|
184 |
+
if ( !empty( $key ) ) {
|
185 |
+
return array( $key => empty( $value ) ? $result[ $key ] : $value );
|
186 |
}
|
187 |
|
188 |
return $result;
|
195 |
*/
|
196 |
static function show_hide() {
|
197 |
return array(
|
198 |
+
'show' => __( 'Show', PT_CV_DOMAIN ),
|
199 |
+
'hide' => __( 'Hide', PT_CV_DOMAIN ),
|
200 |
);
|
201 |
}
|
202 |
|
207 |
*/
|
208 |
static function pagination_types() {
|
209 |
$result = array(
|
210 |
+
'ajax' => __( 'Ajax', PT_CV_DOMAIN ),
|
211 |
'normal' => __( 'Normal', PT_CV_DOMAIN ),
|
212 |
);
|
213 |
|
238 |
*/
|
239 |
static function orders() {
|
240 |
return array(
|
241 |
+
'asc' => __( 'ASC', PT_CV_DOMAIN ),
|
242 |
+
'desc' => __( 'DESC', PT_CV_DOMAIN ),
|
243 |
);
|
244 |
}
|
245 |
|
248 |
*/
|
249 |
static function post_statuses() {
|
250 |
return array(
|
251 |
+
'publish' => __( 'Publish', PT_CV_DOMAIN ),
|
252 |
+
'pending' => __( 'Pending', PT_CV_DOMAIN ),
|
253 |
+
'draft' => __( 'Draft', PT_CV_DOMAIN ),
|
254 |
'auto-draft' => __( 'Auto draft', PT_CV_DOMAIN ),
|
255 |
+
'future' => __( 'Future', PT_CV_DOMAIN ),
|
256 |
+
'private' => __( 'Private', PT_CV_DOMAIN ),
|
257 |
+
'inherit' => __( 'Inherit', PT_CV_DOMAIN ),
|
258 |
+
'trash' => __( 'Trash', PT_CV_DOMAIN ),
|
259 |
);
|
260 |
}
|
261 |
|
266 |
*/
|
267 |
static function advanced_settings() {
|
268 |
return apply_filters(
|
269 |
+
PT_CV_PREFIX_ . 'advanced_settings', array(
|
270 |
+
'taxonomy' => __( 'Taxonomy (Categories, Tags...)', PT_CV_DOMAIN ),
|
271 |
+
'status' => __( 'Status', PT_CV_DOMAIN ),
|
272 |
+
'order' => __( 'Order & Orderby', PT_CV_DOMAIN ),
|
273 |
+
'search' => __( 'Search', PT_CV_DOMAIN ),
|
274 |
+
'author' => __( 'Author', PT_CV_DOMAIN ),
|
275 |
+
)
|
|
|
276 |
);
|
277 |
}
|
278 |
|
282 |
* @return array
|
283 |
*/
|
284 |
static function post_author( $name = 'author', $data = array() ) {
|
285 |
+
$field_name = PT_CV_PREFIX . $name;
|
286 |
+
$selected = isset( $data[ $field_name ] ) ? $data[ $field_name ] : '';
|
287 |
|
288 |
return wp_dropdown_users( array( 'name' => $field_name, 'selected' => $selected, 'class' => 'form-control', 'show_option_none' => __( '— Select —', PT_CV_DOMAIN ), 'echo' => false ) );
|
289 |
}
|
295 |
*/
|
296 |
static function user_list() {
|
297 |
|
298 |
+
$result = array();
|
299 |
+
$show = 'display_name';
|
300 |
|
301 |
$args = array(
|
302 |
+
'fields' => array( 'ID', $show ),
|
303 |
+
'orderby' => 'display_name',
|
304 |
+
'order' => 'ASC',
|
305 |
);
|
306 |
|
307 |
$users = get_users( $args );
|
308 |
foreach ( (array) $users as $user ) {
|
309 |
+
$user->ID = (int) $user->ID;
|
310 |
+
$display = !empty( $user->$show ) ? $user->$show : '(' . $user->user_login . ')';
|
311 |
|
312 |
+
$result[ $user->ID ] = esc_html( $display );
|
313 |
}
|
314 |
|
315 |
return $result;
|
320 |
*/
|
321 |
static function post_regular_orderby() {
|
322 |
$regular_orderby = array(
|
323 |
+
'' => __( '— Select —', PT_CV_DOMAIN ),
|
324 |
+
'ID' => __( 'ID', PT_CV_DOMAIN ),
|
325 |
+
'title' => __( 'Title', PT_CV_DOMAIN ),
|
326 |
+
'date' => __( 'Created date', PT_CV_DOMAIN ),
|
327 |
+
'modified' => __( 'Modified date', PT_CV_DOMAIN ),
|
328 |
);
|
329 |
|
330 |
$result = apply_filters( PT_CV_PREFIX_ . 'regular_orderby', $regular_orderby );
|
340 |
static function view_type() {
|
341 |
|
342 |
$view_type = array(
|
343 |
+
'grid' => __( 'Grid', PT_CV_DOMAIN ),
|
344 |
+
'collapsible' => __( 'Collapsible List', PT_CV_DOMAIN ),
|
345 |
+
'scrollable' => __( 'Scrollable List', PT_CV_DOMAIN ),
|
346 |
);
|
347 |
|
348 |
$result = apply_filters( PT_CV_PREFIX_ . 'view_type', $view_type );
|
360 |
$view_type_settings = array();
|
361 |
|
362 |
// Settings of Grid type
|
363 |
+
$view_type_settings[ 'grid' ] = PT_CV_Settings::view_type_settings_grid();
|
364 |
|
365 |
// Settings of Collapsible type
|
366 |
+
$view_type_settings[ 'collapsible' ] = PT_CV_Settings::view_type_settings_collapsible();
|
367 |
|
368 |
// Settings of Scrollable type
|
369 |
+
$view_type_settings[ 'scrollable' ] = PT_CV_Settings::view_type_settings_scrollable();
|
370 |
|
371 |
$result = apply_filters( PT_CV_PREFIX_ . 'view_type_settings', $view_type_settings );
|
372 |
|
381 |
static function layout_format() {
|
382 |
|
383 |
$result = array(
|
384 |
+
'1-col' => __( '1 column — All fields inside an output item are shown in one column', PT_CV_DOMAIN ),
|
385 |
+
'2-col' => __( '2 columns — Show thumbnail on the left/right side of other fields', PT_CV_DOMAIN ),
|
386 |
);
|
387 |
|
388 |
$result = apply_filters( PT_CV_PREFIX_ . 'layout_format', $result );
|
396 |
static function open_in() {
|
397 |
|
398 |
$open_in = array(
|
399 |
+
'_self' => __( 'Current tab', PT_CV_DOMAIN ),
|
400 |
'_blank' => __( 'New tab', PT_CV_DOMAIN ),
|
401 |
);
|
402 |
|
412 |
// All available thumbnail sizes
|
413 |
global $_wp_additional_image_sizes;
|
414 |
|
415 |
+
$result = $sizes_to_sort = $dimensions_to_sort = array();
|
416 |
|
417 |
foreach ( get_intermediate_image_sizes() as $size_name ) {
|
418 |
if ( in_array( $size_name, array( 'thumbnail', 'medium', 'large' ) ) ) {
|
419 |
+
$this_size = array();
|
420 |
$this_size[] = get_option( $size_name . '_size_w' );
|
421 |
$this_size[] = get_option( $size_name . '_size_h' );
|
422 |
|
423 |
// Add official sizes to result
|
424 |
+
$result[ $size_name ] = ucfirst( $size_name ) . ' (' . implode( ' × ', $this_size ) . ')';
|
425 |
} else {
|
426 |
+
if ( isset( $_wp_additional_image_sizes ) && isset( $_wp_additional_image_sizes[ $size_name ] ) ) {
|
427 |
|
428 |
+
$this_size = array();
|
429 |
+
$this_size[ 'width' ] = $_wp_additional_image_sizes[ $size_name ][ 'width' ];
|
430 |
+
$this_size[ 'height' ] = $_wp_additional_image_sizes[ $size_name ][ 'height' ];
|
431 |
|
432 |
// Calculate sizes value for sorting
|
433 |
+
$sizes_value = intval( $this_size[ 'width' ] ) * intval( $this_size[ 'height' ] ) + rand( 1, 10 );
|
434 |
|
435 |
+
$dimensions_to_sort[ $sizes_value ] = $size_name;
|
436 |
} else {
|
437 |
$this_size = array( 0, 0 );
|
438 |
}
|
439 |
|
440 |
+
$sizes_to_sort[ $size_name ] = ucfirst( preg_replace( '/[\-_]/', ' ', $size_name ) ) . ' (' . implode( ' × ', $this_size ) . ')';
|
441 |
}
|
442 |
|
443 |
+
if ( !empty( $_size_name ) && $_size_name == $size_name ) {
|
444 |
return $this_size;
|
445 |
}
|
446 |
}
|
447 |
// Add full sizes
|
448 |
+
$result[ 'full' ] = __( 'Original resolution (But resize automatically to fit its container)', PT_CV_DOMAIN );
|
449 |
|
450 |
// Sort custom sizes by index (width * height)
|
451 |
krsort( $dimensions_to_sort );
|
452 |
|
453 |
// Get array element in ASC sorted order
|
454 |
foreach ( array_reverse( $dimensions_to_sort ) as $size_name ) {
|
455 |
+
$result[ $size_name ] = $sizes_to_sort[ $size_name ];
|
456 |
}
|
457 |
|
458 |
$result = apply_filters( PT_CV_PREFIX_ . 'field_thumbnail_sizes', $result );
|
468 |
static function tab_position() {
|
469 |
|
470 |
$tab_position = array(
|
471 |
+
'top' => __( 'Top', PT_CV_DOMAIN ),
|
472 |
+
'left' => __( 'Left', PT_CV_DOMAIN ),
|
473 |
'bottom' => __( 'Bottom', PT_CV_DOMAIN ),
|
474 |
+
'right' => __( 'Right', PT_CV_DOMAIN ),
|
475 |
);
|
476 |
|
477 |
$result = apply_filters( PT_CV_PREFIX_ . 'tab_position', $tab_position );
|
478 |
|
479 |
return $result;
|
|
|
480 |
}
|
481 |
|
482 |
/**
|
487 |
static function thumbnail_position() {
|
488 |
|
489 |
$thumbnail_position = array(
|
490 |
+
'left' => __( 'Left', PT_CV_DOMAIN ),
|
491 |
+
'right' => __( 'Right', PT_CV_DOMAIN ),
|
492 |
);
|
493 |
|
494 |
$result = apply_filters( PT_CV_PREFIX_ . 'thumbnail_position', $thumbnail_position );
|
495 |
|
496 |
return $result;
|
|
|
497 |
}
|
498 |
|
499 |
}
|
public/assets/css/public.css
CHANGED
@@ -168,6 +168,10 @@
|
|
168 |
margin-left: 0;
|
169 |
}
|
170 |
|
|
|
|
|
|
|
|
|
171 |
.pt-cv-pagination li.active a {
|
172 |
border-color: rgba(66, 139, 202, 0.2) !important;
|
173 |
}
|
@@ -182,6 +186,21 @@
|
|
182 |
padding: 10px 15px;
|
183 |
}
|
184 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
185 |
/* View type : Scrollable List */
|
186 |
|
187 |
/* Caption */
|
@@ -189,7 +208,7 @@
|
|
189 |
text-align: left;
|
190 |
left: 0;
|
191 |
right: 15px;
|
192 |
-
bottom:
|
193 |
}
|
194 |
|
195 |
.pt-cv-view .carousel-caption * {
|
@@ -235,6 +254,7 @@
|
|
235 |
width: 40px;
|
236 |
bottom: 0;
|
237 |
top: auto;
|
|
|
238 |
}
|
239 |
|
240 |
/* Indicator */
|
@@ -259,17 +279,6 @@
|
|
259 |
clear: none !important;
|
260 |
}
|
261 |
|
262 |
-
/* Collapsible layout */
|
263 |
-
.pt-cv-view .collapse {
|
264 |
-
display: none;
|
265 |
-
visibility: hidden;
|
266 |
-
}
|
267 |
-
|
268 |
-
.pt-cv-view .collapse.in {
|
269 |
-
display: block;
|
270 |
-
visibility: visible;
|
271 |
-
}
|
272 |
-
|
273 |
/* @Panels-minified */
|
274 |
.pt-cv-view .panel {
|
275 |
margin-bottom: 20px;
|
168 |
margin-left: 0;
|
169 |
}
|
170 |
|
171 |
+
.pt-cv-pagination a {
|
172 |
+
cursor: pointer;
|
173 |
+
}
|
174 |
+
|
175 |
.pt-cv-pagination li.active a {
|
176 |
border-color: rgba(66, 139, 202, 0.2) !important;
|
177 |
}
|
186 |
padding: 10px 15px;
|
187 |
}
|
188 |
|
189 |
+
.pt-cv-collapsible .panel-body {
|
190 |
+
margin: 10px;
|
191 |
+
}
|
192 |
+
|
193 |
+
.pt-cv-view .collapse {
|
194 |
+
display: none;
|
195 |
+
visibility: hidden;
|
196 |
+
}
|
197 |
+
|
198 |
+
.pt-cv-view .collapse.in {
|
199 |
+
display: block;
|
200 |
+
visibility: visible;
|
201 |
+
overflow: auto;
|
202 |
+
}
|
203 |
+
|
204 |
/* View type : Scrollable List */
|
205 |
|
206 |
/* Caption */
|
208 |
text-align: left;
|
209 |
left: 0;
|
210 |
right: 15px;
|
211 |
+
bottom: 1.8em;
|
212 |
}
|
213 |
|
214 |
.pt-cv-view .carousel-caption * {
|
254 |
width: 40px;
|
255 |
bottom: 0;
|
256 |
top: auto;
|
257 |
+
color: #00A100;
|
258 |
}
|
259 |
|
260 |
/* Indicator */
|
279 |
clear: none !important;
|
280 |
}
|
281 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
282 |
/* @Panels-minified */
|
283 |
.pt-cv-view .panel {
|
284 |
margin-bottom: 20px;
|
public/assets/js/public.js
CHANGED
@@ -8,25 +8,24 @@
|
|
8 |
* @copyright 2014 PT Guy
|
9 |
*/
|
10 |
|
11 |
-
(function ($) {
|
12 |
"use strict";
|
13 |
|
14 |
$.PT_CV_Public = $.PT_CV_Public || { };
|
15 |
|
16 |
-
$.PT_CV_Public = function (options) {
|
17 |
-
this.options = $.extend({
|
18 |
_autoload: 1
|
19 |
-
}, options);
|
20 |
|
21 |
// Autoload all registered functions
|
22 |
-
if (this.options._autoload !== 0) {
|
23 |
this.move_bootstrap_to_top();
|
24 |
this.pagination();
|
25 |
}
|
26 |
};
|
27 |
|
28 |
$.PT_CV_Public.prototype = {
|
29 |
-
|
30 |
/**
|
31 |
* Manually move Bootstrap to top of all styles
|
32 |
*
|
@@ -40,13 +39,12 @@
|
|
40 |
var _prefix = PT_CV_PUBLIC._prefix;
|
41 |
|
42 |
var selector = _prefix + 'bootstrap-style-css';
|
43 |
-
var bootstrap_css = $('#' + selector);
|
44 |
-
if (bootstrap_css.length > 0) {
|
45 |
bootstrap_css.remove();
|
46 |
-
$('title').after("<!-- Manually move Bootstrap to top of all styles --><link rel='stylesheet' id='" + selector + "' href='" + bootstrap_css.attr('href') + "' type='text/css' media='all' />");
|
47 |
}
|
48 |
},
|
49 |
-
|
50 |
/**
|
51 |
* Bootstrap pagination
|
52 |
* @returns {undefined}
|
@@ -56,15 +54,15 @@
|
|
56 |
var _prefix = PT_CV_PUBLIC._prefix;
|
57 |
|
58 |
// Bootstrap paginator
|
59 |
-
$('.' + _prefix + 'pagination.' + _prefix + 'ajax').each(function () {
|
60 |
-
var this_ = $(this);
|
61 |
-
var total_pages = $(this).attr('data-totalpages');
|
62 |
-
$(this).bootstrapPaginator({
|
63 |
bootstrapMajorVersion: 3,
|
64 |
-
totalPages
|
65 |
-
shouldShowPage
|
66 |
-
if (total_pages && total_pages < 10) {
|
67 |
-
switch (type) {
|
68 |
case "first":
|
69 |
case "last":
|
70 |
return false;
|
@@ -76,17 +74,16 @@
|
|
76 |
}
|
77 |
},
|
78 |
// When changing page
|
79 |
-
onPageClicked
|
80 |
var selected_page = page;
|
81 |
|
82 |
-
$self._setup_pagination(this_, selected_page, function () {
|
83 |
PT_CV_PUBLIC.paging = 0;
|
84 |
-
});
|
85 |
}
|
86 |
-
});
|
87 |
-
});
|
88 |
},
|
89 |
-
|
90 |
/**
|
91 |
* Get parameters to process pagination
|
92 |
*
|
@@ -95,38 +92,37 @@
|
|
95 |
* @param function callback
|
96 |
* @returns {undefined}
|
97 |
*/
|
98 |
-
_setup_pagination: function (this_, selected_page, callback) {
|
99 |
var $self = this;
|
100 |
var _prefix = PT_CV_PUBLIC._prefix;
|
101 |
|
102 |
PT_CV_PUBLIC.paging = PT_CV_PUBLIC.paging || 0;
|
103 |
// Prevent duplicate processing
|
104 |
-
if (PT_CV_PUBLIC.paging) {
|
105 |
return;
|
106 |
} else {
|
107 |
PT_CV_PUBLIC.paging = 1;
|
108 |
}
|
109 |
|
110 |
-
var session_id = this_.attr('data-sid');
|
111 |
-
var spinner = this_.next('.' + _prefix + 'spinner');
|
112 |
|
113 |
// Get the pagination element
|
114 |
var pagination_wrapper = this_;
|
115 |
-
if (this_.parent('.' + _prefix + 'pagination-wrapper').length) {
|
116 |
-
pagination_wrapper = this_.parent('.' + _prefix + 'pagination-wrapper');
|
117 |
}
|
118 |
|
119 |
// Get the View element
|
120 |
-
var pages_holder = pagination_wrapper.prev('.' + _prefix + 'view');
|
121 |
|
122 |
// For Timeline
|
123 |
-
if (pages_holder.hasClass(_prefix + 'timeline')) {
|
124 |
-
pages_holder = pages_holder.children('.tl-items');
|
125 |
}
|
126 |
|
127 |
-
$self._get_page(session_id, selected_page, spinner, pages_holder, callback);
|
128 |
},
|
129 |
-
|
130 |
/**
|
131 |
* Get wrapper of selected page
|
132 |
*
|
@@ -137,46 +133,45 @@
|
|
137 |
* @param null|function callback The callback function
|
138 |
* @returns void
|
139 |
*/
|
140 |
-
_get_page: function (session_id, selected_page, spinner, pages_holder, callback) {
|
141 |
|
142 |
var $self = this;
|
143 |
// Show content of page if it existed
|
144 |
-
var page_existed = $self._active_page(selected_page, pages_holder, callback);
|
145 |
// If page is loaded, exit
|
146 |
-
if (page_existed) {
|
147 |
return;
|
148 |
}
|
149 |
|
150 |
// Setup data
|
151 |
var data = {
|
152 |
-
action
|
153 |
-
sid
|
154 |
-
page
|
155 |
-
lang
|
156 |
ajax_nonce: PT_CV_PUBLIC._nonce
|
157 |
};
|
158 |
|
159 |
// Sent POST request
|
160 |
-
$.ajax({
|
161 |
-
type
|
162 |
-
url
|
163 |
-
data
|
164 |
beforeSend: function () {
|
165 |
// Show loading icon
|
166 |
-
spinner.addClass('active');
|
167 |
}
|
168 |
-
}).done(function (response) {
|
169 |
-
|
170 |
-
|
171 |
|
172 |
-
|
173 |
-
|
174 |
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
},
|
179 |
-
|
180 |
/**
|
181 |
* Show content of selected page
|
182 |
*
|
@@ -185,49 +180,49 @@
|
|
185 |
* @param null|function callback The callback function
|
186 |
* @returns bool
|
187 |
*/
|
188 |
-
_active_page: function (selected_page, pages_holder, callback) {
|
189 |
var _prefix = PT_CV_PUBLIC._prefix;
|
190 |
var page_existed = false;
|
191 |
-
var page_selector = '#' + _prefix + 'page' + '-' + parseInt(selected_page);
|
192 |
|
193 |
-
if (pages_holder.children(page_selector).length) {
|
194 |
page_existed = true;
|
195 |
|
196 |
// Hide all pages
|
197 |
pages_holder.children().hide();
|
198 |
|
199 |
// Show this page
|
200 |
-
pages_holder.children(page_selector).show();
|
201 |
|
202 |
// Scroll to this page
|
203 |
-
$('html, body').animate({
|
204 |
-
scrollTop: pages_holder.children(page_selector).offset().top - 160
|
205 |
-
}, 1000);
|
206 |
}
|
207 |
|
208 |
-
if (callback && typeof callback === 'function') {
|
209 |
callback();
|
210 |
}
|
211 |
|
212 |
// Trigger to make Pinterest layout works when do pagination
|
213 |
-
if ($('.' + _prefix + 'pinterest').length || $('.' + _prefix + 'same-height').length) {
|
214 |
-
$('body').trigger(_prefix + 'custom-trigger');
|
215 |
-
$(window).trigger(_prefix + 'resize');
|
216 |
}
|
217 |
|
218 |
// Trigger action after pagination finished
|
219 |
-
$('body').trigger(_prefix + 'pagination-finished');
|
220 |
|
221 |
return page_existed;
|
222 |
}
|
223 |
};
|
224 |
|
225 |
-
$(function () {
|
226 |
|
227 |
var _prefix = PT_CV_PUBLIC._prefix;
|
228 |
|
229 |
// Run at page load
|
230 |
-
new $.PT_CV_Public({_prefix: _prefix});
|
231 |
-
});
|
232 |
|
233 |
-
}(jQuery));
|
8 |
* @copyright 2014 PT Guy
|
9 |
*/
|
10 |
|
11 |
+
( function ( $ ) {
|
12 |
"use strict";
|
13 |
|
14 |
$.PT_CV_Public = $.PT_CV_Public || { };
|
15 |
|
16 |
+
$.PT_CV_Public = function ( options ) {
|
17 |
+
this.options = $.extend( {
|
18 |
_autoload: 1
|
19 |
+
}, options );
|
20 |
|
21 |
// Autoload all registered functions
|
22 |
+
if ( this.options._autoload !== 0 ) {
|
23 |
this.move_bootstrap_to_top();
|
24 |
this.pagination();
|
25 |
}
|
26 |
};
|
27 |
|
28 |
$.PT_CV_Public.prototype = {
|
|
|
29 |
/**
|
30 |
* Manually move Bootstrap to top of all styles
|
31 |
*
|
39 |
var _prefix = PT_CV_PUBLIC._prefix;
|
40 |
|
41 |
var selector = _prefix + 'bootstrap-style-css';
|
42 |
+
var bootstrap_css = $( '#' + selector );
|
43 |
+
if ( bootstrap_css.length > 0 ) {
|
44 |
bootstrap_css.remove();
|
45 |
+
$( 'title' ).after( "<!-- Manually move Bootstrap to top of all styles --><link rel='stylesheet' id='" + selector + "' href='" + bootstrap_css.attr( 'href' ) + "' type='text/css' media='all' />" );
|
46 |
}
|
47 |
},
|
|
|
48 |
/**
|
49 |
* Bootstrap pagination
|
50 |
* @returns {undefined}
|
54 |
var _prefix = PT_CV_PUBLIC._prefix;
|
55 |
|
56 |
// Bootstrap paginator
|
57 |
+
$( '.' + _prefix + 'pagination.' + _prefix + 'ajax' ).each( function () {
|
58 |
+
var this_ = $( this );
|
59 |
+
var total_pages = $( this ).attr( 'data-totalpages' );
|
60 |
+
$( this ).bootstrapPaginator( {
|
61 |
bootstrapMajorVersion: 3,
|
62 |
+
totalPages: total_pages,
|
63 |
+
shouldShowPage: function ( type, page, current ) {
|
64 |
+
if ( total_pages && total_pages < 10 ) {
|
65 |
+
switch ( type ) {
|
66 |
case "first":
|
67 |
case "last":
|
68 |
return false;
|
74 |
}
|
75 |
},
|
76 |
// When changing page
|
77 |
+
onPageClicked: function ( e, originalEvent, type, page ) {
|
78 |
var selected_page = page;
|
79 |
|
80 |
+
$self._setup_pagination( this_, selected_page, function () {
|
81 |
PT_CV_PUBLIC.paging = 0;
|
82 |
+
} );
|
83 |
}
|
84 |
+
} );
|
85 |
+
} );
|
86 |
},
|
|
|
87 |
/**
|
88 |
* Get parameters to process pagination
|
89 |
*
|
92 |
* @param function callback
|
93 |
* @returns {undefined}
|
94 |
*/
|
95 |
+
_setup_pagination: function ( this_, selected_page, callback ) {
|
96 |
var $self = this;
|
97 |
var _prefix = PT_CV_PUBLIC._prefix;
|
98 |
|
99 |
PT_CV_PUBLIC.paging = PT_CV_PUBLIC.paging || 0;
|
100 |
// Prevent duplicate processing
|
101 |
+
if ( PT_CV_PUBLIC.paging ) {
|
102 |
return;
|
103 |
} else {
|
104 |
PT_CV_PUBLIC.paging = 1;
|
105 |
}
|
106 |
|
107 |
+
var session_id = this_.attr( 'data-sid' );
|
108 |
+
var spinner = this_.next( '.' + _prefix + 'spinner' );
|
109 |
|
110 |
// Get the pagination element
|
111 |
var pagination_wrapper = this_;
|
112 |
+
if ( this_.parent( '.' + _prefix + 'pagination-wrapper' ).length ) {
|
113 |
+
pagination_wrapper = this_.parent( '.' + _prefix + 'pagination-wrapper' );
|
114 |
}
|
115 |
|
116 |
// Get the View element
|
117 |
+
var pages_holder = pagination_wrapper.prev( '.' + _prefix + 'view' );
|
118 |
|
119 |
// For Timeline
|
120 |
+
if ( pages_holder.hasClass( _prefix + 'timeline' ) ) {
|
121 |
+
pages_holder = pages_holder.children( '.tl-items' );
|
122 |
}
|
123 |
|
124 |
+
$self._get_page( session_id, selected_page, spinner, pages_holder, callback );
|
125 |
},
|
|
|
126 |
/**
|
127 |
* Get wrapper of selected page
|
128 |
*
|
133 |
* @param null|function callback The callback function
|
134 |
* @returns void
|
135 |
*/
|
136 |
+
_get_page: function ( session_id, selected_page, spinner, pages_holder, callback ) {
|
137 |
|
138 |
var $self = this;
|
139 |
// Show content of page if it existed
|
140 |
+
var page_existed = $self._active_page( selected_page, pages_holder, callback );
|
141 |
// If page is loaded, exit
|
142 |
+
if ( page_existed ) {
|
143 |
return;
|
144 |
}
|
145 |
|
146 |
// Setup data
|
147 |
var data = {
|
148 |
+
action: 'pagination_request',
|
149 |
+
sid: session_id,
|
150 |
+
page: selected_page,
|
151 |
+
lang: PT_CV_PUBLIC.lang,
|
152 |
ajax_nonce: PT_CV_PUBLIC._nonce
|
153 |
};
|
154 |
|
155 |
// Sent POST request
|
156 |
+
$.ajax( {
|
157 |
+
type: "POST",
|
158 |
+
url: PT_CV_PUBLIC.ajaxurl,
|
159 |
+
data: data,
|
160 |
beforeSend: function () {
|
161 |
// Show loading icon
|
162 |
+
spinner.addClass( 'active' );
|
163 |
}
|
164 |
+
} ).done( function ( response ) {
|
165 |
+
// Hide loading icon
|
166 |
+
spinner.removeClass( 'active' );
|
167 |
|
168 |
+
// Update content of Preview box
|
169 |
+
pages_holder.append( response );
|
170 |
|
171 |
+
// Active current page
|
172 |
+
$self._active_page( selected_page, pages_holder, callback );
|
173 |
+
} );
|
174 |
},
|
|
|
175 |
/**
|
176 |
* Show content of selected page
|
177 |
*
|
180 |
* @param null|function callback The callback function
|
181 |
* @returns bool
|
182 |
*/
|
183 |
+
_active_page: function ( selected_page, pages_holder, callback ) {
|
184 |
var _prefix = PT_CV_PUBLIC._prefix;
|
185 |
var page_existed = false;
|
186 |
+
var page_selector = '#' + _prefix + 'page' + '-' + parseInt( selected_page );
|
187 |
|
188 |
+
if ( pages_holder.children( page_selector ).length ) {
|
189 |
page_existed = true;
|
190 |
|
191 |
// Hide all pages
|
192 |
pages_holder.children().hide();
|
193 |
|
194 |
// Show this page
|
195 |
+
pages_holder.children( page_selector ).show();
|
196 |
|
197 |
// Scroll to this page
|
198 |
+
$( 'html, body' ).animate( {
|
199 |
+
scrollTop: pages_holder.children( page_selector ).offset().top - 160
|
200 |
+
}, 1000 );
|
201 |
}
|
202 |
|
203 |
+
if ( callback && typeof callback === 'function' ) {
|
204 |
callback();
|
205 |
}
|
206 |
|
207 |
// Trigger to make Pinterest layout works when do pagination
|
208 |
+
if ( $( '.' + _prefix + 'pinterest' ).length || $( '.' + _prefix + 'same-height' ).length ) {
|
209 |
+
$( 'body' ).trigger( _prefix + 'custom-trigger' );
|
210 |
+
$( window ).trigger( _prefix + 'resize' );
|
211 |
}
|
212 |
|
213 |
// Trigger action after pagination finished
|
214 |
+
$( 'body' ).trigger( _prefix + 'pagination-finished' );
|
215 |
|
216 |
return page_existed;
|
217 |
}
|
218 |
};
|
219 |
|
220 |
+
$( function () {
|
221 |
|
222 |
var _prefix = PT_CV_PUBLIC._prefix;
|
223 |
|
224 |
// Run at page load
|
225 |
+
new $.PT_CV_Public( { _prefix: _prefix } );
|
226 |
+
} );
|
227 |
|
228 |
+
}( jQuery ) );
|
public/content-views.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Content Views for Public
|
4 |
*
|
@@ -8,7 +9,6 @@
|
|
8 |
* @link http://www.contentviewspro.com/
|
9 |
* @copyright 2014 PT Guy
|
10 |
*/
|
11 |
-
|
12 |
class PT_Content_Views {
|
13 |
|
14 |
/**
|
@@ -230,8 +230,8 @@ class PT_Content_Views {
|
|
230 |
*/
|
231 |
public function load_plugin_textdomain() {
|
232 |
|
233 |
-
$domain
|
234 |
-
$locale
|
235 |
|
236 |
// Load translation file in wp-content/languages/content-views/
|
237 |
load_textdomain( $domain, trailingslashit( WP_LANG_DIR ) . $domain . '/' . $domain . '-' . $locale . '.mo' );
|
@@ -247,37 +247,35 @@ class PT_Content_Views {
|
|
247 |
* Register custom post type : View
|
248 |
*/
|
249 |
$labels = array(
|
250 |
-
'name'
|
251 |
-
'singular_name'
|
252 |
-
'menu_name'
|
253 |
-
'name_admin_bar'
|
254 |
-
'add_new'
|
255 |
-
'add_new_item'
|
256 |
-
'new_item'
|
257 |
-
'edit_item'
|
258 |
-
'view_item'
|
259 |
-
'all_items'
|
260 |
-
'search_items'
|
261 |
-
'parent_item_colon'
|
262 |
-
'not_found'
|
263 |
'not_found_in_trash' => __( 'No views found in Trash.', PT_CV_DOMAIN ),
|
264 |
);
|
265 |
|
266 |
$args = array(
|
267 |
-
'labels'
|
268 |
-
'public'
|
269 |
-
|
270 |
// Hide in menu, but can see All Views page
|
271 |
-
'show_ui'
|
272 |
-
'show_in_menu'
|
273 |
-
|
274 |
-
'
|
275 |
-
'
|
276 |
-
'
|
277 |
-
'
|
278 |
-
'
|
279 |
-
'
|
280 |
-
'supports' => array( 'title', 'author', 'custom-fields' ),
|
281 |
);
|
282 |
|
283 |
register_post_type( PT_CV_POST_TYPE, $args );
|
@@ -314,7 +312,7 @@ class PT_Content_Views {
|
|
314 |
*/
|
315 |
public function update_view_count() {
|
316 |
global $post;
|
317 |
-
if ( !
|
318 |
return;
|
319 |
}
|
320 |
if ( is_single( $post->ID ) ) {
|
@@ -329,7 +327,7 @@ class PT_Content_Views {
|
|
329 |
*/
|
330 |
public function init_global_variables() {
|
331 |
global $processed_view_assets, $processed_views;
|
332 |
-
$processed_view_assets
|
333 |
}
|
334 |
|
335 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Content Views for Public
|
5 |
*
|
9 |
* @link http://www.contentviewspro.com/
|
10 |
* @copyright 2014 PT Guy
|
11 |
*/
|
|
|
12 |
class PT_Content_Views {
|
13 |
|
14 |
/**
|
230 |
*/
|
231 |
public function load_plugin_textdomain() {
|
232 |
|
233 |
+
$domain = $this->plugin_slug;
|
234 |
+
$locale = apply_filters( 'plugin_locale', get_locale(), $domain );
|
235 |
|
236 |
// Load translation file in wp-content/languages/content-views/
|
237 |
load_textdomain( $domain, trailingslashit( WP_LANG_DIR ) . $domain . '/' . $domain . '-' . $locale . '.mo' );
|
247 |
* Register custom post type : View
|
248 |
*/
|
249 |
$labels = array(
|
250 |
+
'name' => _x( 'Views', 'post type general name', PT_CV_DOMAIN ),
|
251 |
+
'singular_name' => _x( 'View', 'post type singular name', PT_CV_DOMAIN ),
|
252 |
+
'menu_name' => _x( 'Views', 'admin menu', PT_CV_DOMAIN ),
|
253 |
+
'name_admin_bar' => _x( 'View', 'add new on admin bar', PT_CV_DOMAIN ),
|
254 |
+
'add_new' => _x( 'Add New', PT_CV_POST_TYPE, PT_CV_DOMAIN ),
|
255 |
+
'add_new_item' => __( 'Add New View', PT_CV_DOMAIN ),
|
256 |
+
'new_item' => __( 'New View', PT_CV_DOMAIN ),
|
257 |
+
'edit_item' => __( 'Edit View', PT_CV_DOMAIN ),
|
258 |
+
'view_item' => __( 'View View', PT_CV_DOMAIN ),
|
259 |
+
'all_items' => __( 'All Views', PT_CV_DOMAIN ),
|
260 |
+
'search_items' => __( 'Search Views', PT_CV_DOMAIN ),
|
261 |
+
'parent_item_colon' => __( 'Parent Views:', PT_CV_DOMAIN ),
|
262 |
+
'not_found' => __( 'No views found.', PT_CV_DOMAIN ),
|
263 |
'not_found_in_trash' => __( 'No views found in Trash.', PT_CV_DOMAIN ),
|
264 |
);
|
265 |
|
266 |
$args = array(
|
267 |
+
'labels' => $labels,
|
268 |
+
'public' => false,
|
|
|
269 |
// Hide in menu, but can see All Views page
|
270 |
+
'show_ui' => true, // set "true" to fix "Invalid post type" error
|
271 |
+
'show_in_menu' => false,
|
272 |
+
'query_var' => true,
|
273 |
+
'rewrite' => array( 'slug' => PT_CV_POST_TYPE ),
|
274 |
+
'capability_type' => 'post',
|
275 |
+
'has_archive' => true,
|
276 |
+
'hierarchical' => false,
|
277 |
+
'menu_position' => null,
|
278 |
+
'supports' => array( 'title', 'author', 'custom-fields' ),
|
|
|
279 |
);
|
280 |
|
281 |
register_post_type( PT_CV_POST_TYPE, $args );
|
312 |
*/
|
313 |
public function update_view_count() {
|
314 |
global $post;
|
315 |
+
if ( !isset( $post ) || !is_object( $post ) ) {
|
316 |
return;
|
317 |
}
|
318 |
if ( is_single( $post->ID ) ) {
|
327 |
*/
|
328 |
public function init_global_variables() {
|
329 |
global $processed_view_assets, $processed_views;
|
330 |
+
$processed_view_assets = $processed_views = array();
|
331 |
}
|
332 |
|
333 |
}
|
public/templates/collapsible/html/main.php
CHANGED
@@ -8,19 +8,18 @@
|
|
8 |
* @link http://www.contentviewspro.com/
|
9 |
* @copyright 2014 PT Guy
|
10 |
*/
|
11 |
-
|
12 |
$html = array();
|
13 |
|
14 |
-
$layout = $dargs['layout-format'];
|
15 |
|
16 |
// Prevent the case: there are 2 columns but have not setting for thumbnail position
|
17 |
-
if ( $layout == '2-col' && !
|
18 |
$layout = '1-col';
|
19 |
}
|
20 |
|
21 |
// Get title
|
22 |
-
$heading = isset( $fields_html['title'] ) ? $fields_html['title'] : '';
|
23 |
-
unset( $fields_html['title'] );
|
24 |
|
25 |
switch ( $layout ) {
|
26 |
case '1-col':
|
@@ -31,19 +30,19 @@ switch ( $layout ) {
|
|
31 |
case '2-col':
|
32 |
|
33 |
// Thumbnail html
|
34 |
-
$thumbnail_html = $fields_html['thumbnail'];
|
35 |
|
36 |
// Other fields html
|
37 |
-
unset( $fields_html['thumbnail'] );
|
38 |
$others_html = implode( "\n", $fields_html );
|
39 |
|
40 |
-
$html[]
|
41 |
-
$html[]
|
42 |
|
43 |
break;
|
44 |
}
|
45 |
|
46 |
-
$random_id
|
47 |
?>
|
48 |
<div class="panel panel-default">
|
49 |
<div class="panel-heading">
|
8 |
* @link http://www.contentviewspro.com/
|
9 |
* @copyright 2014 PT Guy
|
10 |
*/
|
|
|
11 |
$html = array();
|
12 |
|
13 |
+
$layout = $dargs[ 'layout-format' ];
|
14 |
|
15 |
// Prevent the case: there are 2 columns but have not setting for thumbnail position
|
16 |
+
if ( $layout == '2-col' && !isset( $dargs[ 'field-settings' ][ 'thumbnail' ] ) ) {
|
17 |
$layout = '1-col';
|
18 |
}
|
19 |
|
20 |
// Get title
|
21 |
+
$heading = isset( $fields_html[ 'title' ] ) ? $fields_html[ 'title' ] : '';
|
22 |
+
unset( $fields_html[ 'title' ] );
|
23 |
|
24 |
switch ( $layout ) {
|
25 |
case '1-col':
|
30 |
case '2-col':
|
31 |
|
32 |
// Thumbnail html
|
33 |
+
$thumbnail_html = $fields_html[ 'thumbnail' ];
|
34 |
|
35 |
// Other fields html
|
36 |
+
unset( $fields_html[ 'thumbnail' ] );
|
37 |
$others_html = implode( "\n", $fields_html );
|
38 |
|
39 |
+
$html[] = $thumbnail_html;
|
40 |
+
$html[] = $others_html;
|
41 |
|
42 |
break;
|
43 |
}
|
44 |
|
45 |
+
$random_id = PT_CV_Functions::string_random();
|
46 |
?>
|
47 |
<div class="panel panel-default">
|
48 |
<div class="panel-heading">
|
public/templates/grid/html/main.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Layout Name: Grid
|
4 |
*
|
@@ -8,13 +9,12 @@
|
|
8 |
* @link http://www.contentviewspro.com/
|
9 |
* @copyright 2014 PT Guy
|
10 |
*/
|
11 |
-
|
12 |
$html = array();
|
13 |
|
14 |
-
$layout = $dargs['layout-format'];
|
15 |
|
16 |
// Prevent the case: there are 2 columns but have not setting for thumbnail position
|
17 |
-
if ( $layout == '2-col' && !
|
18 |
$layout = '1-col';
|
19 |
}
|
20 |
|
@@ -27,14 +27,14 @@ switch ( $layout ) {
|
|
27 |
case '2-col':
|
28 |
|
29 |
// Thumbnail html
|
30 |
-
$html[] = $fields_html['thumbnail'];
|
31 |
|
32 |
// Other fields html
|
33 |
-
unset( $fields_html['thumbnail'] );
|
34 |
$others_html = implode( "\n", $fields_html );
|
35 |
-
$html[]
|
36 |
|
37 |
break;
|
38 |
}
|
39 |
|
40 |
-
echo balanceTags( implode( "\n", $html ) );
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Layout Name: Grid
|
5 |
*
|
9 |
* @link http://www.contentviewspro.com/
|
10 |
* @copyright 2014 PT Guy
|
11 |
*/
|
|
|
12 |
$html = array();
|
13 |
|
14 |
+
$layout = $dargs[ 'layout-format' ];
|
15 |
|
16 |
// Prevent the case: there are 2 columns but have not setting for thumbnail position
|
17 |
+
if ( $layout == '2-col' && !isset( $dargs[ 'field-settings' ][ 'thumbnail' ] ) ) {
|
18 |
$layout = '1-col';
|
19 |
}
|
20 |
|
27 |
case '2-col':
|
28 |
|
29 |
// Thumbnail html
|
30 |
+
$html[] = $fields_html[ 'thumbnail' ];
|
31 |
|
32 |
// Other fields html
|
33 |
+
unset( $fields_html[ 'thumbnail' ] );
|
34 |
$others_html = implode( "\n", $fields_html );
|
35 |
+
$html[] = $others_html;
|
36 |
|
37 |
break;
|
38 |
}
|
39 |
|
40 |
+
echo balanceTags( implode( "\n", $html ) );
|
public/templates/scrollable/html/main.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Layout Name: Scrollable List
|
4 |
*
|
@@ -8,16 +9,16 @@
|
|
8 |
* @link http://www.contentviewspro.com/
|
9 |
* @copyright 2014 PT Guy
|
10 |
*/
|
11 |
-
|
12 |
$html = array();
|
13 |
|
14 |
-
$ex_cap_cls = PT_CV_PREFIX . 'cap-w-img'
|
|
|
15 |
|
16 |
-
$img = strip_tags( isset( $fields_html['thumbnail'] ) ? $fields_html['thumbnail'] : '', '<img>' );
|
17 |
-
if ( !
|
18 |
// Thumbnail html
|
19 |
-
$html[] = $fields_html['thumbnail'];
|
20 |
-
unset( $fields_html['thumbnail'] );
|
21 |
} else {
|
22 |
$ex_cap_cls = PT_CV_PREFIX . 'cap-wo-img';
|
23 |
}
|
@@ -26,7 +27,7 @@ if ( ! empty( $img ) ) {
|
|
26 |
$others_html = implode( "\n", $fields_html );
|
27 |
|
28 |
// Get wrapper class of caption
|
29 |
-
$caption_class
|
30 |
-
$html[]
|
31 |
|
32 |
-
echo balanceTags( implode( "\n", $html ) );
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Layout Name: Scrollable List
|
5 |
*
|
9 |
* @link http://www.contentviewspro.com/
|
10 |
* @copyright 2014 PT Guy
|
11 |
*/
|
|
|
12 |
$html = array();
|
13 |
|
14 |
+
$ex_cap_cls = PT_CV_PREFIX . 'cap-w-img';
|
15 |
+
;
|
16 |
|
17 |
+
$img = strip_tags( isset( $fields_html[ 'thumbnail' ] ) ? $fields_html[ 'thumbnail' ] : '', '<img>' );
|
18 |
+
if ( !empty( $img ) ) {
|
19 |
// Thumbnail html
|
20 |
+
$html[] = $fields_html[ 'thumbnail' ];
|
21 |
+
unset( $fields_html[ 'thumbnail' ] );
|
22 |
} else {
|
23 |
$ex_cap_cls = PT_CV_PREFIX . 'cap-wo-img';
|
24 |
}
|
27 |
$others_html = implode( "\n", $fields_html );
|
28 |
|
29 |
// Get wrapper class of caption
|
30 |
+
$caption_class = apply_filters( PT_CV_PREFIX_ . 'scrollable_caption_class', array( 'carousel-caption', $ex_cap_cls ) );
|
31 |
+
$html[] = sprintf( '<div class="%s">%s</div>', esc_attr( implode( ' ', array_filter( $caption_class ) ) ), balanceTags( $others_html ) );
|
32 |
|
33 |
+
echo balanceTags( implode( "\n", $html ) );
|