Version Description
- ready for WP 3.5
- added support for custom fields for Media
- added color to the custom field types
- fixed default sorting for Post(types) and Media
- fixed problem with different date formats in custom fields. all dates will parsed by strtotime() now.
- fixed bug which could trigger a conflict when saving the setting on other plugins
- fixed bug when returning an admin class atrribute
- improved perfomance on post count on user overview screen
Download this release
Release Info
Developer | codepress |
Plugin | Admin Columns |
Version | 1.4.7 |
Comparing to | |
See all releases |
Code changes from version 1.4.6.4 to 1.4.7
- assets/css/admin-column.css +74 -18
- assets/css/column.css +19 -0
- assets/images/import_export.png +0 -0
- assets/js/admin-column.js +599 -389
- classes/license.php +95 -0
- classes/sortable.php +1249 -1240
- classes/utility.php +24 -25
- classes/values.php +529 -517
- classes/values/comments.php +249 -249
- classes/values/media.php +211 -211
- classes/values/posts.php +342 -342
- classes/values/users.php +158 -158
- codepress-admin-columns.php +2670 -2609
- readme.txt +408 -397
assets/css/admin-column.css
CHANGED
@@ -214,7 +214,7 @@
|
|
214 |
}
|
215 |
#general-cpac-settings .cpac-option-list li .cpac-type-inside input,
|
216 |
#general-cpac-settings .cpac-option-list li .cpac-type-inside select {
|
217 |
-
|
218 |
}
|
219 |
#general-cpac-settings .cpac-option-list li .cpac-type-inside input.input-width {
|
220 |
min-width: 25px;
|
@@ -301,6 +301,27 @@
|
|
301 |
border-bottom: none;
|
302 |
border-top: none;
|
303 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
304 |
#cpac-box-plugin_settings table.addons {
|
305 |
/* max-width: 620px; */
|
306 |
}
|
@@ -362,21 +383,6 @@
|
|
362 |
float: left;
|
363 |
width: 220px;
|
364 |
}
|
365 |
-
#cpac-box-plugin_settings table.addons .button {
|
366 |
-
position: relative;
|
367 |
-
}
|
368 |
-
#cpac-box-plugin_settings table.addons .button.loading {
|
369 |
-
padding-right: 25px;
|
370 |
-
}
|
371 |
-
#cpac-box-plugin_settings table.addons .button.loading span {
|
372 |
-
position: absolute;
|
373 |
-
top: 2px;
|
374 |
-
right: 6px;
|
375 |
-
background: transparent url('../images/loading.gif') no-repeat right 50%;
|
376 |
-
width: 16px;
|
377 |
-
height: 16px;
|
378 |
-
display: inline-block;
|
379 |
-
}
|
380 |
|
381 |
/* =Restore settings
|
382 |
-------------------------------------------------------------- */
|
@@ -405,8 +411,14 @@
|
|
405 |
-------------------------------------------------------------- */
|
406 |
#addons-cpac-settings {
|
407 |
overflow: hidden;
|
408 |
-
background
|
409 |
-
background
|
|
|
|
|
|
|
|
|
|
|
|
|
410 |
border-color: green;
|
411 |
}
|
412 |
#addons-cpac-settings h3 {
|
@@ -501,6 +513,50 @@
|
|
501 |
padding: 0 6px;
|
502 |
}
|
503 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
504 |
/* =Tooltip
|
505 |
-------------------------------------------------------------- */
|
506 |
.qtip .qtip-tip {
|
214 |
}
|
215 |
#general-cpac-settings .cpac-option-list li .cpac-type-inside input,
|
216 |
#general-cpac-settings .cpac-option-list li .cpac-type-inside select {
|
217 |
+
width: 184px;
|
218 |
}
|
219 |
#general-cpac-settings .cpac-option-list li .cpac-type-inside input.input-width {
|
220 |
min-width: 25px;
|
301 |
border-bottom: none;
|
302 |
border-top: none;
|
303 |
}
|
304 |
+
#cpac-box-plugin_settings .button {
|
305 |
+
position: relative;
|
306 |
+
}
|
307 |
+
#cpac-box-plugin_settings .button.loading {
|
308 |
+
padding-right: 25px;
|
309 |
+
}
|
310 |
+
#cpac-box-plugin_settings .button.loading span {
|
311 |
+
position: absolute;
|
312 |
+
top: 2px;
|
313 |
+
right: 6px;
|
314 |
+
background: transparent url('../images/loading.gif') no-repeat right 50%;
|
315 |
+
width: 16px;
|
316 |
+
height: 16px;
|
317 |
+
display: inline-block;
|
318 |
+
}
|
319 |
+
#cpac-box-plugin_settings td.first-col {
|
320 |
+
width: 18%;
|
321 |
+
}
|
322 |
+
|
323 |
+
/* =Addon settings
|
324 |
+
-------------------------------------------------------------- */
|
325 |
#cpac-box-plugin_settings table.addons {
|
326 |
/* max-width: 620px; */
|
327 |
}
|
383 |
float: left;
|
384 |
width: 220px;
|
385 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
386 |
|
387 |
/* =Restore settings
|
388 |
-------------------------------------------------------------- */
|
411 |
-------------------------------------------------------------- */
|
412 |
#addons-cpac-settings {
|
413 |
overflow: hidden;
|
414 |
+
background: #ccffcc;
|
415 |
+
background: -moz-linear-gradient(top, #c3f5c2 1%, #ccffcc 100%); /* FF3.6+ */
|
416 |
+
background: -webkit-gradient(linear, left top, left bottom, color-stop(1%,#c3f5c2), color-stop(100%,#ccffcc)); /* Chrome,Safari4+ */
|
417 |
+
background: -webkit-linear-gradient(top, #c3f5c2 1%,#ccffcc 100%); /* Chrome10+,Safari5.1+ */
|
418 |
+
background: -o-linear-gradient(top, #c3f5c2 1%,#ccffcc 100%); /* Opera 11.10+ */
|
419 |
+
background: -ms-linear-gradient(top, #c3f5c2 1%,#ccffcc 100%); /* IE10+ */
|
420 |
+
background: linear-gradient(to bottom, #c3f5c2 1%,#ccffcc 100%); /* W3C */
|
421 |
+
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#c3f5c2', endColorstr='#ccffcc',GradientType=0 ); /* IE6-9 */
|
422 |
border-color: green;
|
423 |
}
|
424 |
#addons-cpac-settings h3 {
|
513 |
padding: 0 6px;
|
514 |
}
|
515 |
|
516 |
+
/* =Import / Export
|
517 |
+
-------------------------------------------------------------- */
|
518 |
+
div.cpac_export {
|
519 |
+
width: 20%;
|
520 |
+
float: left;
|
521 |
+
}
|
522 |
+
#cpac_export_output {
|
523 |
+
width: 80%;
|
524 |
+
float: left;
|
525 |
+
display: none;
|
526 |
+
}
|
527 |
+
#cpac_export_output textarea {
|
528 |
+
width: 100%;
|
529 |
+
height: 80%;
|
530 |
+
}
|
531 |
+
#cpac_export_submit {
|
532 |
+
display: inline-block;
|
533 |
+
margin: 10px 0;
|
534 |
+
}
|
535 |
+
#cpac_import_input {}
|
536 |
+
#cpac_import_input textarea {
|
537 |
+
width: 100%;
|
538 |
+
height: 80%;
|
539 |
+
}
|
540 |
+
#cpac_import_submit {
|
541 |
+
display: inline-block;
|
542 |
+
margin: 10px 0;
|
543 |
+
}
|
544 |
+
.export-message,
|
545 |
+
.import-message {
|
546 |
+
background-color: #FFFFE0;
|
547 |
+
border: 1px solid #E6DB55;
|
548 |
+
padding: 4px 6px;
|
549 |
+
border-radius: 3px;
|
550 |
+
display: none;
|
551 |
+
}
|
552 |
+
|
553 |
+
/* =WP Pointer
|
554 |
+
-------------------------------------------------------------- */
|
555 |
+
.wp-pointer-content ol {
|
556 |
+
margin-left: 1.5em;
|
557 |
+
padding: 0 15px;
|
558 |
+
}
|
559 |
+
|
560 |
/* =Tooltip
|
561 |
-------------------------------------------------------------- */
|
562 |
.qtip .qtip-tip {
|
assets/css/column.css
CHANGED
@@ -14,6 +14,25 @@ span.status-closed {
|
|
14 |
color: red;
|
15 |
}
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
/* =Comment Counts column
|
18 |
-------------------------------------------------------------- */
|
19 |
.column-comment-count a.post-com-count {
|
14 |
color: red;
|
15 |
}
|
16 |
|
17 |
+
/* =Color Column
|
18 |
+
-------------------------------------------------------------- */
|
19 |
+
div.cpac-color {
|
20 |
+
line-height: 26px;
|
21 |
+
}
|
22 |
+
div.cpac-color span {
|
23 |
+
border: 1px solid #CCCCCC;
|
24 |
+
display: block;
|
25 |
+
-webkit-border-radius: 3px;
|
26 |
+
border-radius: 3px;
|
27 |
+
color: #ffffff;
|
28 |
+
float: left;
|
29 |
+
height: 16px;
|
30 |
+
margin-right: 12px;
|
31 |
+
min-width: 30px;
|
32 |
+
overflow: hidden;
|
33 |
+
padding: 4px 5px;
|
34 |
+
}
|
35 |
+
|
36 |
/* =Comment Counts column
|
37 |
-------------------------------------------------------------- */
|
38 |
.column-comment-count a.post-com-count {
|
assets/images/import_export.png
ADDED
Binary file
|
assets/js/admin-column.js
CHANGED
@@ -1,424 +1,634 @@
|
|
1 |
-
|
2 |
-
* fires when the dom is ready
|
3 |
-
*
|
4 |
-
*/
|
5 |
-
jQuery(document).ready(function()
|
6 |
-
{
|
7 |
-
if (jQuery('#cpac').length == 0)
|
8 |
-
return false;
|
9 |
-
|
10 |
-
cpac_sortable();
|
11 |
-
cpac_checked();
|
12 |
-
cpac_box_events();
|
13 |
-
cpac_menu();
|
14 |
-
cpac_add_custom_column();
|
15 |
-
cpac_clear_input_defaults();
|
16 |
-
cpac_tooltips();
|
17 |
-
cpac_addon_activation();
|
18 |
-
cpac_width_range();
|
19 |
-
});
|
20 |
-
|
21 |
-
/**
|
22 |
-
* sortable
|
23 |
-
*
|
24 |
-
*/
|
25 |
-
function cpac_sortable()
|
26 |
-
{
|
27 |
-
jQuery('ul.cpac-option-list').sortable({
|
28 |
-
handle: 'div.cpac-sort-handle',
|
29 |
-
placeholder: 'cpac-placeholder',
|
30 |
-
forcePlaceholderSize: true
|
31 |
-
});
|
32 |
-
}
|
33 |
|
34 |
-
/**
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
function
|
39 |
-
{
|
40 |
-
|
41 |
-
|
42 |
-
var li = jQuery(this).closest('li');
|
43 |
-
var state = jQuery('.cpac-state', li);
|
44 |
-
var value = state.attr('value');
|
45 |
-
|
46 |
-
// toggle on
|
47 |
-
if ( value != 'on') {
|
48 |
-
li.addClass('active');
|
49 |
-
state.attr('value', 'on');
|
50 |
-
}
|
51 |
-
|
52 |
-
// toggle off
|
53 |
-
else {
|
54 |
-
li.removeClass('active');
|
55 |
-
state.attr('value', '');
|
56 |
-
}
|
57 |
-
}
|
58 |
-
});
|
59 |
-
}
|
60 |
-
|
61 |
-
/**
|
62 |
-
* Open and close box
|
63 |
-
*
|
64 |
-
*/
|
65 |
-
function cpac_box_events()
|
66 |
-
{
|
67 |
-
// fold in/out
|
68 |
-
jQuery('#cpac .cpac-option-list .cpac-action').unbind('click').click(function(e){
|
69 |
-
e.preventDefault();
|
70 |
-
var li = jQuery(this).closest('li');
|
71 |
-
li.find('.cpac-type-inside').slideToggle(150, function() {
|
72 |
-
li.toggleClass('opened');
|
73 |
-
});
|
74 |
-
});
|
75 |
-
|
76 |
-
// remove custom field box
|
77 |
-
jQuery('#cpac .cpac-delete-custom-field-box').unbind('click').click(function(e){
|
78 |
-
e.preventDefault();
|
79 |
-
var el = jQuery(this).closest('li');
|
80 |
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
});
|
88 |
-
}
|
89 |
|
90 |
-
/**
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
function
|
95 |
-
{
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
e.preventDefault();
|
103 |
-
var id = jQuery(this).attr('href');
|
104 |
-
|
105 |
-
if ( id ) {
|
106 |
-
// remove current
|
107 |
-
jQuery('#cpac .cpac-menu a').removeClass('current');
|
108 |
-
jQuery('#cpac .cpac-box-row').hide().removeClass('current');
|
109 |
-
|
110 |
-
// set current
|
111 |
-
jQuery(this).addClass('current');
|
112 |
-
jQuery(id).show().addClass('current');
|
113 |
-
|
114 |
-
// set refere
|
115 |
-
var querystring = '&cpac_type=' + id.replace('#','');
|
116 |
-
referer.attr('value', referer_value + querystring );
|
117 |
-
}
|
118 |
-
});
|
119 |
-
}
|
120 |
|
121 |
-
/**
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
function
|
126 |
-
{
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
}
|
144 |
-
}
|
145 |
});
|
|
|
146 |
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
|
|
|
|
|
|
|
|
|
|
156 |
|
157 |
-
//
|
158 |
-
|
159 |
-
|
|
|
160 |
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
// Replace inputs ID's
|
169 |
-
var inputs = jQuery(clone).find('input, select');
|
170 |
-
jQuery(inputs).each(function(ik, iv){
|
171 |
-
jQuery(iv).attr('name', jQuery(iv).attr('name').replace(id, new_id) );
|
172 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
|
174 |
-
//
|
175 |
-
|
176 |
-
|
177 |
-
var
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
// remove description
|
184 |
-
clone.find('.remove-description').remove();
|
185 |
-
|
186 |
-
// change label text
|
187 |
-
clone.find('label.main-label, .cpac-type-inside input.text').text('Custom Field');
|
188 |
-
clone.find('.cpac-type-inside input.text').val('Custom Field');
|
189 |
-
|
190 |
-
// add remove button
|
191 |
-
if ( clone.find('.cpac-delete-custom-field-box').length == 0 ) {
|
192 |
-
var remove = '<p><a href="javascript:;" class="cpac-delete-custom-field-box">Remove</a>';
|
193 |
-
clone.find('.cpac-type-inside').append(remove);
|
194 |
-
}
|
195 |
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
// retrigger click events
|
200 |
-
cpac_box_events();
|
201 |
-
});
|
202 |
-
}
|
203 |
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
*/
|
208 |
-
function cpac_clear_input_defaults()
|
209 |
-
{
|
210 |
-
jQuery.fn.cleardefault = function() {
|
211 |
-
return this.focus(function() {
|
212 |
-
if( this.value == this.defaultValue ) {
|
213 |
-
this.value = "";
|
214 |
-
}
|
215 |
-
}).blur(function() {
|
216 |
-
if( !this.value.length ) {
|
217 |
-
this.value = this.defaultValue;
|
218 |
}
|
219 |
});
|
220 |
-
}
|
221 |
-
jQuery("#cpac-box-plugin_settings .addons input").cleardefault();
|
222 |
-
}
|
223 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
224 |
|
225 |
-
|
226 |
-
|
227 |
-
*
|
228 |
-
*/
|
229 |
-
function cpac_tooltips()
|
230 |
-
{
|
231 |
-
jQuery('#cpac .activation_type span').each(function() {
|
232 |
-
var info = jQuery(this).next('.cpac-tooltip').html();
|
233 |
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
249 |
},
|
250 |
-
|
251 |
-
corner:
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
|
|
256 |
}
|
257 |
-
}
|
258 |
-
},
|
259 |
-
position: {
|
260 |
-
corner: {
|
261 |
-
target: 'bottomRight'
|
262 |
},
|
263 |
-
|
264 |
-
|
265 |
-
|
|
|
266 |
}
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
fixed: true ,
|
271 |
-
delay: 100
|
272 |
-
}
|
273 |
-
});
|
274 |
-
});
|
275 |
-
}
|
276 |
|
277 |
-
/**
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
function cpac_width_range()
|
282 |
-
{
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
// loop through all width-range-sliders
|
287 |
-
jQuery('.input-width-range').each( function(){
|
288 |
-
|
289 |
-
var input = jQuery(this).closest('.cpac-type-inside').find('.input-width');
|
290 |
-
var descr = jQuery(this).closest('.cpac-type-inside').find('.width-decription');
|
291 |
-
var input_default = jQuery(input)[0].defaultValue;
|
292 |
-
var translation_default = descr.attr('title');
|
293 |
|
294 |
-
//
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
302 |
|
303 |
-
// set
|
304 |
-
|
305 |
|
306 |
-
//
|
307 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
308 |
|
309 |
-
//
|
310 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
311 |
}
|
312 |
-
});
|
313 |
-
}
|
314 |
-
}
|
315 |
|
316 |
-
/**
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
function
|
321 |
-
{
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
341 |
|
342 |
-
|
343 |
-
|
344 |
-
var
|
345 |
-
|
346 |
-
|
|
|
347 |
|
348 |
-
|
349 |
-
if ( key == default_val ) {
|
350 |
-
jQuery(msg).text(msg_fillin).hide().fadeIn();
|
351 |
return false;
|
352 |
-
}
|
353 |
-
|
354 |
-
// set loading icon
|
355 |
-
button.addClass('loading');
|
356 |
-
|
357 |
-
// update key
|
358 |
-
jQuery.ajax({
|
359 |
-
url : ajaxurl,
|
360 |
-
type : 'POST',
|
361 |
-
dataType : 'json',
|
362 |
-
data : {
|
363 |
-
action : 'cpac_addon_activation',
|
364 |
-
type : 'sortable',
|
365 |
-
key : key
|
366 |
-
},
|
367 |
-
success: function(data) {
|
368 |
-
if ( data != null ) {
|
369 |
-
jQuery('div.activate', row).hide(); // hide activation button
|
370 |
-
jQuery('div.deactivate', row).show(); // show deactivation button
|
371 |
-
jQuery('div.deactivate span.masked_key', row).text(data); // display the returned masked key
|
372 |
-
} else {
|
373 |
-
jQuery(msg).text(msg_unrecognised).hide().fadeIn();
|
374 |
-
}
|
375 |
-
},
|
376 |
-
error: function(xhr, ajaxOptions, thrownError) {
|
377 |
-
//console.log(xhr);
|
378 |
-
//console.log(ajaxOptions);
|
379 |
-
//console.log(thrownError);
|
380 |
-
jQuery(msg).text(msg_unrecognised).hide().fadeIn();
|
381 |
-
},
|
382 |
-
complete: function() {
|
383 |
-
button.removeClass('loading');
|
384 |
-
}
|
385 |
});
|
386 |
-
}
|
387 |
-
|
388 |
-
// Deactivate
|
389 |
-
if ( parent_class.hasClass('deactivate') ) {
|
390 |
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
421 |
});
|
422 |
-
}
|
423 |
-
}
|
424 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
(function($){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
+
/**
|
4 |
+
* fires when the dom is ready
|
5 |
+
*
|
6 |
+
*/
|
7 |
+
$(document).ready(function()
|
8 |
+
{
|
9 |
+
if ($('#cpac').length == 0)
|
10 |
+
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
+
cpac_sortable();
|
13 |
+
cpac_checked();
|
14 |
+
cpac_box_events();
|
15 |
+
cpac_menu();
|
16 |
+
cpac_add_custom_column();
|
17 |
+
cpac_clear_input_defaults();
|
18 |
+
cpac_tooltips();
|
19 |
+
cpac_addon_activation();
|
20 |
+
cpac_width_range();
|
21 |
+
cpac_export();
|
22 |
+
cpac_import();
|
23 |
+
cpac_pointer();
|
24 |
});
|
|
|
25 |
|
26 |
+
/**
|
27 |
+
* sortable
|
28 |
+
*
|
29 |
+
*/
|
30 |
+
function cpac_sortable()
|
31 |
+
{
|
32 |
+
$('ul.cpac-option-list').sortable({
|
33 |
+
handle: 'div.cpac-sort-handle',
|
34 |
+
placeholder: 'cpac-placeholder',
|
35 |
+
forcePlaceholderSize: true
|
36 |
+
});
|
37 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
+
/**
|
40 |
+
* checked
|
41 |
+
*
|
42 |
+
*/
|
43 |
+
function cpac_checked()
|
44 |
+
{
|
45 |
+
$('#cpac .cpac-option-list li .cpac-type-options').live({
|
46 |
+
click: function() {
|
47 |
+
var li = $(this).closest('li');
|
48 |
+
var state = $('.cpac-state', li);
|
49 |
+
var value = state.attr('value');
|
50 |
+
|
51 |
+
// toggle on
|
52 |
+
if ( value != 'on') {
|
53 |
+
li.addClass('active');
|
54 |
+
state.attr('value', 'on');
|
55 |
+
}
|
56 |
+
|
57 |
+
// toggle off
|
58 |
+
else {
|
59 |
+
li.removeClass('active');
|
60 |
+
state.attr('value', '');
|
61 |
+
}
|
62 |
+
}
|
63 |
});
|
64 |
+
}
|
65 |
|
66 |
+
/**
|
67 |
+
* Open and close box
|
68 |
+
*
|
69 |
+
*/
|
70 |
+
function cpac_box_events()
|
71 |
+
{
|
72 |
+
// fold in/out
|
73 |
+
$('#cpac .cpac-option-list .cpac-action').unbind('click').click(function(e){
|
74 |
+
e.preventDefault();
|
75 |
+
var li = $(this).closest('li');
|
76 |
+
li.find('.cpac-type-inside').slideToggle(150, function() {
|
77 |
+
li.toggleClass('opened');
|
78 |
+
});
|
79 |
+
});
|
80 |
|
81 |
+
// remove custom field box
|
82 |
+
$('#cpac .cpac-delete-custom-field-box').unbind('click').click(function(e){
|
83 |
+
e.preventDefault();
|
84 |
+
var el = $(this).closest('li');
|
85 |
|
86 |
+
el.addClass('deleting').animate({
|
87 |
+
opacity : 0,
|
88 |
+
height: 0
|
89 |
+
}, 350, function() {
|
90 |
+
el.remove();
|
91 |
+
});
|
|
|
|
|
|
|
|
|
|
|
92 |
});
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* Menu
|
97 |
+
*
|
98 |
+
*/
|
99 |
+
function cpac_menu()
|
100 |
+
{
|
101 |
+
// referer
|
102 |
+
var referer = $("input[type='hidden'][name='_wp_http_referer']");
|
103 |
+
var referer_value = referer.attr('value');
|
104 |
|
105 |
+
// click
|
106 |
+
$('#cpac .cpac-menu a').click( function(e, el) {
|
107 |
+
e.preventDefault();
|
108 |
+
var id = $(this).attr('href');
|
109 |
+
|
110 |
+
if ( id ) {
|
111 |
+
// remove current
|
112 |
+
$('#cpac .cpac-menu a').removeClass('current');
|
113 |
+
$('#cpac .cpac-box-row').hide().removeClass('current');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
|
115 |
+
// set current
|
116 |
+
$(this).addClass('current');
|
117 |
+
$(id).show().addClass('current');
|
|
|
|
|
|
|
|
|
118 |
|
119 |
+
// set refere
|
120 |
+
var querystring = '&cpac_type=' + id.replace('#','');
|
121 |
+
referer.attr('value', referer_value + querystring );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
}
|
123 |
});
|
124 |
+
}
|
|
|
|
|
125 |
|
126 |
+
/**
|
127 |
+
* add custom columns
|
128 |
+
*
|
129 |
+
*/
|
130 |
+
function cpac_add_custom_column()
|
131 |
+
{
|
132 |
+
$('.cpac-add-customfield-column').click(function(e){
|
133 |
+
e.preventDefault();
|
134 |
+
|
135 |
+
var list = $(this).closest('td').find('ul.cpac-option-list');
|
136 |
+
var metafields = $('li.cpac-box-metafield', list);
|
137 |
+
|
138 |
+
// get unique ID number...
|
139 |
+
var ids = [];
|
140 |
+
metafields.each(function(k,v) {
|
141 |
+
var _class = $(v).attr('class');
|
142 |
+
var classes = _class.split(' ');
|
143 |
+
$.each(classes, function(kc,vc){
|
144 |
+
if ( vc.indexOf('cpac-box-column-meta-') === 0 ) {
|
145 |
+
var id = vc.replace('cpac-box-column-meta-','');
|
146 |
+
if ( id )
|
147 |
+
ids.push(id);
|
148 |
+
}
|
149 |
+
});
|
150 |
+
});
|
151 |
|
152 |
+
// ...and sort them
|
153 |
+
ids.sort(sortNumber);
|
|
|
|
|
|
|
|
|
|
|
|
|
154 |
|
155 |
+
if ( !ids )
|
156 |
+
return;
|
157 |
+
|
158 |
+
function sortNumber(a,b) {
|
159 |
+
return b - a;
|
160 |
+
}
|
161 |
+
|
162 |
+
// ID's
|
163 |
+
var id = parseFloat(ids[0]);
|
164 |
+
var new_id = id + 1;
|
165 |
+
|
166 |
+
// Clone
|
167 |
+
var clone = $( '.cpac-box-column-meta-' + id, list ).clone();
|
168 |
+
|
169 |
+
// Toggle class
|
170 |
+
$(clone).removeClass('cpac-box-column-meta-' + id );
|
171 |
+
$(clone).addClass('cpac-box-column-meta-' + new_id );
|
172 |
+
|
173 |
+
// Replace inputs ID's
|
174 |
+
var inputs = $(clone).find('input, select');
|
175 |
+
$(inputs).each(function(ik, iv){
|
176 |
+
$(iv).attr('name', $(iv).attr('name').replace(id, new_id) );
|
177 |
+
});
|
178 |
+
|
179 |
+
// Replace label ID's
|
180 |
+
var labels = $(clone).find('label');
|
181 |
+
$(labels).each(function(ik, iv){
|
182 |
+
var attr_for = $(iv).attr('for');
|
183 |
+
if ( attr_for ) {
|
184 |
+
$(iv).attr('for', attr_for.replace(id, new_id) );
|
185 |
+
}
|
186 |
+
});
|
187 |
+
|
188 |
+
// remove description
|
189 |
+
clone.find('.remove-description').remove();
|
190 |
+
|
191 |
+
// change label text
|
192 |
+
clone.find('label.main-label, .cpac-type-inside input.text').text('Custom Field');
|
193 |
+
clone.find('.cpac-type-inside input.text').val('Custom Field');
|
194 |
+
|
195 |
+
// add remove button
|
196 |
+
if ( clone.find('.cpac-delete-custom-field-box').length == 0 ) {
|
197 |
+
var remove = '<p><a href="javascript:;" class="cpac-delete-custom-field-box">Remove</a>';
|
198 |
+
clone.find('.cpac-type-inside').append(remove);
|
199 |
+
}
|
200 |
+
|
201 |
+
// add cloned box to the list
|
202 |
+
list.append(clone);
|
203 |
+
|
204 |
+
// retrigger click events
|
205 |
+
cpac_box_events();
|
206 |
+
|
207 |
+
// re-init width range slider
|
208 |
+
cpac_width_range();
|
209 |
+
});
|
210 |
+
}
|
211 |
+
|
212 |
+
/**
|
213 |
+
* Clear Input Defaults
|
214 |
+
*
|
215 |
+
*/
|
216 |
+
function cpac_clear_input_defaults()
|
217 |
+
{
|
218 |
+
$.fn.cleardefault = function() {
|
219 |
+
return this.focus(function() {
|
220 |
+
if( this.value == this.defaultValue ) {
|
221 |
+
this.value = "";
|
222 |
+
}
|
223 |
+
}).blur(function() {
|
224 |
+
if( !this.value.length ) {
|
225 |
+
this.value = this.defaultValue;
|
226 |
+
}
|
227 |
+
});
|
228 |
+
};
|
229 |
+
$("#cpac-box-plugin_settings .addons input").cleardefault();
|
230 |
+
}
|
231 |
+
|
232 |
+
|
233 |
+
/**
|
234 |
+
* Tooltip
|
235 |
+
*
|
236 |
+
*/
|
237 |
+
function cpac_tooltips()
|
238 |
+
{
|
239 |
+
$('#cpac .activation_type span').each(function() {
|
240 |
+
var info = $(this).next('.cpac-tooltip').html();
|
241 |
+
|
242 |
+
if ( ! info )
|
243 |
+
return;
|
244 |
+
|
245 |
+
$('#cpac .activation_type span').qtip({
|
246 |
+
content: info,
|
247 |
+
title: 'title',
|
248 |
+
style: {
|
249 |
+
width: 400,
|
250 |
+
padding: 0,
|
251 |
+
background: 'transparent',
|
252 |
+
color: 'black',
|
253 |
+
textAlign: 'left',
|
254 |
+
border: {
|
255 |
+
width: 0,
|
256 |
+
radius: 0
|
257 |
+
},
|
258 |
+
tip: {
|
259 |
+
corner: 'topMiddle',
|
260 |
+
color: '#8cc1e9',
|
261 |
+
size: {
|
262 |
+
x: 32,
|
263 |
+
y : 15
|
264 |
+
}
|
265 |
+
}
|
266 |
},
|
267 |
+
position: {
|
268 |
+
corner: {
|
269 |
+
target: 'bottomRight'
|
270 |
+
},
|
271 |
+
adjust: {
|
272 |
+
x: -80,
|
273 |
+
y: 0
|
274 |
}
|
|
|
|
|
|
|
|
|
|
|
275 |
},
|
276 |
+
hide: {
|
277 |
+
when: 'mouseout',
|
278 |
+
fixed: true ,
|
279 |
+
delay: 100
|
280 |
}
|
281 |
+
});
|
282 |
+
});
|
283 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
284 |
|
285 |
+
/**
|
286 |
+
* Width range
|
287 |
+
*
|
288 |
+
*/
|
289 |
+
function cpac_width_range()
|
290 |
+
{
|
291 |
+
if ( $('.input-width-range').length == false )
|
292 |
+
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
293 |
|
294 |
+
// loop through all width-range-sliders
|
295 |
+
$('.input-width-range').each( function(){
|
296 |
+
|
297 |
+
var input = $(this).closest('.cpac-type-inside').find('.input-width');
|
298 |
+
var descr = $(this).closest('.cpac-type-inside').find('.width-decription');
|
299 |
+
var input_default = $(input)[0].defaultValue;
|
300 |
+
var translation_default = descr.attr('title');
|
301 |
+
|
302 |
+
// add slider
|
303 |
+
$(this).slider({
|
304 |
+
range: 'min',
|
305 |
+
value: 1,
|
306 |
+
min: 0,
|
307 |
+
max: 100,
|
308 |
+
value: input_default,
|
309 |
+
slide: function( event, ui ) {
|
310 |
+
|
311 |
+
// set default
|
312 |
+
var descr_value = ui.value > 0 ? ui.value + '%' : translation_default;
|
313 |
+
|
314 |
+
// set input value
|
315 |
+
$(input).val( ui.value );
|
316 |
+
|
317 |
+
// set description
|
318 |
+
$(descr).text( descr_value );
|
319 |
+
}
|
320 |
+
});
|
321 |
+
});
|
322 |
+
}
|
323 |
+
|
324 |
+
/**
|
325 |
+
* Addon actviate/deactivate
|
326 |
+
*
|
327 |
+
*/
|
328 |
+
function cpac_addon_activation()
|
329 |
+
{
|
330 |
+
$('#cpac-box-plugin_settings .addons .activation_code a.button').click(function(e) {
|
331 |
+
e.preventDefault();
|
332 |
+
|
333 |
+
// get input values
|
334 |
+
var row = $(this).closest('tr');
|
335 |
+
var type = $(row).attr('id').replace('cpac-activation-','');
|
336 |
+
var parent_class = $(this).parent('div');
|
337 |
+
var msg = $(row).find('.activation-error-msg');
|
338 |
+
|
339 |
+
// get translated string
|
340 |
+
var translations = $('#cpac-box-plugin_settings .addon-translation-string');
|
341 |
+
var msg_fillin = $('.tstring-fill-in',translations).text();
|
342 |
+
var msg_unrecognised = $('.tstring-unrecognised',translations).text();
|
343 |
+
|
344 |
+
// reset
|
345 |
+
$(msg).empty();
|
346 |
+
|
347 |
+
// Activate
|
348 |
+
if ( parent_class.hasClass('activate') ) {
|
349 |
+
|
350 |
+
// get input values
|
351 |
+
var input = $('.activate input', row);
|
352 |
+
var button = $('.activate .button', row);
|
353 |
+
var key = input.val();
|
354 |
+
var default_val = $(input)[0].defaultValue;
|
355 |
+
|
356 |
+
// make sure the input value has changed
|
357 |
+
if ( key == default_val ) {
|
358 |
+
$(msg).text(msg_fillin).hide().fadeIn();
|
359 |
+
return false;
|
360 |
+
}
|
361 |
|
362 |
+
// set loading icon
|
363 |
+
button.addClass('loading');
|
364 |
|
365 |
+
// update key
|
366 |
+
$.ajax({
|
367 |
+
url : ajaxurl,
|
368 |
+
type : 'POST',
|
369 |
+
dataType : 'json',
|
370 |
+
data : {
|
371 |
+
action : 'cpac_addon_activation',
|
372 |
+
type : 'sortable',
|
373 |
+
key : key
|
374 |
+
},
|
375 |
+
success: function(data) {
|
376 |
+
if ( data != null ) {
|
377 |
+
$('div.activate', row).hide(); // hide activation button
|
378 |
+
$('div.deactivate', row).show(); // show deactivation button
|
379 |
+
$('div.deactivate span.masked_key', row).text(data); // display the returned masked key
|
380 |
+
} else {
|
381 |
+
$(msg).text(msg_unrecognised).hide().fadeIn();
|
382 |
+
}
|
383 |
+
},
|
384 |
+
error: function(xhr, ajaxOptions, thrownError) {
|
385 |
+
//console.log(xhr);
|
386 |
+
//console.log(ajaxOptions);
|
387 |
+
//console.log(thrownError);
|
388 |
+
$(msg).text(msg_unrecognised).hide().fadeIn();
|
389 |
+
},
|
390 |
+
complete: function() {
|
391 |
+
button.removeClass('loading');
|
392 |
+
}
|
393 |
+
});
|
394 |
+
}
|
395 |
+
|
396 |
+
// Deactivate
|
397 |
+
if ( parent_class.hasClass('deactivate') ) {
|
398 |
+
|
399 |
+
var button = $('.deactivate .button', row);
|
400 |
+
var input = $('.activate input', row);
|
401 |
+
|
402 |
+
// set loading icon
|
403 |
+
button.addClass('loading');
|
404 |
|
405 |
+
// update key
|
406 |
+
$.ajax({
|
407 |
+
url : ajaxurl,
|
408 |
+
type : 'POST',
|
409 |
+
dataType : 'json',
|
410 |
+
data : {
|
411 |
+
action : 'cpac_addon_activation',
|
412 |
+
type : 'sortable',
|
413 |
+
key : 'remove'
|
414 |
+
},
|
415 |
+
success: function(data) {
|
416 |
+
$('div.activate', row).show(); // show activation button
|
417 |
+
$('div.deactivate', row).hide(); // hide deactivation button
|
418 |
+
$('div.deactivate span.masked_key', row).empty(); // remove masked key
|
419 |
+
input.val('');
|
420 |
+
},
|
421 |
+
error: function(xhr, ajaxOptions, thrownError) {
|
422 |
+
//console.log(xhr);
|
423 |
+
//console.log(ajaxOptions);
|
424 |
+
//console.log(thrownError);
|
425 |
+
},
|
426 |
+
complete: function() {
|
427 |
+
button.removeClass('loading');
|
428 |
+
}
|
429 |
+
});
|
430 |
}
|
431 |
+
});
|
432 |
+
}
|
|
|
433 |
|
434 |
+
/**
|
435 |
+
* Export Settings
|
436 |
+
*
|
437 |
+
*/
|
438 |
+
function cpac_export()
|
439 |
+
{
|
440 |
+
// Submit Export
|
441 |
+
$('#cpac_export_submit').click( function(e){
|
442 |
+
|
443 |
+
var values = [];
|
444 |
+
|
445 |
+
// get selected values
|
446 |
+
$('#cpac_export_types :selected').each(function(i, selected){
|
447 |
+
values[i] = $(selected).val();
|
448 |
+
});
|
449 |
+
|
450 |
+
var btn = $(this);
|
451 |
+
var export_container = $('#cpac_export_output');
|
452 |
+
var export_textarea = $('textarea', export_container);
|
453 |
+
var msg = btn.next('.export-message');
|
454 |
+
|
455 |
+
// reset
|
456 |
+
export_container.hide();
|
457 |
+
export_textarea.empty();
|
458 |
+
msg.hide();
|
459 |
+
|
460 |
+
// get export code
|
461 |
+
if ( values ) {
|
462 |
+
|
463 |
+
// set loading icon
|
464 |
+
btn.addClass('loading');
|
465 |
+
|
466 |
+
$.ajax({
|
467 |
+
url : ajaxurl,
|
468 |
+
type : 'POST',
|
469 |
+
dataType : 'json',
|
470 |
+
data : {
|
471 |
+
action : 'cpac_get_export',
|
472 |
+
types : values
|
473 |
+
},
|
474 |
+
success: function(data) {
|
475 |
+
if ( data != null ) {
|
476 |
+
|
477 |
+
// succes
|
478 |
+
if ( 1 == data.status ) {
|
479 |
+
export_textarea.text(data.msg);
|
480 |
+
export_container.show();
|
481 |
+
}
|
482 |
+
|
483 |
+
// fail
|
484 |
+
else if ( data.msg ) {
|
485 |
+
msg.text(data.msg).show();
|
486 |
+
}
|
487 |
+
|
488 |
+
} else {
|
489 |
+
// error msg
|
490 |
+
}
|
491 |
+
},
|
492 |
+
error: function(xhr, ajaxOptions, thrownError) {},
|
493 |
+
complete: function() {
|
494 |
+
btn.removeClass('loading');
|
495 |
+
}
|
496 |
+
});
|
497 |
+
}
|
498 |
+
|
499 |
+
e.preventDefault;
|
500 |
+
});
|
501 |
|
502 |
+
// Select Export Code
|
503 |
+
$('#cpac_export_output textarea').focus(function() {
|
504 |
+
var t = $(this);
|
505 |
+
t.select();
|
506 |
+
|
507 |
+
t.mouseup(function() { // Work around Chrome's little problem
|
508 |
|
509 |
+
t.unbind("mouseup"); // Prevent further mouseup intervention
|
|
|
|
|
510 |
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
511 |
});
|
512 |
+
});
|
513 |
+
}
|
|
|
|
|
514 |
|
515 |
+
/**
|
516 |
+
* Import Settings
|
517 |
+
*
|
518 |
+
*/
|
519 |
+
function cpac_import()
|
520 |
+
{
|
521 |
+
$('#cpac_import_submit'). click( function(e){
|
522 |
+
|
523 |
+
var btn = $(this);
|
524 |
+
var import_code = $('#cpac_import_input textarea').val();
|
525 |
+
var msg = btn.next('.import-message');
|
526 |
+
|
527 |
+
btn.addClass('loading');
|
528 |
+
msg.hide();
|
529 |
+
|
530 |
+
if ( import_code ) {
|
531 |
+
|
532 |
+
$.ajax({
|
533 |
+
url : ajaxurl,
|
534 |
+
type : 'POST',
|
535 |
+
dataType : 'json',
|
536 |
+
data : {
|
537 |
+
action : 'cpac_import',
|
538 |
+
import_code : import_code
|
539 |
+
},
|
540 |
+
success: function(data) {
|
541 |
+
if ( data != null ) {
|
542 |
+
|
543 |
+
// succes
|
544 |
+
if ( 1 == data.status ) {
|
545 |
+
msg.html(data.msg).show();
|
546 |
+
}
|
547 |
+
|
548 |
+
// fail
|
549 |
+
else if ( data.msg ) {
|
550 |
+
msg.text(data.msg).show();
|
551 |
+
}
|
552 |
+
}
|
553 |
+
|
554 |
+
else {
|
555 |
+
msg.text('error').show();
|
556 |
+
}
|
557 |
+
},
|
558 |
+
error: function(xhr, ajaxOptions, thrownError) {},
|
559 |
+
complete: function() {
|
560 |
+
btn.removeClass('loading');
|
561 |
+
}
|
562 |
+
});
|
563 |
+
}
|
564 |
+
|
565 |
+
else {
|
566 |
+
btn.removeClass('loading');
|
567 |
+
msg.text('empty').show();
|
568 |
+
}
|
569 |
+
|
570 |
+
e.preventDefault;
|
571 |
+
});
|
572 |
+
|
573 |
+
// Select Import Code
|
574 |
+
$('#cpac_import_input textarea').focus(function() {
|
575 |
+
var t = $(this);
|
576 |
+
t.select();
|
577 |
+
|
578 |
+
t.mouseup(function() { // Work around Chrome's little problem
|
579 |
+
|
580 |
+
t.unbind("mouseup"); // Prevent further mouseup intervention
|
581 |
+
return false;
|
582 |
});
|
583 |
+
});
|
584 |
+
}
|
585 |
+
|
586 |
+
/**
|
587 |
+
* WP Pointer
|
588 |
+
*
|
589 |
+
* credits to ACF ( Elliot Condon )
|
590 |
+
*/
|
591 |
+
function cpac_pointer()
|
592 |
+
{
|
593 |
+
$('a.cpac-pointer').each(function(){
|
594 |
+
|
595 |
+
// vars
|
596 |
+
var a = $(this),
|
597 |
+
html = a.attr('rel');
|
598 |
+
|
599 |
+
// create pointer
|
600 |
+
a.pointer({
|
601 |
+
content: $('#' + html).html(),
|
602 |
+
position: {
|
603 |
+
my: 'left bottom',
|
604 |
+
at: 'left top',
|
605 |
+
edge: 'bottom',
|
606 |
+
},
|
607 |
+
close: function() {
|
608 |
+
a.removeClass('open');
|
609 |
+
}
|
610 |
+
});
|
611 |
+
|
612 |
+
// click
|
613 |
+
a.click( function() {
|
614 |
+
if( a.hasClass('open') ) {
|
615 |
+
a.removeClass('open');
|
616 |
+
}
|
617 |
+
else {
|
618 |
+
a.addClass('open');
|
619 |
+
}
|
620 |
+
});
|
621 |
+
|
622 |
+
// show on hover
|
623 |
+
a.hover( function() {
|
624 |
+
$(this).pointer('open');
|
625 |
+
}, function() {
|
626 |
+
if( ! a.hasClass('open') ) {
|
627 |
+
$(this).pointer('close');
|
628 |
+
}
|
629 |
+
|
630 |
+
});
|
631 |
+
});
|
632 |
+
}
|
633 |
+
|
634 |
+
})(jQuery);
|
classes/license.php
ADDED
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class cpac_licence
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* The type of licence to check or activate
|
7 |
+
*
|
8 |
+
* @var string $type
|
9 |
+
*/
|
10 |
+
private $type;
|
11 |
+
|
12 |
+
public function __construct($type)
|
13 |
+
{
|
14 |
+
$this->type = $type;
|
15 |
+
}
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Unlocks
|
19 |
+
*
|
20 |
+
* @since 1.3
|
21 |
+
*/
|
22 |
+
public function is_unlocked()
|
23 |
+
{
|
24 |
+
return preg_match( '/^[a-f0-9]{40}$/i', $this->get_license_key( $this->type ) );
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Check license key with API
|
29 |
+
*
|
30 |
+
* @since 1.3.3
|
31 |
+
*/
|
32 |
+
private function check_remote_key( $key )
|
33 |
+
{
|
34 |
+
if ( empty( $key ) ) {
|
35 |
+
return false;
|
36 |
+
}
|
37 |
+
|
38 |
+
// check key with remote API
|
39 |
+
$response = wp_remote_post( $this->api_url, array(
|
40 |
+
'body' => array(
|
41 |
+
'api' => 'addon',
|
42 |
+
'key' => $key,
|
43 |
+
'type' => $this->type
|
44 |
+
)
|
45 |
+
));
|
46 |
+
|
47 |
+
// license will be valid in case of WP error or succes
|
48 |
+
if ( is_wp_error($response) || ( isset($response['body']) && json_decode($response['body']) == 'valid' ) ) {
|
49 |
+
return true;
|
50 |
+
}
|
51 |
+
|
52 |
+
return false;
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Set masked license key
|
57 |
+
*
|
58 |
+
* @since 1.3.1
|
59 |
+
*/
|
60 |
+
public function get_masked_license_key()
|
61 |
+
{
|
62 |
+
return '**************************'.substr( $this->get_license_key(), -4 );
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Get license key
|
67 |
+
*
|
68 |
+
* @since 1.3
|
69 |
+
*/
|
70 |
+
private function get_license_key()
|
71 |
+
{
|
72 |
+
return get_option("cpac_{$this->type}_ac");
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Set license key
|
77 |
+
*
|
78 |
+
* @since 1.3
|
79 |
+
*/
|
80 |
+
private function set_license_key( $key )
|
81 |
+
{
|
82 |
+
update_option( "cpac_{$this->type}_ac", trim( $key ) );
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Remove license key
|
87 |
+
*
|
88 |
+
* @since 1.3.1
|
89 |
+
*/
|
90 |
+
private function remove_license_key()
|
91 |
+
{
|
92 |
+
delete_option( "cpac_{$this->type}_ac" );
|
93 |
+
delete_transient("cpac_{$this->type}_trnsnt");
|
94 |
+
}
|
95 |
+
}
|
classes/sortable.php
CHANGED
@@ -1,1241 +1,1250 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Coderess Sortable Columns Class
|
5 |
-
*
|
6 |
-
* @since 1.3
|
7 |
-
*
|
8 |
-
*/
|
9 |
-
class Codepress_Sortable_Columns extends Codepress_Admin_Columns
|
10 |
-
{
|
11 |
-
private $post_types,
|
12 |
-
$unlocked,
|
13 |
-
$show_all_results
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
*
|
18 |
-
*
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
*
|
28 |
-
*
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
$
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
add_action( '
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
*
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
/**
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
*
|
103 |
-
*
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
*
|
113 |
-
*
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
*
|
123 |
-
*
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
*
|
133 |
-
*
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
$
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
break;
|
248 |
-
|
249 |
-
case 'column-
|
250 |
-
$sort_flag = SORT_REGULAR;
|
251 |
-
foreach ( $this->get_users_data() as $u ) {
|
252 |
-
if ($u->
|
253 |
-
$cusers[$u->ID] = $this->prepare_sort_string_value($u->
|
254 |
-
}
|
255 |
-
}
|
256 |
-
break;
|
257 |
-
|
258 |
-
case 'column-
|
259 |
-
$sort_flag = SORT_REGULAR;
|
260 |
-
foreach ( $this->get_users_data() as $u ) {
|
261 |
-
if ($u->
|
262 |
-
$cusers[$u->ID] = $this->prepare_sort_string_value($u->
|
263 |
-
}
|
264 |
-
}
|
265 |
-
break;
|
266 |
-
|
267 |
-
case 'column-
|
268 |
-
$sort_flag = SORT_REGULAR;
|
269 |
-
foreach ( $this->get_users_data() as $u ) {
|
270 |
-
if ($u->
|
271 |
-
$cusers[$u->ID] = $this->prepare_sort_string_value($u->
|
272 |
-
}
|
273 |
-
}
|
274 |
-
break;
|
275 |
-
|
276 |
-
case 'column-
|
277 |
-
$
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
foreach ( $this->get_users_data() as $u ) {
|
299 |
-
$
|
300 |
-
$cusers[$u->ID] = $this->prepare_sort_string_value($
|
301 |
-
}
|
302 |
-
}
|
303 |
-
break;
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
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 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
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 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
case '
|
492 |
-
$pieces['orderby'] = '
|
493 |
-
break;
|
494 |
-
|
495 |
-
|
496 |
-
$
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
//
|
529 |
-
if ( $
|
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 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
break;
|
600 |
-
|
601 |
-
case 'column-
|
602 |
-
$sort_flag = SORT_NUMERIC;
|
603 |
-
foreach ( $this->get_any_posts_by_posttype('attachment') as $p ) {
|
604 |
-
$meta
|
605 |
-
$
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
if ( $
|
647 |
-
$cposts[$p->ID] = $
|
648 |
-
}
|
649 |
-
}
|
650 |
-
break;
|
651 |
-
|
652 |
-
case 'column-
|
653 |
-
$sort_flag = SORT_STRING;
|
654 |
-
foreach ( $this->get_any_posts_by_posttype('attachment') as $p ) {
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
$file
|
666 |
-
if ( $file || $this->show_all_results ) {
|
667 |
-
$
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
//
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
break;
|
757 |
-
|
758 |
-
case 'column-
|
759 |
-
$
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
$
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
$
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
$
|
859 |
-
|
860 |
-
$
|
861 |
-
}
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
$
|
873 |
-
|
874 |
-
$
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
$this->
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
//
|
956 |
-
$
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
|
1047 |
-
|
1048 |
-
|
1049 |
-
|
1050 |
-
|
1051 |
-
|
1052 |
-
|
1053 |
-
|
1054 |
-
|
1055 |
-
|
1056 |
-
|
1057 |
-
|
1058 |
-
|
1059 |
-
|
1060 |
-
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
'
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
1084 |
-
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
-
|
1118 |
-
|
1119 |
-
|
1120 |
-
|
1121 |
-
|
1122 |
-
|
1123 |
-
|
1124 |
-
|
1125 |
-
|
1126 |
-
|
1127 |
-
|
1128 |
-
|
1129 |
-
|
1130 |
-
|
1131 |
-
|
1132 |
-
|
1133 |
-
|
1134 |
-
|
1135 |
-
|
1136 |
-
|
1137 |
-
|
1138 |
-
|
1139 |
-
|
1140 |
-
|
1141 |
-
|
1142 |
-
|
1143 |
-
|
1144 |
-
|
1145 |
-
|
1146 |
-
|
1147 |
-
|
1148 |
-
|
1149 |
-
|
1150 |
-
|
1151 |
-
|
1152 |
-
|
1153 |
-
|
1154 |
-
|
1155 |
-
|
1156 |
-
|
1157 |
-
|
1158 |
-
|
1159 |
-
|
1160 |
-
|
1161 |
-
|
1162 |
-
if ( $
|
1163 |
-
|
1164 |
-
|
1165 |
-
|
1166 |
-
|
1167 |
-
|
1168 |
-
|
1169 |
-
|
1170 |
-
|
1171 |
-
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
|
1177 |
-
|
1178 |
-
|
1179 |
-
|
1180 |
-
|
1181 |
-
|
1182 |
-
|
1183 |
-
|
1184 |
-
|
1185 |
-
|
1186 |
-
|
1187 |
-
|
1188 |
-
|
1189 |
-
|
1190 |
-
|
1191 |
-
|
1192 |
-
|
1193 |
-
|
1194 |
-
|
1195 |
-
|
1196 |
-
|
1197 |
-
|
1198 |
-
|
1199 |
-
|
1200 |
-
|
1201 |
-
|
1202 |
-
|
1203 |
-
|
1204 |
-
|
1205 |
-
|
1206 |
-
|
1207 |
-
|
1208 |
-
|
1209 |
-
|
1210 |
-
|
1211 |
-
|
1212 |
-
|
1213 |
-
|
1214 |
-
|
1215 |
-
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
1219 |
-
|
1220 |
-
|
1221 |
-
|
1222 |
-
|
1223 |
-
|
1224 |
-
|
1225 |
-
|
1226 |
-
|
1227 |
-
|
1228 |
-
|
1229 |
-
|
1230 |
-
|
1231 |
-
|
1232 |
-
|
1233 |
-
|
1234 |
-
|
1235 |
-
|
1236 |
-
|
1237 |
-
|
1238 |
-
|
1239 |
-
|
1240 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1241 |
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Coderess Sortable Columns Class
|
5 |
+
*
|
6 |
+
* @since 1.3
|
7 |
+
*
|
8 |
+
*/
|
9 |
+
class Codepress_Sortable_Columns extends Codepress_Admin_Columns
|
10 |
+
{
|
11 |
+
private $post_types,
|
12 |
+
$unlocked,
|
13 |
+
$show_all_results,
|
14 |
+
$current_user_id;
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Constructor
|
18 |
+
*
|
19 |
+
* @since 1.0
|
20 |
+
*/
|
21 |
+
function __construct()
|
22 |
+
{
|
23 |
+
add_action( 'wp_loaded', array( $this, 'init') );
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Initialize
|
28 |
+
*
|
29 |
+
* @since 1.0
|
30 |
+
*/
|
31 |
+
public function init()
|
32 |
+
{
|
33 |
+
$licence = new cpac_licence('sortable');
|
34 |
+
|
35 |
+
// vars
|
36 |
+
$this->unlocked = $licence->is_unlocked();
|
37 |
+
$this->post_types = Codepress_Admin_Columns::get_post_types();
|
38 |
+
$this->show_all_results = false;
|
39 |
+
$this->current_user_id = get_current_user_id();
|
40 |
+
|
41 |
+
// init sorting
|
42 |
+
add_action( 'admin_init', array( $this, 'register_sortable_columns' ) );
|
43 |
+
|
44 |
+
// init filtering
|
45 |
+
add_action( 'admin_init', array( $this, 'register_filtering_columns' ) );
|
46 |
+
|
47 |
+
// handle requests for sorting columns
|
48 |
+
add_filter( 'request', array( $this, 'handle_requests_orderby_column'), 1 );
|
49 |
+
add_action( 'pre_user_query', array( $this, 'handle_requests_orderby_users_column'), 1 );
|
50 |
+
add_action( 'admin_init', array( $this, 'handle_requests_orderby_links_column'), 1 );
|
51 |
+
add_action( 'admin_init', array( $this, 'handle_requests_orderby_comments_column'), 1 );
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Register sortable columns
|
56 |
+
*
|
57 |
+
* Hooks into apply_filters( "manage_{$screen->id}_sortable_columns" ) which is found in class-wp-list-table.php
|
58 |
+
*
|
59 |
+
* @since 1.0
|
60 |
+
*/
|
61 |
+
function register_sortable_columns()
|
62 |
+
{
|
63 |
+
if ( ! $this->unlocked )
|
64 |
+
return false;
|
65 |
+
|
66 |
+
/** Posts */
|
67 |
+
foreach ( $this->post_types as $post_type ) {
|
68 |
+
add_filter( "manage_edit-{$post_type}_sortable_columns", array($this, 'callback_add_sortable_posts_column'));
|
69 |
+
}
|
70 |
+
|
71 |
+
/** Users */
|
72 |
+
add_filter( "manage_users_sortable_columns", array($this, 'callback_add_sortable_users_column'));
|
73 |
+
|
74 |
+
/** Media */
|
75 |
+
add_filter( "manage_upload_sortable_columns", array($this, 'callback_add_sortable_media_column'));
|
76 |
+
|
77 |
+
/** Links */
|
78 |
+
add_filter( "manage_link-manager_sortable_columns", array($this, 'callback_add_sortable_links_column'));
|
79 |
+
|
80 |
+
/** Comments */
|
81 |
+
add_filter( "manage_edit-comments_sortable_columns", array($this, 'callback_add_sortable_comments_column'));
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Callback add Posts sortable column
|
86 |
+
*
|
87 |
+
* @since 1.0
|
88 |
+
*/
|
89 |
+
public function callback_add_sortable_posts_column($columns)
|
90 |
+
{
|
91 |
+
global $post_type;
|
92 |
+
|
93 |
+
// in some cases post_type is an array ( when clicking a tag inside the overview screen icm CCTM ), then we use this as a fallback so we get a string
|
94 |
+
if ( is_array($post_type) )
|
95 |
+
$post_type = $_REQUEST['post_type'];
|
96 |
+
|
97 |
+
return $this->add_managed_sortable_columns($post_type, $columns);
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Callback add Users sortable column
|
102 |
+
*
|
103 |
+
* @since 1.1
|
104 |
+
*/
|
105 |
+
public function callback_add_sortable_users_column($columns)
|
106 |
+
{
|
107 |
+
return $this->add_managed_sortable_columns('wp-users', $columns);
|
108 |
+
}
|
109 |
+
|
110 |
+
/**
|
111 |
+
* Callback add Media sortable column
|
112 |
+
*
|
113 |
+
* @since 1.3
|
114 |
+
*/
|
115 |
+
public function callback_add_sortable_media_column($columns)
|
116 |
+
{
|
117 |
+
return $this->add_managed_sortable_columns('wp-media', $columns);
|
118 |
+
}
|
119 |
+
|
120 |
+
/**
|
121 |
+
* Callback add Links sortable column
|
122 |
+
*
|
123 |
+
* @since 1.3.1
|
124 |
+
*/
|
125 |
+
public function callback_add_sortable_links_column($columns)
|
126 |
+
{
|
127 |
+
return $this->add_managed_sortable_columns('wp-links', $columns);
|
128 |
+
}
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Callback add Comments sortable column
|
132 |
+
*
|
133 |
+
* @since 1.3.1
|
134 |
+
*/
|
135 |
+
public function callback_add_sortable_comments_column($columns)
|
136 |
+
{
|
137 |
+
return $this->add_managed_sortable_columns('wp-comments', $columns);
|
138 |
+
}
|
139 |
+
|
140 |
+
/**
|
141 |
+
* Add managed sortable columns by Type
|
142 |
+
*
|
143 |
+
* @since 1.1
|
144 |
+
*/
|
145 |
+
private function add_managed_sortable_columns( $type = 'post', $columns )
|
146 |
+
{
|
147 |
+
$display_columns = $this->get_merged_columns($type);
|
148 |
+
|
149 |
+
if ( ! $display_columns )
|
150 |
+
return $columns;
|
151 |
+
|
152 |
+
foreach ( $display_columns as $id => $vars ) {
|
153 |
+
if ( isset($vars['options']['sortorder']) && $vars['options']['sortorder'] == 'on' ){
|
154 |
+
|
155 |
+
// register format
|
156 |
+
$columns[$id] = $this->sanitize_string($vars['label']);
|
157 |
+
}
|
158 |
+
}
|
159 |
+
|
160 |
+
return $columns;
|
161 |
+
}
|
162 |
+
|
163 |
+
/**
|
164 |
+
* Admin requests for orderby column
|
165 |
+
*
|
166 |
+
* Only works for WP_Query objects ( such as posts and media )
|
167 |
+
*
|
168 |
+
* @since 1.0
|
169 |
+
*/
|
170 |
+
public function handle_requests_orderby_column( $vars )
|
171 |
+
{
|
172 |
+
/** Users */
|
173 |
+
// You would expect to see get_orderby_users_vars(), but sorting for
|
174 |
+
// users is handled through a different filter. Not 'request', but 'pre_user_query'.
|
175 |
+
// See handle_requests_orderby_users_column().
|
176 |
+
|
177 |
+
/** Media */
|
178 |
+
if ( $this->request_uri_is('upload') ) {
|
179 |
+
$vars = $this->get_orderby_media_vars($vars);
|
180 |
+
}
|
181 |
+
|
182 |
+
/** Posts */
|
183 |
+
elseif ( !empty($vars['post_type']) ) {
|
184 |
+
$vars = $this->get_orderby_posts_vars($vars);
|
185 |
+
}
|
186 |
+
|
187 |
+
return $vars;
|
188 |
+
}
|
189 |
+
|
190 |
+
/**
|
191 |
+
* Orderby Users column
|
192 |
+
*
|
193 |
+
* @since 1.3
|
194 |
+
*/
|
195 |
+
public function handle_requests_orderby_users_column($user_query)
|
196 |
+
{
|
197 |
+
// query vars
|
198 |
+
$vars = $user_query->query_vars;
|
199 |
+
|
200 |
+
// Column
|
201 |
+
$column = $this->get_orderby_type( $vars['orderby'], 'wp-users' );
|
202 |
+
|
203 |
+
if ( empty($column) )
|
204 |
+
return $user_query;
|
205 |
+
|
206 |
+
// id
|
207 |
+
$type = $id = key($column);
|
208 |
+
|
209 |
+
// Check for user custom fields: column-meta-[customfieldname]
|
210 |
+
if ( Codepress_Admin_Columns::is_column_meta($type) )
|
211 |
+
$type = 'column-user-meta';
|
212 |
+
|
213 |
+
// Check for post count: column-user_postcount-[posttype]
|
214 |
+
if ( Codepress_Admin_Columns::get_posttype_by_postcount_column($type) )
|
215 |
+
$type = 'column-user_postcount';
|
216 |
+
|
217 |
+
// var
|
218 |
+
$cusers = array();
|
219 |
+
switch( $type ) :
|
220 |
+
|
221 |
+
case 'column-user_id':
|
222 |
+
$user_query->query_orderby = "ORDER BY ID {$user_query->query_vars['order']}";
|
223 |
+
$user_query->query_vars['orderby'] = 'ID';
|
224 |
+
break;
|
225 |
+
|
226 |
+
case 'column-user_registered':
|
227 |
+
$user_query->query_orderby = "ORDER BY user_registered {$user_query->query_vars['order']}";
|
228 |
+
$user_query->query_vars['orderby'] = 'registered';
|
229 |
+
break;
|
230 |
+
|
231 |
+
case 'column-nickname' :
|
232 |
+
$sort_flag = SORT_REGULAR;
|
233 |
+
foreach ( $this->get_users_data() as $u ) {
|
234 |
+
if ($u->nickname || $this->show_all_results ) {
|
235 |
+
$cusers[$u->ID] = $this->prepare_sort_string_value($u->nickname);
|
236 |
+
}
|
237 |
+
}
|
238 |
+
break;
|
239 |
+
|
240 |
+
case 'column-first_name' :
|
241 |
+
$sort_flag = SORT_REGULAR;
|
242 |
+
foreach ( $this->get_users_data() as $u ) {
|
243 |
+
if ($u->first_name || $this->show_all_results ) {
|
244 |
+
$cusers[$u->ID] = $this->prepare_sort_string_value($u->first_name);
|
245 |
+
}
|
246 |
+
}
|
247 |
+
break;
|
248 |
+
|
249 |
+
case 'column-last_name' :
|
250 |
+
$sort_flag = SORT_REGULAR;
|
251 |
+
foreach ( $this->get_users_data() as $u ) {
|
252 |
+
if ($u->last_name || $this->show_all_results ) {
|
253 |
+
$cusers[$u->ID] = $this->prepare_sort_string_value($u->last_name);
|
254 |
+
}
|
255 |
+
}
|
256 |
+
break;
|
257 |
+
|
258 |
+
case 'column-user_url' :
|
259 |
+
$sort_flag = SORT_REGULAR;
|
260 |
+
foreach ( $this->get_users_data() as $u ) {
|
261 |
+
if ($u->user_url || $this->show_all_results ) {
|
262 |
+
$cusers[$u->ID] = $this->prepare_sort_string_value($u->user_url);
|
263 |
+
}
|
264 |
+
}
|
265 |
+
break;
|
266 |
+
|
267 |
+
case 'column-user_description' :
|
268 |
+
$sort_flag = SORT_REGULAR;
|
269 |
+
foreach ( $this->get_users_data() as $u ) {
|
270 |
+
if ($u->user_description || $this->show_all_results ) {
|
271 |
+
$cusers[$u->ID] = $this->prepare_sort_string_value($u->user_description);
|
272 |
+
}
|
273 |
+
}
|
274 |
+
break;
|
275 |
+
|
276 |
+
case 'column-user_postcount' :
|
277 |
+
$post_type = Codepress_Admin_Columns::get_posttype_by_postcount_column($id);
|
278 |
+
if ( $post_type ) {
|
279 |
+
$sort_flag = SORT_REGULAR;
|
280 |
+
foreach ( $this->get_users_data() as $u ) {
|
281 |
+
$count = Codepress_Admin_Columns::get_post_count( $post_type, $u->ID );
|
282 |
+
$cusers[$u->ID] = $this->prepare_sort_string_value($count);
|
283 |
+
}
|
284 |
+
}
|
285 |
+
break;
|
286 |
+
|
287 |
+
case 'column-user-meta' :
|
288 |
+
$field = $column[$id]['field'];
|
289 |
+
if ( $field ) {
|
290 |
+
|
291 |
+
// order numeric or string
|
292 |
+
$sort_flag = SORT_REGULAR;
|
293 |
+
if ( $column[$id]['field_type'] == 'numeric' || $column[$id]['field_type'] == 'library_id' ) {
|
294 |
+
$sort_flag = SORT_NUMERIC;
|
295 |
+
}
|
296 |
+
|
297 |
+
// sort by metavalue
|
298 |
+
foreach ( $this->get_users_data() as $u ) {
|
299 |
+
$value = get_metadata('user', $u->ID, $field, true);
|
300 |
+
$cusers[$u->ID] = $this->prepare_sort_string_value($value);
|
301 |
+
}
|
302 |
+
}
|
303 |
+
break;
|
304 |
+
|
305 |
+
/** native WP columns */
|
306 |
+
|
307 |
+
// role column
|
308 |
+
case 'role' :
|
309 |
+
$sort_flag = SORT_REGULAR;
|
310 |
+
foreach ( $this->get_users_data() as $u ) {
|
311 |
+
$role = !empty($u->roles[0]) ? $u->roles[0] : '';
|
312 |
+
if ($role || $this->show_all_results ) {
|
313 |
+
$cusers[$u->ID] = $this->prepare_sort_string_value($role);
|
314 |
+
}
|
315 |
+
}
|
316 |
+
break;
|
317 |
+
|
318 |
+
endswitch;
|
319 |
+
|
320 |
+
if ( isset($sort_flag) ) {
|
321 |
+
$user_query = $this->get_users_query_vars( $user_query, $cusers, $sort_flag );
|
322 |
+
}
|
323 |
+
|
324 |
+
return $user_query;
|
325 |
+
}
|
326 |
+
|
327 |
+
/**
|
328 |
+
* Orderby Links column
|
329 |
+
*
|
330 |
+
* Makes use of filter 'get_bookmarks' from bookmark.php to change the result set of the links
|
331 |
+
*
|
332 |
+
* @since 1.3.1
|
333 |
+
*/
|
334 |
+
public function handle_requests_orderby_links_column()
|
335 |
+
{
|
336 |
+
// fire only when we are in the admins link-manager
|
337 |
+
if ( $this->request_uri_is('link-manager') )
|
338 |
+
add_filter( 'get_bookmarks', array( $this, 'callback_requests_orderby_links_column'), 10, 2);
|
339 |
+
}
|
340 |
+
|
341 |
+
/**
|
342 |
+
* Orderby Links column
|
343 |
+
*
|
344 |
+
* @since 1.3.1
|
345 |
+
*/
|
346 |
+
public function callback_requests_orderby_links_column($results, $vars)
|
347 |
+
{
|
348 |
+
global $wpdb;
|
349 |
+
|
350 |
+
// apply sorting preference
|
351 |
+
$this->apply_sorting_preference( $vars, 'wp-links' );
|
352 |
+
|
353 |
+
// Column
|
354 |
+
$column = $this->get_orderby_type( $vars['orderby'], 'wp-links' );
|
355 |
+
|
356 |
+
if ( empty($column) )
|
357 |
+
return $results;
|
358 |
+
|
359 |
+
// id
|
360 |
+
$type = $id = key($column);
|
361 |
+
|
362 |
+
// var
|
363 |
+
$length = '';
|
364 |
+
switch( $type ) :
|
365 |
+
|
366 |
+
case 'column-link_id':
|
367 |
+
if ( version_compare( get_bloginfo('version'), '3.2', '>' ) )
|
368 |
+
$vars['orderby'] = 'link_id';
|
369 |
+
else
|
370 |
+
$vars['orderby'] = 'id';
|
371 |
+
break;
|
372 |
+
|
373 |
+
case 'column-owner':
|
374 |
+
$vars['orderby'] = 'link_owner';
|
375 |
+
break;
|
376 |
+
|
377 |
+
case 'column-length':
|
378 |
+
$vars['orderby'] = 'length';
|
379 |
+
$length = ", CHAR_LENGTH(link_name) AS length";
|
380 |
+
break;
|
381 |
+
|
382 |
+
case 'column-target':
|
383 |
+
$vars['orderby'] = 'link_target';
|
384 |
+
break;
|
385 |
+
|
386 |
+
case 'column-description':
|
387 |
+
$vars['orderby'] = 'link_description';
|
388 |
+
break;
|
389 |
+
|
390 |
+
case 'column-notes':
|
391 |
+
$vars['orderby'] = 'link_notes';
|
392 |
+
break;
|
393 |
+
|
394 |
+
case 'column-rss':
|
395 |
+
$vars['orderby'] = 'link_rss';
|
396 |
+
break;
|
397 |
+
|
398 |
+
/** native WP columns */
|
399 |
+
|
400 |
+
// Relationship
|
401 |
+
case 'rel':
|
402 |
+
$vars['orderby'] = 'link_rel';
|
403 |
+
break;
|
404 |
+
|
405 |
+
default:
|
406 |
+
$vars['orderby'] = '';
|
407 |
+
|
408 |
+
endswitch;
|
409 |
+
|
410 |
+
// get bookmarks by orderby vars
|
411 |
+
if ( $vars['orderby'] ) {
|
412 |
+
$vars['order'] = mysql_escape_string($vars['order']);
|
413 |
+
$sql = "SELECT * {$length} FROM {$wpdb->links} WHERE 1=1 ORDER BY {$vars['orderby']} {$vars['order']}";
|
414 |
+
$results = $wpdb->get_results($sql);
|
415 |
+
|
416 |
+
// check for errors
|
417 |
+
if( is_wp_error($results) )
|
418 |
+
return false;
|
419 |
+
}
|
420 |
+
|
421 |
+
return $results;
|
422 |
+
}
|
423 |
+
|
424 |
+
/**
|
425 |
+
* Orderby Comments column
|
426 |
+
*
|
427 |
+
* @since 1.3.1
|
428 |
+
*/
|
429 |
+
public function callback_requests_orderby_comments_column($pieces, $ref_comment)
|
430 |
+
{
|
431 |
+
// get query vars
|
432 |
+
$vars = $ref_comment->query_vars;
|
433 |
+
|
434 |
+
// Column
|
435 |
+
$column = $this->get_orderby_type( $vars['orderby'], 'wp-comments' );
|
436 |
+
|
437 |
+
if ( empty($column) )
|
438 |
+
return $pieces;
|
439 |
+
|
440 |
+
// id
|
441 |
+
$type = $id = key($column);
|
442 |
+
|
443 |
+
// var
|
444 |
+
switch( $type ) :
|
445 |
+
|
446 |
+
case 'column-comment_id':
|
447 |
+
$pieces['orderby'] = 'comment_ID';
|
448 |
+
break;
|
449 |
+
|
450 |
+
case 'column-author_author':
|
451 |
+
$pieces['orderby'] = 'comment_author';
|
452 |
+
break;
|
453 |
+
|
454 |
+
case 'column-author_ip':
|
455 |
+
$pieces['orderby'] = 'comment_author_IP';
|
456 |
+
break;
|
457 |
+
|
458 |
+
case 'column-author_url':
|
459 |
+
$pieces['orderby'] = 'comment_author_url';
|
460 |
+
break;
|
461 |
+
|
462 |
+
case 'column-author_email':
|
463 |
+
$pieces['orderby'] = 'comment_author_email';
|
464 |
+
break;
|
465 |
+
|
466 |
+
case 'column-reply_to':
|
467 |
+
break;
|
468 |
+
|
469 |
+
case 'column-approved':
|
470 |
+
$pieces['orderby'] = 'comment_approved';
|
471 |
+
break;
|
472 |
+
|
473 |
+
case 'column-date':
|
474 |
+
$pieces['orderby'] = 'comment_date';
|
475 |
+
break;
|
476 |
+
|
477 |
+
case 'column-agent':
|
478 |
+
$pieces['orderby'] = 'comment_agent';
|
479 |
+
break;
|
480 |
+
|
481 |
+
case 'column-excerpt':
|
482 |
+
$pieces['orderby'] = 'comment_content';
|
483 |
+
break;
|
484 |
+
|
485 |
+
case 'column-date_gmt':
|
486 |
+
break;
|
487 |
+
|
488 |
+
/** native WP columns */
|
489 |
+
|
490 |
+
// Relationship
|
491 |
+
case 'comment':
|
492 |
+
$pieces['orderby'] = 'comment_content';
|
493 |
+
break;
|
494 |
+
|
495 |
+
default:
|
496 |
+
$vars['orderby'] = '';
|
497 |
+
|
498 |
+
endswitch;
|
499 |
+
|
500 |
+
return $pieces;
|
501 |
+
}
|
502 |
+
|
503 |
+
/**
|
504 |
+
* Orderby Comments column
|
505 |
+
*
|
506 |
+
* @since 1.3.1
|
507 |
+
*/
|
508 |
+
public function handle_requests_orderby_comments_column()
|
509 |
+
{
|
510 |
+
// fire only when we are in the admins edit-comments
|
511 |
+
if ( $this->request_uri_is('edit-comments') ) {
|
512 |
+
add_filter('comments_clauses', array( $this, 'callback_requests_orderby_comments_column'), 10, 2);
|
513 |
+
}
|
514 |
+
}
|
515 |
+
|
516 |
+
/**
|
517 |
+
* Get sorting vars in User Query Object
|
518 |
+
*
|
519 |
+
* @since 1.3
|
520 |
+
*/
|
521 |
+
private function get_users_query_vars( $user_query, $sortusers, $sort_flags = SORT_REGULAR )
|
522 |
+
{
|
523 |
+
global $wpdb;
|
524 |
+
|
525 |
+
// vars
|
526 |
+
$vars = $user_query->query_vars;
|
527 |
+
|
528 |
+
// sorting
|
529 |
+
if ( $vars['order'] == 'ASC' )
|
530 |
+
asort($sortusers, $sort_flags);
|
531 |
+
else
|
532 |
+
arsort($sortusers, $sort_flags);
|
533 |
+
|
534 |
+
// alter orderby SQL
|
535 |
+
if ( ! empty ( $sortusers ) ) {
|
536 |
+
$ids = implode(',', array_keys($sortusers));
|
537 |
+
$user_query->query_where .= " AND {$wpdb->prefix}users.ID IN ({$ids})";
|
538 |
+
$user_query->query_orderby = "ORDER BY FIELD({$wpdb->prefix}users.ID,{$ids})";
|
539 |
+
}
|
540 |
+
|
541 |
+
// cleanup the vars we dont need
|
542 |
+
$vars['order'] = '';
|
543 |
+
$vars['orderby'] = '';
|
544 |
+
|
545 |
+
// set query vars
|
546 |
+
$user_query->query_vars = $vars;
|
547 |
+
|
548 |
+
return $user_query;
|
549 |
+
}
|
550 |
+
|
551 |
+
/**
|
552 |
+
* Orderby Media column
|
553 |
+
*
|
554 |
+
* @since 1.3
|
555 |
+
*/
|
556 |
+
private function get_orderby_media_vars($vars)
|
557 |
+
{
|
558 |
+
// apply sorting preference
|
559 |
+
$this->apply_sorting_preference( $vars, 'wp-media' );
|
560 |
+
|
561 |
+
// when sorting still isn't set we will just return the requested vars
|
562 |
+
if ( empty( $vars['orderby'] ) )
|
563 |
+
return $vars;
|
564 |
+
|
565 |
+
// Column
|
566 |
+
$column = $this->get_orderby_type( $vars['orderby'], 'wp-media' );
|
567 |
+
|
568 |
+
if ( empty($column) )
|
569 |
+
return $vars;
|
570 |
+
|
571 |
+
$id = key($column);
|
572 |
+
|
573 |
+
// var
|
574 |
+
$cposts = array();
|
575 |
+
switch( $id ) :
|
576 |
+
|
577 |
+
case 'column-mediaid' :
|
578 |
+
$vars['orderby'] = 'ID';
|
579 |
+
break;
|
580 |
+
|
581 |
+
case 'column-width' :
|
582 |
+
$sort_flag = SORT_NUMERIC;
|
583 |
+
foreach ( $this->get_any_posts_by_posttype('attachment') as $p ) {
|
584 |
+
$meta = wp_get_attachment_metadata($p->ID);
|
585 |
+
$width = !empty($meta['width']) ? $meta['width'] : 0;
|
586 |
+
if ( $width || $this->show_all_results )
|
587 |
+
$cposts[$p->ID] = $width;
|
588 |
+
}
|
589 |
+
break;
|
590 |
+
|
591 |
+
case 'column-height' :
|
592 |
+
$sort_flag = SORT_NUMERIC;
|
593 |
+
foreach ( $this->get_any_posts_by_posttype('attachment') as $p ) {
|
594 |
+
$meta = wp_get_attachment_metadata($p->ID);
|
595 |
+
$height = !empty($meta['height']) ? $meta['height'] : 0;
|
596 |
+
if ( $height || $this->show_all_results )
|
597 |
+
$cposts[$p->ID] = $height;
|
598 |
+
}
|
599 |
+
break;
|
600 |
+
|
601 |
+
case 'column-dimensions' :
|
602 |
+
$sort_flag = SORT_NUMERIC;
|
603 |
+
foreach ( $this->get_any_posts_by_posttype('attachment') as $p ) {
|
604 |
+
$meta = wp_get_attachment_metadata($p->ID);
|
605 |
+
$height = !empty($meta['height']) ? $meta['height'] : 0;
|
606 |
+
$width = !empty($meta['width']) ? $meta['width'] : 0;
|
607 |
+
$surface = $height*$width;
|
608 |
+
|
609 |
+
if ( $surface || $this->show_all_results )
|
610 |
+
$cposts[$p->ID] = $surface;
|
611 |
+
}
|
612 |
+
break;
|
613 |
+
|
614 |
+
case 'column-caption' :
|
615 |
+
$sort_flag = SORT_STRING;
|
616 |
+
foreach ( $this->get_any_posts_by_posttype('attachment') as $p ) {
|
617 |
+
if ( $p->post_excerpt || $this->show_all_results ) {
|
618 |
+
$cposts[$p->ID] = $this->prepare_sort_string_value($p->post_excerpt);
|
619 |
+
}
|
620 |
+
}
|
621 |
+
break;
|
622 |
+
|
623 |
+
case 'column-description' :
|
624 |
+
$sort_flag = SORT_STRING;
|
625 |
+
foreach ( $this->get_any_posts_by_posttype('attachment') as $p ) {
|
626 |
+
if ( $p->post_content || $this->show_all_results ) {
|
627 |
+
$cposts[$p->ID] = $this->prepare_sort_string_value( $p->post_content );
|
628 |
+
}
|
629 |
+
}
|
630 |
+
break;
|
631 |
+
|
632 |
+
case 'column-mime_type' :
|
633 |
+
$sort_flag = SORT_STRING;
|
634 |
+
foreach ( $this->get_any_posts_by_posttype('attachment') as $p ) {
|
635 |
+
if ( $p->post_mime_type || $this->show_all_results ) {
|
636 |
+
$cposts[$p->ID] = $this->prepare_sort_string_value( $p->post_mime_type );
|
637 |
+
}
|
638 |
+
}
|
639 |
+
break;
|
640 |
+
|
641 |
+
case 'column-file_name' :
|
642 |
+
$sort_flag = SORT_STRING;
|
643 |
+
foreach ( $this->get_any_posts_by_posttype('attachment') as $p ) {
|
644 |
+
$meta = get_post_meta($p->ID, '_wp_attached_file', true);
|
645 |
+
$file = !empty($meta) ? basename($meta) : '';
|
646 |
+
if ( $file || $this->show_all_results ) {
|
647 |
+
$cposts[$p->ID] = $file;
|
648 |
+
}
|
649 |
+
}
|
650 |
+
break;
|
651 |
+
|
652 |
+
case 'column-alternate_text' :
|
653 |
+
$sort_flag = SORT_STRING;
|
654 |
+
foreach ( $this->get_any_posts_by_posttype('attachment') as $p ) {
|
655 |
+
$alt = get_post_meta($p->ID, '_wp_attachment_image_alt', true);
|
656 |
+
if ( $alt || $this->show_all_results ) {
|
657 |
+
$cposts[$p->ID] = $this->prepare_sort_string_value( $alt );
|
658 |
+
}
|
659 |
+
}
|
660 |
+
break;
|
661 |
+
|
662 |
+
case 'column-filesize' :
|
663 |
+
$sort_flag = SORT_NUMERIC;
|
664 |
+
foreach ( $this->get_any_posts_by_posttype('attachment') as $p ) {
|
665 |
+
$file = wp_get_attachment_url($p->ID);
|
666 |
+
if ( $file || $this->show_all_results ) {
|
667 |
+
$abs = str_replace( WP_CONTENT_URL, WP_CONTENT_DIR, $file);
|
668 |
+
$cposts[$p->ID] = $this->prepare_sort_string_value( filesize($abs) );
|
669 |
+
}
|
670 |
+
}
|
671 |
+
break;
|
672 |
+
|
673 |
+
endswitch;
|
674 |
+
|
675 |
+
// we will add the sorted post ids to vars['post__in'] and remove unused vars
|
676 |
+
if ( isset($sort_flag) ) {
|
677 |
+
$vars = $this->get_vars_post__in( $vars, $cposts, $sort_flag );
|
678 |
+
}
|
679 |
+
|
680 |
+
return $vars;
|
681 |
+
}
|
682 |
+
|
683 |
+
/**
|
684 |
+
* Orderby Posts column
|
685 |
+
*
|
686 |
+
* @since 1.3
|
687 |
+
*/
|
688 |
+
private function get_orderby_posts_vars($vars)
|
689 |
+
{
|
690 |
+
$post_type = $vars['post_type'];
|
691 |
+
|
692 |
+
// apply sorting preference
|
693 |
+
$this->apply_sorting_preference( $vars, $post_type );
|
694 |
+
|
695 |
+
// no sorting
|
696 |
+
if ( empty( $vars['orderby'] ) ) {
|
697 |
+
return $vars;
|
698 |
+
}
|
699 |
+
|
700 |
+
// Column
|
701 |
+
$column = $this->get_orderby_type( $vars['orderby'], $post_type );
|
702 |
+
|
703 |
+
if ( empty($column) )
|
704 |
+
return $vars;
|
705 |
+
|
706 |
+
// id
|
707 |
+
$type = $id = key($column);
|
708 |
+
|
709 |
+
// Check for taxonomies, such as column-taxonomy-[taxname]
|
710 |
+
if ( strpos($type, 'column-taxonomy-') !== false )
|
711 |
+
$type = 'column-taxonomy';
|
712 |
+
|
713 |
+
// Check for Custom Field
|
714 |
+
if ( Codepress_Admin_Columns::is_column_meta($type) )
|
715 |
+
$type = 'column-post-meta';
|
716 |
+
|
717 |
+
// var
|
718 |
+
$cposts = array();
|
719 |
+
switch( $type ) :
|
720 |
+
|
721 |
+
case 'column-postid' :
|
722 |
+
$vars['orderby'] = 'ID';
|
723 |
+
break;
|
724 |
+
|
725 |
+
case 'column-order' :
|
726 |
+
$vars['orderby'] = 'menu_order';
|
727 |
+
break;
|
728 |
+
|
729 |
+
case 'column-modified' :
|
730 |
+
$vars['orderby'] = 'modified';
|
731 |
+
break;
|
732 |
+
|
733 |
+
case 'column-comment-count' :
|
734 |
+
$vars['orderby'] = 'comment_count';
|
735 |
+
break;
|
736 |
+
|
737 |
+
case 'column-post-meta' :
|
738 |
+
$field = $column[$id]['field'];
|
739 |
+
|
740 |
+
// orderby type
|
741 |
+
$field_type = 'meta_value';
|
742 |
+
if ( $column[$id]['field_type'] == 'numeric' || $column[$id]['field_type'] == 'library_id' )
|
743 |
+
$field_type = 'meta_value_num';
|
744 |
+
|
745 |
+
$vars = array_merge($vars, array(
|
746 |
+
'meta_key' => $field,
|
747 |
+
'orderby' => $field_type
|
748 |
+
));
|
749 |
+
break;
|
750 |
+
|
751 |
+
case 'column-excerpt' :
|
752 |
+
$sort_flag = SORT_STRING;
|
753 |
+
foreach ( $this->get_any_posts_by_posttype($post_type) as $p ) {
|
754 |
+
$cposts[$p->ID] = $this->prepare_sort_string_value($p->post_content);
|
755 |
+
}
|
756 |
+
break;
|
757 |
+
|
758 |
+
case 'column-word-count' :
|
759 |
+
$sort_flag = SORT_NUMERIC;
|
760 |
+
foreach ( $this->get_any_posts_by_posttype($post_type) as $p ) {
|
761 |
+
$cposts[$p->ID] = str_word_count( Codepress_Admin_Columns::strip_trim( $p->post_content ) );
|
762 |
+
}
|
763 |
+
break;
|
764 |
+
|
765 |
+
case 'column-page-template' :
|
766 |
+
$sort_flag = SORT_STRING;
|
767 |
+
$templates = get_page_templates();
|
768 |
+
foreach ( $this->get_any_posts_by_posttype($post_type) as $p ) {
|
769 |
+
$page_template = get_post_meta($p->ID, '_wp_page_template', true);
|
770 |
+
$cposts[$p->ID] = array_search($page_template, $templates);
|
771 |
+
}
|
772 |
+
break;
|
773 |
+
|
774 |
+
case 'column-post_formats' :
|
775 |
+
$sort_flag = SORT_REGULAR;
|
776 |
+
foreach ( $this->get_any_posts_by_posttype($post_type) as $p ) {
|
777 |
+
$cposts[$p->ID] = get_post_format($p->ID);
|
778 |
+
}
|
779 |
+
break;
|
780 |
+
|
781 |
+
case 'column-attachment' :
|
782 |
+
case 'column-attachment-count' :
|
783 |
+
$sort_flag = SORT_NUMERIC;
|
784 |
+
foreach ( $this->get_any_posts_by_posttype($post_type) as $p ) {
|
785 |
+
$cposts[$p->ID] = count( Codepress_Admin_Columns::get_attachment_ids($p->ID) );
|
786 |
+
}
|
787 |
+
break;
|
788 |
+
|
789 |
+
case 'column-page-slug' :
|
790 |
+
$sort_flag = SORT_REGULAR;
|
791 |
+
foreach ( $this->get_any_posts_by_posttype($post_type) as $p ) {
|
792 |
+
$cposts[$p->ID] = $p->post_name;
|
793 |
+
}
|
794 |
+
break;
|
795 |
+
|
796 |
+
case 'column-sticky' :
|
797 |
+
$sort_flag = SORT_REGULAR;
|
798 |
+
$stickies = get_option('sticky_posts');
|
799 |
+
foreach ( $this->get_any_posts_by_posttype($post_type) as $p ) {
|
800 |
+
$cposts[$p->ID] = $p->ID;
|
801 |
+
if ( !empty($stickies) && in_array($p->ID, $stickies ) ) {
|
802 |
+
$cposts[$p->ID] = 0;
|
803 |
+
}
|
804 |
+
}
|
805 |
+
break;
|
806 |
+
|
807 |
+
case 'column-featured_image' :
|
808 |
+
$sort_flag = SORT_REGULAR;
|
809 |
+
foreach ( $this->get_any_posts_by_posttype($post_type) as $p ) {
|
810 |
+
$cposts[$p->ID] = $p->ID;
|
811 |
+
$thumb = get_the_post_thumbnail($p->ID);
|
812 |
+
if ( !empty($thumb) ) {
|
813 |
+
$cposts[$p->ID] = 0;
|
814 |
+
}
|
815 |
+
}
|
816 |
+
break;
|
817 |
+
|
818 |
+
case 'column-roles' :
|
819 |
+
$sort_flag = SORT_STRING;
|
820 |
+
foreach ( $this->get_any_posts_by_posttype($post_type) as $p ) {
|
821 |
+
$cposts[$p->ID] = 0;
|
822 |
+
$userdata = get_userdata($p->post_author);
|
823 |
+
if ( !empty($userdata->roles[0]) ) {
|
824 |
+
$cposts[$p->ID] = $userdata->roles[0];
|
825 |
+
}
|
826 |
+
}
|
827 |
+
break;
|
828 |
+
|
829 |
+
case 'column-status' :
|
830 |
+
$sort_flag = SORT_STRING;
|
831 |
+
foreach ( $this->get_any_posts_by_posttype($post_type) as $p ) {
|
832 |
+
$cposts[$p->ID] = $p->post_status.strtotime($p->post_date);
|
833 |
+
}
|
834 |
+
break;
|
835 |
+
|
836 |
+
case 'column-comment-status' :
|
837 |
+
$sort_flag = SORT_STRING;
|
838 |
+
foreach ( $this->get_any_posts_by_posttype($post_type) as $p ) {
|
839 |
+
$cposts[$p->ID] = $p->comment_status;
|
840 |
+
}
|
841 |
+
break;
|
842 |
+
|
843 |
+
case 'column-ping-status' :
|
844 |
+
$sort_flag = SORT_STRING;
|
845 |
+
foreach ( $this->get_any_posts_by_posttype($post_type) as $p ) {
|
846 |
+
$cposts[$p->ID] = $p->ping_status;
|
847 |
+
}
|
848 |
+
break;
|
849 |
+
|
850 |
+
case 'column-taxonomy' :
|
851 |
+
$sort_flag = SORT_STRING; // needed to sort
|
852 |
+
$taxonomy = str_replace('column-taxonomy-', '', $id);
|
853 |
+
$cposts = $this->get_posts_sorted_by_taxonomy($post_type, $taxonomy);
|
854 |
+
break;
|
855 |
+
|
856 |
+
case 'column-author-name' :
|
857 |
+
$sort_flag = SORT_STRING;
|
858 |
+
$display_as = $column[$id]['display_as'];
|
859 |
+
if( 'userid' == $display_as ) {
|
860 |
+
$sort_flag = SORT_NUMERIC;
|
861 |
+
}
|
862 |
+
foreach ( $this->get_any_posts_by_posttype($post_type) as $p ) {
|
863 |
+
if ( !empty($p->post_author) ) {
|
864 |
+
$name = Codepress_Admin_Columns::get_author_field_by_nametype($display_as, $p->post_author);
|
865 |
+
$cposts[$p->ID] = $name;
|
866 |
+
}
|
867 |
+
}
|
868 |
+
break;
|
869 |
+
|
870 |
+
case 'column-before-moretag' :
|
871 |
+
$sort_flag = SORT_STRING;
|
872 |
+
foreach ( $this->get_any_posts_by_posttype($post_type) as $p ) {
|
873 |
+
$extended = get_extended($p->post_content);
|
874 |
+
$content = !empty($extended['extended']) ? $extended['main'] : '';
|
875 |
+
$cposts[$p->ID] = $this->prepare_sort_string_value($content);
|
876 |
+
}
|
877 |
+
break;
|
878 |
+
|
879 |
+
/** native WP columns */
|
880 |
+
|
881 |
+
// categories
|
882 |
+
case 'categories' :
|
883 |
+
$sort_flag = SORT_STRING; // needed to sort
|
884 |
+
$cposts = $this->get_posts_sorted_by_taxonomy($post_type, 'category');
|
885 |
+
break;
|
886 |
+
|
887 |
+
// tags
|
888 |
+
case 'tags' :
|
889 |
+
$sort_flag = SORT_STRING; // needed to sort
|
890 |
+
$cposts = $this->get_posts_sorted_by_taxonomy($post_type, 'post_tag');
|
891 |
+
break;
|
892 |
+
|
893 |
+
endswitch;
|
894 |
+
|
895 |
+
// we will add the sorted post ids to vars['post__in'] and remove unused vars
|
896 |
+
if ( isset($sort_flag) ) {
|
897 |
+
$vars = $this->get_vars_post__in( $vars, $cposts, $sort_flag );
|
898 |
+
}
|
899 |
+
|
900 |
+
return $vars;
|
901 |
+
}
|
902 |
+
|
903 |
+
/**
|
904 |
+
* Set sorting preference
|
905 |
+
*
|
906 |
+
* after sorting we will save this sorting preference to the column item
|
907 |
+
* we set the default_order to either asc, desc or empty.
|
908 |
+
* only ONE column item PER type can have a default_order
|
909 |
+
*
|
910 |
+
* @since 1.4.6.5
|
911 |
+
*/
|
912 |
+
function set_sorting_preference( $type, $orderby = '', $order = 'asc' )
|
913 |
+
{
|
914 |
+
if ( !$orderby )
|
915 |
+
return false;
|
916 |
+
|
917 |
+
$options = get_user_meta( $this->current_user_id, 'cpac_sorting_preference', true );
|
918 |
+
|
919 |
+
$options[$type] = array(
|
920 |
+
'orderby' => $orderby,
|
921 |
+
'order' => $order
|
922 |
+
);
|
923 |
+
|
924 |
+
update_user_meta( $this->current_user_id, 'cpac_sorting_preference', $options );
|
925 |
+
}
|
926 |
+
|
927 |
+
/**
|
928 |
+
* Get sorting preference
|
929 |
+
*
|
930 |
+
* The default sorting of the column is saved to it's property default_order.
|
931 |
+
* Returns the orderby and order value of that column.
|
932 |
+
*
|
933 |
+
* @since 1.4.6.5
|
934 |
+
*/
|
935 |
+
function get_sorting_preference( $type )
|
936 |
+
{
|
937 |
+
$options = get_user_meta( $this->current_user_id, 'cpac_sorting_preference', true );
|
938 |
+
|
939 |
+
if ( empty($options[$type]) )
|
940 |
+
return false;
|
941 |
+
|
942 |
+
return $options[$type];
|
943 |
+
}
|
944 |
+
|
945 |
+
/**
|
946 |
+
* Apply sorting preference
|
947 |
+
*
|
948 |
+
* @since 1.4.6.5
|
949 |
+
*/
|
950 |
+
function apply_sorting_preference( &$vars, $type )
|
951 |
+
{
|
952 |
+
// user has not sorted
|
953 |
+
if ( empty( $vars['orderby'] ) ) {
|
954 |
+
|
955 |
+
// did the user sorted this column some other time?
|
956 |
+
if ( $preference = $this->get_sorting_preference($type) ) {
|
957 |
+
$vars['orderby'] = $preference['orderby'];
|
958 |
+
$vars['order'] = $preference['order'];
|
959 |
+
|
960 |
+
// used by active state in column header
|
961 |
+
$_GET['orderby'] = $preference['orderby'];
|
962 |
+
$_GET['order'] = $preference['order'];
|
963 |
+
}
|
964 |
+
}
|
965 |
+
|
966 |
+
// save the order preference
|
967 |
+
if ( !empty( $vars['orderby'] ) ) {
|
968 |
+
$this->set_sorting_preference( $type, $vars['orderby'], $vars['order'] );
|
969 |
+
}
|
970 |
+
}
|
971 |
+
|
972 |
+
/**
|
973 |
+
* Get posts sorted by taxonomy
|
974 |
+
*
|
975 |
+
* This will post ID's by the first term in the taxonomy
|
976 |
+
*
|
977 |
+
* @since 1.4.5
|
978 |
+
*/
|
979 |
+
function get_posts_sorted_by_taxonomy($post_type, $taxonomy = 'category')
|
980 |
+
{
|
981 |
+
$cposts = array();
|
982 |
+
foreach ( $this->get_any_posts_by_posttype($post_type) as $p ) {
|
983 |
+
$cposts[$p->ID] = '';
|
984 |
+
$terms = get_the_terms($p->ID, $taxonomy);
|
985 |
+
if ( !is_wp_error($terms) && !empty($terms) ) {
|
986 |
+
// only use the first term to sort
|
987 |
+
$term = array_shift(array_values($terms));
|
988 |
+
if ( isset($term->term_id) ) {
|
989 |
+
$cposts[$p->ID] = sanitize_term_field('name', $term->name, $term->term_id, $term->taxonomy, 'display');
|
990 |
+
}
|
991 |
+
}
|
992 |
+
}
|
993 |
+
return $cposts;
|
994 |
+
}
|
995 |
+
|
996 |
+
/**
|
997 |
+
* Set post__in for use in WP_Query
|
998 |
+
*
|
999 |
+
* This will order the ID's asc or desc and set the appropriate filters.
|
1000 |
+
*
|
1001 |
+
* @since 1.2.1
|
1002 |
+
*/
|
1003 |
+
private function get_vars_post__in( &$vars, $sortposts, $sort_flags = SORT_REGULAR )
|
1004 |
+
{
|
1005 |
+
// sort post ids by value
|
1006 |
+
if ( $vars['order'] == 'asc' )
|
1007 |
+
asort($sortposts, $sort_flags);
|
1008 |
+
else
|
1009 |
+
arsort($sortposts, $sort_flags);
|
1010 |
+
|
1011 |
+
// this will make sure WP_Query will use the order of the ids that we have just set in 'post__in'
|
1012 |
+
// set priority higher then default to prevent conflicts with 3rd party plugins
|
1013 |
+
add_filter('posts_orderby', array( $this, 'filter_orderby_post__in'), 10, 2 );
|
1014 |
+
|
1015 |
+
// cleanup the vars we dont need
|
1016 |
+
$vars['order'] = '';
|
1017 |
+
$vars['orderby'] = '';
|
1018 |
+
|
1019 |
+
// add the sorted post ids to the query with the use of post__in
|
1020 |
+
$vars['post__in'] = array_keys($sortposts);
|
1021 |
+
|
1022 |
+
return $vars;
|
1023 |
+
}
|
1024 |
+
|
1025 |
+
/**
|
1026 |
+
* Get orderby type
|
1027 |
+
*
|
1028 |
+
* @since 1.1
|
1029 |
+
*/
|
1030 |
+
private function get_orderby_type($orderby, $type)
|
1031 |
+
{
|
1032 |
+
$db_columns = Codepress_Admin_Columns::get_stored_columns($type);
|
1033 |
+
|
1034 |
+
if ( $db_columns ) {
|
1035 |
+
foreach ( $db_columns as $id => $vars ) {
|
1036 |
+
|
1037 |
+
// check which custom column was clicked
|
1038 |
+
if ( isset( $vars['label'] ) && $orderby == $this->sanitize_string( $vars['label'] ) ) {
|
1039 |
+
$column[$id] = $vars;
|
1040 |
+
return $column;
|
1041 |
+
}
|
1042 |
+
}
|
1043 |
+
}
|
1044 |
+
return false;
|
1045 |
+
}
|
1046 |
+
|
1047 |
+
/**
|
1048 |
+
* Maintain order of ids that are set in the post__in var.
|
1049 |
+
*
|
1050 |
+
* This will force the returned posts to use the order of the ID's that
|
1051 |
+
* have been set in post__in. Without this the ID's will be set in numeric order.
|
1052 |
+
* See the WP_Query object for more info about the use of post__in.
|
1053 |
+
*
|
1054 |
+
* @since 1.2.1
|
1055 |
+
*/
|
1056 |
+
public function filter_orderby_post__in($orderby, $wp)
|
1057 |
+
{
|
1058 |
+
global $wpdb;
|
1059 |
+
|
1060 |
+
// we need the query vars
|
1061 |
+
$vars = $wp->query_vars;
|
1062 |
+
if ( ! empty ( $vars['post__in'] ) ) {
|
1063 |
+
// now we can get the ids
|
1064 |
+
$ids = implode(',', $vars['post__in']);
|
1065 |
+
|
1066 |
+
// by adding FIELD to the SQL query we are forcing the order of the ID's
|
1067 |
+
return "FIELD({$wpdb->prefix}posts.ID,{$ids})";
|
1068 |
+
}
|
1069 |
+
}
|
1070 |
+
|
1071 |
+
/**
|
1072 |
+
* Get any posts by post_type
|
1073 |
+
*
|
1074 |
+
* @since 1.2.1
|
1075 |
+
*/
|
1076 |
+
private function get_any_posts_by_posttype( $post_type )
|
1077 |
+
{
|
1078 |
+
$any_posts = (array) get_posts(array(
|
1079 |
+
'numberposts' => -1,
|
1080 |
+
'post_status' => 'any',
|
1081 |
+
'post_type' => $post_type
|
1082 |
+
));
|
1083 |
+
|
1084 |
+
// trash posts are not included in the posts_status 'any' by default
|
1085 |
+
$trash_posts = (array) get_posts(array(
|
1086 |
+
'numberposts' => -1,
|
1087 |
+
'post_status' => 'trash',
|
1088 |
+
'post_type' => $post_type
|
1089 |
+
));
|
1090 |
+
|
1091 |
+
$all_posts = array_merge($any_posts, $trash_posts);
|
1092 |
+
|
1093 |
+
return (array) $all_posts;
|
1094 |
+
}
|
1095 |
+
|
1096 |
+
/**
|
1097 |
+
* Request URI is
|
1098 |
+
*
|
1099 |
+
* @since 1.3.1
|
1100 |
+
*/
|
1101 |
+
private function request_uri_is( $screen_id = '' )
|
1102 |
+
{
|
1103 |
+
if (strpos( $_SERVER['REQUEST_URI'], "/{$screen_id}.php" ) !== false )
|
1104 |
+
return true;
|
1105 |
+
|
1106 |
+
return false;
|
1107 |
+
}
|
1108 |
+
|
1109 |
+
/**
|
1110 |
+
* Prepare the value for being by sorting
|
1111 |
+
*
|
1112 |
+
* @since 1.3
|
1113 |
+
*/
|
1114 |
+
private function prepare_sort_string_value($string)
|
1115 |
+
{
|
1116 |
+
// remove tags and only get the first 20 chars and force lowercase.
|
1117 |
+
$string = strtolower( substr( Codepress_Admin_Columns::strip_trim($string),0 ,20 ) );
|
1118 |
+
|
1119 |
+
return $string;
|
1120 |
+
}
|
1121 |
+
|
1122 |
+
/**
|
1123 |
+
* Get users data
|
1124 |
+
*
|
1125 |
+
* @since 1.3
|
1126 |
+
*/
|
1127 |
+
function get_users_data()
|
1128 |
+
{
|
1129 |
+
$userdatas = array();
|
1130 |
+
$wp_users = get_users( array(
|
1131 |
+
'blog_id' => $GLOBALS['blog_id'],
|
1132 |
+
));
|
1133 |
+
foreach ( $wp_users as $u ) {
|
1134 |
+
$userdatas[$u->ID] = get_userdata($u->ID);
|
1135 |
+
}
|
1136 |
+
return $userdatas;
|
1137 |
+
}
|
1138 |
+
|
1139 |
+
/**
|
1140 |
+
* Register filtering columns
|
1141 |
+
*
|
1142 |
+
* @since 1.4.2
|
1143 |
+
*/
|
1144 |
+
function register_filtering_columns()
|
1145 |
+
{
|
1146 |
+
if ( ! $this->unlocked || apply_filters( 'cpac-remove-filtering-columns', true ) )
|
1147 |
+
return false;
|
1148 |
+
|
1149 |
+
// hook into wordpress
|
1150 |
+
add_action('restrict_manage_posts', array($this, 'callback_restrict_posts'));
|
1151 |
+
}
|
1152 |
+
|
1153 |
+
/**
|
1154 |
+
* Add taxonomy filters to posts
|
1155 |
+
*
|
1156 |
+
* @since 1.4.2
|
1157 |
+
*/
|
1158 |
+
function callback_restrict_posts()
|
1159 |
+
{
|
1160 |
+
global $post_type_object;
|
1161 |
+
|
1162 |
+
if ( !isset($post_type_object->name) )
|
1163 |
+
return false;
|
1164 |
+
|
1165 |
+
// make a filter foreach taxonomy
|
1166 |
+
$taxonomies = get_object_taxonomies($post_type_object->name, 'names');
|
1167 |
+
|
1168 |
+
// get stored columns
|
1169 |
+
$db_columns = Codepress_Admin_Columns::get_stored_columns($post_type_object->name);
|
1170 |
+
|
1171 |
+
if ( $taxonomies ) {
|
1172 |
+
foreach ( $taxonomies as $tax ) {
|
1173 |
+
|
1174 |
+
// ignore core taxonomies
|
1175 |
+
if ( in_array($tax, array('post_tag','category','post_format') ) ) {
|
1176 |
+
continue;
|
1177 |
+
}
|
1178 |
+
|
1179 |
+
// only display taxonomy that is active as a column
|
1180 |
+
if ( isset($db_columns['column-taxonomy-'.$tax]) && $db_columns['column-taxonomy-'.$tax]['state'] == 'on' ) {
|
1181 |
+
|
1182 |
+
$terms = get_terms($tax);
|
1183 |
+
$terms = $this->indent($terms, 0, 'parent', 'term_id');
|
1184 |
+
$terms = $this->apply_dropdown_markup($terms);
|
1185 |
+
|
1186 |
+
$select = "<option value=''>".__('Show all ', CPAC_TEXTDOMAIN)."{$tax}</option>";
|
1187 |
+
if (!empty($terms)) {
|
1188 |
+
foreach( $terms as $term_slug => $term) {
|
1189 |
+
|
1190 |
+
$selected = isset($_GET[$tax]) && $term_slug == $_GET[$tax] ? " selected='selected'" : '';
|
1191 |
+
$select .= "<option value='{$term_slug}'{$selected}>{$term}</option>";
|
1192 |
+
}
|
1193 |
+
echo "<select class='postform' name='{$tax}'>{$select}</select>";
|
1194 |
+
}
|
1195 |
+
}
|
1196 |
+
}
|
1197 |
+
}
|
1198 |
+
}
|
1199 |
+
|
1200 |
+
/**
|
1201 |
+
* Applies dropdown markup for taxonomy dropdown
|
1202 |
+
*
|
1203 |
+
* @since 1.4.2
|
1204 |
+
*/
|
1205 |
+
private function apply_dropdown_markup($array, $level = 0, $output = array())
|
1206 |
+
{
|
1207 |
+
foreach($array as $v) {
|
1208 |
+
|
1209 |
+
$prefix = '';
|
1210 |
+
for($i=0; $i<$level; $i++) {
|
1211 |
+
$prefix .= ' ';
|
1212 |
+
}
|
1213 |
+
|
1214 |
+
$output[$v->slug] = $prefix . $v->name;
|
1215 |
+
|
1216 |
+
if ( !empty($v->children) ) {
|
1217 |
+
$output = $this->apply_dropdown_markup($v->children, ($level + 1), $output);
|
1218 |
+
}
|
1219 |
+
}
|
1220 |
+
|
1221 |
+
return $output;
|
1222 |
+
}
|
1223 |
+
|
1224 |
+
/**
|
1225 |
+
* Indents any object as long as it has a unique id and that of its parent.
|
1226 |
+
*
|
1227 |
+
* @since 1.4.2
|
1228 |
+
*/
|
1229 |
+
private function indent($array, $parentId = 0, $parentKey = 'post_parent', $selfKey = 'ID', $childrenKey = 'children')
|
1230 |
+
{
|
1231 |
+
$indent = array();
|
1232 |
+
|
1233 |
+
// clean counter
|
1234 |
+
$i = 0;
|
1235 |
+
|
1236 |
+
foreach($array as $v) {
|
1237 |
+
|
1238 |
+
if ($v->$parentKey == $parentId) {
|
1239 |
+
$indent[$i] = $v;
|
1240 |
+
$indent[$i]->$childrenKey = $this->indent($array, $v->$selfKey, $parentKey, $selfKey);
|
1241 |
+
|
1242 |
+
$i++;
|
1243 |
+
}
|
1244 |
+
}
|
1245 |
+
|
1246 |
+
return $indent;
|
1247 |
+
}
|
1248 |
+
}
|
1249 |
+
|
1250 |
?>
|
classes/utility.php
CHANGED
@@ -1,26 +1,25 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Fix for getting the columns loaded by WordPress SEO Yoast
|
5 |
-
*
|
6 |
-
* The added columns from WordPress SEO by Yoast weren't available on
|
7 |
-
* the admin columns settings page. The
|
8 |
-
* from loading. This fix will also load this class when admin columns is loaded.
|
9 |
-
*
|
10 |
-
* @since 1.4.6
|
11 |
-
*/
|
12 |
-
function pre_load_wordpress_seo_class_metabox()
|
13 |
-
{
|
14 |
-
global $pagenow;
|
15 |
-
|
16 |
-
if (
|
17 |
-
isset($_REQUEST['page']) &&
|
18 |
-
'codepress-admin-columns' == $_REQUEST['page'] &&
|
19 |
-
'options-general.php' == $pagenow &&
|
20 |
-
defined('WPSEO_PATH') &&
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
}
|
26 |
add_action( 'plugins_loaded', 'pre_load_wordpress_seo_class_metabox', 0 );
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Fix for getting the columns loaded by WordPress SEO Yoast
|
5 |
+
*
|
6 |
+
* The added columns from WordPress SEO by Yoast weren't available on
|
7 |
+
* the admin columns settings page. The reason was that class-metabox.php was prevented
|
8 |
+
* from loading. This fix will also load this class when admin columns is loaded.
|
9 |
+
*
|
10 |
+
* @since 1.4.6
|
11 |
+
*/
|
12 |
+
function pre_load_wordpress_seo_class_metabox()
|
13 |
+
{
|
14 |
+
global $pagenow;
|
15 |
+
|
16 |
+
if (
|
17 |
+
isset( $_REQUEST['page'] ) &&
|
18 |
+
'codepress-admin-columns' == $_REQUEST['page'] &&
|
19 |
+
'options-general.php' == $pagenow &&
|
20 |
+
defined('WPSEO_PATH') && file_exists(WPSEO_PATH.'admin/class-metabox.php')
|
21 |
+
) {
|
22 |
+
require_once WPSEO_PATH.'admin/class-metabox.php';
|
23 |
+
}
|
24 |
+
}
|
|
|
25 |
add_action( 'plugins_loaded', 'pre_load_wordpress_seo_class_metabox', 0 );
|
classes/values.php
CHANGED
@@ -1,518 +1,530 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* CPAC_Values Class
|
5 |
-
*
|
6 |
-
* @since 1.4.4
|
7 |
-
*
|
8 |
-
*/
|
9 |
-
class CPAC_Values
|
10 |
-
{
|
11 |
-
protected $excerpt_length, $thumbnail_size;
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Constructor
|
15 |
-
*
|
16 |
-
* @since 1.0
|
17 |
-
*/
|
18 |
-
function __construct()
|
19 |
-
{
|
20 |
-
// number of words
|
21 |
-
$this->excerpt_length = 20;
|
22 |
-
$this->thumbnail_size = apply_filters( 'cpac_thumbnail_size', array(80,80) );
|
23 |
-
}
|
24 |
-
|
25 |
-
/**
|
26 |
-
* Admin requests for orderby column
|
27 |
-
*
|
28 |
-
* @since 1.0
|
29 |
-
*/
|
30 |
-
public function get_stored_columns($type)
|
31 |
-
{
|
32 |
-
return Codepress_Admin_Columns::get_stored_columns($type);
|
33 |
-
}
|
34 |
-
|
35 |
-
/**
|
36 |
-
* Checks if column-meta key exists
|
37 |
-
*
|
38 |
-
* @since 1.0
|
39 |
-
*/
|
40 |
-
public static function is_column_meta( $id = '' )
|
41 |
-
{
|
42 |
-
return Codepress_Admin_Columns::is_column_meta( $id );
|
43 |
-
}
|
44 |
-
|
45 |
-
/**
|
46 |
-
* Returns excerpt
|
47 |
-
*
|
48 |
-
* @since 1.0
|
49 |
-
*/
|
50 |
-
protected function get_post_excerpt($post_id)
|
51 |
-
{
|
52 |
-
global $post;
|
53 |
-
|
54 |
-
$save_post = $post;
|
55 |
-
$post = get_post($post_id);
|
56 |
-
$excerpt = get_the_excerpt();
|
57 |
-
$post = $save_post;
|
58 |
-
|
59 |
-
$output = $this->get_shortened_string($excerpt, $this->excerpt_length );
|
60 |
-
|
61 |
-
return $output;
|
62 |
-
}
|
63 |
-
|
64 |
-
/**
|
65 |
-
* Returns shortened string
|
66 |
-
*
|
67 |
-
* @since 1.0
|
68 |
-
*/
|
69 |
-
protected function get_shortened_string($string = '', $num_words = 55, $more = null)
|
70 |
-
{
|
71 |
-
if (!$string)
|
72 |
-
return false;
|
73 |
-
|
74 |
-
return wp_trim_words( $string, $num_words, $more );
|
75 |
-
}
|
76 |
-
|
77 |
-
/**
|
78 |
-
* Get image from assets folder
|
79 |
-
*
|
80 |
-
* @since 1.3.1
|
81 |
-
*/
|
82 |
-
protected function get_asset_image($name = '', $title = '')
|
83 |
-
{
|
84 |
-
if ( $name )
|
85 |
-
return sprintf("<img alt='' src='%s' title='%s'/>", CPAC_URL."/assets/images/{$name}", $title);
|
86 |
-
}
|
87 |
-
|
88 |
-
/**
|
89 |
-
* Shorten URL
|
90 |
-
*
|
91 |
-
* @since 1.3.1
|
92 |
-
*/
|
93 |
-
protected function get_shorten_url($url = '')
|
94 |
-
{
|
95 |
-
if ( !$url )
|
96 |
-
return false;
|
97 |
-
|
98 |
-
// shorten url
|
99 |
-
$short_url = url_shorten( $url );
|
100 |
-
|
101 |
-
return "<a title='{$url}' href='{$url}'>{$short_url}</a>";
|
102 |
-
}
|
103 |
-
|
104 |
-
/**
|
105 |
-
* Get column value of post attachments
|
106 |
-
*
|
107 |
-
* @since 1.0
|
108 |
-
*/
|
109 |
-
protected function get_column_value_attachments( $post_id )
|
110 |
-
{
|
111 |
-
$result = '';
|
112 |
-
$attachment_ids = $this->get_attachment_ids($post_id);
|
113 |
-
if ( $attachment_ids ) {
|
114 |
-
foreach ( $attachment_ids as $attach_id ) {
|
115 |
-
if ( wp_get_attachment_image($attach_id) )
|
116 |
-
$result .= wp_get_attachment_image( $attach_id, $this->thumbnail_size, true );
|
117 |
-
}
|
118 |
-
}
|
119 |
-
return $result;
|
120 |
-
}
|
121 |
-
|
122 |
-
/**
|
123 |
-
* Get column value of post attachments
|
124 |
-
*
|
125 |
-
* @since 1.2.1
|
126 |
-
*/
|
127 |
-
protected function get_attachment_ids( $post_id )
|
128 |
-
{
|
129 |
-
return Codepress_Admin_Columns::get_attachment_ids( $post_id );
|
130 |
-
}
|
131 |
-
|
132 |
-
/**
|
133 |
-
* Get a thumbnail
|
134 |
-
*
|
135 |
-
* @since 1.0
|
136 |
-
*/
|
137 |
-
protected function get_thumbnail( $image = '' )
|
138 |
-
{
|
139 |
-
if ( empty($image) )
|
140 |
-
return false;
|
141 |
-
|
142 |
-
// get thumbnail image size
|
143 |
-
$image_size = $this->thumbnail_size; // w, h
|
144 |
-
|
145 |
-
// incase the thumbnail dimension is set by name
|
146 |
-
if ( !is_array($image_size) ) {
|
147 |
-
global $_wp_additional_image_sizes;
|
148 |
-
if ( isset($_wp_additional_image_sizes[$image_size]) ) {
|
149 |
-
$_size = $_wp_additional_image_sizes[$image_size];
|
150 |
-
$image_size = array( $_size['width'], $_size['height'] );
|
151 |
-
}
|
152 |
-
}
|
153 |
-
|
154 |
-
// fallback for image size incase the passed size name does not exists
|
155 |
-
if ( !isset($image_size[0]) || !isset($image_size[1]) ) {
|
156 |
-
$image_size = array(80, 80);
|
157 |
-
}
|
158 |
-
|
159 |
-
// get correct image path
|
160 |
-
$image_path = str_replace( WP_CONTENT_URL, WP_CONTENT_DIR, $image);
|
161 |
-
|
162 |
-
// resize image
|
163 |
-
if ( file_exists($image_path) && $this->is_image($image_path) ) {
|
164 |
-
$resized = image_resize( $image_path, $image_size[0], $image_size[1], true);
|
165 |
-
|
166 |
-
// resize worked
|
167 |
-
if ( ! is_wp_error( $resized ) ) {
|
168 |
-
$image = str_replace( WP_CONTENT_DIR, WP_CONTENT_URL, $resized);
|
169 |
-
|
170 |
-
return "<img src='{$image}' alt='' width='{$image_size[0]}' height='{$image_size[1]}' />";
|
171 |
-
}
|
172 |
-
|
173 |
-
// resizing failed so let's return full image with maxed dimensions
|
174 |
-
else {
|
175 |
-
return "<img src='{$image}' alt='' style='max-width:{$image_size[0]}px;max-height:{$image_size[1]}px' />";
|
176 |
-
}
|
177 |
-
}
|
178 |
-
|
179 |
-
return false;
|
180 |
-
}
|
181 |
-
|
182 |
-
/**
|
183 |
-
* Checks an URL for image extension
|
184 |
-
*
|
185 |
-
* @since 1.2
|
186 |
-
*/
|
187 |
-
protected function is_image($url)
|
188 |
-
{
|
189 |
-
$validExt = array('.jpg', '.jpeg', '.gif', '.png', '.bmp');
|
190 |
-
$ext = strrchr($url, '.');
|
191 |
-
|
192 |
-
return in_array($ext, $validExt);
|
193 |
-
}
|
194 |
-
|
195 |
-
/**
|
196 |
-
* Get a thumbnail
|
197 |
-
*
|
198 |
-
* @since 1.3.1
|
199 |
-
*/
|
200 |
-
protected function get_media_thumbnails($meta)
|
201 |
-
{
|
202 |
-
$meta = $this->strip_trim( str_replace(' ','', $meta) );
|
203 |
-
|
204 |
-
// split media ids
|
205 |
-
$media_ids = array($meta);
|
206 |
-
if ( strpos($meta, ',') !== false )
|
207 |
-
$media_ids = explode(',', $meta);
|
208 |
-
|
209 |
-
// check if media exists
|
210 |
-
$thumbs = '';
|
211 |
-
foreach ( $media_ids as $media_id )
|
212 |
-
if ( is_numeric($media_id) )
|
213 |
-
$thumbs .= wp_get_attachment_url($media_id) ? "<span class='cpac-column-value-image'>".wp_get_attachment_image( $media_id, array(80,80), true )."</span>" : '';
|
214 |
-
|
215 |
-
return $thumbs;
|
216 |
-
}
|
217 |
-
|
218 |
-
/**
|
219 |
-
* Convert file size to readable format
|
220 |
-
*
|
221 |
-
* @since 1.4.5
|
222 |
-
*/
|
223 |
-
function get_readable_filesize($size)
|
224 |
-
{
|
225 |
-
$filesizename = array(" Bytes", " KB", " MB", " GB", " TB", " PB", " EB", " ZB", " YB");
|
226 |
-
return $size ? round($size/pow(1024, ($i = floor(log($size, 1024)))), 2) . $filesizename[$i] : '0 Bytes';
|
227 |
-
}
|
228 |
-
|
229 |
-
/**
|
230 |
-
* Get column value of Custom Field
|
231 |
-
*
|
232 |
-
* @since 1.0
|
233 |
-
*/
|
234 |
-
protected function get_column_value_custom_field($object_id, $column_name, $meta_type = 'post')
|
235 |
-
{
|
236 |
-
/** Users */
|
237 |
-
if ( $meta_type == 'user' ) {
|
238 |
-
$type = 'wp-users';
|
239 |
-
}
|
240 |
-
|
241 |
-
/**
|
242 |
-
|
243 |
-
$type
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
$
|
254 |
-
|
255 |
-
//
|
256 |
-
$field
|
257 |
-
|
258 |
-
|
259 |
-
$
|
260 |
-
|
261 |
-
//
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
//
|
268 |
-
if (
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
$
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
//
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
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 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
//
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
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 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
*
|
503 |
-
*
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
518 |
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* CPAC_Values Class
|
5 |
+
*
|
6 |
+
* @since 1.4.4
|
7 |
+
*
|
8 |
+
*/
|
9 |
+
class CPAC_Values
|
10 |
+
{
|
11 |
+
protected $excerpt_length, $thumbnail_size;
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Constructor
|
15 |
+
*
|
16 |
+
* @since 1.0
|
17 |
+
*/
|
18 |
+
function __construct()
|
19 |
+
{
|
20 |
+
// number of words
|
21 |
+
$this->excerpt_length = 20;
|
22 |
+
$this->thumbnail_size = apply_filters( 'cpac_thumbnail_size', array(80,80) );
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Admin requests for orderby column
|
27 |
+
*
|
28 |
+
* @since 1.0
|
29 |
+
*/
|
30 |
+
public function get_stored_columns($type)
|
31 |
+
{
|
32 |
+
return Codepress_Admin_Columns::get_stored_columns($type);
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Checks if column-meta key exists
|
37 |
+
*
|
38 |
+
* @since 1.0
|
39 |
+
*/
|
40 |
+
public static function is_column_meta( $id = '' )
|
41 |
+
{
|
42 |
+
return Codepress_Admin_Columns::is_column_meta( $id );
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Returns excerpt
|
47 |
+
*
|
48 |
+
* @since 1.0
|
49 |
+
*/
|
50 |
+
protected function get_post_excerpt($post_id)
|
51 |
+
{
|
52 |
+
global $post;
|
53 |
+
|
54 |
+
$save_post = $post;
|
55 |
+
$post = get_post($post_id);
|
56 |
+
$excerpt = get_the_excerpt();
|
57 |
+
$post = $save_post;
|
58 |
+
|
59 |
+
$output = $this->get_shortened_string($excerpt, $this->excerpt_length );
|
60 |
+
|
61 |
+
return $output;
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Returns shortened string
|
66 |
+
*
|
67 |
+
* @since 1.0
|
68 |
+
*/
|
69 |
+
protected function get_shortened_string($string = '', $num_words = 55, $more = null)
|
70 |
+
{
|
71 |
+
if (!$string)
|
72 |
+
return false;
|
73 |
+
|
74 |
+
return wp_trim_words( $string, $num_words, $more );
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Get image from assets folder
|
79 |
+
*
|
80 |
+
* @since 1.3.1
|
81 |
+
*/
|
82 |
+
protected function get_asset_image($name = '', $title = '')
|
83 |
+
{
|
84 |
+
if ( $name )
|
85 |
+
return sprintf("<img alt='' src='%s' title='%s'/>", CPAC_URL."/assets/images/{$name}", $title);
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Shorten URL
|
90 |
+
*
|
91 |
+
* @since 1.3.1
|
92 |
+
*/
|
93 |
+
protected function get_shorten_url($url = '')
|
94 |
+
{
|
95 |
+
if ( !$url )
|
96 |
+
return false;
|
97 |
+
|
98 |
+
// shorten url
|
99 |
+
$short_url = url_shorten( $url );
|
100 |
+
|
101 |
+
return "<a title='{$url}' href='{$url}'>{$short_url}</a>";
|
102 |
+
}
|
103 |
+
|
104 |
+
/**
|
105 |
+
* Get column value of post attachments
|
106 |
+
*
|
107 |
+
* @since 1.0
|
108 |
+
*/
|
109 |
+
protected function get_column_value_attachments( $post_id )
|
110 |
+
{
|
111 |
+
$result = '';
|
112 |
+
$attachment_ids = $this->get_attachment_ids($post_id);
|
113 |
+
if ( $attachment_ids ) {
|
114 |
+
foreach ( $attachment_ids as $attach_id ) {
|
115 |
+
if ( wp_get_attachment_image($attach_id) )
|
116 |
+
$result .= wp_get_attachment_image( $attach_id, $this->thumbnail_size, true );
|
117 |
+
}
|
118 |
+
}
|
119 |
+
return $result;
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Get column value of post attachments
|
124 |
+
*
|
125 |
+
* @since 1.2.1
|
126 |
+
*/
|
127 |
+
protected function get_attachment_ids( $post_id )
|
128 |
+
{
|
129 |
+
return Codepress_Admin_Columns::get_attachment_ids( $post_id );
|
130 |
+
}
|
131 |
+
|
132 |
+
/**
|
133 |
+
* Get a thumbnail
|
134 |
+
*
|
135 |
+
* @since 1.0
|
136 |
+
*/
|
137 |
+
protected function get_thumbnail( $image = '' )
|
138 |
+
{
|
139 |
+
if ( empty($image) )
|
140 |
+
return false;
|
141 |
+
|
142 |
+
// get thumbnail image size
|
143 |
+
$image_size = $this->thumbnail_size; // w, h
|
144 |
+
|
145 |
+
// incase the thumbnail dimension is set by name
|
146 |
+
if ( !is_array($image_size) ) {
|
147 |
+
global $_wp_additional_image_sizes;
|
148 |
+
if ( isset($_wp_additional_image_sizes[$image_size]) ) {
|
149 |
+
$_size = $_wp_additional_image_sizes[$image_size];
|
150 |
+
$image_size = array( $_size['width'], $_size['height'] );
|
151 |
+
}
|
152 |
+
}
|
153 |
+
|
154 |
+
// fallback for image size incase the passed size name does not exists
|
155 |
+
if ( !isset($image_size[0]) || !isset($image_size[1]) ) {
|
156 |
+
$image_size = array(80, 80);
|
157 |
+
}
|
158 |
+
|
159 |
+
// get correct image path
|
160 |
+
$image_path = str_replace( WP_CONTENT_URL, WP_CONTENT_DIR, $image);
|
161 |
+
|
162 |
+
// resize image
|
163 |
+
if ( file_exists($image_path) && $this->is_image($image_path) ) {
|
164 |
+
$resized = image_resize( $image_path, $image_size[0], $image_size[1], true);
|
165 |
+
|
166 |
+
// resize worked
|
167 |
+
if ( ! is_wp_error( $resized ) ) {
|
168 |
+
$image = str_replace( WP_CONTENT_DIR, WP_CONTENT_URL, $resized);
|
169 |
+
|
170 |
+
return "<img src='{$image}' alt='' width='{$image_size[0]}' height='{$image_size[1]}' />";
|
171 |
+
}
|
172 |
+
|
173 |
+
// resizing failed so let's return full image with maxed dimensions
|
174 |
+
else {
|
175 |
+
return "<img src='{$image}' alt='' style='max-width:{$image_size[0]}px;max-height:{$image_size[1]}px' />";
|
176 |
+
}
|
177 |
+
}
|
178 |
+
|
179 |
+
return false;
|
180 |
+
}
|
181 |
+
|
182 |
+
/**
|
183 |
+
* Checks an URL for image extension
|
184 |
+
*
|
185 |
+
* @since 1.2
|
186 |
+
*/
|
187 |
+
protected function is_image($url)
|
188 |
+
{
|
189 |
+
$validExt = array('.jpg', '.jpeg', '.gif', '.png', '.bmp');
|
190 |
+
$ext = strrchr($url, '.');
|
191 |
+
|
192 |
+
return in_array($ext, $validExt);
|
193 |
+
}
|
194 |
+
|
195 |
+
/**
|
196 |
+
* Get a thumbnail
|
197 |
+
*
|
198 |
+
* @since 1.3.1
|
199 |
+
*/
|
200 |
+
protected function get_media_thumbnails($meta)
|
201 |
+
{
|
202 |
+
$meta = $this->strip_trim( str_replace(' ','', $meta) );
|
203 |
+
|
204 |
+
// split media ids
|
205 |
+
$media_ids = array($meta);
|
206 |
+
if ( strpos($meta, ',') !== false )
|
207 |
+
$media_ids = explode(',', $meta);
|
208 |
+
|
209 |
+
// check if media exists
|
210 |
+
$thumbs = '';
|
211 |
+
foreach ( $media_ids as $media_id )
|
212 |
+
if ( is_numeric($media_id) )
|
213 |
+
$thumbs .= wp_get_attachment_url($media_id) ? "<span class='cpac-column-value-image'>".wp_get_attachment_image( $media_id, array(80,80), true )."</span>" : '';
|
214 |
+
|
215 |
+
return $thumbs;
|
216 |
+
}
|
217 |
+
|
218 |
+
/**
|
219 |
+
* Convert file size to readable format
|
220 |
+
*
|
221 |
+
* @since 1.4.5
|
222 |
+
*/
|
223 |
+
function get_readable_filesize($size)
|
224 |
+
{
|
225 |
+
$filesizename = array(" Bytes", " KB", " MB", " GB", " TB", " PB", " EB", " ZB", " YB");
|
226 |
+
return $size ? round($size/pow(1024, ($i = floor(log($size, 1024)))), 2) . $filesizename[$i] : '0 Bytes';
|
227 |
+
}
|
228 |
+
|
229 |
+
/**
|
230 |
+
* Get column value of Custom Field
|
231 |
+
*
|
232 |
+
* @since 1.0
|
233 |
+
*/
|
234 |
+
protected function get_column_value_custom_field($object_id, $column_name, $meta_type = 'post')
|
235 |
+
{
|
236 |
+
/** Users */
|
237 |
+
if ( $meta_type == 'user' ) {
|
238 |
+
$type = 'wp-users';
|
239 |
+
}
|
240 |
+
|
241 |
+
/** Media */
|
242 |
+
if ( $meta_type == 'media' ) {
|
243 |
+
$type = 'wp-media';
|
244 |
+
$meta_type = 'post';
|
245 |
+
}
|
246 |
+
|
247 |
+
/** Posts */
|
248 |
+
else {
|
249 |
+
$type = get_post_type($object_id);
|
250 |
+
}
|
251 |
+
|
252 |
+
// get column
|
253 |
+
$columns = $this->get_stored_columns($type);
|
254 |
+
|
255 |
+
// inputs
|
256 |
+
$field = isset($columns[$column_name]['field']) ? $columns[$column_name]['field'] : '';
|
257 |
+
$fieldtype = isset($columns[$column_name]['field_type']) ? $columns[$column_name]['field_type'] : '';
|
258 |
+
$before = isset($columns[$column_name]['before']) ? $columns[$column_name]['before'] : '';
|
259 |
+
$after = isset($columns[$column_name]['after']) ? $columns[$column_name]['after'] : '';
|
260 |
+
|
261 |
+
// rename hidden custom fields to their original name
|
262 |
+
$field = substr($field,0,10) == "cpachidden" ? str_replace('cpachidden','',$field) : $field;
|
263 |
+
|
264 |
+
// Get meta field value
|
265 |
+
$meta = get_metadata($meta_type, $object_id, $field, true);
|
266 |
+
|
267 |
+
// multiple meta values
|
268 |
+
if ( ( $fieldtype == 'array' && is_array($meta) ) || is_array($meta) ) {
|
269 |
+
$meta = get_metadata($meta_type, $object_id, $field, true);
|
270 |
+
$meta = $this->recursive_implode(', ', $meta);
|
271 |
+
}
|
272 |
+
|
273 |
+
// make sure there are no serialized arrays or null data
|
274 |
+
if ( !is_string($meta) )
|
275 |
+
return false;
|
276 |
+
|
277 |
+
// handles each field type differently..
|
278 |
+
switch ($fieldtype) :
|
279 |
+
|
280 |
+
// Image
|
281 |
+
case "image" :
|
282 |
+
$meta = $this->get_thumbnail($meta);
|
283 |
+
break;
|
284 |
+
|
285 |
+
// Media Library ID
|
286 |
+
case "library_id" :
|
287 |
+
$meta = $this->get_media_thumbnails($meta);
|
288 |
+
break;
|
289 |
+
|
290 |
+
// Excerpt
|
291 |
+
case "excerpt" :
|
292 |
+
$meta = $this->get_shortened_string($meta, $this->excerpt_length);
|
293 |
+
break;
|
294 |
+
|
295 |
+
// Date
|
296 |
+
case "date" :
|
297 |
+
$meta = $this->get_date($meta);
|
298 |
+
break;
|
299 |
+
|
300 |
+
// Post Title
|
301 |
+
case "title_by_id" :
|
302 |
+
$titles = $this->get_custom_field_value_title($meta);
|
303 |
+
if ( $titles )
|
304 |
+
$meta = $titles;
|
305 |
+
break;
|
306 |
+
|
307 |
+
// User Name
|
308 |
+
case "user_by_id" :
|
309 |
+
$names = $this->get_custom_field_value_user($meta);
|
310 |
+
if ( $names )
|
311 |
+
$meta = $names;
|
312 |
+
break;
|
313 |
+
|
314 |
+
// Checkmark
|
315 |
+
case "checkmark" :
|
316 |
+
$checkmark = $this->get_asset_image('checkmark.png');
|
317 |
+
|
318 |
+
if ( empty($meta) || 'false' === $meta || '0' === $meta ) {
|
319 |
+
$checkmark = '';
|
320 |
+
}
|
321 |
+
|
322 |
+
$meta = $checkmark;
|
323 |
+
break;
|
324 |
+
|
325 |
+
// Color
|
326 |
+
case "color" :
|
327 |
+
if ( !empty($meta) ) {
|
328 |
+
$meta = "<div class='cpac-color'><span style='background-color:{$meta}'></span>{$meta}</div>";
|
329 |
+
}
|
330 |
+
break;
|
331 |
+
|
332 |
+
endswitch;
|
333 |
+
|
334 |
+
// filter for customization
|
335 |
+
$meta = apply_filters('cpac_get_column_value_custom_field', $meta, $fieldtype, $field, $type, $object_id );
|
336 |
+
|
337 |
+
// add before and after string
|
338 |
+
if ( $meta ) {
|
339 |
+
$meta = "{$before}{$meta}{$after}";
|
340 |
+
}
|
341 |
+
|
342 |
+
return $meta;
|
343 |
+
}
|
344 |
+
|
345 |
+
/**
|
346 |
+
* Get custom field value 'Title by ID'
|
347 |
+
*
|
348 |
+
* @since 1.3
|
349 |
+
*/
|
350 |
+
protected function get_custom_field_value_title($meta)
|
351 |
+
{
|
352 |
+
//remove white spaces and strip tags
|
353 |
+
$meta = $this->strip_trim( str_replace(' ','', $meta) );
|
354 |
+
|
355 |
+
// var
|
356 |
+
$ids = $titles = array();
|
357 |
+
|
358 |
+
// check for multiple id's
|
359 |
+
if ( strpos($meta, ',') !== false )
|
360 |
+
$ids = explode(',',$meta);
|
361 |
+
elseif ( is_numeric($meta) )
|
362 |
+
$ids[] = $meta;
|
363 |
+
|
364 |
+
// display title with link
|
365 |
+
if ( $ids && is_array($ids) ) {
|
366 |
+
foreach ( $ids as $id ) {
|
367 |
+
$title = is_numeric($id) ? get_the_title($id) : '';
|
368 |
+
$link = get_edit_post_link($id);
|
369 |
+
if ( $title )
|
370 |
+
$titles[] = $link ? "<a href='{$link}'>{$title}</a>" : $title;
|
371 |
+
}
|
372 |
+
}
|
373 |
+
|
374 |
+
return implode('<span class="cpac-divider"></span>', $titles);
|
375 |
+
}
|
376 |
+
|
377 |
+
/**
|
378 |
+
* Get custom field value 'User by ID'
|
379 |
+
*
|
380 |
+
* @since 1.4.6.3
|
381 |
+
*/
|
382 |
+
protected function get_custom_field_value_user($meta)
|
383 |
+
{
|
384 |
+
//remove white spaces and strip tags
|
385 |
+
$meta = $this->strip_trim( str_replace(' ','', $meta) );
|
386 |
+
|
387 |
+
// var
|
388 |
+
$ids = $names = array();
|
389 |
+
|
390 |
+
// check for multiple id's
|
391 |
+
if ( strpos($meta, ',') !== false )
|
392 |
+
$ids = explode(',',$meta);
|
393 |
+
elseif ( is_numeric($meta) )
|
394 |
+
$ids[] = $meta;
|
395 |
+
|
396 |
+
// display username
|
397 |
+
if ( $ids && is_array($ids) ) {
|
398 |
+
foreach ( $ids as $id ) {
|
399 |
+
if ( !is_numeric($id) )
|
400 |
+
continue;
|
401 |
+
|
402 |
+
$userdata = get_userdata($id);
|
403 |
+
if ( is_object($userdata) && !empty( $userdata->display_name ) ) {
|
404 |
+
$names[] = $userdata->display_name;
|
405 |
+
}
|
406 |
+
}
|
407 |
+
}
|
408 |
+
|
409 |
+
return implode('<span class="cpac-divider"></span>', $names);
|
410 |
+
}
|
411 |
+
|
412 |
+
/**
|
413 |
+
* Get column value of Custom Field
|
414 |
+
*
|
415 |
+
* @since 1.2
|
416 |
+
*/
|
417 |
+
protected function get_user_column_value_custom_field($user_id, $id)
|
418 |
+
{
|
419 |
+
$columns = $this->get_stored_columns('wp-users');
|
420 |
+
|
421 |
+
// inputs
|
422 |
+
$field = isset($columns[$id]['field']) ? $columns[$id]['field'] : '';
|
423 |
+
$fieldtype = isset($columns[$id]['field_type']) ? $columns[$id]['field_type'] : '';
|
424 |
+
$before = isset($columns[$id]['before']) ? $columns[$id]['before'] : '';
|
425 |
+
$after = isset($columns[$id]['after']) ? $columns[$id]['after'] : '';
|
426 |
+
|
427 |
+
// Get meta field value
|
428 |
+
$meta = get_user_meta($user_id, $field, true);
|
429 |
+
|
430 |
+
// multiple meta values
|
431 |
+
if ( ( $fieldtype == 'array' && is_array($meta) ) || is_array($meta) ) {
|
432 |
+
$meta = get_user_meta($user_id, $field);
|
433 |
+
$meta = $this->recursive_implode(', ', $meta);
|
434 |
+
}
|
435 |
+
|
436 |
+
// make sure there are no serialized arrays or empty meta data
|
437 |
+
if ( empty($meta) || !is_string($meta) )
|
438 |
+
return false;
|
439 |
+
|
440 |
+
// handles each field type differently..
|
441 |
+
switch ($fieldtype) :
|
442 |
+
|
443 |
+
// Image
|
444 |
+
case "image" :
|
445 |
+
$meta = $this->get_thumbnail($meta);
|
446 |
+
break;
|
447 |
+
|
448 |
+
// Media Library ID
|
449 |
+
case "library_id" :
|
450 |
+
$meta = $this->get_media_thumbnails($meta);
|
451 |
+
break;
|
452 |
+
|
453 |
+
// Excerpt
|
454 |
+
case "excerpt" :
|
455 |
+
$meta = $this->get_shortened_string($meta, $this->excerpt_length);
|
456 |
+
break;
|
457 |
+
|
458 |
+
endswitch;
|
459 |
+
|
460 |
+
// filter for customization
|
461 |
+
$meta = apply_filters('cpac_get_user_column_value_custom_field', $meta, $fieldtype, $field );
|
462 |
+
|
463 |
+
// add before and after string
|
464 |
+
$meta = "{$before}{$meta}{$after}";
|
465 |
+
|
466 |
+
return $meta;
|
467 |
+
}
|
468 |
+
|
469 |
+
/**
|
470 |
+
* Implode for multi dimensional array
|
471 |
+
*
|
472 |
+
* @since 1.0
|
473 |
+
*/
|
474 |
+
protected function recursive_implode( $glue, $pieces )
|
475 |
+
{
|
476 |
+
foreach( $pieces as $r_pieces ) {
|
477 |
+
if( is_array( $r_pieces ) ) {
|
478 |
+
$retVal[] = $this->recursive_implode( $glue, $r_pieces );
|
479 |
+
}
|
480 |
+
else {
|
481 |
+
$retVal[] = $r_pieces;
|
482 |
+
}
|
483 |
+
}
|
484 |
+
if ( isset($retVal) && is_array($retVal) )
|
485 |
+
return implode( $glue, $retVal );
|
486 |
+
|
487 |
+
return false;
|
488 |
+
}
|
489 |
+
|
490 |
+
/**
|
491 |
+
* Strip tags and trim
|
492 |
+
*
|
493 |
+
* @since 1.3
|
494 |
+
*/
|
495 |
+
protected function strip_trim($string)
|
496 |
+
{
|
497 |
+
return Codepress_Admin_Columns::strip_trim($string);
|
498 |
+
}
|
499 |
+
|
500 |
+
/**
|
501 |
+
* Get date
|
502 |
+
*
|
503 |
+
* @since 1.3.1
|
504 |
+
*/
|
505 |
+
protected function get_date($date)
|
506 |
+
{
|
507 |
+
if ( ! $date )
|
508 |
+
return false;
|
509 |
+
|
510 |
+
return date_i18n( get_option('date_format'), strtotime($date) );
|
511 |
+
}
|
512 |
+
|
513 |
+
/**
|
514 |
+
* Get time
|
515 |
+
*
|
516 |
+
* @since 1.3.1
|
517 |
+
*/
|
518 |
+
protected function get_time($date)
|
519 |
+
{
|
520 |
+
if ( ! $date )
|
521 |
+
return false;
|
522 |
+
|
523 |
+
if ( ! is_numeric($date) )
|
524 |
+
$date = strtotime($date);
|
525 |
+
|
526 |
+
return date_i18n( get_option('time_format'), $date );
|
527 |
+
}
|
528 |
+
}
|
529 |
+
|
530 |
?>
|
classes/values/comments.php
CHANGED
@@ -1,250 +1,250 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* CPAC_Comments_Values Class
|
5 |
-
*
|
6 |
-
* @since 1.4.4
|
7 |
-
*
|
8 |
-
*/
|
9 |
-
class CPAC_Comments_Values extends CPAC_Values
|
10 |
-
{
|
11 |
-
/**
|
12 |
-
* Constructor
|
13 |
-
*
|
14 |
-
* @since 1.4.4
|
15 |
-
*/
|
16 |
-
function __construct()
|
17 |
-
{
|
18 |
-
parent::__construct();
|
19 |
-
|
20 |
-
add_action( 'manage_comments_custom_column', array( $this, 'manage_comments_column_value'), 10, 2 );
|
21 |
-
}
|
22 |
-
|
23 |
-
/**
|
24 |
-
* Manage custom column for Comments
|
25 |
-
*
|
26 |
-
* @since 1.3.1
|
27 |
-
*/
|
28 |
-
public function manage_comments_column_value( $column_name, $comment_id )
|
29 |
-
{
|
30 |
-
$type = $column_name;
|
31 |
-
|
32 |
-
// comments object
|
33 |
-
$comment = get_comment($comment_id);
|
34 |
-
|
35 |
-
// Check for custom fields, such as column-meta-[customfieldname]
|
36 |
-
if ( $this->is_column_meta($type) )
|
37 |
-
$type = 'column-comment-meta';
|
38 |
-
|
39 |
-
// Hook
|
40 |
-
do_action('cpac-manage-comments-column', $type, $column_name, $comment_id);
|
41 |
-
|
42 |
-
$result = '';
|
43 |
-
switch ($type) :
|
44 |
-
|
45 |
-
// comment id
|
46 |
-
case "column-comment_id" :
|
47 |
-
$result = $comment_id;
|
48 |
-
break;
|
49 |
-
|
50 |
-
// author
|
51 |
-
case "column-author_author" :
|
52 |
-
$result = $comment->comment_author;
|
53 |
-
break;
|
54 |
-
|
55 |
-
// avatar
|
56 |
-
case "column-author_avatar" :
|
57 |
-
$result = get_avatar( $comment, 80 );
|
58 |
-
break;
|
59 |
-
|
60 |
-
// url
|
61 |
-
case "column-author_url" :
|
62 |
-
$result = $this->get_shorten_url($comment->comment_author_url);
|
63 |
-
break;
|
64 |
-
|
65 |
-
// ip
|
66 |
-
case "column-author_ip" :
|
67 |
-
$result = $comment->comment_author_IP;
|
68 |
-
break;
|
69 |
-
|
70 |
-
// email
|
71 |
-
case "column-author_email" :
|
72 |
-
$result = $comment->comment_author_email;
|
73 |
-
break;
|
74 |
-
|
75 |
-
// parent
|
76 |
-
case "column-reply_to" :
|
77 |
-
if ( $comment->comment_approved ) {
|
78 |
-
$parent = get_comment( $comment->comment_parent );
|
79 |
-
$parent_link = esc_url( get_comment_link( $comment->comment_parent ) );
|
80 |
-
$name = get_comment_author( $parent->comment_ID );
|
81 |
-
$result = sprintf( '<a href="%1$s">%2$s</a>', $parent_link, $name );
|
82 |
-
}
|
83 |
-
break;
|
84 |
-
|
85 |
-
// approved
|
86 |
-
case "column-approved" :
|
87 |
-
$result = $this->get_asset_image('no.png');
|
88 |
-
if ( $comment->comment_approved )
|
89 |
-
$result = $this->get_asset_image('checkmark.png');
|
90 |
-
break;
|
91 |
-
|
92 |
-
// date
|
93 |
-
case "column-date" :
|
94 |
-
$comment_url = esc_url( get_comment_link( $comment_id ) );
|
95 |
-
$result = sprintf( __( 'Submitted on <a href="%1$s">%2$s at %3$s</a>' ),
|
96 |
-
$comment_url,
|
97 |
-
$this->get_date($comment->comment_date),
|
98 |
-
$this->get_time($comment->comment_date)
|
99 |
-
);
|
100 |
-
$result = "<div class='submitted-on'>{$result}</div>";
|
101 |
-
break;
|
102 |
-
|
103 |
-
// date GMT
|
104 |
-
case "column-date_gmt" :
|
105 |
-
$comment_url = esc_url( get_comment_link( $comment_id ) );
|
106 |
-
$result = sprintf( __( 'Submitted on <a href="%1$s">%2$s at %3$s</a>' ),
|
107 |
-
$comment_url,
|
108 |
-
$this->get_date($comment->comment_date_gmt),
|
109 |
-
$this->get_time($comment->comment_date_gmt)
|
110 |
-
);
|
111 |
-
$result = "<div class='submitted-on'>{$result}</div>";
|
112 |
-
break;
|
113 |
-
|
114 |
-
// custom field
|
115 |
-
case "column-comment-meta" :
|
116 |
-
$result = $this->get_column_value_custom_field($comment_id, $column_name, 'comment');
|
117 |
-
break;
|
118 |
-
|
119 |
-
// agent
|
120 |
-
case "column-agent" :
|
121 |
-
$result = $comment->comment_agent;
|
122 |
-
break;
|
123 |
-
|
124 |
-
// excerpt
|
125 |
-
case "column-excerpt" :
|
126 |
-
$comment = get_comment($comment_id);
|
127 |
-
$result = $this->get_shortened_string($comment->comment_content, $this->excerpt_length);
|
128 |
-
break;
|
129 |
-
|
130 |
-
// actions
|
131 |
-
case "column-actions" :
|
132 |
-
$result = $this->get_column_value_actions($comment);
|
133 |
-
break;
|
134 |
-
|
135 |
-
// word count
|
136 |
-
case "column-word-count" :
|
137 |
-
$result = str_word_count( $this->strip_trim( $comment->comment_content ) );
|
138 |
-
break;
|
139 |
-
|
140 |
-
default :
|
141 |
-
$result = '';
|
142 |
-
|
143 |
-
endswitch;
|
144 |
-
|
145 |
-
// Filter for customizing the result output
|
146 |
-
apply_filters('cpac-comments-column-result', $result, $type, $column_name, $comment_id);
|
147 |
-
|
148 |
-
echo $result;
|
149 |
-
}
|
150 |
-
|
151 |
-
/**
|
152 |
-
* Get column value of comments actions
|
153 |
-
*
|
154 |
-
* This part is copied from the Comments List Table class
|
155 |
-
*
|
156 |
-
* @since 1.4.2
|
157 |
-
*/
|
158 |
-
private function get_column_value_actions( $comment )
|
159 |
-
{
|
160 |
-
global $post, $comment_status;
|
161 |
-
|
162 |
-
// set uased vars
|
163 |
-
$user_can = current_user_can( 'edit_comment', $comment->comment_ID );
|
164 |
-
$the_comment_status = wp_get_comment_status( $comment->comment_ID );
|
165 |
-
|
166 |
-
if ( $user_can ) {
|
167 |
-
$del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) );
|
168 |
-
$approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "approve-comment_$comment->comment_ID" ) );
|
169 |
-
|
170 |
-
$url = "comment.php?c=$comment->comment_ID";
|
171 |
-
|
172 |
-
$approve_url = esc_url( $url . "&action=approvecomment&$approve_nonce" );
|
173 |
-
$unapprove_url = esc_url( $url . "&action=unapprovecomment&$approve_nonce" );
|
174 |
-
$spam_url = esc_url( $url . "&action=spamcomment&$del_nonce" );
|
175 |
-
$unspam_url = esc_url( $url . "&action=unspamcomment&$del_nonce" );
|
176 |
-
$trash_url = esc_url( $url . "&action=trashcomment&$del_nonce" );
|
177 |
-
$untrash_url = esc_url( $url . "&action=untrashcomment&$del_nonce" );
|
178 |
-
$delete_url = esc_url( $url . "&action=deletecomment&$del_nonce" );
|
179 |
-
}
|
180 |
-
|
181 |
-
/** begin - copied from class-wp-comments-list-table */
|
182 |
-
if ( $user_can ) {
|
183 |
-
// preorder it: Approve | Reply | Quick Edit | Edit | Spam | Trash
|
184 |
-
$actions = array(
|
185 |
-
'approve' => '', 'unapprove' => '',
|
186 |
-
'reply' => '',
|
187 |
-
'quickedit' => '',
|
188 |
-
'edit' => '',
|
189 |
-
'spam' => '', 'unspam' => '',
|
190 |
-
'trash' => '', 'untrash' => '', 'delete' => ''
|
191 |
-
);
|
192 |
-
|
193 |
-
if ( $comment_status && 'all' != $comment_status ) { // not looking at all comments
|
194 |
-
if ( 'approved' == $the_comment_status )
|
195 |
-
$actions['unapprove'] = "<a href='$unapprove_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&new=unapproved vim-u vim-destructive' title='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
|
196 |
-
else if ( 'unapproved' == $the_comment_status )
|
197 |
-
$actions['approve'] = "<a href='$approve_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&new=approved vim-a vim-destructive' title='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
|
198 |
-
} else {
|
199 |
-
$actions['approve'] = "<a href='$approve_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved vim-a' title='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
|
200 |
-
$actions['unapprove'] = "<a href='$unapprove_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved vim-u' title='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
|
201 |
-
}
|
202 |
-
|
203 |
-
if ( 'spam' != $the_comment_status && 'trash' != $the_comment_status ) {
|
204 |
-
$actions['spam'] = "<a href='$spam_url' class='delete:the-comment-list:comment-$comment->comment_ID::spam=1 vim-s vim-destructive' title='" . esc_attr__( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '</a>';
|
205 |
-
} elseif ( 'spam' == $the_comment_status ) {
|
206 |
-
$actions['unspam'] = "<a href='$unspam_url' class='delete:the-comment-list:comment-$comment->comment_ID:66cc66:unspam=1 vim-z vim-destructive'>" . _x( 'Not Spam', 'comment' ) . '</a>';
|
207 |
-
} elseif ( 'trash' == $the_comment_status ) {
|
208 |
-
$actions['untrash'] = "<a href='$untrash_url' class='delete:the-comment-list:comment-$comment->comment_ID:66cc66:untrash=1 vim-z vim-destructive'>" . __( 'Restore' ) . '</a>';
|
209 |
-
}
|
210 |
-
|
211 |
-
if ( 'spam' == $the_comment_status || 'trash' == $the_comment_status || !EMPTY_TRASH_DAYS ) {
|
212 |
-
$actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID::delete=1 delete vim-d vim-destructive'>" . __( 'Delete Permanently' ) . '</a>';
|
213 |
-
} else {
|
214 |
-
$actions['trash'] = "<a href='$trash_url' class='delete:the-comment-list:comment-$comment->comment_ID::trash=1 delete vim-d vim-destructive' title='" . esc_attr__( 'Move this comment to the trash' ) . "'>" . _x( 'Trash', 'verb' ) . '</a>';
|
215 |
-
}
|
216 |
-
|
217 |
-
if ( 'spam' != $the_comment_status && 'trash' != $the_comment_status ) {
|
218 |
-
$actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' title='" . esc_attr__( 'Edit comment' ) . "'>". __( 'Edit' ) . '</a>';
|
219 |
-
$actions['quickedit'] = '<a onclick="commentReply.open( \''.$comment->comment_ID.'\',\''.$post->ID.'\',\'edit\' );return false;" class="vim-q" title="'.esc_attr__( 'Quick Edit' ).'" href="#">' . __( 'Quick Edit' ) . '</a>';
|
220 |
-
$actions['reply'] = '<a onclick="commentReply.open( \''.$comment->comment_ID.'\',\''.$post->ID.'\' );return false;" class="vim-r" title="'.esc_attr__( 'Reply to this comment' ).'" href="#">' . __( 'Reply' ) . '</a>';
|
221 |
-
}
|
222 |
-
|
223 |
-
$actions = apply_filters( 'comment_row_actions', array_filter( $actions ), $comment );
|
224 |
-
|
225 |
-
$i = 0;
|
226 |
-
$result = '<div class="cp-row-actions">';
|
227 |
-
foreach ( $actions as $action => $link ) {
|
228 |
-
++$i;
|
229 |
-
( ( ( 'approve' == $action || 'unapprove' == $action ) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | ';
|
230 |
-
|
231 |
-
// Reply and quickedit need a hide-if-no-js span when not added with ajax
|
232 |
-
if ( ( 'reply' == $action || 'quickedit' == $action ) && ! defined('DOING_AJAX') )
|
233 |
-
$action .= ' hide-if-no-js';
|
234 |
-
elseif ( ( $action == 'untrash' && $the_comment_status == 'trash' ) || ( $action == 'unspam' && $the_comment_status == 'spam' ) ) {
|
235 |
-
if ( '1' == get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true ) )
|
236 |
-
$action .= ' approve';
|
237 |
-
else
|
238 |
-
$action .= ' unapprove';
|
239 |
-
}
|
240 |
-
|
241 |
-
$result .= "<span class='$action'>$sep$link</span>";
|
242 |
-
}
|
243 |
-
$result .= '</div>';
|
244 |
-
}
|
245 |
-
return $result;
|
246 |
-
// end copied
|
247 |
-
}
|
248 |
-
}
|
249 |
-
|
250 |
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* CPAC_Comments_Values Class
|
5 |
+
*
|
6 |
+
* @since 1.4.4
|
7 |
+
*
|
8 |
+
*/
|
9 |
+
class CPAC_Comments_Values extends CPAC_Values
|
10 |
+
{
|
11 |
+
/**
|
12 |
+
* Constructor
|
13 |
+
*
|
14 |
+
* @since 1.4.4
|
15 |
+
*/
|
16 |
+
function __construct()
|
17 |
+
{
|
18 |
+
parent::__construct();
|
19 |
+
|
20 |
+
add_action( 'manage_comments_custom_column', array( $this, 'manage_comments_column_value'), 10, 2 );
|
21 |
+
}
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Manage custom column for Comments
|
25 |
+
*
|
26 |
+
* @since 1.3.1
|
27 |
+
*/
|
28 |
+
public function manage_comments_column_value( $column_name, $comment_id )
|
29 |
+
{
|
30 |
+
$type = $column_name;
|
31 |
+
|
32 |
+
// comments object
|
33 |
+
$comment = get_comment($comment_id);
|
34 |
+
|
35 |
+
// Check for custom fields, such as column-meta-[customfieldname]
|
36 |
+
if ( $this->is_column_meta($type) )
|
37 |
+
$type = 'column-comment-meta';
|
38 |
+
|
39 |
+
// Hook
|
40 |
+
do_action('cpac-manage-comments-column', $type, $column_name, $comment_id);
|
41 |
+
|
42 |
+
$result = '';
|
43 |
+
switch ($type) :
|
44 |
+
|
45 |
+
// comment id
|
46 |
+
case "column-comment_id" :
|
47 |
+
$result = $comment_id;
|
48 |
+
break;
|
49 |
+
|
50 |
+
// author
|
51 |
+
case "column-author_author" :
|
52 |
+
$result = $comment->comment_author;
|
53 |
+
break;
|
54 |
+
|
55 |
+
// avatar
|
56 |
+
case "column-author_avatar" :
|
57 |
+
$result = get_avatar( $comment, 80 );
|
58 |
+
break;
|
59 |
+
|
60 |
+
// url
|
61 |
+
case "column-author_url" :
|
62 |
+
$result = $this->get_shorten_url($comment->comment_author_url);
|
63 |
+
break;
|
64 |
+
|
65 |
+
// ip
|
66 |
+
case "column-author_ip" :
|
67 |
+
$result = $comment->comment_author_IP;
|
68 |
+
break;
|
69 |
+
|
70 |
+
// email
|
71 |
+
case "column-author_email" :
|
72 |
+
$result = $comment->comment_author_email;
|
73 |
+
break;
|
74 |
+
|
75 |
+
// parent
|
76 |
+
case "column-reply_to" :
|
77 |
+
if ( $comment->comment_approved ) {
|
78 |
+
$parent = get_comment( $comment->comment_parent );
|
79 |
+
$parent_link = esc_url( get_comment_link( $comment->comment_parent ) );
|
80 |
+
$name = get_comment_author( $parent->comment_ID );
|
81 |
+
$result = sprintf( '<a href="%1$s">%2$s</a>', $parent_link, $name );
|
82 |
+
}
|
83 |
+
break;
|
84 |
+
|
85 |
+
// approved
|
86 |
+
case "column-approved" :
|
87 |
+
$result = $this->get_asset_image('no.png');
|
88 |
+
if ( $comment->comment_approved )
|
89 |
+
$result = $this->get_asset_image('checkmark.png');
|
90 |
+
break;
|
91 |
+
|
92 |
+
// date
|
93 |
+
case "column-date" :
|
94 |
+
$comment_url = esc_url( get_comment_link( $comment_id ) );
|
95 |
+
$result = sprintf( __( 'Submitted on <a href="%1$s">%2$s at %3$s</a>' ),
|
96 |
+
$comment_url,
|
97 |
+
$this->get_date($comment->comment_date),
|
98 |
+
$this->get_time($comment->comment_date)
|
99 |
+
);
|
100 |
+
$result = "<div class='submitted-on'>{$result}</div>";
|
101 |
+
break;
|
102 |
+
|
103 |
+
// date GMT
|
104 |
+
case "column-date_gmt" :
|
105 |
+
$comment_url = esc_url( get_comment_link( $comment_id ) );
|
106 |
+
$result = sprintf( __( 'Submitted on <a href="%1$s">%2$s at %3$s</a>' ),
|
107 |
+
$comment_url,
|
108 |
+
$this->get_date($comment->comment_date_gmt),
|
109 |
+
$this->get_time($comment->comment_date_gmt)
|
110 |
+
);
|
111 |
+
$result = "<div class='submitted-on'>{$result}</div>";
|
112 |
+
break;
|
113 |
+
|
114 |
+
// custom field
|
115 |
+
case "column-comment-meta" :
|
116 |
+
$result = $this->get_column_value_custom_field($comment_id, $column_name, 'comment');
|
117 |
+
break;
|
118 |
+
|
119 |
+
// agent
|
120 |
+
case "column-agent" :
|
121 |
+
$result = $comment->comment_agent;
|
122 |
+
break;
|
123 |
+
|
124 |
+
// excerpt
|
125 |
+
case "column-excerpt" :
|
126 |
+
$comment = get_comment($comment_id);
|
127 |
+
$result = $this->get_shortened_string($comment->comment_content, $this->excerpt_length);
|
128 |
+
break;
|
129 |
+
|
130 |
+
// actions
|
131 |
+
case "column-actions" :
|
132 |
+
$result = $this->get_column_value_actions($comment);
|
133 |
+
break;
|
134 |
+
|
135 |
+
// word count
|
136 |
+
case "column-word-count" :
|
137 |
+
$result = str_word_count( $this->strip_trim( $comment->comment_content ) );
|
138 |
+
break;
|
139 |
+
|
140 |
+
default :
|
141 |
+
$result = '';
|
142 |
+
|
143 |
+
endswitch;
|
144 |
+
|
145 |
+
// Filter for customizing the result output
|
146 |
+
apply_filters('cpac-comments-column-result', $result, $type, $column_name, $comment_id);
|
147 |
+
|
148 |
+
echo $result;
|
149 |
+
}
|
150 |
+
|
151 |
+
/**
|
152 |
+
* Get column value of comments actions
|
153 |
+
*
|
154 |
+
* This part is copied from the Comments List Table class
|
155 |
+
*
|
156 |
+
* @since 1.4.2
|
157 |
+
*/
|
158 |
+
private function get_column_value_actions( $comment )
|
159 |
+
{
|
160 |
+
global $post, $comment_status;
|
161 |
+
|
162 |
+
// set uased vars
|
163 |
+
$user_can = current_user_can( 'edit_comment', $comment->comment_ID );
|
164 |
+
$the_comment_status = wp_get_comment_status( $comment->comment_ID );
|
165 |
+
|
166 |
+
if ( $user_can ) {
|
167 |
+
$del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) );
|
168 |
+
$approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "approve-comment_$comment->comment_ID" ) );
|
169 |
+
|
170 |
+
$url = "comment.php?c=$comment->comment_ID";
|
171 |
+
|
172 |
+
$approve_url = esc_url( $url . "&action=approvecomment&$approve_nonce" );
|
173 |
+
$unapprove_url = esc_url( $url . "&action=unapprovecomment&$approve_nonce" );
|
174 |
+
$spam_url = esc_url( $url . "&action=spamcomment&$del_nonce" );
|
175 |
+
$unspam_url = esc_url( $url . "&action=unspamcomment&$del_nonce" );
|
176 |
+
$trash_url = esc_url( $url . "&action=trashcomment&$del_nonce" );
|
177 |
+
$untrash_url = esc_url( $url . "&action=untrashcomment&$del_nonce" );
|
178 |
+
$delete_url = esc_url( $url . "&action=deletecomment&$del_nonce" );
|
179 |
+
}
|
180 |
+
|
181 |
+
/** begin - copied from class-wp-comments-list-table */
|
182 |
+
if ( $user_can ) {
|
183 |
+
// preorder it: Approve | Reply | Quick Edit | Edit | Spam | Trash
|
184 |
+
$actions = array(
|
185 |
+
'approve' => '', 'unapprove' => '',
|
186 |
+
'reply' => '',
|
187 |
+
'quickedit' => '',
|
188 |
+
'edit' => '',
|
189 |
+
'spam' => '', 'unspam' => '',
|
190 |
+
'trash' => '', 'untrash' => '', 'delete' => ''
|
191 |
+
);
|
192 |
+
|
193 |
+
if ( $comment_status && 'all' != $comment_status ) { // not looking at all comments
|
194 |
+
if ( 'approved' == $the_comment_status )
|
195 |
+
$actions['unapprove'] = "<a href='$unapprove_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&new=unapproved vim-u vim-destructive' title='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
|
196 |
+
else if ( 'unapproved' == $the_comment_status )
|
197 |
+
$actions['approve'] = "<a href='$approve_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&new=approved vim-a vim-destructive' title='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
|
198 |
+
} else {
|
199 |
+
$actions['approve'] = "<a href='$approve_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved vim-a' title='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
|
200 |
+
$actions['unapprove'] = "<a href='$unapprove_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved vim-u' title='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
|
201 |
+
}
|
202 |
+
|
203 |
+
if ( 'spam' != $the_comment_status && 'trash' != $the_comment_status ) {
|
204 |
+
$actions['spam'] = "<a href='$spam_url' class='delete:the-comment-list:comment-$comment->comment_ID::spam=1 vim-s vim-destructive' title='" . esc_attr__( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '</a>';
|
205 |
+
} elseif ( 'spam' == $the_comment_status ) {
|
206 |
+
$actions['unspam'] = "<a href='$unspam_url' class='delete:the-comment-list:comment-$comment->comment_ID:66cc66:unspam=1 vim-z vim-destructive'>" . _x( 'Not Spam', 'comment' ) . '</a>';
|
207 |
+
} elseif ( 'trash' == $the_comment_status ) {
|
208 |
+
$actions['untrash'] = "<a href='$untrash_url' class='delete:the-comment-list:comment-$comment->comment_ID:66cc66:untrash=1 vim-z vim-destructive'>" . __( 'Restore' ) . '</a>';
|
209 |
+
}
|
210 |
+
|
211 |
+
if ( 'spam' == $the_comment_status || 'trash' == $the_comment_status || !EMPTY_TRASH_DAYS ) {
|
212 |
+
$actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID::delete=1 delete vim-d vim-destructive'>" . __( 'Delete Permanently' ) . '</a>';
|
213 |
+
} else {
|
214 |
+
$actions['trash'] = "<a href='$trash_url' class='delete:the-comment-list:comment-$comment->comment_ID::trash=1 delete vim-d vim-destructive' title='" . esc_attr__( 'Move this comment to the trash' ) . "'>" . _x( 'Trash', 'verb' ) . '</a>';
|
215 |
+
}
|
216 |
+
|
217 |
+
if ( 'spam' != $the_comment_status && 'trash' != $the_comment_status ) {
|
218 |
+
$actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' title='" . esc_attr__( 'Edit comment' ) . "'>". __( 'Edit' ) . '</a>';
|
219 |
+
$actions['quickedit'] = '<a onclick="commentReply.open( \''.$comment->comment_ID.'\',\''.$post->ID.'\',\'edit\' );return false;" class="vim-q" title="'.esc_attr__( 'Quick Edit' ).'" href="#">' . __( 'Quick Edit' ) . '</a>';
|
220 |
+
$actions['reply'] = '<a onclick="commentReply.open( \''.$comment->comment_ID.'\',\''.$post->ID.'\' );return false;" class="vim-r" title="'.esc_attr__( 'Reply to this comment' ).'" href="#">' . __( 'Reply' ) . '</a>';
|
221 |
+
}
|
222 |
+
|
223 |
+
$actions = apply_filters( 'comment_row_actions', array_filter( $actions ), $comment );
|
224 |
+
|
225 |
+
$i = 0;
|
226 |
+
$result = '<div class="cp-row-actions">';
|
227 |
+
foreach ( $actions as $action => $link ) {
|
228 |
+
++$i;
|
229 |
+
( ( ( 'approve' == $action || 'unapprove' == $action ) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | ';
|
230 |
+
|
231 |
+
// Reply and quickedit need a hide-if-no-js span when not added with ajax
|
232 |
+
if ( ( 'reply' == $action || 'quickedit' == $action ) && ! defined('DOING_AJAX') )
|
233 |
+
$action .= ' hide-if-no-js';
|
234 |
+
elseif ( ( $action == 'untrash' && $the_comment_status == 'trash' ) || ( $action == 'unspam' && $the_comment_status == 'spam' ) ) {
|
235 |
+
if ( '1' == get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true ) )
|
236 |
+
$action .= ' approve';
|
237 |
+
else
|
238 |
+
$action .= ' unapprove';
|
239 |
+
}
|
240 |
+
|
241 |
+
$result .= "<span class='$action'>$sep$link</span>";
|
242 |
+
}
|
243 |
+
$result .= '</div>';
|
244 |
+
}
|
245 |
+
return $result;
|
246 |
+
// end copied
|
247 |
+
}
|
248 |
+
}
|
249 |
+
|
250 |
?>
|
classes/values/media.php
CHANGED
@@ -1,212 +1,212 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* CPAC_Media_Values Class
|
5 |
-
*
|
6 |
-
* @since 1.4.4
|
7 |
-
*
|
8 |
-
*/
|
9 |
-
class CPAC_Media_Values extends CPAC_Values
|
10 |
-
{
|
11 |
-
/**
|
12 |
-
* Constructor
|
13 |
-
*
|
14 |
-
* @since 1.4.4
|
15 |
-
*/
|
16 |
-
function __construct()
|
17 |
-
{
|
18 |
-
parent::__construct();
|
19 |
-
|
20 |
-
add_action( 'manage_media_custom_column', array( $this, 'manage_media_column_value'), 10, 2 );
|
21 |
-
}
|
22 |
-
|
23 |
-
/**
|
24 |
-
* Manage custom column for Media.
|
25 |
-
*
|
26 |
-
* @since 1.3
|
27 |
-
*/
|
28 |
-
public function manage_media_column_value( $column_name, $media_id )
|
29 |
-
{
|
30 |
-
$type = $column_name;
|
31 |
-
|
32 |
-
//$meta = wp_get_attachment_metadata($media_id);
|
33 |
-
$meta = get_post_meta( $media_id, '_wp_attachment_metadata', true );
|
34 |
-
$p = get_post($media_id);
|
35 |
-
|
36 |
-
// Check for custom fields, such as column-meta-[customfieldname]
|
37 |
-
if ( $this->is_column_meta($type) )
|
38 |
-
$type = 'column-meta';
|
39 |
-
|
40 |
-
// Hook
|
41 |
-
do_action('cpac-manage-media-column', $type, $column_name, $media_id);
|
42 |
-
|
43 |
-
$result = '';
|
44 |
-
switch ($type) :
|
45 |
-
|
46 |
-
// media id
|
47 |
-
case "column-mediaid" :
|
48 |
-
$result = $media_id;
|
49 |
-
break;
|
50 |
-
|
51 |
-
// dimensions
|
52 |
-
case "column-dimensions" :
|
53 |
-
if ( !empty($meta['width']) && !empty($meta['height']) )
|
54 |
-
$result = "{$meta['width']} x {$meta['height']}";
|
55 |
-
break;
|
56 |
-
|
57 |
-
// width
|
58 |
-
case "column-width" :
|
59 |
-
$result = !empty($meta['width']) ? $meta['width'] : '';
|
60 |
-
break;
|
61 |
-
|
62 |
-
// height
|
63 |
-
case "column-height" :
|
64 |
-
$result = !empty($meta['height']) ? $meta['height'] : '';
|
65 |
-
break;
|
66 |
-
|
67 |
-
// description
|
68 |
-
case "column-description" :
|
69 |
-
$result = $p->post_content;
|
70 |
-
break;
|
71 |
-
|
72 |
-
// caption
|
73 |
-
case "column-caption" :
|
74 |
-
$result = $p->post_excerpt;
|
75 |
-
break;
|
76 |
-
|
77 |
-
// alternate text
|
78 |
-
case "column-alternate_text" :
|
79 |
-
$alt = get_post_meta($media_id, '_wp_attachment_image_alt', true);
|
80 |
-
$result = $this->strip_trim($alt);
|
81 |
-
break;
|
82 |
-
|
83 |
-
// mime type
|
84 |
-
case "column-mime_type" :
|
85 |
-
$result = $p->post_mime_type;
|
86 |
-
break;
|
87 |
-
|
88 |
-
// file name
|
89 |
-
case "column-file_name" :
|
90 |
-
$file = wp_get_attachment_url($p->ID);
|
91 |
-
$filename = basename($file);
|
92 |
-
$result = "<a title='{$filename}' href='{$file}'>{$filename}</a>";
|
93 |
-
break;
|
94 |
-
|
95 |
-
// file paths
|
96 |
-
case "column-file_paths" :
|
97 |
-
$sizes = get_intermediate_image_sizes();
|
98 |
-
$url = wp_get_attachment_url($p->ID);
|
99 |
-
$filename = basename($url);
|
100 |
-
$paths[] = "<a title='{$filename}' href='{$url}'>" . __('original', CPAC_TEXTDOMAIN) . "</a>";
|
101 |
-
if ( $sizes ) {
|
102 |
-
foreach ( $sizes as $size ) {
|
103 |
-
$src = wp_get_attachment_image_src( $media_id, $size );
|
104 |
-
if (!empty($src[0])) {
|
105 |
-
$filename = basename($src[0]);
|
106 |
-
$paths[] = "<a title='{$filename}' href='{$src[0]}'>{$size}</a>";
|
107 |
-
}
|
108 |
-
}
|
109 |
-
}
|
110 |
-
$result = implode('<span class="cpac-divider"></span>', $paths);
|
111 |
-
break;
|
112 |
-
|
113 |
-
case "column-actions" :
|
114 |
-
$result = $this->get_column_value_actions($media_id);
|
115 |
-
break;
|
116 |
-
|
117 |
-
case "column-filesize" :
|
118 |
-
$file = wp_get_attachment_url($p->ID);
|
119 |
-
$abs = str_replace( WP_CONTENT_URL, WP_CONTENT_DIR, $file);
|
120 |
-
if ( file_exists($abs) ) {
|
121 |
-
$result = $this->get_readable_filesize(filesize($abs));
|
122 |
-
}
|
123 |
-
break;
|
124 |
-
|
125 |
-
// Custom Field
|
126 |
-
case "column-meta" :
|
127 |
-
$result = $this->get_column_value_custom_field($media_id, $column_name, '
|
128 |
-
break;
|
129 |
-
|
130 |
-
// Image metadata EXIF or IPTC data
|
131 |
-
case "column-image-aperture" :
|
132 |
-
$result = !empty( $meta['image_meta']['aperture'] ) ? $meta['image_meta']['aperture'] : '';
|
133 |
-
break;
|
134 |
-
|
135 |
-
case "column-image-credit" :
|
136 |
-
$result = !empty( $meta['image_meta']['credit'] ) ? $meta['image_meta']['credit'] : '';
|
137 |
-
break;
|
138 |
-
|
139 |
-
case "column-image-camera" :
|
140 |
-
$result = !empty( $meta['image_meta']['camera'] ) ? $meta['image_meta']['camera'] : '';
|
141 |
-
break;
|
142 |
-
|
143 |
-
case "column-image-caption" :
|
144 |
-
$result = !empty( $meta['image_meta']['caption'] ) ? $meta['image_meta']['caption'] : '';
|
145 |
-
break;
|
146 |
-
|
147 |
-
case "column-image-created_timestamp" :
|
148 |
-
if ( !empty( $meta['image_meta']['created_timestamp'] ) ) {
|
149 |
-
$result = date_i18n( get_option('date_format') . ' ' . get_option('time_format') , strtotime($meta['image_meta']['created_timestamp']) );
|
150 |
-
}
|
151 |
-
break;
|
152 |
-
|
153 |
-
case "column-image-copyright" :
|
154 |
-
$result = !empty( $meta['image_meta']['copyright'] ) ? $meta['image_meta']['copyright'] : '';
|
155 |
-
break;
|
156 |
-
|
157 |
-
case "column-image-focal_length" :
|
158 |
-
$result = !empty( $meta['image_meta']['focal_length'] ) ? $meta['image_meta']['focal_length'] : '';
|
159 |
-
break;
|
160 |
-
|
161 |
-
case "column-image-iso" :
|
162 |
-
$result = !empty( $meta['image_meta']['iso'] ) ? $meta['image_meta']['iso'] : '';
|
163 |
-
break;
|
164 |
-
|
165 |
-
case "column-image-shutter_speed" :
|
166 |
-
$result = !empty( $meta['image_meta']['shutter_speed'] ) ? $meta['image_meta']['shutter_speed'] : '';
|
167 |
-
break;
|
168 |
-
|
169 |
-
case "column-image-title" :
|
170 |
-
$result = !empty( $meta['image_meta']['title'] ) ? $meta['image_meta']['title'] : '';
|
171 |
-
break;
|
172 |
-
|
173 |
-
default :
|
174 |
-
$result = '';
|
175 |
-
|
176 |
-
endswitch;
|
177 |
-
|
178 |
-
// Filter for customizing the result output
|
179 |
-
apply_filters('cpac-media-column-result', $result, $type, $column_name, $media_id);
|
180 |
-
|
181 |
-
echo $result;
|
182 |
-
}
|
183 |
-
|
184 |
-
/**
|
185 |
-
* Get column value of media actions
|
186 |
-
*
|
187 |
-
* This part is copied from the Media List Table class
|
188 |
-
*
|
189 |
-
* @since 1.4.2
|
190 |
-
*/
|
191 |
-
private function get_column_value_actions( $id )
|
192 |
-
{
|
193 |
-
if ( file_exists(ABSPATH . 'wp-admin/includes/class-wp-list-table.php') )
|
194 |
-
require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php');
|
195 |
-
if ( file_exists(ABSPATH . 'wp-admin/includes/class-wp-media-list-table.php') )
|
196 |
-
require_once(ABSPATH . 'wp-admin/includes/class-wp-media-list-table.php');
|
197 |
-
|
198 |
-
// we need class to get the object actions
|
199 |
-
$m = new WP_Media_List_Table;
|
200 |
-
|
201 |
-
// prevent php notice
|
202 |
-
$m->is_trash = isset( $_REQUEST['status'] ) && 'trash' == $_REQUEST['status'];
|
203 |
-
|
204 |
-
// get media actions
|
205 |
-
$media = get_post($id);
|
206 |
-
$actions = $m->_get_row_actions( $media, _draft_or_post_title($id) );
|
207 |
-
|
208 |
-
return implode(' | ', $actions);
|
209 |
-
}
|
210 |
-
}
|
211 |
-
|
212 |
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* CPAC_Media_Values Class
|
5 |
+
*
|
6 |
+
* @since 1.4.4
|
7 |
+
*
|
8 |
+
*/
|
9 |
+
class CPAC_Media_Values extends CPAC_Values
|
10 |
+
{
|
11 |
+
/**
|
12 |
+
* Constructor
|
13 |
+
*
|
14 |
+
* @since 1.4.4
|
15 |
+
*/
|
16 |
+
function __construct()
|
17 |
+
{
|
18 |
+
parent::__construct();
|
19 |
+
|
20 |
+
add_action( 'manage_media_custom_column', array( $this, 'manage_media_column_value'), 10, 2 );
|
21 |
+
}
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Manage custom column for Media.
|
25 |
+
*
|
26 |
+
* @since 1.3
|
27 |
+
*/
|
28 |
+
public function manage_media_column_value( $column_name, $media_id )
|
29 |
+
{
|
30 |
+
$type = $column_name;
|
31 |
+
|
32 |
+
//$meta = wp_get_attachment_metadata($media_id);
|
33 |
+
$meta = get_post_meta( $media_id, '_wp_attachment_metadata', true );
|
34 |
+
$p = get_post($media_id);
|
35 |
+
|
36 |
+
// Check for custom fields, such as column-meta-[customfieldname]
|
37 |
+
if ( $this->is_column_meta($type) )
|
38 |
+
$type = 'column-meta';
|
39 |
+
|
40 |
+
// Hook
|
41 |
+
do_action('cpac-manage-media-column', $type, $column_name, $media_id);
|
42 |
+
|
43 |
+
$result = '';
|
44 |
+
switch ($type) :
|
45 |
+
|
46 |
+
// media id
|
47 |
+
case "column-mediaid" :
|
48 |
+
$result = $media_id;
|
49 |
+
break;
|
50 |
+
|
51 |
+
// dimensions
|
52 |
+
case "column-dimensions" :
|
53 |
+
if ( !empty($meta['width']) && !empty($meta['height']) )
|
54 |
+
$result = "{$meta['width']} x {$meta['height']}";
|
55 |
+
break;
|
56 |
+
|
57 |
+
// width
|
58 |
+
case "column-width" :
|
59 |
+
$result = !empty($meta['width']) ? $meta['width'] : '';
|
60 |
+
break;
|
61 |
+
|
62 |
+
// height
|
63 |
+
case "column-height" :
|
64 |
+
$result = !empty($meta['height']) ? $meta['height'] : '';
|
65 |
+
break;
|
66 |
+
|
67 |
+
// description
|
68 |
+
case "column-description" :
|
69 |
+
$result = $p->post_content;
|
70 |
+
break;
|
71 |
+
|
72 |
+
// caption
|
73 |
+
case "column-caption" :
|
74 |
+
$result = $p->post_excerpt;
|
75 |
+
break;
|
76 |
+
|
77 |
+
// alternate text
|
78 |
+
case "column-alternate_text" :
|
79 |
+
$alt = get_post_meta($media_id, '_wp_attachment_image_alt', true);
|
80 |
+
$result = $this->strip_trim($alt);
|
81 |
+
break;
|
82 |
+
|
83 |
+
// mime type
|
84 |
+
case "column-mime_type" :
|
85 |
+
$result = $p->post_mime_type;
|
86 |
+
break;
|
87 |
+
|
88 |
+
// file name
|
89 |
+
case "column-file_name" :
|
90 |
+
$file = wp_get_attachment_url($p->ID);
|
91 |
+
$filename = basename($file);
|
92 |
+
$result = "<a title='{$filename}' href='{$file}'>{$filename}</a>";
|
93 |
+
break;
|
94 |
+
|
95 |
+
// file paths
|
96 |
+
case "column-file_paths" :
|
97 |
+
$sizes = get_intermediate_image_sizes();
|
98 |
+
$url = wp_get_attachment_url($p->ID);
|
99 |
+
$filename = basename($url);
|
100 |
+
$paths[] = "<a title='{$filename}' href='{$url}'>" . __('original', CPAC_TEXTDOMAIN) . "</a>";
|
101 |
+
if ( $sizes ) {
|
102 |
+
foreach ( $sizes as $size ) {
|
103 |
+
$src = wp_get_attachment_image_src( $media_id, $size );
|
104 |
+
if (!empty($src[0])) {
|
105 |
+
$filename = basename($src[0]);
|
106 |
+
$paths[] = "<a title='{$filename}' href='{$src[0]}'>{$size}</a>";
|
107 |
+
}
|
108 |
+
}
|
109 |
+
}
|
110 |
+
$result = implode('<span class="cpac-divider"></span>', $paths);
|
111 |
+
break;
|
112 |
+
|
113 |
+
case "column-actions" :
|
114 |
+
$result = $this->get_column_value_actions($media_id);
|
115 |
+
break;
|
116 |
+
|
117 |
+
case "column-filesize" :
|
118 |
+
$file = wp_get_attachment_url($p->ID);
|
119 |
+
$abs = str_replace( WP_CONTENT_URL, WP_CONTENT_DIR, $file);
|
120 |
+
if ( file_exists($abs) ) {
|
121 |
+
$result = $this->get_readable_filesize(filesize($abs));
|
122 |
+
}
|
123 |
+
break;
|
124 |
+
|
125 |
+
// Custom Field
|
126 |
+
case "column-meta" :
|
127 |
+
$result = $this->get_column_value_custom_field($media_id, $column_name, 'media');
|
128 |
+
break;
|
129 |
+
|
130 |
+
// Image metadata EXIF or IPTC data
|
131 |
+
case "column-image-aperture" :
|
132 |
+
$result = !empty( $meta['image_meta']['aperture'] ) ? $meta['image_meta']['aperture'] : '';
|
133 |
+
break;
|
134 |
+
|
135 |
+
case "column-image-credit" :
|
136 |
+
$result = !empty( $meta['image_meta']['credit'] ) ? $meta['image_meta']['credit'] : '';
|
137 |
+
break;
|
138 |
+
|
139 |
+
case "column-image-camera" :
|
140 |
+
$result = !empty( $meta['image_meta']['camera'] ) ? $meta['image_meta']['camera'] : '';
|
141 |
+
break;
|
142 |
+
|
143 |
+
case "column-image-caption" :
|
144 |
+
$result = !empty( $meta['image_meta']['caption'] ) ? $meta['image_meta']['caption'] : '';
|
145 |
+
break;
|
146 |
+
|
147 |
+
case "column-image-created_timestamp" :
|
148 |
+
if ( !empty( $meta['image_meta']['created_timestamp'] ) ) {
|
149 |
+
$result = date_i18n( get_option('date_format') . ' ' . get_option('time_format') , strtotime($meta['image_meta']['created_timestamp']) );
|
150 |
+
}
|
151 |
+
break;
|
152 |
+
|
153 |
+
case "column-image-copyright" :
|
154 |
+
$result = !empty( $meta['image_meta']['copyright'] ) ? $meta['image_meta']['copyright'] : '';
|
155 |
+
break;
|
156 |
+
|
157 |
+
case "column-image-focal_length" :
|
158 |
+
$result = !empty( $meta['image_meta']['focal_length'] ) ? $meta['image_meta']['focal_length'] : '';
|
159 |
+
break;
|
160 |
+
|
161 |
+
case "column-image-iso" :
|
162 |
+
$result = !empty( $meta['image_meta']['iso'] ) ? $meta['image_meta']['iso'] : '';
|
163 |
+
break;
|
164 |
+
|
165 |
+
case "column-image-shutter_speed" :
|
166 |
+
$result = !empty( $meta['image_meta']['shutter_speed'] ) ? $meta['image_meta']['shutter_speed'] : '';
|
167 |
+
break;
|
168 |
+
|
169 |
+
case "column-image-title" :
|
170 |
+
$result = !empty( $meta['image_meta']['title'] ) ? $meta['image_meta']['title'] : '';
|
171 |
+
break;
|
172 |
+
|
173 |
+
default :
|
174 |
+
$result = '';
|
175 |
+
|
176 |
+
endswitch;
|
177 |
+
|
178 |
+
// Filter for customizing the result output
|
179 |
+
apply_filters('cpac-media-column-result', $result, $type, $column_name, $media_id);
|
180 |
+
|
181 |
+
echo $result;
|
182 |
+
}
|
183 |
+
|
184 |
+
/**
|
185 |
+
* Get column value of media actions
|
186 |
+
*
|
187 |
+
* This part is copied from the Media List Table class
|
188 |
+
*
|
189 |
+
* @since 1.4.2
|
190 |
+
*/
|
191 |
+
private function get_column_value_actions( $id )
|
192 |
+
{
|
193 |
+
if ( file_exists(ABSPATH . 'wp-admin/includes/class-wp-list-table.php') )
|
194 |
+
require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php');
|
195 |
+
if ( file_exists(ABSPATH . 'wp-admin/includes/class-wp-media-list-table.php') )
|
196 |
+
require_once(ABSPATH . 'wp-admin/includes/class-wp-media-list-table.php');
|
197 |
+
|
198 |
+
// we need class to get the object actions
|
199 |
+
$m = new WP_Media_List_Table;
|
200 |
+
|
201 |
+
// prevent php notice
|
202 |
+
$m->is_trash = isset( $_REQUEST['status'] ) && 'trash' == $_REQUEST['status'];
|
203 |
+
|
204 |
+
// get media actions
|
205 |
+
$media = get_post($id);
|
206 |
+
$actions = $m->_get_row_actions( $media, _draft_or_post_title($id) );
|
207 |
+
|
208 |
+
return implode(' | ', $actions);
|
209 |
+
}
|
210 |
+
}
|
211 |
+
|
212 |
?>
|
classes/values/posts.php
CHANGED
@@ -1,343 +1,343 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* CPAC_Posts_Values Class
|
5 |
-
*
|
6 |
-
* @since 1.4.4
|
7 |
-
*
|
8 |
-
*/
|
9 |
-
class CPAC_Posts_Values extends CPAC_Values
|
10 |
-
{
|
11 |
-
/**
|
12 |
-
* Constructor
|
13 |
-
*
|
14 |
-
* @since 1.4.4
|
15 |
-
*/
|
16 |
-
function __construct()
|
17 |
-
{
|
18 |
-
parent::__construct();
|
19 |
-
|
20 |
-
add_action( 'manage_pages_custom_column', array( $this, 'manage_posts_column_value'), 10, 2 );
|
21 |
-
add_action( 'manage_posts_custom_column', array( $this, 'manage_posts_column_value'), 10, 2 );
|
22 |
-
}
|
23 |
-
|
24 |
-
/**
|
25 |
-
* Manage custom column for Post Types.
|
26 |
-
*
|
27 |
-
* @since 1.0
|
28 |
-
*/
|
29 |
-
public function manage_posts_column_value($column_name, $post_id)
|
30 |
-
{
|
31 |
-
$type = $column_name;
|
32 |
-
|
33 |
-
// Check for taxonomies, such as column-taxonomy-[taxname]
|
34 |
-
if ( strpos($type, 'column-taxonomy-') !== false )
|
35 |
-
$type = 'column-taxonomy';
|
36 |
-
|
37 |
-
// Check for custom fields, such as column-meta-[customfieldname]
|
38 |
-
if ( $this->is_column_meta($type) )
|
39 |
-
$type = 'column-post-meta';
|
40 |
-
|
41 |
-
// Hook
|
42 |
-
do_action('cpac-manage-posts-column', $type, $column_name, $post_id);
|
43 |
-
|
44 |
-
// Switch Types
|
45 |
-
$result = '';
|
46 |
-
switch ($type) :
|
47 |
-
|
48 |
-
// Post ID
|
49 |
-
case "column-postid" :
|
50 |
-
$result = $post_id;
|
51 |
-
break;
|
52 |
-
|
53 |
-
// Excerpt
|
54 |
-
case "column-excerpt" :
|
55 |
-
$result = $this->get_post_excerpt($post_id);
|
56 |
-
break;
|
57 |
-
|
58 |
-
// Featured Image
|
59 |
-
case "column-featured_image" :
|
60 |
-
if ( function_exists('has_post_thumbnail') && has_post_thumbnail($post_id) )
|
61 |
-
$result = get_the_post_thumbnail($post_id, $this->thumbnail_size);
|
62 |
-
break;
|
63 |
-
|
64 |
-
// Sticky Post
|
65 |
-
case "column-sticky" :
|
66 |
-
if ( is_sticky($post_id) )
|
67 |
-
$result = $this->get_asset_image('checkmark.png');
|
68 |
-
break;
|
69 |
-
|
70 |
-
// Order
|
71 |
-
case "column-order" :
|
72 |
-
$result = get_post_field('menu_order', $post_id);
|
73 |
-
break;
|
74 |
-
|
75 |
-
// Post Formats
|
76 |
-
case "column-post_formats" :
|
77 |
-
$result = get_post_format($post_id);
|
78 |
-
break;
|
79 |
-
|
80 |
-
// Page template
|
81 |
-
case "column-page-template" :
|
82 |
-
// file name
|
83 |
-
$page_template = get_post_meta($post_id, '_wp_page_template', true);
|
84 |
-
|
85 |
-
// get template nice name
|
86 |
-
$result = array_search($page_template, get_page_templates());
|
87 |
-
break;
|
88 |
-
|
89 |
-
// Slug
|
90 |
-
case "column-page-slug" :
|
91 |
-
$result = get_post($post_id)->post_name;
|
92 |
-
break;
|
93 |
-
|
94 |
-
// Slug
|
95 |
-
case "column-word-count" :
|
96 |
-
$result = str_word_count( $this->strip_trim( get_post($post_id)->post_content ) );
|
97 |
-
break;
|
98 |
-
|
99 |
-
// Taxonomy
|
100 |
-
case "column-taxonomy" :
|
101 |
-
$tax = str_replace('column-taxonomy-', '', $column_name);
|
102 |
-
$tags = get_the_terms($post_id, $tax);
|
103 |
-
$tarr = array();
|
104 |
-
|
105 |
-
// for post formats we will display standard instead of empty
|
106 |
-
if ( $tax == 'post_format' && empty($tags) ) {
|
107 |
-
$result = __('Standard');
|
108 |
-
}
|
109 |
-
|
110 |
-
// add name with link
|
111 |
-
elseif ( !empty($tags) ) {
|
112 |
-
$post_type = get_post_type($post_id);
|
113 |
-
foreach($tags as $tag) {
|
114 |
-
// sanatize title
|
115 |
-
if ( isset($tag->term_id) ) {
|
116 |
-
$tax_title = esc_html(sanitize_term_field('name', $tag->name, $tag->term_id, $tag->taxonomy, 'edit'));
|
117 |
-
$tarr[] = "<a href='edit.php?post_type={$post_type}&{$tag->taxonomy}={$tag->slug}'>{$tax_title}</a>";
|
118 |
-
}
|
119 |
-
}
|
120 |
-
$result = implode(', ', $tarr);
|
121 |
-
}
|
122 |
-
break;
|
123 |
-
|
124 |
-
// Custom Field
|
125 |
-
case "column-post-meta" :
|
126 |
-
$result = $this->get_column_value_custom_field($post_id, $column_name, 'post');
|
127 |
-
break;
|
128 |
-
|
129 |
-
// Attachment
|
130 |
-
case "column-attachment" :
|
131 |
-
$result = $this->get_column_value_attachments($post_id);
|
132 |
-
break;
|
133 |
-
|
134 |
-
// Attachment count
|
135 |
-
case "column-attachment-count" :
|
136 |
-
$result = count($this->get_attachment_ids($post_id));
|
137 |
-
break;
|
138 |
-
|
139 |
-
// Roles
|
140 |
-
case "column-roles" :
|
141 |
-
$user_id = get_post($post_id)->post_author;
|
142 |
-
$userdata = get_userdata( $user_id );
|
143 |
-
if ( !empty($userdata->roles[0]) )
|
144 |
-
$result = implode(', ',$userdata->roles);
|
145 |
-
break;
|
146 |
-
|
147 |
-
// Post status
|
148 |
-
case "column-status" :
|
149 |
-
$p = get_post($post_id);
|
150 |
-
$result = $this->get_post_status_friendly_name( $p->post_status );
|
151 |
-
if ( $p->post_status == 'future')
|
152 |
-
$result = $result . " <p class='description'>" . date_i18n( get_option('date_format') . ' ' . get_option('time_format') , strtotime($p->post_date) ) . "</p>";
|
153 |
-
break;
|
154 |
-
|
155 |
-
// Post comment status
|
156 |
-
case "column-comment-status" :
|
157 |
-
$p = get_post($post_id);
|
158 |
-
$result = $this->get_asset_image('no.png', $p->comment_status);
|
159 |
-
if ( $p->comment_status == 'open' )
|
160 |
-
$result = $this->get_asset_image('checkmark.png', $p->comment_status);
|
161 |
-
break;
|
162 |
-
|
163 |
-
// Post ping status
|
164 |
-
case "column-ping-status" :
|
165 |
-
$p = get_post($post_id);
|
166 |
-
$result = $this->get_asset_image('no.png', $p->ping_status);
|
167 |
-
if ( $p->ping_status == 'open' )
|
168 |
-
$result = $this->get_asset_image('checkmark.png', $p->ping_status);
|
169 |
-
break;
|
170 |
-
|
171 |
-
// Post actions ( delete, edit etc. )
|
172 |
-
case "column-actions" :
|
173 |
-
$result = $this->get_column_value_actions($post_id);
|
174 |
-
break;
|
175 |
-
|
176 |
-
// Post Last modified
|
177 |
-
case "column-modified" :
|
178 |
-
$p = get_post($post_id);
|
179 |
-
$result = $this->get_date($p->post_modified) . ' ' . $this->get_time($p->post_modified);
|
180 |
-
break;
|
181 |
-
|
182 |
-
// Post Comment count
|
183 |
-
case "column-comment-count" :
|
184 |
-
$result = WP_List_Table::comments_bubble( $post_id, get_pending_comments_num( $post_id ) );
|
185 |
-
$result .= $this->get_comment_count_details( $post_id );
|
186 |
-
break;
|
187 |
-
|
188 |
-
// Author Name
|
189 |
-
case "column-author-name" :
|
190 |
-
$result = $this->get_column_value_authorname($post_id, $column_name);
|
191 |
-
break;
|
192 |
-
|
193 |
-
// Before More Tag
|
194 |
-
case "column-before-moretag" :
|
195 |
-
$p = get_post($post_id);
|
196 |
-
$extended = get_extended($p->post_content);
|
197 |
-
|
198 |
-
if ( !empty($extended['extended']) ) {
|
199 |
-
$result = $this->get_shortened_string($extended['main'], $this->excerpt_length );
|
200 |
-
}
|
201 |
-
break;
|
202 |
-
|
203 |
-
default :
|
204 |
-
$result = '';
|
205 |
-
|
206 |
-
endswitch;
|
207 |
-
|
208 |
-
// Filter for customizing the result output
|
209 |
-
apply_filters('cpac-posts-column-result', $result, $type, $column_name, $post_id);
|
210 |
-
|
211 |
-
echo $result;
|
212 |
-
}
|
213 |
-
|
214 |
-
/**
|
215 |
-
* Returns the friendly name for a given status
|
216 |
-
*
|
217 |
-
* @since 1.4.4
|
218 |
-
*/
|
219 |
-
private function get_post_status_friendly_name( $status )
|
220 |
-
{
|
221 |
-
$builtin = array(
|
222 |
-
'publish' => __( 'Published', CPAC_TEXTDOMAIN ),
|
223 |
-
'draft' => __( 'Draft', CPAC_TEXTDOMAIN ),
|
224 |
-
'future' => __( 'Scheduled', CPAC_TEXTDOMAIN ),
|
225 |
-
'private' => __( 'Private', CPAC_TEXTDOMAIN ),
|
226 |
-
'pending' => __( 'Pending Review', CPAC_TEXTDOMAIN ),
|
227 |
-
'trash' => __( 'Trash', CPAC_TEXTDOMAIN )
|
228 |
-
);
|
229 |
-
|
230 |
-
if ( isset($builtin[$status]) )
|
231 |
-
$status = $builtin[$status];
|
232 |
-
|
233 |
-
return $status;
|
234 |
-
}
|
235 |
-
|
236 |
-
/**
|
237 |
-
* Comment count extended
|
238 |
-
*
|
239 |
-
* @since 1.4.4
|
240 |
-
*/
|
241 |
-
private function get_comment_count_details( $post_id )
|
242 |
-
{
|
243 |
-
$c = wp_count_comments($post_id);
|
244 |
-
|
245 |
-
$details = '';
|
246 |
-
if ( $c->approved ) {
|
247 |
-
$url = esc_url( add_query_arg( array('p' => $post_id, 'comment_status' => 'approved'), admin_url( 'edit-comments.php' ) ) );
|
248 |
-
$details .= "<a href='{$url}' class='cp-approved' title='".__('approved', CPAC_TEXTDOMAIN) . "'>{$c->approved}</a>";
|
249 |
-
}
|
250 |
-
if ( $c->moderated ) {
|
251 |
-
$url = esc_url( add_query_arg( array('p' => $post_id, 'comment_status' => 'moderated'), admin_url( 'edit-comments.php' ) ) );
|
252 |
-
$details .= "<a href='{$url}' class='cp-moderated' title='".__('pending', CPAC_TEXTDOMAIN) . "'>{$c->moderated}</a>";
|
253 |
-
}
|
254 |
-
if ( $c->spam ) {
|
255 |
-
$url = esc_url( add_query_arg( array('p' => $post_id, 'comment_status' => 'spam'), admin_url( 'edit-comments.php' ) ) );
|
256 |
-
$details .= "<a href='{$url}' class='cp-spam' title='".__('spam', CPAC_TEXTDOMAIN) . "'>{$c->spam}</a>";
|
257 |
-
}
|
258 |
-
if ( $c->trash ) {
|
259 |
-
$url = esc_url( add_query_arg( array('p' => $post_id, 'comment_status' => 'trash'), admin_url( 'edit-comments.php' ) ) );
|
260 |
-
$details .= "<a href='{$url}' class='cp-trash' title='".__('trash', CPAC_TEXTDOMAIN) . "'>{$c->trash}</a>";
|
261 |
-
}
|
262 |
-
|
263 |
-
if ( $details )
|
264 |
-
return "<p class='description row-actions'>{$details}</p>";
|
265 |
-
|
266 |
-
return false;
|
267 |
-
}
|
268 |
-
|
269 |
-
/**
|
270 |
-
* Get column value of post actions
|
271 |
-
*
|
272 |
-
* This part is copied from the Posts List Table class
|
273 |
-
*
|
274 |
-
* @since 1.4.2
|
275 |
-
*/
|
276 |
-
protected function get_column_value_actions( $post_id )
|
277 |
-
{
|
278 |
-
$actions = array();
|
279 |
-
|
280 |
-
$post = get_post($post_id);
|
281 |
-
$title = _draft_or_post_title();
|
282 |
-
$post_type_object = get_post_type_object( $post->post_type );
|
283 |
-
$can_edit_post = current_user_can( $post_type_object->cap->edit_post, $post->ID );
|
284 |
-
|
285 |
-
if ( $can_edit_post && 'trash' != $post->post_status ) {
|
286 |
-
$actions['edit'] = '<a href="' . get_edit_post_link( $post->ID, true ) . '" title="' . esc_attr( __( 'Edit this item' ) ) . '">' . __( 'Edit' ) . '</a>';
|
287 |
-
$actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr( __( 'Edit this item inline' ) ) . '">' . __( 'Quick Edit' ) . '</a>';
|
288 |
-
}
|
289 |
-
if ( current_user_can( $post_type_object->cap->delete_post, $post->ID ) ) {
|
290 |
-
if ( 'trash' == $post->post_status )
|
291 |
-
$actions['untrash'] = "<a title='" . esc_attr( __( 'Restore this item from the Trash' ) ) . "' href='" . wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&action=untrash', $post->ID ) ), 'untrash-' . $post->post_type . '_' . $post->ID ) . "'>" . __( 'Restore' ) . "</a>";
|
292 |
-
elseif ( EMPTY_TRASH_DAYS )
|
293 |
-
$actions['trash'] = "<a class='submitdelete' title='" . esc_attr( __( 'Move this item to the Trash' ) ) . "' href='" . get_delete_post_link( $post->ID ) . "'>" . __( 'Trash' ) . "</a>";
|
294 |
-
if ( 'trash' == $post->post_status || !EMPTY_TRASH_DAYS )
|
295 |
-
$actions['delete'] = "<a class='submitdelete' title='" . esc_attr( __( 'Delete this item permanently' ) ) . "' href='" . get_delete_post_link( $post->ID, '', true ) . "'>" . __( 'Delete Permanently' ) . "</a>";
|
296 |
-
}
|
297 |
-
if ( $post_type_object->public ) {
|
298 |
-
if ( in_array( $post->post_status, array( 'pending', 'draft', 'future' ) ) ) {
|
299 |
-
if ( $can_edit_post )
|
300 |
-
$actions['view'] = '<a href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink( $post->ID ) ) ) . '" title="' . esc_attr( sprintf( __( 'Preview “%s”' ), $title ) ) . '" rel="permalink">' . __( 'Preview' ) . '</a>';
|
301 |
-
} elseif ( 'trash' != $post->post_status ) {
|
302 |
-
$actions['view'] = '<a href="' . get_permalink( $post->ID ) . '" title="' . esc_attr( sprintf( __( 'View “%s”' ), $title ) ) . '" rel="permalink">' . __( 'View' ) . '</a>';
|
303 |
-
}
|
304 |
-
}
|
305 |
-
|
306 |
-
return implode(' | ', $actions);
|
307 |
-
}
|
308 |
-
|
309 |
-
/**
|
310 |
-
* Get column value of Custom Field
|
311 |
-
*
|
312 |
-
* @since 1.4.6.1
|
313 |
-
*/
|
314 |
-
protected function get_column_value_authorname($post_id, $column_name)
|
315 |
-
{
|
316 |
-
$type = get_post_type($post_id);
|
317 |
-
|
318 |
-
// get column
|
319 |
-
$columns = $this->get_stored_columns($type);
|
320 |
-
|
321 |
-
// get the type of author name
|
322 |
-
$display_as = isset($columns[$column_name]['display_as']) ? $columns[$column_name]['display_as'] : '';
|
323 |
-
|
324 |
-
// get the author
|
325 |
-
$post = get_post($post_id);
|
326 |
-
if ( !isset( $post->post_author) )
|
327 |
-
return false;
|
328 |
-
|
329 |
-
$name = Codepress_Admin_Columns::get_author_field_by_nametype($display_as, $post->post_author);
|
330 |
-
|
331 |
-
// filter for customization
|
332 |
-
$name = apply_filters('cpac_get_column_value_authorname', $name, $column_name, $post_id );
|
333 |
-
|
334 |
-
// add link filter
|
335 |
-
$class = isset( $_GET['author'] ) && $_GET['author'] == $userdata->ID ? ' class="current"' : '';
|
336 |
-
|
337 |
-
$name = "<a href='edit.php?post_type={$type}&author={$post->post_author}'{$class}>{$name}</a>";
|
338 |
-
|
339 |
-
return $name;
|
340 |
-
}
|
341 |
-
}
|
342 |
-
|
343 |
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* CPAC_Posts_Values Class
|
5 |
+
*
|
6 |
+
* @since 1.4.4
|
7 |
+
*
|
8 |
+
*/
|
9 |
+
class CPAC_Posts_Values extends CPAC_Values
|
10 |
+
{
|
11 |
+
/**
|
12 |
+
* Constructor
|
13 |
+
*
|
14 |
+
* @since 1.4.4
|
15 |
+
*/
|
16 |
+
function __construct()
|
17 |
+
{
|
18 |
+
parent::__construct();
|
19 |
+
|
20 |
+
add_action( 'manage_pages_custom_column', array( $this, 'manage_posts_column_value'), 10, 2 );
|
21 |
+
add_action( 'manage_posts_custom_column', array( $this, 'manage_posts_column_value'), 10, 2 );
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Manage custom column for Post Types.
|
26 |
+
*
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
public function manage_posts_column_value($column_name, $post_id)
|
30 |
+
{
|
31 |
+
$type = $column_name;
|
32 |
+
|
33 |
+
// Check for taxonomies, such as column-taxonomy-[taxname]
|
34 |
+
if ( strpos($type, 'column-taxonomy-') !== false )
|
35 |
+
$type = 'column-taxonomy';
|
36 |
+
|
37 |
+
// Check for custom fields, such as column-meta-[customfieldname]
|
38 |
+
if ( $this->is_column_meta($type) )
|
39 |
+
$type = 'column-post-meta';
|
40 |
+
|
41 |
+
// Hook
|
42 |
+
do_action('cpac-manage-posts-column', $type, $column_name, $post_id);
|
43 |
+
|
44 |
+
// Switch Types
|
45 |
+
$result = '';
|
46 |
+
switch ($type) :
|
47 |
+
|
48 |
+
// Post ID
|
49 |
+
case "column-postid" :
|
50 |
+
$result = $post_id;
|
51 |
+
break;
|
52 |
+
|
53 |
+
// Excerpt
|
54 |
+
case "column-excerpt" :
|
55 |
+
$result = $this->get_post_excerpt($post_id);
|
56 |
+
break;
|
57 |
+
|
58 |
+
// Featured Image
|
59 |
+
case "column-featured_image" :
|
60 |
+
if ( function_exists('has_post_thumbnail') && has_post_thumbnail($post_id) )
|
61 |
+
$result = get_the_post_thumbnail($post_id, $this->thumbnail_size);
|
62 |
+
break;
|
63 |
+
|
64 |
+
// Sticky Post
|
65 |
+
case "column-sticky" :
|
66 |
+
if ( is_sticky($post_id) )
|
67 |
+
$result = $this->get_asset_image('checkmark.png');
|
68 |
+
break;
|
69 |
+
|
70 |
+
// Order
|
71 |
+
case "column-order" :
|
72 |
+
$result = get_post_field('menu_order', $post_id);
|
73 |
+
break;
|
74 |
+
|
75 |
+
// Post Formats
|
76 |
+
case "column-post_formats" :
|
77 |
+
$result = get_post_format($post_id);
|
78 |
+
break;
|
79 |
+
|
80 |
+
// Page template
|
81 |
+
case "column-page-template" :
|
82 |
+
// file name
|
83 |
+
$page_template = get_post_meta($post_id, '_wp_page_template', true);
|
84 |
+
|
85 |
+
// get template nice name
|
86 |
+
$result = array_search($page_template, get_page_templates());
|
87 |
+
break;
|
88 |
+
|
89 |
+
// Slug
|
90 |
+
case "column-page-slug" :
|
91 |
+
$result = get_post($post_id)->post_name;
|
92 |
+
break;
|
93 |
+
|
94 |
+
// Slug
|
95 |
+
case "column-word-count" :
|
96 |
+
$result = str_word_count( $this->strip_trim( get_post($post_id)->post_content ) );
|
97 |
+
break;
|
98 |
+
|
99 |
+
// Taxonomy
|
100 |
+
case "column-taxonomy" :
|
101 |
+
$tax = str_replace('column-taxonomy-', '', $column_name);
|
102 |
+
$tags = get_the_terms($post_id, $tax);
|
103 |
+
$tarr = array();
|
104 |
+
|
105 |
+
// for post formats we will display standard instead of empty
|
106 |
+
if ( $tax == 'post_format' && empty($tags) ) {
|
107 |
+
$result = __('Standard');
|
108 |
+
}
|
109 |
+
|
110 |
+
// add name with link
|
111 |
+
elseif ( !empty($tags) ) {
|
112 |
+
$post_type = get_post_type($post_id);
|
113 |
+
foreach($tags as $tag) {
|
114 |
+
// sanatize title
|
115 |
+
if ( isset($tag->term_id) ) {
|
116 |
+
$tax_title = esc_html(sanitize_term_field('name', $tag->name, $tag->term_id, $tag->taxonomy, 'edit'));
|
117 |
+
$tarr[] = "<a href='edit.php?post_type={$post_type}&{$tag->taxonomy}={$tag->slug}'>{$tax_title}</a>";
|
118 |
+
}
|
119 |
+
}
|
120 |
+
$result = implode(', ', $tarr);
|
121 |
+
}
|
122 |
+
break;
|
123 |
+
|
124 |
+
// Custom Field
|
125 |
+
case "column-post-meta" :
|
126 |
+
$result = $this->get_column_value_custom_field($post_id, $column_name, 'post');
|
127 |
+
break;
|
128 |
+
|
129 |
+
// Attachment
|
130 |
+
case "column-attachment" :
|
131 |
+
$result = $this->get_column_value_attachments($post_id);
|
132 |
+
break;
|
133 |
+
|
134 |
+
// Attachment count
|
135 |
+
case "column-attachment-count" :
|
136 |
+
$result = count($this->get_attachment_ids($post_id));
|
137 |
+
break;
|
138 |
+
|
139 |
+
// Roles
|
140 |
+
case "column-roles" :
|
141 |
+
$user_id = get_post($post_id)->post_author;
|
142 |
+
$userdata = get_userdata( $user_id );
|
143 |
+
if ( !empty($userdata->roles[0]) )
|
144 |
+
$result = implode(', ',$userdata->roles);
|
145 |
+
break;
|
146 |
+
|
147 |
+
// Post status
|
148 |
+
case "column-status" :
|
149 |
+
$p = get_post($post_id);
|
150 |
+
$result = $this->get_post_status_friendly_name( $p->post_status );
|
151 |
+
if ( $p->post_status == 'future')
|
152 |
+
$result = $result . " <p class='description'>" . date_i18n( get_option('date_format') . ' ' . get_option('time_format') , strtotime($p->post_date) ) . "</p>";
|
153 |
+
break;
|
154 |
+
|
155 |
+
// Post comment status
|
156 |
+
case "column-comment-status" :
|
157 |
+
$p = get_post($post_id);
|
158 |
+
$result = $this->get_asset_image('no.png', $p->comment_status);
|
159 |
+
if ( $p->comment_status == 'open' )
|
160 |
+
$result = $this->get_asset_image('checkmark.png', $p->comment_status);
|
161 |
+
break;
|
162 |
+
|
163 |
+
// Post ping status
|
164 |
+
case "column-ping-status" :
|
165 |
+
$p = get_post($post_id);
|
166 |
+
$result = $this->get_asset_image('no.png', $p->ping_status);
|
167 |
+
if ( $p->ping_status == 'open' )
|
168 |
+
$result = $this->get_asset_image('checkmark.png', $p->ping_status);
|
169 |
+
break;
|
170 |
+
|
171 |
+
// Post actions ( delete, edit etc. )
|
172 |
+
case "column-actions" :
|
173 |
+
$result = $this->get_column_value_actions($post_id);
|
174 |
+
break;
|
175 |
+
|
176 |
+
// Post Last modified
|
177 |
+
case "column-modified" :
|
178 |
+
$p = get_post($post_id);
|
179 |
+
$result = $this->get_date($p->post_modified) . ' ' . $this->get_time($p->post_modified);
|
180 |
+
break;
|
181 |
+
|
182 |
+
// Post Comment count
|
183 |
+
case "column-comment-count" :
|
184 |
+
$result = WP_List_Table::comments_bubble( $post_id, get_pending_comments_num( $post_id ) );
|
185 |
+
$result .= $this->get_comment_count_details( $post_id );
|
186 |
+
break;
|
187 |
+
|
188 |
+
// Author Name
|
189 |
+
case "column-author-name" :
|
190 |
+
$result = $this->get_column_value_authorname($post_id, $column_name);
|
191 |
+
break;
|
192 |
+
|
193 |
+
// Before More Tag
|
194 |
+
case "column-before-moretag" :
|
195 |
+
$p = get_post($post_id);
|
196 |
+
$extended = get_extended($p->post_content);
|
197 |
+
|
198 |
+
if ( !empty($extended['extended']) ) {
|
199 |
+
$result = $this->get_shortened_string($extended['main'], $this->excerpt_length );
|
200 |
+
}
|
201 |
+
break;
|
202 |
+
|
203 |
+
default :
|
204 |
+
$result = '';
|
205 |
+
|
206 |
+
endswitch;
|
207 |
+
|
208 |
+
// Filter for customizing the result output
|
209 |
+
apply_filters('cpac-posts-column-result', $result, $type, $column_name, $post_id);
|
210 |
+
|
211 |
+
echo $result;
|
212 |
+
}
|
213 |
+
|
214 |
+
/**
|
215 |
+
* Returns the friendly name for a given status
|
216 |
+
*
|
217 |
+
* @since 1.4.4
|
218 |
+
*/
|
219 |
+
private function get_post_status_friendly_name( $status )
|
220 |
+
{
|
221 |
+
$builtin = array(
|
222 |
+
'publish' => __( 'Published', CPAC_TEXTDOMAIN ),
|
223 |
+
'draft' => __( 'Draft', CPAC_TEXTDOMAIN ),
|
224 |
+
'future' => __( 'Scheduled', CPAC_TEXTDOMAIN ),
|
225 |
+
'private' => __( 'Private', CPAC_TEXTDOMAIN ),
|
226 |
+
'pending' => __( 'Pending Review', CPAC_TEXTDOMAIN ),
|
227 |
+
'trash' => __( 'Trash', CPAC_TEXTDOMAIN )
|
228 |
+
);
|
229 |
+
|
230 |
+
if ( isset($builtin[$status]) )
|
231 |
+
$status = $builtin[$status];
|
232 |
+
|
233 |
+
return $status;
|
234 |
+
}
|
235 |
+
|
236 |
+
/**
|
237 |
+
* Comment count extended
|
238 |
+
*
|
239 |
+
* @since 1.4.4
|
240 |
+
*/
|
241 |
+
private function get_comment_count_details( $post_id )
|
242 |
+
{
|
243 |
+
$c = wp_count_comments($post_id);
|
244 |
+
|
245 |
+
$details = '';
|
246 |
+
if ( $c->approved ) {
|
247 |
+
$url = esc_url( add_query_arg( array('p' => $post_id, 'comment_status' => 'approved'), admin_url( 'edit-comments.php' ) ) );
|
248 |
+
$details .= "<a href='{$url}' class='cp-approved' title='".__('approved', CPAC_TEXTDOMAIN) . "'>{$c->approved}</a>";
|
249 |
+
}
|
250 |
+
if ( $c->moderated ) {
|
251 |
+
$url = esc_url( add_query_arg( array('p' => $post_id, 'comment_status' => 'moderated'), admin_url( 'edit-comments.php' ) ) );
|
252 |
+
$details .= "<a href='{$url}' class='cp-moderated' title='".__('pending', CPAC_TEXTDOMAIN) . "'>{$c->moderated}</a>";
|
253 |
+
}
|
254 |
+
if ( $c->spam ) {
|
255 |
+
$url = esc_url( add_query_arg( array('p' => $post_id, 'comment_status' => 'spam'), admin_url( 'edit-comments.php' ) ) );
|
256 |
+
$details .= "<a href='{$url}' class='cp-spam' title='".__('spam', CPAC_TEXTDOMAIN) . "'>{$c->spam}</a>";
|
257 |
+
}
|
258 |
+
if ( $c->trash ) {
|
259 |
+
$url = esc_url( add_query_arg( array('p' => $post_id, 'comment_status' => 'trash'), admin_url( 'edit-comments.php' ) ) );
|
260 |
+
$details .= "<a href='{$url}' class='cp-trash' title='".__('trash', CPAC_TEXTDOMAIN) . "'>{$c->trash}</a>";
|
261 |
+
}
|
262 |
+
|
263 |
+
if ( $details )
|
264 |
+
return "<p class='description row-actions'>{$details}</p>";
|
265 |
+
|
266 |
+
return false;
|
267 |
+
}
|
268 |
+
|
269 |
+
/**
|
270 |
+
* Get column value of post actions
|
271 |
+
*
|
272 |
+
* This part is copied from the Posts List Table class
|
273 |
+
*
|
274 |
+
* @since 1.4.2
|
275 |
+
*/
|
276 |
+
protected function get_column_value_actions( $post_id )
|
277 |
+
{
|
278 |
+
$actions = array();
|
279 |
+
|
280 |
+
$post = get_post($post_id);
|
281 |
+
$title = _draft_or_post_title();
|
282 |
+
$post_type_object = get_post_type_object( $post->post_type );
|
283 |
+
$can_edit_post = current_user_can( $post_type_object->cap->edit_post, $post->ID );
|
284 |
+
|
285 |
+
if ( $can_edit_post && 'trash' != $post->post_status ) {
|
286 |
+
$actions['edit'] = '<a href="' . get_edit_post_link( $post->ID, true ) . '" title="' . esc_attr( __( 'Edit this item' ) ) . '">' . __( 'Edit' ) . '</a>';
|
287 |
+
$actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr( __( 'Edit this item inline' ) ) . '">' . __( 'Quick Edit' ) . '</a>';
|
288 |
+
}
|
289 |
+
if ( current_user_can( $post_type_object->cap->delete_post, $post->ID ) ) {
|
290 |
+
if ( 'trash' == $post->post_status )
|
291 |
+
$actions['untrash'] = "<a title='" . esc_attr( __( 'Restore this item from the Trash' ) ) . "' href='" . wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&action=untrash', $post->ID ) ), 'untrash-' . $post->post_type . '_' . $post->ID ) . "'>" . __( 'Restore' ) . "</a>";
|
292 |
+
elseif ( EMPTY_TRASH_DAYS )
|
293 |
+
$actions['trash'] = "<a class='submitdelete' title='" . esc_attr( __( 'Move this item to the Trash' ) ) . "' href='" . get_delete_post_link( $post->ID ) . "'>" . __( 'Trash' ) . "</a>";
|
294 |
+
if ( 'trash' == $post->post_status || !EMPTY_TRASH_DAYS )
|
295 |
+
$actions['delete'] = "<a class='submitdelete' title='" . esc_attr( __( 'Delete this item permanently' ) ) . "' href='" . get_delete_post_link( $post->ID, '', true ) . "'>" . __( 'Delete Permanently' ) . "</a>";
|
296 |
+
}
|
297 |
+
if ( $post_type_object->public ) {
|
298 |
+
if ( in_array( $post->post_status, array( 'pending', 'draft', 'future' ) ) ) {
|
299 |
+
if ( $can_edit_post )
|
300 |
+
$actions['view'] = '<a href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink( $post->ID ) ) ) . '" title="' . esc_attr( sprintf( __( 'Preview “%s”' ), $title ) ) . '" rel="permalink">' . __( 'Preview' ) . '</a>';
|
301 |
+
} elseif ( 'trash' != $post->post_status ) {
|
302 |
+
$actions['view'] = '<a href="' . get_permalink( $post->ID ) . '" title="' . esc_attr( sprintf( __( 'View “%s”' ), $title ) ) . '" rel="permalink">' . __( 'View' ) . '</a>';
|
303 |
+
}
|
304 |
+
}
|
305 |
+
|
306 |
+
return implode(' | ', $actions);
|
307 |
+
}
|
308 |
+
|
309 |
+
/**
|
310 |
+
* Get column value of Custom Field
|
311 |
+
*
|
312 |
+
* @since 1.4.6.1
|
313 |
+
*/
|
314 |
+
protected function get_column_value_authorname($post_id, $column_name)
|
315 |
+
{
|
316 |
+
$type = get_post_type($post_id);
|
317 |
+
|
318 |
+
// get column
|
319 |
+
$columns = $this->get_stored_columns($type);
|
320 |
+
|
321 |
+
// get the type of author name
|
322 |
+
$display_as = isset($columns[$column_name]['display_as']) ? $columns[$column_name]['display_as'] : '';
|
323 |
+
|
324 |
+
// get the author
|
325 |
+
$post = get_post($post_id);
|
326 |
+
if ( !isset( $post->post_author) )
|
327 |
+
return false;
|
328 |
+
|
329 |
+
$name = Codepress_Admin_Columns::get_author_field_by_nametype($display_as, $post->post_author);
|
330 |
+
|
331 |
+
// filter for customization
|
332 |
+
$name = apply_filters('cpac_get_column_value_authorname', $name, $column_name, $post_id );
|
333 |
+
|
334 |
+
// add link filter
|
335 |
+
$class = isset( $_GET['author'] ) && $_GET['author'] == $userdata->ID ? ' class="current"' : '';
|
336 |
+
|
337 |
+
$name = "<a href='edit.php?post_type={$type}&author={$post->post_author}'{$class}>{$name}</a>";
|
338 |
+
|
339 |
+
return $name;
|
340 |
+
}
|
341 |
+
}
|
342 |
+
|
343 |
?>
|
classes/values/users.php
CHANGED
@@ -1,159 +1,159 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* CPAC_Users_Values Class
|
5 |
-
*
|
6 |
-
* @since 1.4.4
|
7 |
-
*
|
8 |
-
*/
|
9 |
-
class CPAC_Users_Values extends CPAC_Values
|
10 |
-
{
|
11 |
-
/**
|
12 |
-
* Constructor
|
13 |
-
*
|
14 |
-
* @since 1.4.4
|
15 |
-
*/
|
16 |
-
function __construct()
|
17 |
-
{
|
18 |
-
parent::__construct();
|
19 |
-
|
20 |
-
add_filter( 'manage_users_custom_column', array( $this, 'manage_users_column_value'), 10, 3 );
|
21 |
-
}
|
22 |
-
|
23 |
-
/**
|
24 |
-
* Manage custom column for Users.
|
25 |
-
*
|
26 |
-
* @since 1.1
|
27 |
-
*/
|
28 |
-
public function manage_users_column_value( $value, $column_name, $user_id )
|
29 |
-
{
|
30 |
-
$type = $column_name;
|
31 |
-
|
32 |
-
$userdata = get_userdata( $user_id );
|
33 |
-
|
34 |
-
if ( ! $userdata )
|
35 |
-
return false;
|
36 |
-
|
37 |
-
// Check for user custom fields: column-meta-[customfieldname]
|
38 |
-
if ( $this->is_column_meta($type) )
|
39 |
-
$type = 'column-user-meta';
|
40 |
-
|
41 |
-
// Check for post count: column-user_postcount-[posttype]
|
42 |
-
if ( Codepress_Admin_Columns::get_posttype_by_postcount_column($type) )
|
43 |
-
$type = 'column-user_postcount';
|
44 |
-
|
45 |
-
// Hook
|
46 |
-
do_action('cpac-manage-users-column', $type, $column_name, $user_id);
|
47 |
-
|
48 |
-
$result = '';
|
49 |
-
switch ($type) :
|
50 |
-
|
51 |
-
// user id
|
52 |
-
case "column-user_id" :
|
53 |
-
$result = $user_id;
|
54 |
-
break;
|
55 |
-
|
56 |
-
// first name
|
57 |
-
case "column-nickname" :
|
58 |
-
$result = $userdata->nickname;
|
59 |
-
break;
|
60 |
-
|
61 |
-
// first name
|
62 |
-
case "column-first_name" :
|
63 |
-
$result = $userdata->first_name;
|
64 |
-
break;
|
65 |
-
|
66 |
-
// last name
|
67 |
-
case "column-last_name" :
|
68 |
-
$result = $userdata->last_name;
|
69 |
-
break;
|
70 |
-
|
71 |
-
// user url
|
72 |
-
case "column-user_url" :
|
73 |
-
$result = $userdata->user_url;
|
74 |
-
break;
|
75 |
-
|
76 |
-
// user registration date
|
77 |
-
case "column-user_registered" :
|
78 |
-
$result = $userdata->user_registered;
|
79 |
-
break;
|
80 |
-
|
81 |
-
// user description
|
82 |
-
case "column-user_description" :
|
83 |
-
$result = $this->get_shortened_string( get_the_author_meta('user_description', $user_id), $this->excerpt_length );
|
84 |
-
break;
|
85 |
-
|
86 |
-
// user description
|
87 |
-
case "column-user_postcount" :
|
88 |
-
$post_type = Codepress_Admin_Columns::get_posttype_by_postcount_column($column_name);
|
89 |
-
|
90 |
-
// get post count
|
91 |
-
$count = Codepress_Admin_Columns::get_post_count( $post_type, $user_id );
|
92 |
-
|
93 |
-
// set result
|
94 |
-
$result = $count > 0 ? "<a href='edit.php?post_type={$post_type}&author={$user_id}'>{$count}</a>" : (string) $count;
|
95 |
-
break;
|
96 |
-
|
97 |
-
// user actions
|
98 |
-
case "column-actions" :
|
99 |
-
$result = $this->get_column_value_actions($user_id, 'users');
|
100 |
-
break;
|
101 |
-
|
102 |
-
// user meta data ( custom field )
|
103 |
-
case "column-user-meta" :
|
104 |
-
$result = $this->get_column_value_custom_field($user_id, $column_name, 'user');
|
105 |
-
break;
|
106 |
-
|
107 |
-
default :
|
108 |
-
$result = $value;
|
109 |
-
|
110 |
-
endswitch;
|
111 |
-
|
112 |
-
// Filter for customizing the result output
|
113 |
-
apply_filters('cpac-users-column-result', $result, $type, $column_name, $user_id);
|
114 |
-
|
115 |
-
return $result;
|
116 |
-
}
|
117 |
-
|
118 |
-
/**
|
119 |
-
* Get column value of user actions
|
120 |
-
*
|
121 |
-
* This part is copied from the Users List Table class
|
122 |
-
*
|
123 |
-
* @since 1.4.2
|
124 |
-
*/
|
125 |
-
private function get_column_value_actions( $id )
|
126 |
-
{
|
127 |
-
$actions = array();
|
128 |
-
|
129 |
-
$user_object = new WP_User( $id );
|
130 |
-
$screen = get_current_screen();
|
131 |
-
|
132 |
-
if ( 'site-users-network' == $screen->id )
|
133 |
-
$url = "site-users.php?id={$this->site_id}&";
|
134 |
-
else
|
135 |
-
$url = 'users.php?';
|
136 |
-
|
137 |
-
if ( get_current_user_id() == $user_object->ID ) {
|
138 |
-
$edit_link = 'profile.php';
|
139 |
-
} else {
|
140 |
-
$edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( stripslashes( $_SERVER['REQUEST_URI'] ) ), "user-edit.php?user_id=$user_object->ID" ) );
|
141 |
-
}
|
142 |
-
|
143 |
-
if ( current_user_can( 'edit_user', $user_object->ID ) ) {
|
144 |
-
$edit = "<strong><a href=\"$edit_link\">$user_object->user_login</a></strong><br />";
|
145 |
-
$actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
|
146 |
-
} else {
|
147 |
-
$edit = "<strong>$user_object->user_login</strong><br />";
|
148 |
-
}
|
149 |
-
|
150 |
-
if ( !is_multisite() && get_current_user_id() != $user_object->ID && current_user_can( 'delete_user', $user_object->ID ) )
|
151 |
-
$actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url( "users.php?action=delete&user=$user_object->ID", 'bulk-users' ) . "'>" . __( 'Delete' ) . "</a>";
|
152 |
-
if ( is_multisite() && get_current_user_id() != $user_object->ID && current_user_can( 'remove_user', $user_object->ID ) )
|
153 |
-
$actions['remove'] = "<a class='submitdelete' href='" . wp_nonce_url( $url."action=remove&user=$user_object->ID", 'bulk-users' ) . "'>" . __( 'Remove' ) . "</a>";
|
154 |
-
|
155 |
-
return implode(' | ', $actions);
|
156 |
-
}
|
157 |
-
}
|
158 |
-
|
159 |
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* CPAC_Users_Values Class
|
5 |
+
*
|
6 |
+
* @since 1.4.4
|
7 |
+
*
|
8 |
+
*/
|
9 |
+
class CPAC_Users_Values extends CPAC_Values
|
10 |
+
{
|
11 |
+
/**
|
12 |
+
* Constructor
|
13 |
+
*
|
14 |
+
* @since 1.4.4
|
15 |
+
*/
|
16 |
+
function __construct()
|
17 |
+
{
|
18 |
+
parent::__construct();
|
19 |
+
|
20 |
+
add_filter( 'manage_users_custom_column', array( $this, 'manage_users_column_value'), 10, 3 );
|
21 |
+
}
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Manage custom column for Users.
|
25 |
+
*
|
26 |
+
* @since 1.1
|
27 |
+
*/
|
28 |
+
public function manage_users_column_value( $value, $column_name, $user_id )
|
29 |
+
{
|
30 |
+
$type = $column_name;
|
31 |
+
|
32 |
+
$userdata = get_userdata( $user_id );
|
33 |
+
|
34 |
+
if ( ! $userdata )
|
35 |
+
return false;
|
36 |
+
|
37 |
+
// Check for user custom fields: column-meta-[customfieldname]
|
38 |
+
if ( $this->is_column_meta($type) )
|
39 |
+
$type = 'column-user-meta';
|
40 |
+
|
41 |
+
// Check for post count: column-user_postcount-[posttype]
|
42 |
+
if ( Codepress_Admin_Columns::get_posttype_by_postcount_column($type) )
|
43 |
+
$type = 'column-user_postcount';
|
44 |
+
|
45 |
+
// Hook
|
46 |
+
do_action('cpac-manage-users-column', $type, $column_name, $user_id);
|
47 |
+
|
48 |
+
$result = '';
|
49 |
+
switch ($type) :
|
50 |
+
|
51 |
+
// user id
|
52 |
+
case "column-user_id" :
|
53 |
+
$result = $user_id;
|
54 |
+
break;
|
55 |
+
|
56 |
+
// first name
|
57 |
+
case "column-nickname" :
|
58 |
+
$result = $userdata->nickname;
|
59 |
+
break;
|
60 |
+
|
61 |
+
// first name
|
62 |
+
case "column-first_name" :
|
63 |
+
$result = $userdata->first_name;
|
64 |
+
break;
|
65 |
+
|
66 |
+
// last name
|
67 |
+
case "column-last_name" :
|
68 |
+
$result = $userdata->last_name;
|
69 |
+
break;
|
70 |
+
|
71 |
+
// user url
|
72 |
+
case "column-user_url" :
|
73 |
+
$result = $userdata->user_url;
|
74 |
+
break;
|
75 |
+
|
76 |
+
// user registration date
|
77 |
+
case "column-user_registered" :
|
78 |
+
$result = $userdata->user_registered;
|
79 |
+
break;
|
80 |
+
|
81 |
+
// user description
|
82 |
+
case "column-user_description" :
|
83 |
+
$result = $this->get_shortened_string( get_the_author_meta('user_description', $user_id), $this->excerpt_length );
|
84 |
+
break;
|
85 |
+
|
86 |
+
// user description
|
87 |
+
case "column-user_postcount" :
|
88 |
+
$post_type = Codepress_Admin_Columns::get_posttype_by_postcount_column($column_name);
|
89 |
+
|
90 |
+
// get post count
|
91 |
+
$count = Codepress_Admin_Columns::get_post_count( $post_type, $user_id );
|
92 |
+
|
93 |
+
// set result
|
94 |
+
$result = $count > 0 ? "<a href='edit.php?post_type={$post_type}&author={$user_id}'>{$count}</a>" : (string) $count;
|
95 |
+
break;
|
96 |
+
|
97 |
+
// user actions
|
98 |
+
case "column-actions" :
|
99 |
+
$result = $this->get_column_value_actions($user_id, 'users');
|
100 |
+
break;
|
101 |
+
|
102 |
+
// user meta data ( custom field )
|
103 |
+
case "column-user-meta" :
|
104 |
+
$result = $this->get_column_value_custom_field($user_id, $column_name, 'user');
|
105 |
+
break;
|
106 |
+
|
107 |
+
default :
|
108 |
+
$result = $value;
|
109 |
+
|
110 |
+
endswitch;
|
111 |
+
|
112 |
+
// Filter for customizing the result output
|
113 |
+
apply_filters('cpac-users-column-result', $result, $type, $column_name, $user_id);
|
114 |
+
|
115 |
+
return $result;
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Get column value of user actions
|
120 |
+
*
|
121 |
+
* This part is copied from the Users List Table class
|
122 |
+
*
|
123 |
+
* @since 1.4.2
|
124 |
+
*/
|
125 |
+
private function get_column_value_actions( $id )
|
126 |
+
{
|
127 |
+
$actions = array();
|
128 |
+
|
129 |
+
$user_object = new WP_User( $id );
|
130 |
+
$screen = get_current_screen();
|
131 |
+
|
132 |
+
if ( 'site-users-network' == $screen->id )
|
133 |
+
$url = "site-users.php?id={$this->site_id}&";
|
134 |
+
else
|
135 |
+
$url = 'users.php?';
|
136 |
+
|
137 |
+
if ( get_current_user_id() == $user_object->ID ) {
|
138 |
+
$edit_link = 'profile.php';
|
139 |
+
} else {
|
140 |
+
$edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( stripslashes( $_SERVER['REQUEST_URI'] ) ), "user-edit.php?user_id=$user_object->ID" ) );
|
141 |
+
}
|
142 |
+
|
143 |
+
if ( current_user_can( 'edit_user', $user_object->ID ) ) {
|
144 |
+
$edit = "<strong><a href=\"$edit_link\">$user_object->user_login</a></strong><br />";
|
145 |
+
$actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
|
146 |
+
} else {
|
147 |
+
$edit = "<strong>$user_object->user_login</strong><br />";
|
148 |
+
}
|
149 |
+
|
150 |
+
if ( !is_multisite() && get_current_user_id() != $user_object->ID && current_user_can( 'delete_user', $user_object->ID ) )
|
151 |
+
$actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url( "users.php?action=delete&user=$user_object->ID", 'bulk-users' ) . "'>" . __( 'Delete' ) . "</a>";
|
152 |
+
if ( is_multisite() && get_current_user_id() != $user_object->ID && current_user_can( 'remove_user', $user_object->ID ) )
|
153 |
+
$actions['remove'] = "<a class='submitdelete' href='" . wp_nonce_url( $url."action=remove&user=$user_object->ID", 'bulk-users' ) . "'>" . __( 'Remove' ) . "</a>";
|
154 |
+
|
155 |
+
return implode(' | ', $actions);
|
156 |
+
}
|
157 |
+
}
|
158 |
+
|
159 |
?>
|
codepress-admin-columns.php
CHANGED
@@ -1,2610 +1,2671 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
|
4 |
-
Plugin Name: Codepress Admin Columns
|
5 |
-
Version: 1.4.
|
6 |
-
Description: Customise columns on the administration screens for post(types), pages, media, comments, links and users with an easy to use drag-and-drop interface.
|
7 |
-
Author: Codepress
|
8 |
-
Author URI: http://www.codepress.nl
|
9 |
-
Plugin URI: http://www.codepress.nl/plugins/codepress-admin-columns/
|
10 |
-
Text Domain: codepress-admin-columns
|
11 |
-
Domain Path: /languages
|
12 |
-
License: GPLv2
|
13 |
-
|
14 |
-
Copyright 2011-2012 Codepress info@codepress.nl
|
15 |
-
|
16 |
-
This program is free software; you can redistribute it and/or modify
|
17 |
-
it under the terms of the GNU General Public License version 2 as published by
|
18 |
-
the Free Software Foundation.
|
19 |
-
|
20 |
-
This program is distributed in the hope that it will be useful,
|
21 |
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
22 |
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
23 |
-
GNU General Public License for more details.
|
24 |
-
|
25 |
-
You should have received a copy of the GNU General Public License
|
26 |
-
along with this program; if not, write to the Free Software
|
27 |
-
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
28 |
-
*/
|
29 |
-
|
30 |
-
define( 'CPAC_VERSION', '1.4.
|
31 |
-
define( 'CPAC_TEXTDOMAIN', 'codepress-admin-columns' );
|
32 |
-
define( 'CPAC_SLUG', 'codepress-admin-columns' );
|
33 |
-
define( 'CPAC_URL', plugins_url('', __FILE__) );
|
34 |
-
|
35 |
-
// only run plugin in the admin interface
|
36 |
-
if ( !is_admin() )
|
37 |
-
return false;
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Dependencies
|
41 |
-
*
|
42 |
-
* @since 1.3
|
43 |
-
*/
|
44 |
-
require_once dirname( __FILE__ ) . '/classes/utility.php';
|
45 |
-
require_once dirname( __FILE__ ) . '/classes/sortable.php';
|
46 |
-
require_once dirname( __FILE__ ) . '/classes/values.php';
|
47 |
-
require_once dirname( __FILE__ ) . '/classes/values/posts.php';
|
48 |
-
require_once dirname( __FILE__ ) . '/classes/values/users.php';
|
49 |
-
require_once dirname( __FILE__ ) . '/classes/values/media.php';
|
50 |
-
require_once dirname( __FILE__ ) . '/classes/values/link.php';
|
51 |
-
require_once dirname( __FILE__ ) . '/classes/values/comments.php';
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
*
|
56 |
-
*
|
57 |
-
*
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
$
|
64 |
-
$
|
65 |
-
$
|
66 |
-
$
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
*
|
71 |
-
*
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
*
|
84 |
-
*
|
85 |
-
*
|
86 |
-
*
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
$this->
|
96 |
-
$this->
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
add_action( '
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
add_action( 'admin_init', array( $this, '
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
*
|
130 |
-
*
|
131 |
-
*
|
132 |
-
*
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
add_action( "
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
*
|
163 |
-
*
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
*
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
new
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
*
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
/**
|
210 |
-
add_filter( "
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
if ( $
|
342 |
-
foreach ( $
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
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 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
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 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
$
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
$
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
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 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
'
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
)
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
*
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
$
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
$
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
}
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
*
|
791 |
-
*
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
//
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
$
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
*
|
912 |
-
*
|
913 |
-
* @since 1.
|
914 |
-
*/
|
915 |
-
public function
|
916 |
-
{
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
|
1047 |
-
|
1048 |
-
|
1049 |
-
|
1050 |
-
|
1051 |
-
|
1052 |
-
|
1053 |
-
|
1054 |
-
|
1055 |
-
|
1056 |
-
|
1057 |
-
|
1058 |
-
|
1059 |
-
|
1060 |
-
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
1084 |
-
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
-
|
1118 |
-
|
1119 |
-
|
1120 |
-
|
1121 |
-
|
1122 |
-
|
1123 |
-
|
1124 |
-
|
1125 |
-
|
1126 |
-
|
1127 |
-
|
1128 |
-
|
1129 |
-
|
1130 |
-
|
1131 |
-
|
1132 |
-
|
1133 |
-
|
1134 |
-
|
1135 |
-
|
1136 |
-
|
1137 |
-
|
1138 |
-
|
1139 |
-
|
1140 |
-
|
1141 |
-
|
1142 |
-
|
1143 |
-
|
1144 |
-
|
1145 |
-
|
1146 |
-
|
1147 |
-
|
1148 |
-
|
1149 |
-
|
1150 |
-
|
1151 |
-
*
|
1152 |
-
|
1153 |
-
|
1154 |
-
|
1155 |
-
|
1156 |
-
|
1157 |
-
|
1158 |
-
|
1159 |
-
|
1160 |
-
|
1161 |
-
|
1162 |
-
|
1163 |
-
|
1164 |
-
|
1165 |
-
|
1166 |
-
|
1167 |
-
*
|
1168 |
-
|
1169 |
-
|
1170 |
-
|
1171 |
-
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
|
1177 |
-
|
1178 |
-
|
1179 |
-
|
1180 |
-
|
1181 |
-
|
1182 |
-
|
1183 |
-
|
1184 |
-
|
1185 |
-
|
1186 |
-
|
1187 |
-
|
1188 |
-
|
1189 |
-
|
1190 |
-
|
1191 |
-
|
1192 |
-
|
1193 |
-
|
1194 |
-
|
1195 |
-
|
1196 |
-
|
1197 |
-
//
|
1198 |
-
|
1199 |
-
|
1200 |
-
|
1201 |
-
|
1202 |
-
|
1203 |
-
|
1204 |
-
|
1205 |
-
|
1206 |
-
|
1207 |
-
|
1208 |
-
|
1209 |
-
|
1210 |
-
|
1211 |
-
|
1212 |
-
|
1213 |
-
|
1214 |
-
|
1215 |
-
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
1219 |
-
|
1220 |
-
|
1221 |
-
|
1222 |
-
|
1223 |
-
|
1224 |
-
|
1225 |
-
|
1226 |
-
|
1227 |
-
|
1228 |
-
|
1229 |
-
|
1230 |
-
|
1231 |
-
|
1232 |
-
|
1233 |
-
|
1234 |
-
|
1235 |
-
|
1236 |
-
|
1237 |
-
|
1238 |
-
|
1239 |
-
|
1240 |
-
|
1241 |
-
|
1242 |
-
|
1243 |
-
|
1244 |
-
|
1245 |
-
|
1246 |
-
|
1247 |
-
|
1248 |
-
|
1249 |
-
|
1250 |
-
|
1251 |
-
|
1252 |
-
|
1253 |
-
|
1254 |
-
|
1255 |
-
|
1256 |
-
|
1257 |
-
|
1258 |
-
|
1259 |
-
|
1260 |
-
|
1261 |
-
|
1262 |
-
|
1263 |
-
|
1264 |
-
|
1265 |
-
|
1266 |
-
|
1267 |
-
|
1268 |
-
|
1269 |
-
|
1270 |
-
|
1271 |
-
|
1272 |
-
|
1273 |
-
|
1274 |
-
|
1275 |
-
'
|
1276 |
-
|
1277 |
-
|
1278 |
-
|
1279 |
-
|
1280 |
-
|
1281 |
-
|
1282 |
-
|
1283 |
-
|
1284 |
-
|
1285 |
-
|
1286 |
-
|
1287 |
-
|
1288 |
-
|
1289 |
-
)
|
1290 |
-
|
1291 |
-
|
1292 |
-
|
1293 |
-
|
1294 |
-
|
1295 |
-
|
1296 |
-
'
|
1297 |
-
|
1298 |
-
|
1299 |
-
|
1300 |
-
|
1301 |
-
|
1302 |
-
|
1303 |
-
|
1304 |
-
|
1305 |
-
|
1306 |
-
|
1307 |
-
|
1308 |
-
|
1309 |
-
|
1310 |
-
)
|
1311 |
-
|
1312 |
-
|
1313 |
-
|
1314 |
-
|
1315 |
-
|
1316 |
-
|
1317 |
-
|
1318 |
-
|
1319 |
-
|
1320 |
-
|
1321 |
-
|
1322 |
-
|
1323 |
-
|
1324 |
-
|
1325 |
-
|
1326 |
-
|
1327 |
-
|
1328 |
-
|
1329 |
-
|
1330 |
-
|
1331 |
-
|
1332 |
-
|
1333 |
-
|
1334 |
-
|
1335 |
-
|
1336 |
-
|
1337 |
-
|
1338 |
-
|
1339 |
-
|
1340 |
-
|
1341 |
-
|
1342 |
-
|
1343 |
-
|
1344 |
-
|
1345 |
-
|
1346 |
-
|
1347 |
-
|
1348 |
-
|
1349 |
-
|
1350 |
-
|
1351 |
-
|
1352 |
-
|
1353 |
-
|
1354 |
-
|
1355 |
-
|
1356 |
-
|
1357 |
-
|
1358 |
-
|
1359 |
-
|
1360 |
-
|
1361 |
-
|
1362 |
-
|
1363 |
-
|
1364 |
-
|
1365 |
-
|
1366 |
-
|
1367 |
-
|
1368 |
-
|
1369 |
-
|
1370 |
-
|
1371 |
-
|
1372 |
-
|
1373 |
-
|
1374 |
-
|
1375 |
-
|
1376 |
-
|
1377 |
-
|
1378 |
-
|
1379 |
-
|
1380 |
-
|
1381 |
-
|
1382 |
-
|
1383 |
-
|
1384 |
-
|
1385 |
-
|
1386 |
-
|
1387 |
-
|
1388 |
-
|
1389 |
-
|
1390 |
-
|
1391 |
-
|
1392 |
-
|
1393 |
-
|
1394 |
-
|
1395 |
-
|
1396 |
-
|
1397 |
-
|
1398 |
-
|
1399 |
-
|
1400 |
-
|
1401 |
-
|
1402 |
-
|
1403 |
-
|
1404 |
-
|
1405 |
-
|
1406 |
-
|
1407 |
-
|
1408 |
-
|
1409 |
-
|
1410 |
-
|
1411 |
-
|
1412 |
-
|
1413 |
-
|
1414 |
-
|
1415 |
-
|
1416 |
-
|
1417 |
-
|
1418 |
-
|
1419 |
-
|
1420 |
-
|
1421 |
-
|
1422 |
-
|
1423 |
-
|
1424 |
-
|
1425 |
-
|
1426 |
-
|
1427 |
-
|
1428 |
-
|
1429 |
-
|
1430 |
-
|
1431 |
-
|
1432 |
-
'
|
1433 |
-
|
1434 |
-
|
1435 |
-
|
1436 |
-
|
1437 |
-
|
1438 |
-
|
1439 |
-
|
1440 |
-
|
1441 |
-
|
1442 |
-
|
1443 |
-
|
1444 |
-
|
1445 |
-
|
1446 |
-
|
1447 |
-
|
1448 |
-
|
1449 |
-
|
1450 |
-
|
1451 |
-
|
1452 |
-
|
1453 |
-
|
1454 |
-
|
1455 |
-
|
1456 |
-
|
1457 |
-
|
1458 |
-
'
|
1459 |
-
)
|
1460 |
-
|
1461 |
-
|
1462 |
-
//
|
1463 |
-
$
|
1464 |
-
|
1465 |
-
|
1466 |
-
|
1467 |
-
|
1468 |
-
|
1469 |
-
|
1470 |
-
|
1471 |
-
|
1472 |
-
|
1473 |
-
|
1474 |
-
|
1475 |
-
|
1476 |
-
|
1477 |
-
|
1478 |
-
|
1479 |
-
|
1480 |
-
|
1481 |
-
|
1482 |
-
|
1483 |
-
|
1484 |
-
|
1485 |
-
|
1486 |
-
|
1487 |
-
|
1488 |
-
'column-
|
1489 |
-
'label' => __('
|
1490 |
-
)
|
1491 |
-
|
1492 |
-
|
1493 |
-
|
1494 |
-
|
1495 |
-
|
1496 |
-
)
|
1497 |
-
|
1498 |
-
|
1499 |
-
|
1500 |
-
|
1501 |
-
|
1502 |
-
|
1503 |
-
|
1504 |
-
|
1505 |
-
|
1506 |
-
|
1507 |
-
|
1508 |
-
|
1509 |
-
|
1510 |
-
|
1511 |
-
|
1512 |
-
|
1513 |
-
|
1514 |
-
|
1515 |
-
|
1516 |
-
'
|
1517 |
-
|
1518 |
-
|
1519 |
-
|
1520 |
-
|
1521 |
-
|
1522 |
-
|
1523 |
-
|
1524 |
-
|
1525 |
-
|
1526 |
-
|
1527 |
-
|
1528 |
-
|
1529 |
-
|
1530 |
-
|
1531 |
-
|
1532 |
-
|
1533 |
-
|
1534 |
-
|
1535 |
-
|
1536 |
-
|
1537 |
-
|
1538 |
-
|
1539 |
-
|
1540 |
-
|
1541 |
-
|
1542 |
-
'
|
1543 |
-
|
1544 |
-
|
1545 |
-
|
1546 |
-
|
1547 |
-
|
1548 |
-
'
|
1549 |
-
|
1550 |
-
|
1551 |
-
|
1552 |
-
|
1553 |
-
|
1554 |
-
'
|
1555 |
-
|
1556 |
-
|
1557 |
-
|
1558 |
-
|
1559 |
-
|
1560 |
-
'
|
1561 |
-
|
1562 |
-
'
|
1563 |
-
|
1564 |
-
|
1565 |
-
|
1566 |
-
|
1567 |
-
|
1568 |
-
|
1569 |
-
|
1570 |
-
|
1571 |
-
),
|
1572 |
-
'
|
1573 |
-
'
|
1574 |
-
|
1575 |
-
|
1576 |
-
|
1577 |
-
|
1578 |
-
|
1579 |
-
|
1580 |
-
|
1581 |
-
|
1582 |
-
|
1583 |
-
|
1584 |
-
|
1585 |
-
|
1586 |
-
|
1587 |
-
|
1588 |
-
|
1589 |
-
|
1590 |
-
|
1591 |
-
|
1592 |
-
|
1593 |
-
|
1594 |
-
|
1595 |
-
|
1596 |
-
|
1597 |
-
|
1598 |
-
|
1599 |
-
|
1600 |
-
|
1601 |
-
|
1602 |
-
|
1603 |
-
|
1604 |
-
|
1605 |
-
|
1606 |
-
|
1607 |
-
|
1608 |
-
|
1609 |
-
|
1610 |
-
|
1611 |
-
|
1612 |
-
|
1613 |
-
|
1614 |
-
|
1615 |
-
|
1616 |
-
|
1617 |
-
|
1618 |
-
|
1619 |
-
|
1620 |
-
|
1621 |
-
|
1622 |
-
|
1623 |
-
|
1624 |
-
|
1625 |
-
|
1626 |
-
|
1627 |
-
|
1628 |
-
|
1629 |
-
|
1630 |
-
|
1631 |
-
|
1632 |
-
|
1633 |
-
|
1634 |
-
|
1635 |
-
|
1636 |
-
|
1637 |
-
|
1638 |
-
|
1639 |
-
|
1640 |
-
|
1641 |
-
|
1642 |
-
|
1643 |
-
|
1644 |
-
|
1645 |
-
|
1646 |
-
|
1647 |
-
|
1648 |
-
|
1649 |
-
|
1650 |
-
|
1651 |
-
|
1652 |
-
|
1653 |
-
|
1654 |
-
|
1655 |
-
|
1656 |
-
|
1657 |
-
|
1658 |
-
|
1659 |
-
|
1660 |
-
|
1661 |
-
|
1662 |
-
|
1663 |
-
|
1664 |
-
|
1665 |
-
|
1666 |
-
|
1667 |
-
|
1668 |
-
|
1669 |
-
|
1670 |
-
|
1671 |
-
|
1672 |
-
|
1673 |
-
|
1674 |
-
|
1675 |
-
|
1676 |
-
|
1677 |
-
|
1678 |
-
|
1679 |
-
|
1680 |
-
|
1681 |
-
|
1682 |
-
|
1683 |
-
|
1684 |
-
|
1685 |
-
|
1686 |
-
|
1687 |
-
|
1688 |
-
|
1689 |
-
|
1690 |
-
|
1691 |
-
|
1692 |
-
|
1693 |
-
|
1694 |
-
|
1695 |
-
|
1696 |
-
|
1697 |
-
|
1698 |
-
|
1699 |
-
|
1700 |
-
|
1701 |
-
|
1702 |
-
|
1703 |
-
|
1704 |
-
|
1705 |
-
|
1706 |
-
|
1707 |
-
|
1708 |
-
|
1709 |
-
|
1710 |
-
|
1711 |
-
|
1712 |
-
|
1713 |
-
|
1714 |
-
|
1715 |
-
|
1716 |
-
|
1717 |
-
|
1718 |
-
|
1719 |
-
'
|
1720 |
-
'
|
1721 |
-
'
|
1722 |
-
'
|
1723 |
-
'
|
1724 |
-
|
1725 |
-
'
|
1726 |
-
'
|
1727 |
-
)
|
1728 |
-
);
|
1729 |
-
}
|
1730 |
-
|
1731 |
-
// merge with defaults
|
1732 |
-
$custom_columns = $this->parse_defaults($custom_columns);
|
1733 |
-
|
1734 |
-
return apply_filters('cpac-custom-
|
1735 |
-
}
|
1736 |
-
|
1737 |
-
/**
|
1738 |
-
*
|
1739 |
-
*
|
1740 |
-
* @since 1.1
|
1741 |
-
*/
|
1742 |
-
private function
|
1743 |
-
{
|
1744 |
-
|
1745 |
-
|
1746 |
-
|
1747 |
-
|
1748 |
-
'
|
1749 |
-
|
1750 |
-
|
1751 |
-
'
|
1752 |
-
|
1753 |
-
|
1754 |
-
'
|
1755 |
-
'
|
1756 |
-
|
1757 |
-
|
1758 |
-
'
|
1759 |
-
)
|
1760 |
-
|
1761 |
-
|
1762 |
-
|
1763 |
-
|
1764 |
-
|
1765 |
-
|
1766 |
-
|
1767 |
-
|
1768 |
-
|
1769 |
-
|
1770 |
-
|
1771 |
-
|
1772 |
-
|
1773 |
-
|
1774 |
-
|
1775 |
-
|
1776 |
-
|
1777 |
-
|
1778 |
-
|
1779 |
-
|
1780 |
-
|
1781 |
-
|
1782 |
-
|
1783 |
-
|
1784 |
-
|
1785 |
-
|
1786 |
-
|
1787 |
-
|
1788 |
-
|
1789 |
-
|
1790 |
-
|
1791 |
-
|
1792 |
-
|
1793 |
-
|
1794 |
-
|
1795 |
-
|
1796 |
-
|
1797 |
-
|
1798 |
-
|
1799 |
-
|
1800 |
-
|
1801 |
-
|
1802 |
-
|
1803 |
-
|
1804 |
-
|
1805 |
-
|
1806 |
-
|
1807 |
-
|
1808 |
-
|
1809 |
-
|
1810 |
-
|
1811 |
-
|
1812 |
-
|
1813 |
-
|
1814 |
-
|
1815 |
-
|
1816 |
-
|
1817 |
-
|
1818 |
-
|
1819 |
-
|
1820 |
-
|
1821 |
-
|
1822 |
-
|
1823 |
-
|
1824 |
-
|
1825 |
-
|
1826 |
-
|
1827 |
-
|
1828 |
-
|
1829 |
-
|
1830 |
-
|
1831 |
-
|
1832 |
-
|
1833 |
-
|
1834 |
-
|
1835 |
-
|
1836 |
-
|
1837 |
-
|
1838 |
-
|
1839 |
-
|
1840 |
-
|
1841 |
-
|
1842 |
-
|
1843 |
-
|
1844 |
-
|
1845 |
-
|
1846 |
-
|
1847 |
-
|
1848 |
-
|
1849 |
-
|
1850 |
-
|
1851 |
-
|
1852 |
-
|
1853 |
-
|
1854 |
-
|
1855 |
-
|
1856 |
-
|
1857 |
-
|
1858 |
-
|
1859 |
-
|
1860 |
-
|
1861 |
-
|
1862 |
-
|
1863 |
-
|
1864 |
-
|
1865 |
-
|
1866 |
-
|
1867 |
-
|
1868 |
-
|
1869 |
-
|
1870 |
-
|
1871 |
-
|
1872 |
-
|
1873 |
-
|
1874 |
-
|
1875 |
-
|
1876 |
-
|
1877 |
-
|
1878 |
-
|
1879 |
-
|
1880 |
-
|
1881 |
-
|
1882 |
-
|
1883 |
-
|
1884 |
-
|
1885 |
-
|
1886 |
-
|
1887 |
-
|
1888 |
-
|
1889 |
-
|
1890 |
-
//
|
1891 |
-
|
1892 |
-
$
|
1893 |
-
|
1894 |
-
|
1895 |
-
|
1896 |
-
|
1897 |
-
|
1898 |
-
|
1899 |
-
|
1900 |
-
|
1901 |
-
|
1902 |
-
|
1903 |
-
|
1904 |
-
|
1905 |
-
|
1906 |
-
|
1907 |
-
|
1908 |
-
*
|
1909 |
-
*
|
1910 |
-
|
1911 |
-
|
1912 |
-
|
1913 |
-
|
1914 |
-
$
|
1915 |
-
|
1916 |
-
|
1917 |
-
|
1918 |
-
|
1919 |
-
|
1920 |
-
|
1921 |
-
|
1922 |
-
|
1923 |
-
|
1924 |
-
*
|
1925 |
-
|
1926 |
-
|
1927 |
-
|
1928 |
-
|
1929 |
-
|
1930 |
-
|
1931 |
-
|
1932 |
-
|
1933 |
-
|
1934 |
-
|
1935 |
-
|
1936 |
-
|
1937 |
-
|
1938 |
-
|
1939 |
-
|
1940 |
-
|
1941 |
-
|
1942 |
-
|
1943 |
-
|
1944 |
-
|
1945 |
-
|
1946 |
-
$
|
1947 |
-
|
1948 |
-
|
1949 |
-
|
1950 |
-
|
1951 |
-
|
1952 |
-
|
1953 |
-
|
1954 |
-
|
1955 |
-
|
1956 |
-
|
1957 |
-
|
1958 |
-
|
1959 |
-
|
1960 |
-
$
|
1961 |
-
|
1962 |
-
|
1963 |
-
|
1964 |
-
|
1965 |
-
|
1966 |
-
|
1967 |
-
|
1968 |
-
|
1969 |
-
|
1970 |
-
|
1971 |
-
|
1972 |
-
|
1973 |
-
|
1974 |
-
|
1975 |
-
|
1976 |
-
|
1977 |
-
|
1978 |
-
|
1979 |
-
|
1980 |
-
|
1981 |
-
|
1982 |
-
|
1983 |
-
|
1984 |
-
|
1985 |
-
|
1986 |
-
|
1987 |
-
|
1988 |
-
|
1989 |
-
|
1990 |
-
|
1991 |
-
|
1992 |
-
|
1993 |
-
|
1994 |
-
|
1995 |
-
|
1996 |
-
|
1997 |
-
|
1998 |
-
|
1999 |
-
|
2000 |
-
return
|
2001 |
-
|
2002 |
-
|
2003 |
-
|
2004 |
-
|
2005 |
-
|
2006 |
-
|
2007 |
-
|
2008 |
-
|
2009 |
-
|
2010 |
-
|
2011 |
-
|
2012 |
-
|
2013 |
-
|
2014 |
-
|
2015 |
-
|
2016 |
-
|
2017 |
-
|
2018 |
-
|
2019 |
-
|
2020 |
-
|
2021 |
-
|
2022 |
-
|
2023 |
-
|
2024 |
-
|
2025 |
-
|
2026 |
-
|
2027 |
-
|
2028 |
-
|
2029 |
-
|
2030 |
-
|
2031 |
-
|
2032 |
-
|
2033 |
-
|
2034 |
-
|
2035 |
-
|
2036 |
-
|
2037 |
-
|
2038 |
-
|
2039 |
-
|
2040 |
-
|
2041 |
-
|
2042 |
-
|
2043 |
-
|
2044 |
-
|
2045 |
-
|
2046 |
-
|
2047 |
-
|
2048 |
-
|
2049 |
-
|
2050 |
-
|
2051 |
-
|
2052 |
-
*
|
2053 |
-
|
2054 |
-
|
2055 |
-
|
2056 |
-
|
2057 |
-
|
2058 |
-
|
2059 |
-
|
2060 |
-
|
2061 |
-
|
2062 |
-
$
|
2063 |
-
|
2064 |
-
|
2065 |
-
|
2066 |
-
|
2067 |
-
|
2068 |
-
|
2069 |
-
|
2070 |
-
|
2071 |
-
|
2072 |
-
|
2073 |
-
|
2074 |
-
|
2075 |
-
|
2076 |
-
|
2077 |
-
}
|
2078 |
-
|
2079 |
-
/**
|
2080 |
-
*
|
2081 |
-
*
|
2082 |
-
*
|
2083 |
-
|
2084 |
-
|
2085 |
-
|
2086 |
-
|
2087 |
-
|
2088 |
-
|
2089 |
-
|
2090 |
-
|
2091 |
-
|
2092 |
-
|
2093 |
-
|
2094 |
-
|
2095 |
-
|
2096 |
-
|
2097 |
-
|
2098 |
-
|
2099 |
-
|
2100 |
-
|
2101 |
-
|
2102 |
-
|
2103 |
-
|
2104 |
-
|
2105 |
-
|
2106 |
-
|
2107 |
-
|
2108 |
-
|
2109 |
-
|
2110 |
-
|
2111 |
-
|
2112 |
-
|
2113 |
-
|
2114 |
-
|
2115 |
-
|
2116 |
-
|
2117 |
-
|
2118 |
-
|
2119 |
-
|
2120 |
-
|
2121 |
-
|
2122 |
-
|
2123 |
-
|
2124 |
-
|
2125 |
-
|
2126 |
-
|
2127 |
-
|
2128 |
-
|
2129 |
-
|
2130 |
-
|
2131 |
-
|
2132 |
-
|
2133 |
-
|
2134 |
-
|
2135 |
-
|
2136 |
-
|
2137 |
-
|
2138 |
-
|
2139 |
-
|
2140 |
-
|
2141 |
-
|
2142 |
-
|
2143 |
-
|
2144 |
-
|
2145 |
-
|
2146 |
-
|
2147 |
-
|
2148 |
-
|
2149 |
-
|
2150 |
-
|
2151 |
-
|
2152 |
-
|
2153 |
-
|
2154 |
-
|
2155 |
-
|
2156 |
-
|
2157 |
-
|
2158 |
-
|
2159 |
-
|
2160 |
-
|
2161 |
-
|
2162 |
-
|
2163 |
-
|
2164 |
-
|
2165 |
-
|
2166 |
-
|
2167 |
-
|
2168 |
-
|
2169 |
-
|
2170 |
-
|
2171 |
-
|
2172 |
-
|
2173 |
-
|
2174 |
-
|
2175 |
-
|
2176 |
-
|
2177 |
-
|
2178 |
-
|
2179 |
-
|
2180 |
-
|
2181 |
-
|
2182 |
-
|
2183 |
-
|
2184 |
-
|
2185 |
-
|
2186 |
-
|
2187 |
-
|
2188 |
-
|
2189 |
-
|
2190 |
-
|
2191 |
-
|
2192 |
-
|
2193 |
-
|
2194 |
-
|
2195 |
-
|
2196 |
-
|
2197 |
-
|
2198 |
-
|
2199 |
-
|
2200 |
-
|
2201 |
-
|
2202 |
-
|
2203 |
-
|
2204 |
-
|
2205 |
-
|
2206 |
-
|
2207 |
-
|
2208 |
-
|
2209 |
-
|
2210 |
-
|
2211 |
-
|
2212 |
-
|
2213 |
-
|
2214 |
-
|
2215 |
-
|
2216 |
-
|
2217 |
-
|
2218 |
-
|
2219 |
-
|
2220 |
-
|
2221 |
-
|
2222 |
-
|
2223 |
-
|
2224 |
-
|
2225 |
-
|
2226 |
-
|
2227 |
-
|
2228 |
-
|
2229 |
-
|
2230 |
-
|
2231 |
-
)
|
2232 |
-
|
2233 |
-
|
2234 |
-
|
2235 |
-
|
2236 |
-
|
2237 |
-
|
2238 |
-
|
2239 |
-
|
2240 |
-
|
2241 |
-
|
2242 |
-
|
2243 |
-
|
2244 |
-
|
2245 |
-
|
2246 |
-
|
2247 |
-
|
2248 |
-
|
2249 |
-
|
2250 |
-
|
2251 |
-
|
2252 |
-
|
2253 |
-
|
2254 |
-
|
2255 |
-
|
2256 |
-
|
2257 |
-
'
|
2258 |
-
|
2259 |
-
|
2260 |
-
|
2261 |
-
|
2262 |
-
|
2263 |
-
|
2264 |
-
|
2265 |
-
|
2266 |
-
|
2267 |
-
|
2268 |
-
|
2269 |
-
|
2270 |
-
|
2271 |
-
|
2272 |
-
|
2273 |
-
|
2274 |
-
|
2275 |
-
|
2276 |
-
|
2277 |
-
|
2278 |
-
|
2279 |
-
|
2280 |
-
|
2281 |
-
|
2282 |
-
|
2283 |
-
|
2284 |
-
|
2285 |
-
|
2286 |
-
|
2287 |
-
|
2288 |
-
|
2289 |
-
|
2290 |
-
|
2291 |
-
|
2292 |
-
|
2293 |
-
|
2294 |
-
|
2295 |
-
|
2296 |
-
|
2297 |
-
|
2298 |
-
|
2299 |
-
|
2300 |
-
|
2301 |
-
|
2302 |
-
|
2303 |
-
|
2304 |
-
|
2305 |
-
|
2306 |
-
|
2307 |
-
|
2308 |
-
|
2309 |
-
|
2310 |
-
|
2311 |
-
|
2312 |
-
|
2313 |
-
|
2314 |
-
|
2315 |
-
|
2316 |
-
|
2317 |
-
|
2318 |
-
|
2319 |
-
|
2320 |
-
|
2321 |
-
|
2322 |
-
|
2323 |
-
|
2324 |
-
|
2325 |
-
|
2326 |
-
|
2327 |
-
|
2328 |
-
|
2329 |
-
|
2330 |
-
|
2331 |
-
//
|
2332 |
-
$
|
2333 |
-
|
2334 |
-
|
2335 |
-
|
2336 |
-
|
2337 |
-
|
2338 |
-
|
2339 |
-
|
2340 |
-
|
2341 |
-
|
2342 |
-
|
2343 |
-
|
2344 |
-
|
2345 |
-
|
2346 |
-
|
2347 |
-
|
2348 |
-
|
2349 |
-
|
2350 |
-
|
2351 |
-
|
2352 |
-
|
2353 |
-
|
2354 |
-
|
2355 |
-
|
2356 |
-
|
2357 |
-
|
2358 |
-
</
|
2359 |
-
|
2360 |
-
|
2361 |
-
|
2362 |
-
|
2363 |
-
|
2364 |
-
<
|
2365 |
-
|
2366 |
-
|
2367 |
-
|
2368 |
-
|
2369 |
-
|
2370 |
-
|
2371 |
-
|
2372 |
-
|
2373 |
-
|
2374 |
-
|
2375 |
-
|
2376 |
-
|
2377 |
-
|
2378 |
-
|
2379 |
-
|
2380 |
-
|
2381 |
-
|
2382 |
-
|
2383 |
-
|
2384 |
-
|
2385 |
-
|
2386 |
-
|
2387 |
-
|
2388 |
-
|
2389 |
-
|
2390 |
-
|
2391 |
-
|
2392 |
-
|
2393 |
-
|
2394 |
-
|
2395 |
-
|
2396 |
-
|
2397 |
-
|
2398 |
-
|
2399 |
-
|
2400 |
-
|
2401 |
-
|
2402 |
-
|
2403 |
-
|
2404 |
-
|
2405 |
-
|
2406 |
-
|
2407 |
-
|
2408 |
-
|
2409 |
-
|
2410 |
-
|
2411 |
-
|
2412 |
-
|
2413 |
-
|
2414 |
-
|
2415 |
-
|
2416 |
-
|
2417 |
-
|
2418 |
-
|
2419 |
-
|
2420 |
-
|
2421 |
-
|
2422 |
-
|
2423 |
-
|
2424 |
-
|
2425 |
-
|
2426 |
-
|
2427 |
-
|
2428 |
-
|
2429 |
-
|
2430 |
-
|
2431 |
-
|
2432 |
-
|
2433 |
-
|
2434 |
-
|
2435 |
-
|
2436 |
-
|
2437 |
-
|
2438 |
-
|
2439 |
-
|
2440 |
-
|
2441 |
-
|
2442 |
-
|
2443 |
-
|
2444 |
-
|
2445 |
-
|
2446 |
-
|
2447 |
-
|
2448 |
-
|
2449 |
-
|
2450 |
-
|
2451 |
-
|
2452 |
-
|
2453 |
-
|
2454 |
-
|
2455 |
-
|
2456 |
-
|
2457 |
-
|
2458 |
-
|
2459 |
-
|
2460 |
-
|
2461 |
-
|
2462 |
-
|
2463 |
-
|
2464 |
-
|
2465 |
-
$
|
2466 |
-
|
2467 |
-
|
2468 |
-
|
2469 |
-
|
2470 |
-
|
2471 |
-
|
2472 |
-
|
2473 |
-
|
2474 |
-
|
2475 |
-
|
2476 |
-
|
2477 |
-
|
2478 |
-
|
2479 |
-
|
2480 |
-
|
2481 |
-
|
2482 |
-
|
2483 |
-
|
2484 |
-
|
2485 |
-
|
2486 |
-
|
2487 |
-
|
2488 |
-
|
2489 |
-
|
2490 |
-
|
2491 |
-
|
2492 |
-
|
2493 |
-
|
2494 |
-
|
2495 |
-
|
2496 |
-
|
2497 |
-
|
2498 |
-
|
2499 |
-
|
2500 |
-
|
2501 |
-
|
2502 |
-
|
2503 |
-
|
2504 |
-
|
2505 |
-
|
2506 |
-
|
2507 |
-
|
2508 |
-
|
2509 |
-
|
2510 |
-
|
2511 |
-
|
2512 |
-
|
2513 |
-
|
2514 |
-
|
2515 |
-
|
2516 |
-
|
2517 |
-
|
2518 |
-
|
2519 |
-
|
2520 |
-
|
2521 |
-
|
2522 |
-
|
2523 |
-
|
2524 |
-
|
2525 |
-
|
2526 |
-
|
2527 |
-
|
2528 |
-
|
2529 |
-
|
2530 |
-
|
2531 |
-
|
2532 |
-
|
2533 |
-
|
2534 |
-
|
2535 |
-
|
2536 |
-
|
2537 |
-
|
2538 |
-
|
2539 |
-
|
2540 |
-
|
2541 |
-
|
2542 |
-
|
2543 |
-
|
2544 |
-
|
2545 |
-
<
|
2546 |
-
|
2547 |
-
|
2548 |
-
|
2549 |
-
|
2550 |
-
<
|
2551 |
-
|
2552 |
-
<?php
|
2553 |
-
|
2554 |
-
|
2555 |
-
|
2556 |
-
|
2557 |
-
|
2558 |
-
|
2559 |
-
|
2560 |
-
|
2561 |
-
|
2562 |
-
|
2563 |
-
|
2564 |
-
|
2565 |
-
|
2566 |
-
|
2567 |
-
|
2568 |
-
|
2569 |
-
|
2570 |
-
|
2571 |
-
|
2572 |
-
|
2573 |
-
|
2574 |
-
|
2575 |
-
|
2576 |
-
<
|
2577 |
-
<
|
2578 |
-
|
2579 |
-
|
2580 |
-
|
2581 |
-
|
2582 |
-
|
2583 |
-
|
2584 |
-
|
2585 |
-
|
2586 |
-
|
2587 |
-
|
2588 |
-
|
2589 |
-
|
2590 |
-
|
2591 |
-
|
2592 |
-
|
2593 |
-
}
|
2594 |
-
|
2595 |
-
|
2596 |
-
|
2597 |
-
|
2598 |
-
|
2599 |
-
|
2600 |
-
|
2601 |
-
|
2602 |
-
|
2603 |
-
|
2604 |
-
|
2605 |
-
|
2606 |
-
|
2607 |
-
|
2608 |
-
|
2609 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2610 |
?>
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
|
4 |
+
Plugin Name: Codepress Admin Columns
|
5 |
+
Version: 1.4.7
|
6 |
+
Description: Customise columns on the administration screens for post(types), pages, media, comments, links and users with an easy to use drag-and-drop interface.
|
7 |
+
Author: Codepress
|
8 |
+
Author URI: http://www.codepress.nl
|
9 |
+
Plugin URI: http://www.codepress.nl/plugins/codepress-admin-columns/
|
10 |
+
Text Domain: codepress-admin-columns
|
11 |
+
Domain Path: /languages
|
12 |
+
License: GPLv2
|
13 |
+
|
14 |
+
Copyright 2011-2012 Codepress info@codepress.nl
|
15 |
+
|
16 |
+
This program is free software; you can redistribute it and/or modify
|
17 |
+
it under the terms of the GNU General Public License version 2 as published by
|
18 |
+
the Free Software Foundation.
|
19 |
+
|
20 |
+
This program is distributed in the hope that it will be useful,
|
21 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
22 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
23 |
+
GNU General Public License for more details.
|
24 |
+
|
25 |
+
You should have received a copy of the GNU General Public License
|
26 |
+
along with this program; if not, write to the Free Software
|
27 |
+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
28 |
+
*/
|
29 |
+
|
30 |
+
define( 'CPAC_VERSION', '1.4.7' );
|
31 |
+
define( 'CPAC_TEXTDOMAIN', 'codepress-admin-columns' );
|
32 |
+
define( 'CPAC_SLUG', 'codepress-admin-columns' );
|
33 |
+
define( 'CPAC_URL', plugins_url('', __FILE__) );
|
34 |
+
|
35 |
+
// only run plugin in the admin interface
|
36 |
+
if ( !is_admin() )
|
37 |
+
return false;
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Dependencies
|
41 |
+
*
|
42 |
+
* @since 1.3
|
43 |
+
*/
|
44 |
+
require_once dirname( __FILE__ ) . '/classes/utility.php';
|
45 |
+
require_once dirname( __FILE__ ) . '/classes/sortable.php';
|
46 |
+
require_once dirname( __FILE__ ) . '/classes/values.php';
|
47 |
+
require_once dirname( __FILE__ ) . '/classes/values/posts.php';
|
48 |
+
require_once dirname( __FILE__ ) . '/classes/values/users.php';
|
49 |
+
require_once dirname( __FILE__ ) . '/classes/values/media.php';
|
50 |
+
require_once dirname( __FILE__ ) . '/classes/values/link.php';
|
51 |
+
require_once dirname( __FILE__ ) . '/classes/values/comments.php';
|
52 |
+
require_once dirname( __FILE__ ) . '/classes/license.php';
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Codepress Admin Columns Class
|
56 |
+
*
|
57 |
+
* @since 1.0
|
58 |
+
*
|
59 |
+
*/
|
60 |
+
class Codepress_Admin_Columns
|
61 |
+
{
|
62 |
+
private $post_types,
|
63 |
+
$codepress_url,
|
64 |
+
$wordpress_url,
|
65 |
+
$api_url,
|
66 |
+
$admin_page,
|
67 |
+
$use_hidden_custom_fields;
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Constructor
|
71 |
+
*
|
72 |
+
* @since 1.0
|
73 |
+
*/
|
74 |
+
function __construct()
|
75 |
+
{
|
76 |
+
$this->api_url = 'http://www.codepress.nl/';
|
77 |
+
|
78 |
+
// wp is loaded
|
79 |
+
add_action( 'wp_loaded', array( $this, 'init') );
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Initialize plugin.
|
84 |
+
*
|
85 |
+
* Loading sequence is determined and intialized.
|
86 |
+
*
|
87 |
+
* @since 1.0
|
88 |
+
*/
|
89 |
+
public function init()
|
90 |
+
{
|
91 |
+
// vars
|
92 |
+
$this->post_types = self::get_post_types();
|
93 |
+
|
94 |
+
// set
|
95 |
+
$this->codepress_url = 'http://www.codepress.nl/plugins/codepress-admin-columns';
|
96 |
+
$this->plugins_url = 'http://wordpress.org/extend/plugins/codepress-admin-columns/';
|
97 |
+
$this->wordpress_url = 'http://wordpress.org/tags/codepress-admin-columns';
|
98 |
+
|
99 |
+
// enable the use of custom hidden fields
|
100 |
+
$this->use_hidden_custom_fields = apply_filters('cpac_use_hidden_custom_fields', false);
|
101 |
+
|
102 |
+
// translations
|
103 |
+
load_plugin_textdomain( CPAC_TEXTDOMAIN, false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
|
104 |
+
|
105 |
+
// register settings
|
106 |
+
add_action( 'admin_menu', array( $this, 'settings_menu') );
|
107 |
+
add_action( 'admin_init', array( $this, 'register_settings') );
|
108 |
+
|
109 |
+
// styling & scripts
|
110 |
+
add_action( 'admin_enqueue_scripts' , array( $this, 'column_styles') );
|
111 |
+
add_filter( 'admin_body_class', array( $this, 'admin_class' ) );
|
112 |
+
add_action( 'admin_head', array( $this, 'admin_css') );
|
113 |
+
|
114 |
+
// register columns
|
115 |
+
add_action( 'admin_init', array( $this, 'register_columns_headings' ) );
|
116 |
+
add_action( 'admin_init', array( $this, 'register_columns_values' ) );
|
117 |
+
|
118 |
+
// action ajax
|
119 |
+
add_action( 'wp_ajax_cpac_addon_activation', array( $this, 'ajax_activation'));
|
120 |
+
|
121 |
+
// handle requests gets a low priority so it will trigger when all other plugins have loaded their columns
|
122 |
+
add_action( 'admin_init', array( $this, 'handle_requests' ), 1000 );
|
123 |
+
|
124 |
+
// filters
|
125 |
+
add_filter( 'plugin_action_links', array( $this, 'add_settings_link'), 1, 2);
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* Admin Menu.
|
130 |
+
*
|
131 |
+
* Create the admin menu link for the settings page.
|
132 |
+
*
|
133 |
+
* @since 1.0
|
134 |
+
*/
|
135 |
+
public function settings_menu()
|
136 |
+
{
|
137 |
+
$page = add_options_page(
|
138 |
+
// Page title
|
139 |
+
esc_html__( 'Admin Columns Settings', CPAC_TEXTDOMAIN ),
|
140 |
+
// Menu Title
|
141 |
+
esc_html__( 'Admin Columns', CPAC_TEXTDOMAIN ),
|
142 |
+
// Capability
|
143 |
+
'manage_options',
|
144 |
+
// Menu slug
|
145 |
+
CPAC_SLUG,
|
146 |
+
// Callback
|
147 |
+
array( $this, 'plugin_settings_page')
|
148 |
+
);
|
149 |
+
|
150 |
+
// set admin page
|
151 |
+
$this->admin_page = $page;
|
152 |
+
|
153 |
+
// settings page specific styles and scripts
|
154 |
+
add_action( "admin_print_styles-$page", array( $this, 'admin_styles') );
|
155 |
+
add_action( "admin_print_scripts-$page", array( $this, 'admin_scripts') );
|
156 |
+
|
157 |
+
// add help tabs
|
158 |
+
add_action("load-$page", array( $this, 'help_tabs'));
|
159 |
+
}
|
160 |
+
|
161 |
+
/**
|
162 |
+
* Add Settings link to plugin page
|
163 |
+
*
|
164 |
+
* @since 1.0
|
165 |
+
* @param $links string - all settings links
|
166 |
+
* @param $file string - plugin filename
|
167 |
+
* @return string - link to settings page
|
168 |
+
*/
|
169 |
+
function add_settings_link( $links, $file )
|
170 |
+
{
|
171 |
+
if ( $file != plugin_basename( __FILE__ ))
|
172 |
+
return $links;
|
173 |
+
|
174 |
+
array_unshift($links, '<a href="' . admin_url("admin.php") . '?page=' . CPAC_SLUG . '">' . __( 'Settings' ) . '</a>');
|
175 |
+
return $links;
|
176 |
+
}
|
177 |
+
|
178 |
+
/**
|
179 |
+
* Register Column Values
|
180 |
+
*
|
181 |
+
* initializes each Class per type
|
182 |
+
*
|
183 |
+
* @since 1.0
|
184 |
+
*/
|
185 |
+
public function register_columns_values()
|
186 |
+
{
|
187 |
+
new CPAC_Posts_Values();
|
188 |
+
new CPAC_Link_Values();
|
189 |
+
new CPAC_Media_Values();
|
190 |
+
new CPAC_Users_Values();
|
191 |
+
new CPAC_Comments_Values();
|
192 |
+
}
|
193 |
+
/**
|
194 |
+
* Register Columns Headings
|
195 |
+
*
|
196 |
+
* apply_filters location in includes/screen.php
|
197 |
+
*
|
198 |
+
* @since 1.0
|
199 |
+
*/
|
200 |
+
public function register_columns_headings()
|
201 |
+
{
|
202 |
+
/** Posts */
|
203 |
+
foreach ( $this->post_types as $post_type ) {
|
204 |
+
|
205 |
+
// register column per post type
|
206 |
+
add_filter("manage_edit-{$post_type}_columns", array($this, 'callback_add_posts_column_headings'));
|
207 |
+
}
|
208 |
+
|
209 |
+
/** Users */
|
210 |
+
add_filter( "manage_users_columns", array($this, 'callback_add_users_column_headings'), 9);
|
211 |
+
// give higher priority, so it will load just before other plugins to prevent conflicts
|
212 |
+
|
213 |
+
/** Media */
|
214 |
+
add_filter( "manage_upload_columns", array($this, 'callback_add_media_column_headings'));
|
215 |
+
|
216 |
+
/** Links */
|
217 |
+
add_filter( "manage_link-manager_columns", array($this, 'callback_add_links_column_headings'));
|
218 |
+
|
219 |
+
/** Comments */
|
220 |
+
add_filter( "manage_edit-comments_columns", array($this, 'callback_add_comments_column_headings'));
|
221 |
+
}
|
222 |
+
|
223 |
+
/**
|
224 |
+
* Callback add Posts Column
|
225 |
+
*
|
226 |
+
* @since 1.0
|
227 |
+
*/
|
228 |
+
public function callback_add_posts_column_headings($columns)
|
229 |
+
{
|
230 |
+
return $this->add_columns_headings( get_post_type(), $columns);
|
231 |
+
}
|
232 |
+
|
233 |
+
/**
|
234 |
+
* Callback add Users column
|
235 |
+
*
|
236 |
+
* @since 1.1
|
237 |
+
*/
|
238 |
+
public function callback_add_users_column_headings($columns)
|
239 |
+
{
|
240 |
+
return $this->add_columns_headings('wp-users', $columns);
|
241 |
+
}
|
242 |
+
|
243 |
+
/**
|
244 |
+
* Callback add Media column
|
245 |
+
*
|
246 |
+
* @since 1.3
|
247 |
+
*/
|
248 |
+
public function callback_add_media_column_headings($columns)
|
249 |
+
{
|
250 |
+
return $this->add_columns_headings('wp-media', $columns);
|
251 |
+
}
|
252 |
+
|
253 |
+
/**
|
254 |
+
* Callback add Links column
|
255 |
+
*
|
256 |
+
* @since 1.3.1
|
257 |
+
*/
|
258 |
+
public function callback_add_links_column_headings($columns)
|
259 |
+
{
|
260 |
+
return $this->add_columns_headings('wp-links', $columns);
|
261 |
+
}
|
262 |
+
|
263 |
+
/**
|
264 |
+
* Callback add Comments column
|
265 |
+
*
|
266 |
+
* @since 1.3.1
|
267 |
+
*/
|
268 |
+
public function callback_add_comments_column_headings($columns)
|
269 |
+
{
|
270 |
+
return $this->add_columns_headings('wp-comments', $columns);
|
271 |
+
}
|
272 |
+
|
273 |
+
|
274 |
+
|
275 |
+
/**
|
276 |
+
* Add managed columns by Type
|
277 |
+
*
|
278 |
+
* @since 1.4.6.5
|
279 |
+
*/
|
280 |
+
private function get_comment_icon()
|
281 |
+
{
|
282 |
+
return "<span class='vers'><img src='" . trailingslashit( get_admin_url() ) . 'images/comment-grey-bubble.png' . "' alt='Comments'></span>";
|
283 |
+
}
|
284 |
+
|
285 |
+
/**
|
286 |
+
* Add managed columns by Type
|
287 |
+
*
|
288 |
+
* @since 1.1
|
289 |
+
*/
|
290 |
+
protected function add_columns_headings( $type, $columns )
|
291 |
+
{
|
292 |
+
// only get stored columns.. the rest we don't need
|
293 |
+
$db_columns = self::get_stored_columns($type);
|
294 |
+
|
295 |
+
if ( !$db_columns )
|
296 |
+
return $columns;
|
297 |
+
|
298 |
+
// filter already loaded columns by plugins
|
299 |
+
$set_columns = $this->filter_preset_columns( $type, $columns );
|
300 |
+
|
301 |
+
// loop through columns
|
302 |
+
foreach ( $db_columns as $id => $values ) {
|
303 |
+
// is active
|
304 |
+
if ( isset($values['state']) && $values['state'] == 'on' ){
|
305 |
+
|
306 |
+
$label = $values['label'];
|
307 |
+
|
308 |
+
// exception for comments
|
309 |
+
if( 'comments' == $id ) {
|
310 |
+
$label = $this->get_comment_icon();
|
311 |
+
}
|
312 |
+
|
313 |
+
// register format
|
314 |
+
$set_columns[$id] = $label;
|
315 |
+
}
|
316 |
+
}
|
317 |
+
|
318 |
+
return $set_columns;
|
319 |
+
}
|
320 |
+
|
321 |
+
/**
|
322 |
+
* Filter preset columns. These columns apply either for every post or set by a plugin.
|
323 |
+
*
|
324 |
+
* @since 1.0
|
325 |
+
*/
|
326 |
+
private function filter_preset_columns( $type, $columns )
|
327 |
+
{
|
328 |
+
$options = get_option('cpac_options_default');
|
329 |
+
|
330 |
+
if ( !$options )
|
331 |
+
return $columns;
|
332 |
+
|
333 |
+
// we use the wp default columns for filtering...
|
334 |
+
$stored_wp_default_columns = $options[$type];
|
335 |
+
|
336 |
+
// ... the ones that are set by plugins, theme functions and such.
|
337 |
+
$dif_columns = array_diff(array_keys($columns), array_keys($stored_wp_default_columns));
|
338 |
+
|
339 |
+
// we add those to the columns
|
340 |
+
$pre_columns = array();
|
341 |
+
if ( $dif_columns ) {
|
342 |
+
foreach ( $dif_columns as $column ) {
|
343 |
+
$pre_columns[$column] = $columns[$column];
|
344 |
+
}
|
345 |
+
}
|
346 |
+
|
347 |
+
return $pre_columns;
|
348 |
+
}
|
349 |
+
|
350 |
+
/**
|
351 |
+
* Get a list of Column options per post type
|
352 |
+
*
|
353 |
+
* @since 1.0
|
354 |
+
*/
|
355 |
+
private function get_column_boxes($type)
|
356 |
+
{
|
357 |
+
// merge all columns
|
358 |
+
$display_columns = $this->get_merged_columns($type);
|
359 |
+
|
360 |
+
// define
|
361 |
+
$list = '';
|
362 |
+
|
363 |
+
// loop throught the active columns
|
364 |
+
if ( $display_columns ) {
|
365 |
+
foreach ( $display_columns as $id => $values ) {
|
366 |
+
|
367 |
+
$classes = array();
|
368 |
+
|
369 |
+
// set state
|
370 |
+
$state = isset($values['state']) ? $values['state'] : '';
|
371 |
+
|
372 |
+
// class
|
373 |
+
$classes[] = "cpac-box-{$id}";
|
374 |
+
if ( $state ) {
|
375 |
+
$classes[] = 'active';
|
376 |
+
}
|
377 |
+
if ( ! empty($values['options']['class']) ) {
|
378 |
+
$classes[] = $values['options']['class'];
|
379 |
+
}
|
380 |
+
$class = implode(' ', $classes);
|
381 |
+
|
382 |
+
// more box options
|
383 |
+
$more_options = $this->get_additional_box_options($type, $id, $values);
|
384 |
+
$action = "<a class='cpac-action' href='#open'>open</a>";
|
385 |
+
|
386 |
+
// type label
|
387 |
+
$type_label = isset($values['options']['type_label']) ? $values['options']['type_label'] : '';
|
388 |
+
|
389 |
+
// label
|
390 |
+
$label = isset($values['label']) ? str_replace("'", '"', $values['label']) : '';
|
391 |
+
|
392 |
+
// main label
|
393 |
+
$main_label = $values['label'];
|
394 |
+
|
395 |
+
// main label exception for comments
|
396 |
+
if ( 'comments' == $id ) {
|
397 |
+
$main_label = $this->get_comment_icon();
|
398 |
+
}
|
399 |
+
|
400 |
+
// width
|
401 |
+
$width = isset($values['width']) ? $values['width'] : 0;
|
402 |
+
$width_descr = isset($values['width']) && $values['width'] > 0 ? $values['width'] . '%' : __('default', CPAC_TEXTDOMAIN);
|
403 |
+
|
404 |
+
// hide box options
|
405 |
+
$label_hidden = '';
|
406 |
+
if ( ! empty($values['options']['hide_options']) || strpos($label, '<img') !== false ) {
|
407 |
+
$label_hidden = ' style="display:none"';
|
408 |
+
}
|
409 |
+
|
410 |
+
$list .= "
|
411 |
+
<li class='{$class}'>
|
412 |
+
<div class='cpac-sort-handle'></div>
|
413 |
+
<div class='cpac-type-options'>
|
414 |
+
<div class='cpac-checkbox'></div>
|
415 |
+
<input type='hidden' class='cpac-state' name='cpac_options[columns][{$type}][{$id}][state]' value='{$state}'/>
|
416 |
+
<label class='main-label'>{$main_label}</label>
|
417 |
+
</div>
|
418 |
+
<div class='cpac-meta-title'>
|
419 |
+
{$action}
|
420 |
+
<span>{$type_label}</span>
|
421 |
+
</div>
|
422 |
+
<div class='cpac-type-inside'>
|
423 |
+
<label for='cpac_options-{$type}-{$id}-label'{$label_hidden}>Label: </label>
|
424 |
+
<input type='text' name='cpac_options[columns][{$type}][{$id}][label]' id='cpac_options-{$type}-{$id}-label' value='{$label}' class='text'{$label_hidden}/>
|
425 |
+
<label for='cpac_options-{$type}-{$id}-width'>" . __('Width', CPAC_TEXTDOMAIN) . ":</label>
|
426 |
+
<input type='hidden' maxlength='4' class='input-width' name='cpac_options[columns][{$type}][{$id}][width]' id='cpac_options-{$type}-{$id}-width' value='{$width}' />
|
427 |
+
<div class='description width-decription' title='" . __('default', CPAC_TEXTDOMAIN) . "'>{$width_descr}</div>
|
428 |
+
<div class='input-width-range'></div>
|
429 |
+
<br/>
|
430 |
+
{$more_options}
|
431 |
+
</div>
|
432 |
+
</li>
|
433 |
+
";
|
434 |
+
}
|
435 |
+
}
|
436 |
+
|
437 |
+
// custom field button
|
438 |
+
$button_add_column = '';
|
439 |
+
if ( $this->get_meta_by_type($type) )
|
440 |
+
$button_add_column = "<a href='javacript:;' class='cpac-add-customfield-column button'>+ " . __('Add Custom Field Column', CPAC_TEXTDOMAIN) . "</a>";
|
441 |
+
|
442 |
+
return "
|
443 |
+
<div class='cpac-box'>
|
444 |
+
<ul class='cpac-option-list'>
|
445 |
+
{$list}
|
446 |
+
</ul>
|
447 |
+
{$button_add_column}
|
448 |
+
<div class='cpac-reorder-msg'>" . __('drag and drop to reorder', CPAC_TEXTDOMAIN) . "</div>
|
449 |
+
</div>
|
450 |
+
";
|
451 |
+
}
|
452 |
+
|
453 |
+
/**
|
454 |
+
* Get merged columns
|
455 |
+
*
|
456 |
+
* @since 1.0
|
457 |
+
*/
|
458 |
+
protected function get_merged_columns( $type )
|
459 |
+
{
|
460 |
+
/** Comments */
|
461 |
+
if ( $type == 'wp-comments' ) {
|
462 |
+
$wp_default_columns = $this->get_wp_default_comments_columns();
|
463 |
+
$wp_custom_columns = $this->get_custom_comments_columns();
|
464 |
+
}
|
465 |
+
|
466 |
+
/** Links */
|
467 |
+
elseif ( $type == 'wp-links' ) {
|
468 |
+
$wp_default_columns = $this->get_wp_default_links_columns();
|
469 |
+
$wp_custom_columns = $this->get_custom_links_columns();
|
470 |
+
}
|
471 |
+
|
472 |
+
/** Users */
|
473 |
+
elseif ( $type == 'wp-users' ) {
|
474 |
+
$wp_default_columns = $this->get_wp_default_users_columns();
|
475 |
+
$wp_custom_columns = $this->get_custom_users_columns();
|
476 |
+
}
|
477 |
+
|
478 |
+
/** Media */
|
479 |
+
elseif ( $type == 'wp-media' ) {
|
480 |
+
$wp_default_columns = $this->get_wp_default_media_columns();
|
481 |
+
$wp_custom_columns = $this->get_custom_media_columns();
|
482 |
+
}
|
483 |
+
|
484 |
+
/** Posts */
|
485 |
+
else {
|
486 |
+
$wp_default_columns = $this->get_wp_default_posts_columns($type);
|
487 |
+
$wp_custom_columns = $this->get_custom_posts_columns($type);
|
488 |
+
}
|
489 |
+
|
490 |
+
// merge columns
|
491 |
+
$display_columns = $this->parse_columns($wp_custom_columns, $wp_default_columns, $type);
|
492 |
+
|
493 |
+
return $display_columns;
|
494 |
+
}
|
495 |
+
|
496 |
+
/**
|
497 |
+
* Merge the default columns (set by WordPress) and the added custom columns (set by plugins, theme etc.)
|
498 |
+
*
|
499 |
+
* @since 1.3.3
|
500 |
+
*/
|
501 |
+
function parse_columns($wp_custom_columns, $wp_default_columns, $type)
|
502 |
+
{
|
503 |
+
// merge columns
|
504 |
+
$default_columns = wp_parse_args($wp_custom_columns, $wp_default_columns);
|
505 |
+
|
506 |
+
//get saved database columns
|
507 |
+
$db_columns = self::get_stored_columns($type);
|
508 |
+
if ( $db_columns ) {
|
509 |
+
|
510 |
+
// let's remove any unavailable columns.. such as disabled plugins
|
511 |
+
$db_columns = $this->remove_unavailable_columns($db_columns, $default_columns);
|
512 |
+
|
513 |
+
// loop throught the active columns
|
514 |
+
foreach ( $db_columns as $id => $values ) {
|
515 |
+
|
516 |
+
// get column meta options from custom columns
|
517 |
+
if ( $this->is_column_meta($id) && !empty($wp_custom_columns['column-meta-1']['options']) ) {
|
518 |
+
$db_columns[$id]['options'] = $wp_custom_columns['column-meta-1']['options'];
|
519 |
+
}
|
520 |
+
|
521 |
+
// add static options
|
522 |
+
elseif ( isset($default_columns[$id]['options']) )
|
523 |
+
$db_columns[$id]['options'] = $default_columns[$id]['options'];
|
524 |
+
|
525 |
+
unset($default_columns[$id]);
|
526 |
+
}
|
527 |
+
}
|
528 |
+
|
529 |
+
// merge all
|
530 |
+
return wp_parse_args($db_columns, $default_columns);
|
531 |
+
}
|
532 |
+
|
533 |
+
/**
|
534 |
+
* Remove deactivated (plugin) columns
|
535 |
+
*
|
536 |
+
* This will remove any columns that have been stored, but are no longer available. This happends
|
537 |
+
* when plugins are deactivated or when they are removed from the theme functions.
|
538 |
+
*
|
539 |
+
* @since 1.2
|
540 |
+
*/
|
541 |
+
private function remove_unavailable_columns( array $db_columns, array $default_columns)
|
542 |
+
{
|
543 |
+
// check or differences
|
544 |
+
$diff = array_diff( array_keys($db_columns), array_keys($default_columns) );
|
545 |
+
|
546 |
+
if ( ! empty($diff) && is_array($diff) ) {
|
547 |
+
foreach ( $diff as $column_name ){
|
548 |
+
// make an exception for column-meta-xxx
|
549 |
+
if ( ! $this->is_column_meta($column_name) ) {
|
550 |
+
unset($db_columns[$column_name]);
|
551 |
+
}
|
552 |
+
}
|
553 |
+
}
|
554 |
+
|
555 |
+
return $db_columns;
|
556 |
+
}
|
557 |
+
|
558 |
+
/**
|
559 |
+
* Get checkbox
|
560 |
+
*
|
561 |
+
* @since 1.0
|
562 |
+
*/
|
563 |
+
private function get_box($type, $id, $values)
|
564 |
+
{
|
565 |
+
$classes = array();
|
566 |
+
|
567 |
+
// set state
|
568 |
+
$state = isset($values['state']) ? $values['state'] : '';
|
569 |
+
|
570 |
+
// class
|
571 |
+
$classes[] = "cpac-box-{$id}";
|
572 |
+
if ( $state ) {
|
573 |
+
$classes[] = 'active';
|
574 |
+
}
|
575 |
+
if ( ! empty($values['options']['class']) ) {
|
576 |
+
$classes[] = $values['options']['class'];
|
577 |
+
}
|
578 |
+
$class = implode(' ', $classes);
|
579 |
+
|
580 |
+
// more box options
|
581 |
+
$more_options = $this->get_additional_box_options($type, $id, $values);
|
582 |
+
$action = "<a class='cpac-action' href='#open'>open</a>";
|
583 |
+
|
584 |
+
// type label
|
585 |
+
$type_label = isset($values['options']['type_label']) ? $values['options']['type_label'] : '';
|
586 |
+
|
587 |
+
// label
|
588 |
+
$label = isset($values['label']) ? str_replace("'", '"', $values['label']) : '';
|
589 |
+
|
590 |
+
// main label
|
591 |
+
$main_label = $values['label'];
|
592 |
+
|
593 |
+
// main label exception for comments
|
594 |
+
if ( 'comments' == $id ) {
|
595 |
+
$main_label = $this->get_comment_icon();
|
596 |
+
}
|
597 |
+
|
598 |
+
// width
|
599 |
+
$width = isset($values['width']) ? $values['width'] : 0;
|
600 |
+
$width_descr = isset($values['width']) && $values['width'] > 0 ? $values['width'] . '%' : __('default', CPAC_TEXTDOMAIN);
|
601 |
+
|
602 |
+
// hide box options
|
603 |
+
$label_hidden = '';
|
604 |
+
if ( ! empty($values['options']['hide_options']) || strpos($label, '<img') !== false ) {
|
605 |
+
$label_hidden = ' style="display:none"';
|
606 |
+
}
|
607 |
+
|
608 |
+
$list = "
|
609 |
+
<li class='{$class}'>
|
610 |
+
<div class='cpac-sort-handle'></div>
|
611 |
+
<div class='cpac-type-options'>
|
612 |
+
<div class='cpac-checkbox'></div>
|
613 |
+
<input type='hidden' class='cpac-state' name='cpac_options[columns][{$type}][{$id}][state]' value='{$state}'/>
|
614 |
+
<label class='main-label'>{$main_label}</label>
|
615 |
+
</div>
|
616 |
+
<div class='cpac-meta-title'>
|
617 |
+
{$action}
|
618 |
+
<span>{$type_label}</span>
|
619 |
+
</div>
|
620 |
+
<div class='cpac-type-inside'>
|
621 |
+
<label for='cpac_options-{$type}-{$id}-label'{$label_hidden}>Label: </label>
|
622 |
+
<input type='text' name='cpac_options[columns][{$type}][{$id}][label]' id='cpac_options-{$type}-{$id}-label' value='{$label}' class='text'{$label_hidden}/>
|
623 |
+
<label for='cpac_options-{$type}-{$id}-width'>" . __('Width', CPAC_TEXTDOMAIN) . ":</label>
|
624 |
+
<input type='hidden' maxlength='4' class='input-width' name='cpac_options[columns][{$type}][{$id}][width]' id='cpac_options-{$type}-{$id}-width' value='{$width}' />
|
625 |
+
<div class='description width-decription' title='" . __('default', CPAC_TEXTDOMAIN) . "'>{$width_descr}</div>
|
626 |
+
<div class='input-width-range'></div>
|
627 |
+
<br/>
|
628 |
+
{$more_options}
|
629 |
+
</div>
|
630 |
+
</li>
|
631 |
+
";
|
632 |
+
|
633 |
+
return $list;
|
634 |
+
}
|
635 |
+
|
636 |
+
/**
|
637 |
+
* Get additional box option fields
|
638 |
+
*
|
639 |
+
* @since 1.0
|
640 |
+
*/
|
641 |
+
private function get_additional_box_options($type, $id, $values)
|
642 |
+
{
|
643 |
+
$fields = '';
|
644 |
+
|
645 |
+
// Custom Fields
|
646 |
+
if( $this->is_column_meta($id) ) {
|
647 |
+
$fields = $this->get_box_options_customfields($type, $id, $values);
|
648 |
+
}
|
649 |
+
|
650 |
+
// Author Fields
|
651 |
+
if( 'column-author-name' == $id) {
|
652 |
+
$fields = $this->get_box_options_author($type, $id, $values);
|
653 |
+
}
|
654 |
+
|
655 |
+
return $fields;
|
656 |
+
}
|
657 |
+
|
658 |
+
/**
|
659 |
+
* Box Options: Custom Fields
|
660 |
+
*
|
661 |
+
* @since 1.0
|
662 |
+
*/
|
663 |
+
private function get_box_options_customfields($type, $id, $values)
|
664 |
+
{
|
665 |
+
// get post meta fields
|
666 |
+
$fields = $this->get_meta_by_type($type);
|
667 |
+
|
668 |
+
if ( empty($fields) )
|
669 |
+
return false;
|
670 |
+
|
671 |
+
// set meta field options
|
672 |
+
$current = ! empty($values['field']) ? $values['field'] : '' ;
|
673 |
+
$field_options = '';
|
674 |
+
foreach ($fields as $field) {
|
675 |
+
|
676 |
+
$field_options .= sprintf
|
677 |
+
(
|
678 |
+
'<option value="%s"%s>%s</option>',
|
679 |
+
$field,
|
680 |
+
$field == $current? ' selected="selected"':'',
|
681 |
+
|
682 |
+
// change label on hidden fields
|
683 |
+
substr($field,0,10) == "cpachidden" ? str_replace('cpachidden','',$field) : $field
|
684 |
+
);
|
685 |
+
}
|
686 |
+
|
687 |
+
// set meta fieldtype options
|
688 |
+
$currenttype = ! empty($values['field_type']) ? $values['field_type'] : '' ;
|
689 |
+
$fieldtype_options = '';
|
690 |
+
$fieldtypes = array(
|
691 |
+
'' => __('Default'),
|
692 |
+
'image' => __('Image'),
|
693 |
+
'library_id' => __('Media Library Icon', CPAC_TEXTDOMAIN),
|
694 |
+
'excerpt' => __('Excerpt'),
|
695 |
+
'array' => __('Multiple Values', CPAC_TEXTDOMAIN),
|
696 |
+
'numeric' => __('Numeric', CPAC_TEXTDOMAIN),
|
697 |
+
'date' => __('Date', CPAC_TEXTDOMAIN),
|
698 |
+
'title_by_id' => __('Post Title (Post ID\'s)', CPAC_TEXTDOMAIN),
|
699 |
+
'user_by_id' => __('Username (User ID\'s)', CPAC_TEXTDOMAIN),
|
700 |
+
'checkmark' => __('Checkmark (true/false)', CPAC_TEXTDOMAIN),
|
701 |
+
'color' => __('Color', CPAC_TEXTDOMAIN),
|
702 |
+
);
|
703 |
+
|
704 |
+
// add filter
|
705 |
+
$fieldtypes = apply_filters('cpac-field-types', $fieldtypes );
|
706 |
+
|
707 |
+
// set select options
|
708 |
+
foreach ( $fieldtypes as $fkey => $fieldtype ) {
|
709 |
+
$fieldtype_options .= sprintf
|
710 |
+
(
|
711 |
+
'<option value="%s"%s>%s</option>',
|
712 |
+
$fkey,
|
713 |
+
$fkey == $currenttype? ' selected="selected"':'',
|
714 |
+
$fieldtype
|
715 |
+
);
|
716 |
+
}
|
717 |
+
|
718 |
+
// before and after string
|
719 |
+
$before = ! empty($values['before']) ? $values['before'] : '' ;
|
720 |
+
$after = ! empty($values['after']) ? $values['after'] : '' ;
|
721 |
+
|
722 |
+
if ( empty($field_options) )
|
723 |
+
return false;
|
724 |
+
|
725 |
+
// add remove button
|
726 |
+
$remove = '<p class="remove-description description">'.__('This field can not be removed', CPAC_TEXTDOMAIN).'</p>';
|
727 |
+
if ( $id != 'column-meta-1') {
|
728 |
+
$remove = "
|
729 |
+
<p>
|
730 |
+
<a href='javascript:;' class='cpac-delete-custom-field-box'>".__('Remove')."</a>
|
731 |
+
</p>
|
732 |
+
";
|
733 |
+
}
|
734 |
+
|
735 |
+
$inside = "
|
736 |
+
<label for='cpac-{$type}-{$id}-field'>".__('Custom Field', CPAC_TEXTDOMAIN).": </label>
|
737 |
+
<select name='cpac_options[columns][{$type}][{$id}][field]' id='cpac-{$type}-{$id}-field'>{$field_options}</select>
|
738 |
+
<br/>
|
739 |
+
<label for='cpac-{$type}-{$id}-field_type'>".__('Field Type', CPAC_TEXTDOMAIN).": </label>
|
740 |
+
<select name='cpac_options[columns][{$type}][{$id}][field_type]' id='cpac-{$type}-{$id}-field_type'>{$fieldtype_options}</select>
|
741 |
+
<br/>
|
742 |
+
<label for='cpac-{$type}-{$id}-before'>".__('Before', CPAC_TEXTDOMAIN).": </label>
|
743 |
+
<input type='text' class='cpac-before' name='cpac_options[columns][{$type}][{$id}][before]' id='cpac-{$type}-{$id}-before' value='{$before}'/>
|
744 |
+
<br/>
|
745 |
+
<label for='cpac-{$type}-{$id}-after'>".__('After', CPAC_TEXTDOMAIN).": </label>
|
746 |
+
<input type='text' class='cpac-after' name='cpac_options[columns][{$type}][{$id}][after]' id='cpac-{$type}-{$id}-after' value='{$after}'/>
|
747 |
+
<br/>
|
748 |
+
{$remove}
|
749 |
+
";
|
750 |
+
|
751 |
+
return $inside;
|
752 |
+
}
|
753 |
+
|
754 |
+
/**
|
755 |
+
* Box Options: Custom Fields
|
756 |
+
*
|
757 |
+
* @since 1.0
|
758 |
+
*/
|
759 |
+
private function get_box_options_author($type, $id, $values)
|
760 |
+
{
|
761 |
+
$options = '';
|
762 |
+
$author_types = array(
|
763 |
+
'display_name' => __('Display Name', CPAC_TEXTDOMAIN),
|
764 |
+
'first_name' => __('First Name', CPAC_TEXTDOMAIN),
|
765 |
+
'last_name' => __('Last Name', CPAC_TEXTDOMAIN),
|
766 |
+
'first_last_name' => __('First & Last Name', CPAC_TEXTDOMAIN),
|
767 |
+
'nickname' => __('Nickname', CPAC_TEXTDOMAIN),
|
768 |
+
'username' => __('Username', CPAC_TEXTDOMAIN),
|
769 |
+
'email' => __('Email', CPAC_TEXTDOMAIN),
|
770 |
+
'userid' => __('User ID', CPAC_TEXTDOMAIN)
|
771 |
+
);
|
772 |
+
$currentname = ! empty($values['display_as']) ? $values['display_as'] : '' ;
|
773 |
+
foreach ( $author_types as $k => $name ) {
|
774 |
+
$selected = selected( $k, $currentname, false);
|
775 |
+
$options .= "<option value='{$k}' {$selected}>{$name}</option>";
|
776 |
+
}
|
777 |
+
|
778 |
+
$inside = "
|
779 |
+
<label for='cpac-{$type}-{$id}-display_as'>".__('Display name as', CPAC_TEXTDOMAIN).": </label>
|
780 |
+
<select name='cpac_options[columns][{$type}][{$id}][display_as]' id='cpac-{$type}-{$id}-display_as'>
|
781 |
+
{$options}
|
782 |
+
</select>
|
783 |
+
";
|
784 |
+
|
785 |
+
return $inside;
|
786 |
+
}
|
787 |
+
|
788 |
+
/**
|
789 |
+
* Get post meta fields by type; post(types) or users.
|
790 |
+
*
|
791 |
+
* @since 1.0
|
792 |
+
*/
|
793 |
+
private function get_meta_by_type($type = 'post')
|
794 |
+
{
|
795 |
+
global $wpdb;
|
796 |
+
|
797 |
+
/** Comments */
|
798 |
+
if ( $type == 'wp-comments') {
|
799 |
+
$sql = "SELECT DISTINCT meta_key FROM {$wpdb->commentmeta} ORDER BY 1";
|
800 |
+
}
|
801 |
+
|
802 |
+
/** Users */
|
803 |
+
elseif ( $type == 'wp-users') {
|
804 |
+
$sql = "SELECT DISTINCT meta_key FROM {$wpdb->usermeta} ORDER BY 1";
|
805 |
+
}
|
806 |
+
|
807 |
+
/** Media */
|
808 |
+
elseif ( $type == 'wp-media') {
|
809 |
+
$sql = "SELECT DISTINCT meta_key FROM {$wpdb->postmeta} pm JOIN {$wpdb->posts} p ON pm.post_id = p.ID WHERE p.post_type = 'attachment' ORDER BY 1";
|
810 |
+
}
|
811 |
+
|
812 |
+
/** Posts */
|
813 |
+
else {
|
814 |
+
$sql = $wpdb->prepare( "SELECT DISTINCT meta_key FROM {$wpdb->postmeta} pm JOIN {$wpdb->posts} p ON pm.post_id = p.ID WHERE p.post_type = %s ORDER BY 1", $type);
|
815 |
+
}
|
816 |
+
|
817 |
+
// run sql
|
818 |
+
$fields = $wpdb->get_results($sql, ARRAY_N);
|
819 |
+
|
820 |
+
// filter out hidden meta fields
|
821 |
+
$meta_fields = array();
|
822 |
+
if ( $fields ) {
|
823 |
+
foreach ($fields as $field) {
|
824 |
+
|
825 |
+
// give hidden fields a prefix for identifaction
|
826 |
+
if ( $this->use_hidden_custom_fields && substr($field[0],0,1) == "_") {
|
827 |
+
$meta_fields[] = 'cpachidden'.$field[0];
|
828 |
+
}
|
829 |
+
|
830 |
+
// non hidden fields are saved as is
|
831 |
+
elseif ( substr($field[0],0,1) != "_" ) {
|
832 |
+
$meta_fields[] = $field[0];
|
833 |
+
}
|
834 |
+
}
|
835 |
+
}
|
836 |
+
|
837 |
+
if ( !empty($meta_fields) )
|
838 |
+
return $meta_fields;
|
839 |
+
|
840 |
+
return false;
|
841 |
+
}
|
842 |
+
|
843 |
+
/**
|
844 |
+
* Register admin scripts
|
845 |
+
*
|
846 |
+
* @since 1.0
|
847 |
+
*/
|
848 |
+
public function admin_scripts()
|
849 |
+
{
|
850 |
+
wp_enqueue_script( 'wp-pointer' );
|
851 |
+
wp_enqueue_script( 'jquery-ui-slider' );
|
852 |
+
wp_enqueue_script( 'cpac-qtip2', CPAC_URL.'/assets/js/jquery.qtip.js', array('jquery'), CPAC_VERSION );
|
853 |
+
wp_enqueue_script( 'cpac-admin', CPAC_URL.'/assets/js/admin-column.js', array('jquery', 'dashboard', 'jquery-ui-sortable'), CPAC_VERSION );
|
854 |
+
}
|
855 |
+
|
856 |
+
/**
|
857 |
+
* Get column types
|
858 |
+
*
|
859 |
+
* @since 1.1
|
860 |
+
*/
|
861 |
+
private function get_types()
|
862 |
+
{
|
863 |
+
$types = $this->post_types;
|
864 |
+
$types['wp-users'] = 'wp-users';
|
865 |
+
$types['wp-media'] = 'wp-media';
|
866 |
+
$types['wp-links'] = 'wp-links';
|
867 |
+
$types['wp-comments'] = 'wp-comments';
|
868 |
+
|
869 |
+
return $types;
|
870 |
+
}
|
871 |
+
|
872 |
+
/**
|
873 |
+
* Get post types
|
874 |
+
*
|
875 |
+
* @since 1.0
|
876 |
+
*/
|
877 |
+
public static function get_post_types()
|
878 |
+
{
|
879 |
+
$post_types = get_post_types(array(
|
880 |
+
'_builtin' => false
|
881 |
+
));
|
882 |
+
$post_types['post'] = 'post';
|
883 |
+
$post_types['page'] = 'page';
|
884 |
+
|
885 |
+
return apply_filters('cpac-get-post-types', $post_types);
|
886 |
+
}
|
887 |
+
|
888 |
+
/**
|
889 |
+
* Register admin css
|
890 |
+
*
|
891 |
+
* @since 1.0
|
892 |
+
*/
|
893 |
+
public function admin_styles()
|
894 |
+
{
|
895 |
+
wp_enqueue_style( 'wp-pointer' );
|
896 |
+
wp_enqueue_style( 'jquery-ui-lightness', CPAC_URL.'/assets/ui-theme/jquery-ui-1.8.18.custom.css', array(), CPAC_VERSION, 'all' );
|
897 |
+
wp_enqueue_style( 'cpac-admin', CPAC_URL.'/assets/css/admin-column.css', array(), CPAC_VERSION, 'all' );
|
898 |
+
}
|
899 |
+
|
900 |
+
/**
|
901 |
+
* Register column css
|
902 |
+
*
|
903 |
+
* @since 1.0
|
904 |
+
*/
|
905 |
+
public function column_styles()
|
906 |
+
{
|
907 |
+
wp_enqueue_style( 'cpac-columns', CPAC_URL.'/assets/css/column.css', array(), CPAC_VERSION, 'all' );
|
908 |
+
}
|
909 |
+
|
910 |
+
/**
|
911 |
+
* Register plugin options
|
912 |
+
*
|
913 |
+
* @since 1.0
|
914 |
+
*/
|
915 |
+
public function register_settings()
|
916 |
+
{
|
917 |
+
// If we have no options in the database, let's add them now.
|
918 |
+
if ( false === get_option('cpac_options') ) {
|
919 |
+
add_option( 'cpac_options', $this->get_default_plugin_options() );
|
920 |
+
}
|
921 |
+
|
922 |
+
register_setting( 'cpac-settings-group', 'cpac_options', array($this, 'options_callback') );
|
923 |
+
}
|
924 |
+
|
925 |
+
/**
|
926 |
+
* Returns the default plugin options.
|
927 |
+
*
|
928 |
+
* @since 1.0
|
929 |
+
*/
|
930 |
+
public function get_default_plugin_options()
|
931 |
+
{
|
932 |
+
return apply_filters( 'cpac_default_plugin_options', array() );
|
933 |
+
}
|
934 |
+
|
935 |
+
/**
|
936 |
+
* Optional callback.
|
937 |
+
*
|
938 |
+
* @since 1.0
|
939 |
+
*/
|
940 |
+
public function options_callback($options)
|
941 |
+
{
|
942 |
+
return $options;
|
943 |
+
}
|
944 |
+
|
945 |
+
/**
|
946 |
+
* Handle requests.
|
947 |
+
*
|
948 |
+
* @since 1.0
|
949 |
+
*/
|
950 |
+
public function handle_requests()
|
951 |
+
{
|
952 |
+
// only handle updates from the admin columns page
|
953 |
+
if ( isset($_REQUEST['page']) && CPAC_SLUG == $_REQUEST['page'] ) {
|
954 |
+
|
955 |
+
// settings updated
|
956 |
+
if ( ! empty($_REQUEST['settings-updated']) ) {
|
957 |
+
$this->store_wp_default_columns();
|
958 |
+
}
|
959 |
+
|
960 |
+
// restore defaults
|
961 |
+
if ( ! empty($_REQUEST['cpac-restore-defaults']) ) {
|
962 |
+
$this->restore_defaults();
|
963 |
+
}
|
964 |
+
}
|
965 |
+
}
|
966 |
+
|
967 |
+
/**
|
968 |
+
* Stores WP default columns
|
969 |
+
*
|
970 |
+
* This will store columns that are set by WordPress core or theme
|
971 |
+
*
|
972 |
+
* @since 1.2
|
973 |
+
*/
|
974 |
+
private function store_wp_default_columns()
|
975 |
+
{
|
976 |
+
// stores the default columns that are set by WP or theme.
|
977 |
+
$wp_default_columns = array();
|
978 |
+
|
979 |
+
// Posts
|
980 |
+
foreach ( $this->post_types as $post_type ) {
|
981 |
+
$wp_default_columns[$post_type] = $this->get_wp_default_posts_columns($post_type);
|
982 |
+
}
|
983 |
+
|
984 |
+
// Users
|
985 |
+
$wp_default_columns['wp-users'] = $this->get_wp_default_users_columns();
|
986 |
+
|
987 |
+
// Media
|
988 |
+
$wp_default_columns['wp-media'] = $this->get_wp_default_media_columns();
|
989 |
+
|
990 |
+
// Links
|
991 |
+
$wp_default_columns['wp-links'] = $this->get_wp_default_links_columns();
|
992 |
+
|
993 |
+
// Comments
|
994 |
+
$wp_default_columns['wp-comments'] = $this->get_wp_default_comments_columns();
|
995 |
+
|
996 |
+
update_option( 'cpac_options_default', $wp_default_columns );
|
997 |
+
}
|
998 |
+
|
999 |
+
/**
|
1000 |
+
* Restore defaults
|
1001 |
+
*
|
1002 |
+
* @since 1.0
|
1003 |
+
*/
|
1004 |
+
private function restore_defaults()
|
1005 |
+
{
|
1006 |
+
delete_option( 'cpac_options' );
|
1007 |
+
delete_option( 'cpac_options_default' );
|
1008 |
+
}
|
1009 |
+
|
1010 |
+
/**
|
1011 |
+
* Get author field by nametype
|
1012 |
+
*
|
1013 |
+
* Used by posts and sortable
|
1014 |
+
*
|
1015 |
+
* @since 1.4.6.1
|
1016 |
+
*/
|
1017 |
+
public function get_author_field_by_nametype( $nametype, $user_id)
|
1018 |
+
{
|
1019 |
+
$userdata = get_userdata( $user_id );
|
1020 |
+
|
1021 |
+
switch ( $nametype ) :
|
1022 |
+
|
1023 |
+
case "display_name" :
|
1024 |
+
$name = $userdata->display_name;
|
1025 |
+
break;
|
1026 |
+
|
1027 |
+
case "first_name" :
|
1028 |
+
$name = $userdata->first_name;
|
1029 |
+
break;
|
1030 |
+
|
1031 |
+
case "last_name" :
|
1032 |
+
$name = $userdata->last_name;
|
1033 |
+
break;
|
1034 |
+
|
1035 |
+
case "first_last_name" :
|
1036 |
+
$first = !empty($userdata->first_name) ? $userdata->first_name : '';
|
1037 |
+
$last = !empty($userdata->last_name) ? " {$userdata->last_name}" : '';
|
1038 |
+
$name = $first.$last;
|
1039 |
+
break;
|
1040 |
+
|
1041 |
+
case "nickname" :
|
1042 |
+
$name = $userdata->nickname;
|
1043 |
+
break;
|
1044 |
+
|
1045 |
+
case "username" :
|
1046 |
+
$name = $userdata->user_login;
|
1047 |
+
break;
|
1048 |
+
|
1049 |
+
case "email" :
|
1050 |
+
$name = $userdata->user_email;
|
1051 |
+
break;
|
1052 |
+
|
1053 |
+
case "userid" :
|
1054 |
+
$name = $userdata->ID;
|
1055 |
+
break;
|
1056 |
+
|
1057 |
+
default :
|
1058 |
+
$name = $userdata->display_name;
|
1059 |
+
|
1060 |
+
endswitch;
|
1061 |
+
|
1062 |
+
return $name;
|
1063 |
+
}
|
1064 |
+
|
1065 |
+
/**
|
1066 |
+
* Get WP default supported admin columns per post type.
|
1067 |
+
*
|
1068 |
+
* @since 1.0
|
1069 |
+
*/
|
1070 |
+
private function get_wp_default_posts_columns($post_type = 'post')
|
1071 |
+
{
|
1072 |
+
// we need to change the current screen
|
1073 |
+
global $current_screen;
|
1074 |
+
|
1075 |
+
// some plugins depend on settings the $_GET['post_type'] variable such as ALL in One SEO
|
1076 |
+
$_GET['post_type'] = $post_type;
|
1077 |
+
|
1078 |
+
// to prevent possible warning from initializing load-edit.php
|
1079 |
+
// we will set a dummy screen object
|
1080 |
+
if ( empty($current_screen->post_type) ) {
|
1081 |
+
$current_screen = (object) array( 'post_type' => $post_type, 'id' => '', 'base' => '' );
|
1082 |
+
}
|
1083 |
+
|
1084 |
+
// for 3rd party plugin support we will call load-edit.php so all the
|
1085 |
+
// additional columns that are set by them will be avaible for us
|
1086 |
+
do_action('load-edit.php');
|
1087 |
+
|
1088 |
+
// some plugins directly hook into get_column_headers, such as woocommerce
|
1089 |
+
$columns = get_column_headers( 'edit-'.$post_type );
|
1090 |
+
|
1091 |
+
// get default columns
|
1092 |
+
if ( empty($columns) ) {
|
1093 |
+
|
1094 |
+
// deprecated as of wp3.3
|
1095 |
+
if ( file_exists(ABSPATH . 'wp-admin/includes/template.php') )
|
1096 |
+
require_once(ABSPATH . 'wp-admin/includes/template.php');
|
1097 |
+
|
1098 |
+
// introduced since wp3.3
|
1099 |
+
if ( file_exists(ABSPATH . 'wp-admin/includes/screen.php') )
|
1100 |
+
require_once(ABSPATH . 'wp-admin/includes/screen.php');
|
1101 |
+
|
1102 |
+
// used for getting columns
|
1103 |
+
if ( file_exists(ABSPATH . 'wp-admin/includes/class-wp-list-table.php') )
|
1104 |
+
require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php');
|
1105 |
+
if ( file_exists(ABSPATH . 'wp-admin/includes/class-wp-posts-list-table.php') )
|
1106 |
+
require_once(ABSPATH . 'wp-admin/includes/class-wp-posts-list-table.php');
|
1107 |
+
|
1108 |
+
// As of WP Release 3.5 we can use the following.
|
1109 |
+
if ( version_compare( get_bloginfo('version'), '3.4.10', '>=' ) ) {
|
1110 |
+
|
1111 |
+
$table = new WP_Posts_List_Table( array( 'screen' => $post_type ) );
|
1112 |
+
$columns = $table->get_columns();
|
1113 |
+
}
|
1114 |
+
|
1115 |
+
// WP versions older then 3.5
|
1116 |
+
// @todo: make this deprecated
|
1117 |
+
else {
|
1118 |
+
|
1119 |
+
// we need to change the current screen... first lets save original
|
1120 |
+
$org_current_screen = $current_screen;
|
1121 |
+
|
1122 |
+
// prevent php warning
|
1123 |
+
if ( !isset($current_screen) ) $current_screen = new stdClass;
|
1124 |
+
|
1125 |
+
// overwrite current_screen global with our post type of choose...
|
1126 |
+
$current_screen->post_type = $post_type;
|
1127 |
+
|
1128 |
+
// ...so we can get its columns
|
1129 |
+
$columns = WP_Posts_List_Table::get_columns();
|
1130 |
+
|
1131 |
+
// reset current screen
|
1132 |
+
$current_screen = $org_current_screen;
|
1133 |
+
}
|
1134 |
+
}
|
1135 |
+
|
1136 |
+
if ( empty ( $columns ) )
|
1137 |
+
return false;
|
1138 |
+
|
1139 |
+
// change to uniform format
|
1140 |
+
$columns = $this->get_uniform_format($columns);
|
1141 |
+
|
1142 |
+
// add sorting to some of the default links columns
|
1143 |
+
$columns = $this->set_sorting_to_default_posts_columns($columns);
|
1144 |
+
|
1145 |
+
return $columns;
|
1146 |
+
}
|
1147 |
+
|
1148 |
+
/**
|
1149 |
+
* Add Sorting to WP default Posts columns
|
1150 |
+
*
|
1151 |
+
* @since 1.4.5
|
1152 |
+
*/
|
1153 |
+
private function set_sorting_to_default_posts_columns($columns)
|
1154 |
+
{
|
1155 |
+
// categories
|
1156 |
+
if ( !empty($columns['categories']) ) {
|
1157 |
+
$columns['categories']['options']['sortorder'] = 'on';
|
1158 |
+
}
|
1159 |
+
// tags
|
1160 |
+
if ( !empty($columns['tags']) ) {
|
1161 |
+
$columns['tags']['options']['sortorder'] = 'on';
|
1162 |
+
}
|
1163 |
+
return $columns;
|
1164 |
+
}
|
1165 |
+
|
1166 |
+
/**
|
1167 |
+
* Get WP default users columns per post type.
|
1168 |
+
*
|
1169 |
+
* @since 1.1
|
1170 |
+
*/
|
1171 |
+
private function get_wp_default_users_columns()
|
1172 |
+
{
|
1173 |
+
if ( file_exists(ABSPATH . 'wp-admin/includes/class-wp-list-table.php') )
|
1174 |
+
require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php');
|
1175 |
+
if ( file_exists(ABSPATH . 'wp-admin/includes/class-wp-users-list-table.php') )
|
1176 |
+
require_once(ABSPATH . 'wp-admin/includes/class-wp-users-list-table.php');
|
1177 |
+
|
1178 |
+
// turn off site users
|
1179 |
+
$this->is_site_users = false;
|
1180 |
+
|
1181 |
+
// get users columns
|
1182 |
+
$columns = WP_Users_List_Table::get_columns();
|
1183 |
+
|
1184 |
+
// change to uniform format
|
1185 |
+
$columns = $this->get_uniform_format($columns);
|
1186 |
+
|
1187 |
+
return apply_filters('cpac-default-users-columns', $columns);
|
1188 |
+
}
|
1189 |
+
|
1190 |
+
/**
|
1191 |
+
* Get WP default media columns.
|
1192 |
+
*
|
1193 |
+
* @since 1.2.1
|
1194 |
+
*/
|
1195 |
+
private function get_wp_default_media_columns()
|
1196 |
+
{
|
1197 |
+
// @todo could use _get_list_table('WP_Media_List_Table') ?
|
1198 |
+
if ( file_exists(ABSPATH . 'wp-admin/includes/class-wp-list-table.php') )
|
1199 |
+
require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php');
|
1200 |
+
if ( file_exists(ABSPATH . 'wp-admin/includes/class-wp-media-list-table.php') )
|
1201 |
+
require_once(ABSPATH . 'wp-admin/includes/class-wp-media-list-table.php');
|
1202 |
+
|
1203 |
+
// As of WP Release 3.5 we can use the following.
|
1204 |
+
if ( version_compare( get_bloginfo('version'), '3.4.10', '>=' ) ) {
|
1205 |
+
|
1206 |
+
$table = new WP_Media_List_Table(array( 'screen' => 'upload' ));
|
1207 |
+
$columns = $table->get_columns();
|
1208 |
+
}
|
1209 |
+
|
1210 |
+
// WP versions older then 3.5
|
1211 |
+
// @todo: make this deprecated
|
1212 |
+
else {
|
1213 |
+
|
1214 |
+
global $current_screen;
|
1215 |
+
|
1216 |
+
// save original
|
1217 |
+
$org_current_screen = $current_screen;
|
1218 |
+
|
1219 |
+
// prevent php warning
|
1220 |
+
if ( !isset($current_screen) ) $current_screen = new stdClass;
|
1221 |
+
|
1222 |
+
// overwrite current_screen global with our media id...
|
1223 |
+
$current_screen->id = 'upload';
|
1224 |
+
|
1225 |
+
// init media class
|
1226 |
+
$wp_media = new WP_Media_List_Table;
|
1227 |
+
|
1228 |
+
// get media columns
|
1229 |
+
$columns = $wp_media->get_columns();
|
1230 |
+
|
1231 |
+
// reset current screen
|
1232 |
+
$current_screen = $org_current_screen;
|
1233 |
+
}
|
1234 |
+
|
1235 |
+
// change to uniform format
|
1236 |
+
$columns = $this->get_uniform_format($columns);
|
1237 |
+
|
1238 |
+
return apply_filters('cpac-default-media-columns', $columns);
|
1239 |
+
}
|
1240 |
+
|
1241 |
+
/**
|
1242 |
+
* Get WP default links columns.
|
1243 |
+
*
|
1244 |
+
* @since 1.3.1
|
1245 |
+
*/
|
1246 |
+
private function get_wp_default_links_columns()
|
1247 |
+
{
|
1248 |
+
// dependencies
|
1249 |
+
if ( file_exists(ABSPATH . 'wp-admin/includes/class-wp-list-table.php') )
|
1250 |
+
require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php');
|
1251 |
+
if ( file_exists(ABSPATH . 'wp-admin/includes/class-wp-links-list-table.php') )
|
1252 |
+
require_once(ABSPATH . 'wp-admin/includes/class-wp-links-list-table.php');
|
1253 |
+
|
1254 |
+
// get links columns
|
1255 |
+
$columns = WP_Links_List_Table::get_columns();
|
1256 |
+
|
1257 |
+
// change to uniform format
|
1258 |
+
$columns = $this->get_uniform_format($columns);
|
1259 |
+
|
1260 |
+
// add sorting to some of the default links columns
|
1261 |
+
$columns = $this->set_sorting_to_default_links_columns($columns);
|
1262 |
+
|
1263 |
+
return apply_filters('cpac-default-links-columns', $columns);
|
1264 |
+
}
|
1265 |
+
|
1266 |
+
/**
|
1267 |
+
* Add Sorting to WP default links columns
|
1268 |
+
*
|
1269 |
+
* @since 1.4
|
1270 |
+
*/
|
1271 |
+
private function set_sorting_to_default_links_columns($columns)
|
1272 |
+
{
|
1273 |
+
// Relationship
|
1274 |
+
if ( !empty($columns['rel']) ) {
|
1275 |
+
$columns['rel']['options']['sortorder'] = 'on';
|
1276 |
+
}
|
1277 |
+
return $columns;
|
1278 |
+
}
|
1279 |
+
|
1280 |
+
/**
|
1281 |
+
* Get WP default links columns.
|
1282 |
+
*
|
1283 |
+
* @since 1.3.1
|
1284 |
+
*/
|
1285 |
+
private function get_wp_default_comments_columns()
|
1286 |
+
{
|
1287 |
+
// dependencies
|
1288 |
+
if ( file_exists(ABSPATH . 'wp-admin/includes/class-wp-list-table.php') )
|
1289 |
+
require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php');
|
1290 |
+
if ( file_exists(ABSPATH . 'wp-admin/includes/class-wp-comments-list-table.php') )
|
1291 |
+
require_once(ABSPATH . 'wp-admin/includes/class-wp-comments-list-table.php');
|
1292 |
+
|
1293 |
+
// As of WP Release 3.5 we can use the following.
|
1294 |
+
if ( version_compare( get_bloginfo('version'), '3.4.10', '>=' ) ) {
|
1295 |
+
|
1296 |
+
$table = new WP_Comments_List_Table( array( 'screen' => 'edit-comments' ) );
|
1297 |
+
$columns = $table->get_columns();
|
1298 |
+
}
|
1299 |
+
|
1300 |
+
// WP versions older then 3.5
|
1301 |
+
// @todo: make this deprecated
|
1302 |
+
else {
|
1303 |
+
|
1304 |
+
global $current_screen;
|
1305 |
+
|
1306 |
+
// save original
|
1307 |
+
$org_current_screen = $current_screen;
|
1308 |
+
|
1309 |
+
// prevent php warning
|
1310 |
+
if ( !isset($current_screen) ) $current_screen = new stdClass;
|
1311 |
+
|
1312 |
+
// overwrite current_screen global with our media id...
|
1313 |
+
$current_screen->id = 'edit-comments';
|
1314 |
+
|
1315 |
+
// init table object
|
1316 |
+
$wp_comment = new WP_Comments_List_Table;
|
1317 |
+
|
1318 |
+
// get comments
|
1319 |
+
$columns = $wp_comment->get_columns();
|
1320 |
+
|
1321 |
+
// reset current screen
|
1322 |
+
$current_screen = $org_current_screen;
|
1323 |
+
}
|
1324 |
+
|
1325 |
+
// change to uniform format
|
1326 |
+
$columns = $this->get_uniform_format($columns);
|
1327 |
+
|
1328 |
+
// add sorting to some of the default links columns
|
1329 |
+
$columns = $this->set_sorting_to_default_comments_columns($columns);
|
1330 |
+
|
1331 |
+
return apply_filters('cpac-default-comments-columns', $columns);
|
1332 |
+
}
|
1333 |
+
|
1334 |
+
/**
|
1335 |
+
* Add Sorting to WP default comments columns
|
1336 |
+
*
|
1337 |
+
* @since 1.4
|
1338 |
+
*/
|
1339 |
+
private function set_sorting_to_default_comments_columns($columns)
|
1340 |
+
{
|
1341 |
+
// Comment
|
1342 |
+
if ( !empty($columns['comment']) ) {
|
1343 |
+
$columns['comment']['options']['sortorder'] = 'on';
|
1344 |
+
}
|
1345 |
+
return $columns;
|
1346 |
+
}
|
1347 |
+
|
1348 |
+
/**
|
1349 |
+
* Build uniform format for all columns
|
1350 |
+
*
|
1351 |
+
* @since 1.0
|
1352 |
+
*/
|
1353 |
+
private function get_uniform_format($columns)
|
1354 |
+
{
|
1355 |
+
// we remove the checkbox column as an option...
|
1356 |
+
if ( isset($columns['cb']) )
|
1357 |
+
unset($columns['cb']);
|
1358 |
+
|
1359 |
+
// change to uniform format
|
1360 |
+
$uniform_columns = array();
|
1361 |
+
foreach ( (array) $columns as $id => $label ) {
|
1362 |
+
$hide_options = false;
|
1363 |
+
$type_label = $label;
|
1364 |
+
|
1365 |
+
// comment exception
|
1366 |
+
if ( 'comments' == $id ) {
|
1367 |
+
$label = '';
|
1368 |
+
$type_label = __('Comments', CPAC_TEXTDOMAIN);
|
1369 |
+
$hide_options = true;
|
1370 |
+
}
|
1371 |
+
|
1372 |
+
// user icon exception
|
1373 |
+
if ( $id == 'icon' ) {
|
1374 |
+
$type_label = __('Icon', CPAC_TEXTDOMAIN);
|
1375 |
+
}
|
1376 |
+
|
1377 |
+
$uniform_columns[$id] = array(
|
1378 |
+
'label' => $label,
|
1379 |
+
'state' => 'on',
|
1380 |
+
'options' => array(
|
1381 |
+
'type_label' => $type_label,
|
1382 |
+
'hide_options' => $hide_options,
|
1383 |
+
'class' => 'cpac-box-wp-native',
|
1384 |
+
)
|
1385 |
+
);
|
1386 |
+
}
|
1387 |
+
return $uniform_columns;
|
1388 |
+
}
|
1389 |
+
|
1390 |
+
/**
|
1391 |
+
* Custom posts columns
|
1392 |
+
*
|
1393 |
+
* @since 1.0
|
1394 |
+
*/
|
1395 |
+
private function get_custom_posts_columns($post_type)
|
1396 |
+
{
|
1397 |
+
$custom_columns = array(
|
1398 |
+
'column-featured_image' => array(
|
1399 |
+
'label' => __('Featured Image', CPAC_TEXTDOMAIN)
|
1400 |
+
),
|
1401 |
+
'column-excerpt' => array(
|
1402 |
+
'label' => __('Excerpt', CPAC_TEXTDOMAIN)
|
1403 |
+
),
|
1404 |
+
'column-order' => array(
|
1405 |
+
'label' => __('Page Order', CPAC_TEXTDOMAIN)
|
1406 |
+
),
|
1407 |
+
'column-post_formats' => array(
|
1408 |
+
'label' => __('Post Format', CPAC_TEXTDOMAIN)
|
1409 |
+
),
|
1410 |
+
'column-postid' => array(
|
1411 |
+
'label' => __('ID', CPAC_TEXTDOMAIN)
|
1412 |
+
),
|
1413 |
+
'column-page-slug' => array(
|
1414 |
+
'label' => __('Slug', CPAC_TEXTDOMAIN)
|
1415 |
+
),
|
1416 |
+
'column-attachment' => array(
|
1417 |
+
'label' => __('Attachment', CPAC_TEXTDOMAIN)
|
1418 |
+
),
|
1419 |
+
'column-attachment-count' => array(
|
1420 |
+
'label' => __('No. of Attachments', CPAC_TEXTDOMAIN)
|
1421 |
+
),
|
1422 |
+
'column-roles' => array(
|
1423 |
+
'label' => __('Roles', CPAC_TEXTDOMAIN)
|
1424 |
+
),
|
1425 |
+
'column-status' => array(
|
1426 |
+
'label' => __('Status', CPAC_TEXTDOMAIN)
|
1427 |
+
),
|
1428 |
+
'column-comment-status' => array(
|
1429 |
+
'label' => __('Comment status', CPAC_TEXTDOMAIN)
|
1430 |
+
),
|
1431 |
+
'column-ping-status' => array(
|
1432 |
+
'label' => __('Ping status', CPAC_TEXTDOMAIN)
|
1433 |
+
),
|
1434 |
+
'column-actions' => array(
|
1435 |
+
'label' => __('Actions', CPAC_TEXTDOMAIN),
|
1436 |
+
'options' => array(
|
1437 |
+
'sortorder' => false
|
1438 |
+
)
|
1439 |
+
),
|
1440 |
+
'column-modified' => array(
|
1441 |
+
'label' => __('Last modified', CPAC_TEXTDOMAIN)
|
1442 |
+
),
|
1443 |
+
'column-comment-count' => array(
|
1444 |
+
'label' => __('Comment count', CPAC_TEXTDOMAIN)
|
1445 |
+
),
|
1446 |
+
'column-author-name' => array(
|
1447 |
+
'label' => __('Display Author As', CPAC_TEXTDOMAIN),
|
1448 |
+
'display_as' => ''
|
1449 |
+
),
|
1450 |
+
'column-before-moretag' => array(
|
1451 |
+
'label' => __('Before More Tag', CPAC_TEXTDOMAIN)
|
1452 |
+
)
|
1453 |
+
);
|
1454 |
+
|
1455 |
+
// Word count support
|
1456 |
+
if ( post_type_supports($post_type, 'editor') ) {
|
1457 |
+
$custom_columns['column-word-count'] = array(
|
1458 |
+
'label' => __('Word count', CPAC_TEXTDOMAIN)
|
1459 |
+
);
|
1460 |
+
}
|
1461 |
+
|
1462 |
+
// Sticky support
|
1463 |
+
if ( $post_type == 'post' ) {
|
1464 |
+
$custom_columns['column-sticky'] = array(
|
1465 |
+
'label' => __('Sticky', CPAC_TEXTDOMAIN)
|
1466 |
+
);
|
1467 |
+
}
|
1468 |
+
|
1469 |
+
// Order support
|
1470 |
+
if ( post_type_supports($post_type, 'page-attributes') ) {
|
1471 |
+
$custom_columns['column-order'] = array(
|
1472 |
+
'label' => __('Page Order', CPAC_TEXTDOMAIN),
|
1473 |
+
'options' => array(
|
1474 |
+
'type_label' => __('Order', CPAC_TEXTDOMAIN)
|
1475 |
+
)
|
1476 |
+
);
|
1477 |
+
}
|
1478 |
+
|
1479 |
+
// Page Template
|
1480 |
+
if ( $post_type == 'page' ) {
|
1481 |
+
$custom_columns['column-page-template'] = array(
|
1482 |
+
'label' => __('Page Template', CPAC_TEXTDOMAIN)
|
1483 |
+
);
|
1484 |
+
}
|
1485 |
+
|
1486 |
+
// Post Formats
|
1487 |
+
if ( post_type_supports($post_type, 'post-formats') ) {
|
1488 |
+
$custom_columns['column-post_formats'] = array(
|
1489 |
+
'label' => __('Post Format', CPAC_TEXTDOMAIN)
|
1490 |
+
);
|
1491 |
+
}
|
1492 |
+
|
1493 |
+
// Taxonomy support
|
1494 |
+
$taxonomies = get_object_taxonomies($post_type, 'objects');
|
1495 |
+
if ( $taxonomies ) {
|
1496 |
+
foreach ( $taxonomies as $tax_slug => $tax ) {
|
1497 |
+
if ( $tax_slug != 'post_tag' && $tax_slug != 'category' && $tax_slug != 'post_format' ) {
|
1498 |
+
$custom_columns['column-taxonomy-'.$tax->name] = array(
|
1499 |
+
'label' => $tax->label,
|
1500 |
+
'show_filter' => true,
|
1501 |
+
'options' => array(
|
1502 |
+
'type_label' => __('Taxonomy', CPAC_TEXTDOMAIN)
|
1503 |
+
)
|
1504 |
+
);
|
1505 |
+
}
|
1506 |
+
}
|
1507 |
+
}
|
1508 |
+
|
1509 |
+
// Custom Field support
|
1510 |
+
if ( $this->get_meta_by_type($post_type) ) {
|
1511 |
+
$custom_columns['column-meta-1'] = array(
|
1512 |
+
'label' => __('Custom Field', CPAC_TEXTDOMAIN),
|
1513 |
+
'field' => '',
|
1514 |
+
'field_type' => '',
|
1515 |
+
'before' => '',
|
1516 |
+
'after' => '',
|
1517 |
+
'options' => array(
|
1518 |
+
'type_label' => __('Field', CPAC_TEXTDOMAIN),
|
1519 |
+
'class' => 'cpac-box-metafield'
|
1520 |
+
)
|
1521 |
+
);
|
1522 |
+
}
|
1523 |
+
|
1524 |
+
// merge with defaults
|
1525 |
+
$custom_columns = $this->parse_defaults($custom_columns);
|
1526 |
+
|
1527 |
+
return apply_filters('cpac-custom-posts-columns', $custom_columns);
|
1528 |
+
}
|
1529 |
+
|
1530 |
+
/**
|
1531 |
+
* Custom users columns
|
1532 |
+
*
|
1533 |
+
* @since 1.1
|
1534 |
+
*/
|
1535 |
+
private function get_custom_users_columns()
|
1536 |
+
{
|
1537 |
+
$custom_columns = array(
|
1538 |
+
'column-user_id' => array(
|
1539 |
+
'label' => __('User ID', CPAC_TEXTDOMAIN)
|
1540 |
+
),
|
1541 |
+
'column-nickname' => array(
|
1542 |
+
'label' => __('Nickname', CPAC_TEXTDOMAIN)
|
1543 |
+
),
|
1544 |
+
'column-first_name' => array(
|
1545 |
+
'label' => __('First name', CPAC_TEXTDOMAIN)
|
1546 |
+
),
|
1547 |
+
'column-last_name' => array(
|
1548 |
+
'label' => __('Last name', CPAC_TEXTDOMAIN)
|
1549 |
+
),
|
1550 |
+
'column-user_url' => array(
|
1551 |
+
'label' => __('Url', CPAC_TEXTDOMAIN)
|
1552 |
+
),
|
1553 |
+
'column-user_registered' => array(
|
1554 |
+
'label' => __('Registered', CPAC_TEXTDOMAIN)
|
1555 |
+
),
|
1556 |
+
'column-user_description' => array(
|
1557 |
+
'label' => __('Description', CPAC_TEXTDOMAIN)
|
1558 |
+
),
|
1559 |
+
'column-actions' => array(
|
1560 |
+
'label' => __('Actions', CPAC_TEXTDOMAIN),
|
1561 |
+
'options' => array(
|
1562 |
+
'sortorder' => false
|
1563 |
+
)
|
1564 |
+
),
|
1565 |
+
);
|
1566 |
+
|
1567 |
+
// User total number of posts
|
1568 |
+
foreach ( self::get_post_types() as $post_type ) {
|
1569 |
+
$label = $this->get_plural_name($post_type);
|
1570 |
+
$custom_columns['column-user_postcount-'.$post_type] = array(
|
1571 |
+
'label' => __( sprintf('No. of %s',$label), CPAC_TEXTDOMAIN),
|
1572 |
+
'options' => array(
|
1573 |
+
'type_label' => __('Postcount', CPAC_TEXTDOMAIN)
|
1574 |
+
)
|
1575 |
+
);
|
1576 |
+
}
|
1577 |
+
|
1578 |
+
// Custom Field support
|
1579 |
+
$custom_columns['column-meta-1'] = array(
|
1580 |
+
'label' => __('Custom Field', CPAC_TEXTDOMAIN),
|
1581 |
+
'field' => '',
|
1582 |
+
'field_type' => '',
|
1583 |
+
'before' => '',
|
1584 |
+
'after' => '',
|
1585 |
+
'options' => array(
|
1586 |
+
'type_label' => __('Field', CPAC_TEXTDOMAIN),
|
1587 |
+
'class' => 'cpac-box-metafield'
|
1588 |
+
)
|
1589 |
+
);
|
1590 |
+
|
1591 |
+
// merge with defaults
|
1592 |
+
$custom_columns = $this->parse_defaults($custom_columns);
|
1593 |
+
|
1594 |
+
return apply_filters('cpac-custom-users-columns', $custom_columns);
|
1595 |
+
}
|
1596 |
+
|
1597 |
+
/**
|
1598 |
+
* Custom media columns
|
1599 |
+
*
|
1600 |
+
* @since 1.3
|
1601 |
+
*/
|
1602 |
+
private function get_custom_media_columns()
|
1603 |
+
{
|
1604 |
+
$custom_columns = array(
|
1605 |
+
'column-mediaid' => array(
|
1606 |
+
'label' => __('ID', CPAC_TEXTDOMAIN)
|
1607 |
+
),
|
1608 |
+
'column-mime_type' => array(
|
1609 |
+
'label' => __('Mime type', CPAC_TEXTDOMAIN)
|
1610 |
+
),
|
1611 |
+
'column-file_name' => array(
|
1612 |
+
'label' => __('File name', CPAC_TEXTDOMAIN)
|
1613 |
+
),
|
1614 |
+
'column-dimensions' => array(
|
1615 |
+
'label' => __('Dimensions', CPAC_TEXTDOMAIN)
|
1616 |
+
),
|
1617 |
+
'column-height' => array(
|
1618 |
+
'label' => __('Height', CPAC_TEXTDOMAIN)
|
1619 |
+
),
|
1620 |
+
'column-width' => array(
|
1621 |
+
'label' => __('Width', CPAC_TEXTDOMAIN)
|
1622 |
+
),
|
1623 |
+
'column-caption' => array(
|
1624 |
+
'label' => __('Caption', CPAC_TEXTDOMAIN)
|
1625 |
+
),
|
1626 |
+
'column-description' => array(
|
1627 |
+
'label' => __('Description', CPAC_TEXTDOMAIN)
|
1628 |
+
),
|
1629 |
+
'column-alternate_text' => array(
|
1630 |
+
'label' => __('Alt', CPAC_TEXTDOMAIN)
|
1631 |
+
),
|
1632 |
+
'column-file_paths' => array(
|
1633 |
+
'label' => __('Upload paths', CPAC_TEXTDOMAIN),
|
1634 |
+
'options' => array(
|
1635 |
+
'sortorder' => false
|
1636 |
+
)
|
1637 |
+
),
|
1638 |
+
'column-actions' => array(
|
1639 |
+
'label' => __('Actions', CPAC_TEXTDOMAIN),
|
1640 |
+
'options' => array(
|
1641 |
+
'sortorder' => false
|
1642 |
+
)
|
1643 |
+
),
|
1644 |
+
'column-filesize' => array(
|
1645 |
+
'label' => __('File size', CPAC_TEXTDOMAIN)
|
1646 |
+
)
|
1647 |
+
);
|
1648 |
+
|
1649 |
+
// Get extended image metadata, exif or iptc as available.
|
1650 |
+
// uses exif_read_data()
|
1651 |
+
if ( function_exists('exif_read_data') ) {
|
1652 |
+
$custom_columns = array_merge( $custom_columns, array(
|
1653 |
+
'column-image-aperture' => array(
|
1654 |
+
'label' => __('Aperture', CPAC_TEXTDOMAIN),
|
1655 |
+
'options' => array(
|
1656 |
+
'type_label' => __('Aperture EXIF', CPAC_TEXTDOMAIN)
|
1657 |
+
)
|
1658 |
+
),
|
1659 |
+
'column-image-credit' => array(
|
1660 |
+
'label' => __('Credit', CPAC_TEXTDOMAIN),
|
1661 |
+
'options' => array(
|
1662 |
+
'type_label' => __('Credit EXIF', CPAC_TEXTDOMAIN)
|
1663 |
+
)
|
1664 |
+
),
|
1665 |
+
'column-image-camera' => array(
|
1666 |
+
'label' => __('Camera', CPAC_TEXTDOMAIN),
|
1667 |
+
'options' => array(
|
1668 |
+
'type_label' => __('Camera EXIF', CPAC_TEXTDOMAIN)
|
1669 |
+
)
|
1670 |
+
),
|
1671 |
+
'column-image-caption' => array(
|
1672 |
+
'label' => __('Caption', CPAC_TEXTDOMAIN),
|
1673 |
+
'options' => array(
|
1674 |
+
'type_label' => __('Caption EXIF', CPAC_TEXTDOMAIN)
|
1675 |
+
)
|
1676 |
+
),
|
1677 |
+
'column-image-created_timestamp' => array(
|
1678 |
+
'label' => __('Timestamp', CPAC_TEXTDOMAIN),
|
1679 |
+
'options' => array(
|
1680 |
+
'type_label' => __('Timestamp EXIF', CPAC_TEXTDOMAIN)
|
1681 |
+
)
|
1682 |
+
),
|
1683 |
+
'column-image-copyright' => array(
|
1684 |
+
'label' => __('Copyright', CPAC_TEXTDOMAIN),
|
1685 |
+
'options' => array(
|
1686 |
+
'type_label' => __('Copyright EXIF', CPAC_TEXTDOMAIN)
|
1687 |
+
)
|
1688 |
+
),
|
1689 |
+
'column-image-focal_length' => array(
|
1690 |
+
'label' => __('Focal Length', CPAC_TEXTDOMAIN),
|
1691 |
+
'options' => array(
|
1692 |
+
'type_label' => __('Focal Length EXIF', CPAC_TEXTDOMAIN)
|
1693 |
+
)
|
1694 |
+
),
|
1695 |
+
'column-image-iso' => array(
|
1696 |
+
'label' => __('ISO', CPAC_TEXTDOMAIN),
|
1697 |
+
'options' => array(
|
1698 |
+
'type_label' => __('ISO EXIF', CPAC_TEXTDOMAIN)
|
1699 |
+
)
|
1700 |
+
),
|
1701 |
+
'column-image-shutter_speed' => array(
|
1702 |
+
'label' => __('Shutter Speed', CPAC_TEXTDOMAIN),
|
1703 |
+
'options' => array(
|
1704 |
+
'type_label' => __('Shutter Speed EXIF', CPAC_TEXTDOMAIN)
|
1705 |
+
)
|
1706 |
+
),
|
1707 |
+
'column-image-title' => array(
|
1708 |
+
'label' => __('Title', CPAC_TEXTDOMAIN),
|
1709 |
+
'options' => array(
|
1710 |
+
'type_label' => __('Title EXIF', CPAC_TEXTDOMAIN)
|
1711 |
+
)
|
1712 |
+
)
|
1713 |
+
));
|
1714 |
+
}
|
1715 |
+
|
1716 |
+
// Custom Field support
|
1717 |
+
if ( $this->get_meta_by_type('wp-media') ) {
|
1718 |
+
$custom_columns['column-meta-1'] = array(
|
1719 |
+
'label' => __('Custom Field', CPAC_TEXTDOMAIN),
|
1720 |
+
'field' => '',
|
1721 |
+
'field_type' => '',
|
1722 |
+
'before' => '',
|
1723 |
+
'after' => '',
|
1724 |
+
'options' => array(
|
1725 |
+
'type_label' => __('Field', CPAC_TEXTDOMAIN),
|
1726 |
+
'class' => 'cpac-box-metafield'
|
1727 |
+
)
|
1728 |
+
);
|
1729 |
+
}
|
1730 |
+
|
1731 |
+
// merge with defaults
|
1732 |
+
$custom_columns = $this->parse_defaults($custom_columns);
|
1733 |
+
|
1734 |
+
return apply_filters('cpac-custom-media-columns', $custom_columns);
|
1735 |
+
}
|
1736 |
+
|
1737 |
+
/**
|
1738 |
+
* Custom links columns
|
1739 |
+
*
|
1740 |
+
* @since 1.3.1
|
1741 |
+
*/
|
1742 |
+
private function get_custom_links_columns()
|
1743 |
+
{
|
1744 |
+
$custom_columns = array(
|
1745 |
+
'column-link_id' => array (
|
1746 |
+
'label' => __('ID', CPAC_TEXTDOMAIN)
|
1747 |
+
),
|
1748 |
+
'column-description' => array (
|
1749 |
+
'label' => __('Description', CPAC_TEXTDOMAIN)
|
1750 |
+
),
|
1751 |
+
'column-image' => array(
|
1752 |
+
'label' => __('Image', CPAC_TEXTDOMAIN)
|
1753 |
+
),
|
1754 |
+
'column-target' => array(
|
1755 |
+
'label' => __('Target', CPAC_TEXTDOMAIN)
|
1756 |
+
),
|
1757 |
+
'column-owner' => array(
|
1758 |
+
'label' => __('Owner', CPAC_TEXTDOMAIN)
|
1759 |
+
),
|
1760 |
+
'column-notes' => array(
|
1761 |
+
'label' => __('Notes', CPAC_TEXTDOMAIN)
|
1762 |
+
),
|
1763 |
+
'column-rss' => array(
|
1764 |
+
'label' => __('Rss', CPAC_TEXTDOMAIN)
|
1765 |
+
),
|
1766 |
+
'column-length' => array(
|
1767 |
+
'label' => __('Length', CPAC_TEXTDOMAIN)
|
1768 |
+
),
|
1769 |
+
'column-actions' => array(
|
1770 |
+
'label' => __('Actions', CPAC_TEXTDOMAIN),
|
1771 |
+
'options' => array(
|
1772 |
+
'sortorder' => false
|
1773 |
+
)
|
1774 |
+
)
|
1775 |
+
);
|
1776 |
+
|
1777 |
+
// merge with defaults
|
1778 |
+
$custom_columns = $this->parse_defaults($custom_columns);
|
1779 |
+
|
1780 |
+
return apply_filters('cpac-custom-links-columns', $custom_columns);
|
1781 |
+
}
|
1782 |
+
|
1783 |
+
/**
|
1784 |
+
* Custom comments columns
|
1785 |
+
*
|
1786 |
+
* @since 1.3.1
|
1787 |
+
*/
|
1788 |
+
private function get_custom_comments_columns()
|
1789 |
+
{
|
1790 |
+
$custom_columns = array(
|
1791 |
+
'column-comment_id' => array(
|
1792 |
+
'label' => __('ID', CPAC_TEXTDOMAIN)
|
1793 |
+
),
|
1794 |
+
'column-author_author' => array(
|
1795 |
+
'label' => __('Author Name', CPAC_TEXTDOMAIN)
|
1796 |
+
),
|
1797 |
+
'column-author_avatar' => array(
|
1798 |
+
'label' => __('Avatar', CPAC_TEXTDOMAIN)
|
1799 |
+
),
|
1800 |
+
'column-author_url' => array(
|
1801 |
+
'label' => __('Author url', CPAC_TEXTDOMAIN)
|
1802 |
+
),
|
1803 |
+
'column-author_ip' => array(
|
1804 |
+
'label' => __('Author IP', CPAC_TEXTDOMAIN)
|
1805 |
+
),
|
1806 |
+
'column-author_email' => array(
|
1807 |
+
'label' => __('Author email', CPAC_TEXTDOMAIN)
|
1808 |
+
),
|
1809 |
+
'column-reply_to' => array(
|
1810 |
+
'label' => __('In Reply To', CPAC_TEXTDOMAIN),
|
1811 |
+
'options' => array(
|
1812 |
+
'sortorder' => false
|
1813 |
+
)
|
1814 |
+
),
|
1815 |
+
'column-approved' => array(
|
1816 |
+
'label' => __('Approved', CPAC_TEXTDOMAIN)
|
1817 |
+
),
|
1818 |
+
'column-date' => array(
|
1819 |
+
'label' => __('Date', CPAC_TEXTDOMAIN)
|
1820 |
+
),
|
1821 |
+
'column-date_gmt' => array(
|
1822 |
+
'label' => __('Date GMT', CPAC_TEXTDOMAIN)
|
1823 |
+
),
|
1824 |
+
'column-agent' => array(
|
1825 |
+
'label' => __('Agent', CPAC_TEXTDOMAIN)
|
1826 |
+
),
|
1827 |
+
'column-excerpt' => array(
|
1828 |
+
'label' => __('Excerpt', CPAC_TEXTDOMAIN)
|
1829 |
+
),
|
1830 |
+
'column-actions' => array(
|
1831 |
+
'label' => __('Actions', CPAC_TEXTDOMAIN),
|
1832 |
+
'options' => array(
|
1833 |
+
'sortorder' => false
|
1834 |
+
)
|
1835 |
+
),
|
1836 |
+
'column-word-count' => array(
|
1837 |
+
'label' => __('Word count', CPAC_TEXTDOMAIN),
|
1838 |
+
'options' => array(
|
1839 |
+
'sortorder' => false
|
1840 |
+
)
|
1841 |
+
)
|
1842 |
+
);
|
1843 |
+
|
1844 |
+
// Custom Field support
|
1845 |
+
if ( $this->get_meta_by_type('wp-comments') ) {
|
1846 |
+
$custom_columns['column-meta-1'] = array(
|
1847 |
+
'label' => __('Custom Field', CPAC_TEXTDOMAIN),
|
1848 |
+
'field' => '',
|
1849 |
+
'field_type' => '',
|
1850 |
+
'before' => '',
|
1851 |
+
'after' => '',
|
1852 |
+
'options' => array(
|
1853 |
+
'type_label' => __('Field', CPAC_TEXTDOMAIN),
|
1854 |
+
'class' => 'cpac-box-metafield',
|
1855 |
+
'sortorder' => false,
|
1856 |
+
)
|
1857 |
+
);
|
1858 |
+
}
|
1859 |
+
|
1860 |
+
// merge with defaults
|
1861 |
+
$custom_columns = $this->parse_defaults($custom_columns);
|
1862 |
+
|
1863 |
+
return apply_filters('cpac-custom-comments-columns', $custom_columns);
|
1864 |
+
}
|
1865 |
+
|
1866 |
+
/**
|
1867 |
+
* Parse defaults
|
1868 |
+
*
|
1869 |
+
* @since 1.1
|
1870 |
+
*/
|
1871 |
+
private function parse_defaults($columns)
|
1872 |
+
{
|
1873 |
+
// default arguments
|
1874 |
+
$defaults = array(
|
1875 |
+
|
1876 |
+
// stored values
|
1877 |
+
'label' => '', // custom label
|
1878 |
+
'state' => '', // display state
|
1879 |
+
'width' => '', // column width
|
1880 |
+
|
1881 |
+
// static values
|
1882 |
+
'options' => array(
|
1883 |
+
'type_label' => __('Custom', CPAC_TEXTDOMAIN),
|
1884 |
+
'hide_options' => false,
|
1885 |
+
'class' => 'cpac-box-custom',
|
1886 |
+
'sortorder' => 'on',
|
1887 |
+
)
|
1888 |
+
);
|
1889 |
+
|
1890 |
+
// parse args
|
1891 |
+
foreach ( $columns as $k => $column ) {
|
1892 |
+
$c[$k] = wp_parse_args( $column, $defaults);
|
1893 |
+
|
1894 |
+
// parse options args
|
1895 |
+
if ( isset($column['options']) )
|
1896 |
+
$c[$k]['options'] = wp_parse_args( $column['options'], $defaults['options']);
|
1897 |
+
|
1898 |
+
// set type label
|
1899 |
+
if ( empty($column['options']['type_label']) && !empty($column['label']) )
|
1900 |
+
$c[$k]['options']['type_label'] = $column['label'];
|
1901 |
+
}
|
1902 |
+
|
1903 |
+
return $c;
|
1904 |
+
}
|
1905 |
+
|
1906 |
+
/**
|
1907 |
+
* Admin requests for orderby column
|
1908 |
+
*
|
1909 |
+
* @since 1.0
|
1910 |
+
*/
|
1911 |
+
public static function get_stored_columns($type)
|
1912 |
+
{
|
1913 |
+
// get plugin options
|
1914 |
+
$options = get_option('cpac_options');
|
1915 |
+
|
1916 |
+
// get saved columns
|
1917 |
+
if ( !empty($options['columns'][$type]) )
|
1918 |
+
return $options['columns'][$type];
|
1919 |
+
|
1920 |
+
return false;
|
1921 |
+
}
|
1922 |
+
|
1923 |
+
/**
|
1924 |
+
* Post Type Menu
|
1925 |
+
*
|
1926 |
+
* @since 1.0
|
1927 |
+
*/
|
1928 |
+
private function get_menu()
|
1929 |
+
{
|
1930 |
+
// set
|
1931 |
+
$menu = '';
|
1932 |
+
$count = 1;
|
1933 |
+
|
1934 |
+
// referer
|
1935 |
+
$referer = ! empty($_REQUEST['cpac_type']) ? $_REQUEST['cpac_type'] : '';
|
1936 |
+
|
1937 |
+
// loop
|
1938 |
+
foreach ( $this->get_types() as $type ) {
|
1939 |
+
$label = $this->get_singular_name($type);
|
1940 |
+
$clean_label = $this->sanitize_string($type);
|
1941 |
+
|
1942 |
+
// divider
|
1943 |
+
$divider = $count++ == 1 ? '' : ' | ';
|
1944 |
+
|
1945 |
+
// current
|
1946 |
+
$current = '';
|
1947 |
+
if ( $this->is_menu_type_current($type) )
|
1948 |
+
$current = ' class="current"';
|
1949 |
+
|
1950 |
+
// menu list
|
1951 |
+
$menu .= "
|
1952 |
+
<li>{$divider}<a{$current} href='#cpac-box-{$clean_label}'>{$label}</a></li>
|
1953 |
+
";
|
1954 |
+
}
|
1955 |
+
|
1956 |
+
// settings url
|
1957 |
+
$class_current_settings = $this->is_menu_type_current('plugin_settings') ? ' current': '';
|
1958 |
+
|
1959 |
+
// options button
|
1960 |
+
$options_btn = "<a href='#cpac-box-plugin_settings' class='cpac-settings-link{$class_current_settings}'>".__('Addons', CPAC_TEXTDOMAIN)."</a>";
|
1961 |
+
//$options_btn = '';
|
1962 |
+
|
1963 |
+
return "
|
1964 |
+
<div class='cpac-menu'>
|
1965 |
+
<ul class='subsubsub'>
|
1966 |
+
{$menu}
|
1967 |
+
</ul>
|
1968 |
+
{$options_btn}
|
1969 |
+
</div>
|
1970 |
+
";
|
1971 |
+
}
|
1972 |
+
|
1973 |
+
/**
|
1974 |
+
* Checks if menu type is currently viewed
|
1975 |
+
*
|
1976 |
+
* @since 1.0
|
1977 |
+
*/
|
1978 |
+
private function is_menu_type_current( $type )
|
1979 |
+
{
|
1980 |
+
// referer
|
1981 |
+
$referer = ! empty($_REQUEST['cpac_type']) ? $_REQUEST['cpac_type'] : '';
|
1982 |
+
|
1983 |
+
// get label
|
1984 |
+
$clean_label = $this->sanitize_string($type);
|
1985 |
+
|
1986 |
+
// get first element from post-types
|
1987 |
+
$first = array_shift( array_values($this->post_types) );
|
1988 |
+
|
1989 |
+
// display the page that was being viewed before saving
|
1990 |
+
if ( $referer ) {
|
1991 |
+
if ( $referer == 'cpac-box-'.$clean_label ) {
|
1992 |
+
return true;
|
1993 |
+
}
|
1994 |
+
|
1995 |
+
// settings page has not yet been saved
|
1996 |
+
} elseif ( $first == $type ) {
|
1997 |
+
return true;
|
1998 |
+
}
|
1999 |
+
|
2000 |
+
return false;
|
2001 |
+
}
|
2002 |
+
|
2003 |
+
/**
|
2004 |
+
* Get singular name of post type
|
2005 |
+
*
|
2006 |
+
* @since 1.0
|
2007 |
+
*/
|
2008 |
+
private function get_singular_name( $type )
|
2009 |
+
{
|
2010 |
+
// Links
|
2011 |
+
if ( $type == 'wp-links' )
|
2012 |
+
$label = __('Links');
|
2013 |
+
|
2014 |
+
// Comments
|
2015 |
+
elseif ( $type == 'wp-comments' )
|
2016 |
+
$label = __('Comments');
|
2017 |
+
|
2018 |
+
// Users
|
2019 |
+
elseif ( $type == 'wp-users' )
|
2020 |
+
$label = __('Users');
|
2021 |
+
|
2022 |
+
// Media
|
2023 |
+
elseif ( $type == 'wp-media' )
|
2024 |
+
$label = __('Media Library');
|
2025 |
+
|
2026 |
+
// Posts
|
2027 |
+
else {
|
2028 |
+
$posttype_obj = get_post_type_object($type);
|
2029 |
+
$label = $posttype_obj->labels->singular_name;
|
2030 |
+
}
|
2031 |
+
|
2032 |
+
return $label;
|
2033 |
+
}
|
2034 |
+
|
2035 |
+
/**
|
2036 |
+
* Get plural name of post type
|
2037 |
+
*
|
2038 |
+
* @since 1.3.1
|
2039 |
+
*/
|
2040 |
+
private function get_plural_name( $type )
|
2041 |
+
{
|
2042 |
+
$posttype_obj = get_post_type_object($type);
|
2043 |
+
if ( $posttype_obj )
|
2044 |
+
return $posttype_obj->labels->name;
|
2045 |
+
|
2046 |
+
return false;
|
2047 |
+
}
|
2048 |
+
|
2049 |
+
/**
|
2050 |
+
* Get screen link to overview screen
|
2051 |
+
*
|
2052 |
+
* @since 1.3.1
|
2053 |
+
*/
|
2054 |
+
private function get_type_screen_link( $type )
|
2055 |
+
{
|
2056 |
+
// Links
|
2057 |
+
if ( $type == 'wp-comments' )
|
2058 |
+
$link = get_admin_url() . 'edit-comments.php';
|
2059 |
+
|
2060 |
+
// Links
|
2061 |
+
if ( $type == 'wp-links' )
|
2062 |
+
$link = get_admin_url() . 'link-manager.php';
|
2063 |
+
|
2064 |
+
// Users
|
2065 |
+
if ( $type == 'wp-users' )
|
2066 |
+
$link = get_admin_url() . 'users.php';
|
2067 |
+
|
2068 |
+
// Media
|
2069 |
+
elseif ( $type == 'wp-media' )
|
2070 |
+
$link = get_admin_url() . 'upload.php';
|
2071 |
+
|
2072 |
+
// Posts
|
2073 |
+
else
|
2074 |
+
$link = get_admin_url() . "edit.php?post_type={$type}";
|
2075 |
+
|
2076 |
+
return $link;
|
2077 |
+
}
|
2078 |
+
|
2079 |
+
/**
|
2080 |
+
* Sanitize label
|
2081 |
+
*
|
2082 |
+
* Uses intern wordpress function esc_url so it matches the label sorting url.
|
2083 |
+
*
|
2084 |
+
* @since 1.0
|
2085 |
+
*/
|
2086 |
+
protected function sanitize_string($string)
|
2087 |
+
{
|
2088 |
+
$string = esc_url($string);
|
2089 |
+
$string = str_replace('http://','', $string);
|
2090 |
+
$string = str_replace('https://','', $string);
|
2091 |
+
|
2092 |
+
return $string;
|
2093 |
+
}
|
2094 |
+
|
2095 |
+
/**
|
2096 |
+
* Checks if column-meta key exists
|
2097 |
+
*
|
2098 |
+
* @since 1.0
|
2099 |
+
*/
|
2100 |
+
public static function is_column_meta( $id = '' )
|
2101 |
+
{
|
2102 |
+
if ( strpos($id, 'column-meta-') !== false )
|
2103 |
+
return true;
|
2104 |
+
|
2105 |
+
return false;
|
2106 |
+
}
|
2107 |
+
|
2108 |
+
/**
|
2109 |
+
* Get the posttype from columnname
|
2110 |
+
*
|
2111 |
+
* @since 1.3.1
|
2112 |
+
*/
|
2113 |
+
public static function get_posttype_by_postcount_column( $id = '' )
|
2114 |
+
{
|
2115 |
+
if ( strpos($id, 'column-user_postcount-') !== false )
|
2116 |
+
return str_replace('column-user_postcount-', '', $id);
|
2117 |
+
|
2118 |
+
return false;
|
2119 |
+
}
|
2120 |
+
|
2121 |
+
/**
|
2122 |
+
* Get column value of post attachments
|
2123 |
+
*
|
2124 |
+
* @since 1.2.1
|
2125 |
+
*/
|
2126 |
+
public static function get_attachment_ids( $post_id )
|
2127 |
+
{
|
2128 |
+
return get_posts(array(
|
2129 |
+
'post_type' => 'attachment',
|
2130 |
+
'numberposts' => -1,
|
2131 |
+
'post_status' => null,
|
2132 |
+
'post_parent' => $post_id,
|
2133 |
+
'fields' => 'ids'
|
2134 |
+
));
|
2135 |
+
}
|
2136 |
+
|
2137 |
+
/**
|
2138 |
+
* Strip tags and trim
|
2139 |
+
*
|
2140 |
+
* @since 1.3
|
2141 |
+
*/
|
2142 |
+
public static function strip_trim($string)
|
2143 |
+
{
|
2144 |
+
return trim(strip_tags($string));
|
2145 |
+
}
|
2146 |
+
|
2147 |
+
/**
|
2148 |
+
* Admin body class
|
2149 |
+
*
|
2150 |
+
* @since 1.4
|
2151 |
+
*/
|
2152 |
+
function admin_class( $classes )
|
2153 |
+
{
|
2154 |
+
global $current_screen;
|
2155 |
+
|
2156 |
+
// we dont need the 'edit-' part
|
2157 |
+
$screen = str_replace('edit-', '', $current_screen->id);
|
2158 |
+
|
2159 |
+
// media library exception
|
2160 |
+
if ( $current_screen->base == 'upload' && $current_screen->id == 'upload' ) {
|
2161 |
+
$screen = 'media';
|
2162 |
+
}
|
2163 |
+
|
2164 |
+
// link exception
|
2165 |
+
if ( $current_screen->base == 'link-manager' && $current_screen->id == 'link-manager' ) {
|
2166 |
+
$screen = 'links';
|
2167 |
+
}
|
2168 |
+
|
2169 |
+
// loop the available types
|
2170 |
+
foreach ( $this->get_types() as $type => $label ) {
|
2171 |
+
|
2172 |
+
// match against screen or wp-screen
|
2173 |
+
if ( $type == $screen || $type == "wp-{$screen}" )
|
2174 |
+
$classes .= " cp-{$type}";
|
2175 |
+
}
|
2176 |
+
|
2177 |
+
return $classes;
|
2178 |
+
}
|
2179 |
+
|
2180 |
+
|
2181 |
+
/**
|
2182 |
+
* Admin CSS for Column width
|
2183 |
+
*
|
2184 |
+
* @since 1.4
|
2185 |
+
*/
|
2186 |
+
function admin_css()
|
2187 |
+
{
|
2188 |
+
$css = '';
|
2189 |
+
|
2190 |
+
// loop throug the available types...
|
2191 |
+
foreach ( $this->get_types() as $type ) {
|
2192 |
+
$cols = self::get_stored_columns($type);
|
2193 |
+
if ( $cols ) {
|
2194 |
+
|
2195 |
+
// loop through each available column...
|
2196 |
+
foreach ( $cols as $col_name => $col ) {
|
2197 |
+
|
2198 |
+
// and check for stored width and add it to the css
|
2199 |
+
if (!empty($col['width']) && is_numeric($col['width']) && $col['width'] > 0 ) {
|
2200 |
+
$css .= ".cp-{$type} .wrap table th.column-{$col_name} { width: {$col['width']}% !important; }";
|
2201 |
+
}
|
2202 |
+
}
|
2203 |
+
}
|
2204 |
+
}
|
2205 |
+
|
2206 |
+
echo "<style type='text/css'>{$css}</style>";
|
2207 |
+
}
|
2208 |
+
|
2209 |
+
/**
|
2210 |
+
* Ajax activation
|
2211 |
+
*
|
2212 |
+
* @since 1.3.1
|
2213 |
+
*/
|
2214 |
+
public function ajax_activation()
|
2215 |
+
{
|
2216 |
+
// keys
|
2217 |
+
$key = $_POST['key'];
|
2218 |
+
$type = $_POST['type'];
|
2219 |
+
|
2220 |
+
$licence = new cpac_licence( $type );
|
2221 |
+
|
2222 |
+
// update key
|
2223 |
+
if ( $key == 'remove' ) {
|
2224 |
+
$licence->remove_license_key();
|
2225 |
+
}
|
2226 |
+
|
2227 |
+
// set license key
|
2228 |
+
elseif ( $licence->check_remote_key( $key ) ) {
|
2229 |
+
|
2230 |
+
// set key
|
2231 |
+
$licence->set_license_key( $key );
|
2232 |
+
|
2233 |
+
// returned masked key
|
2234 |
+
echo json_encode( $licence->get_masked_license_key() );
|
2235 |
+
}
|
2236 |
+
|
2237 |
+
exit;
|
2238 |
+
}
|
2239 |
+
|
2240 |
+
/**
|
2241 |
+
* Add help tabs
|
2242 |
+
*
|
2243 |
+
* @since 1.3
|
2244 |
+
*/
|
2245 |
+
public function help_tabs($page)
|
2246 |
+
{
|
2247 |
+
$screen = get_current_screen();
|
2248 |
+
|
2249 |
+
if ( $screen->id != $this->admin_page || ! method_exists($screen,'add_help_tab') )
|
2250 |
+
return;
|
2251 |
+
|
2252 |
+
$admin_url = get_admin_url();
|
2253 |
+
|
2254 |
+
// add help content
|
2255 |
+
$tabs = array(
|
2256 |
+
array(
|
2257 |
+
'title' => 'Overview',
|
2258 |
+
'content' => "
|
2259 |
+
<h5>Codepress Admin Columns</h5>
|
2260 |
+
<p>
|
2261 |
+
This plugin is for adding and removing additional columns to the administration screens for post(types), pages, media library, comments, links and users. Change the column's label and reorder them.
|
2262 |
+
</p>
|
2263 |
+
|
2264 |
+
"
|
2265 |
+
),
|
2266 |
+
array(
|
2267 |
+
'title' => 'Basics',
|
2268 |
+
'content' => "
|
2269 |
+
<h5>Show / Hide</h5>
|
2270 |
+
<p>
|
2271 |
+
You can switch columns on or off by cliking on the checkbox. This will show or hide each column heading.
|
2272 |
+
</p>
|
2273 |
+
<h5>Change order</h5>
|
2274 |
+
<p>
|
2275 |
+
By dragging the columns you can change the order which they will appear in.
|
2276 |
+
</p>
|
2277 |
+
<h5>Change label</h5>
|
2278 |
+
<p>
|
2279 |
+
By clicking on the triangle you will see the column options. Here you can change each label of the columns heading.
|
2280 |
+
</p>
|
2281 |
+
<h5>Change coluimn width</h5>
|
2282 |
+
<p>
|
2283 |
+
By clicking on the triangle you will see the column options. By using the draggable slider yo can set the width of the columns in percentages.
|
2284 |
+
</p>
|
2285 |
+
"
|
2286 |
+
),
|
2287 |
+
array(
|
2288 |
+
'title' => 'Custom Field',
|
2289 |
+
'content' => "
|
2290 |
+
<h5>'Custom Field' column</h5>
|
2291 |
+
<p>
|
2292 |
+
The custom field colum uses the custom fields from posts and users. There are 8 types which you can set.
|
2293 |
+
</p>
|
2294 |
+
<ul>
|
2295 |
+
<li><strong>Default</strong><br/>Value: Can be either a string or array. Arrays will be flattened and values are seperated by a ',' comma.</li>
|
2296 |
+
<li><strong>Image</strong><br/>Value: should only contain an image URL.</li>
|
2297 |
+
<li><strong>Media Library Icon</strong><br/>Value: should only contain Attachment IDs ( seperated by ',' ).</li>
|
2298 |
+
<li><strong>Excerpt</strong><br/>Value: This will show the first 20 words of the Post content.</li>
|
2299 |
+
<li><strong>Multiple Values</strong><br/>Value: should be an array. This will flatten any ( multi dimensional ) array.</li>
|
2300 |
+
<li><strong>Numeric</strong><br/>Value: Integers only.<br/>If you have the 'sorting addon' this will be used for sorting, so you can sort your posts on numeric (custom field) values.</li>
|
2301 |
+
<li><strong>Date</strong><br/>Value: Can be unix time stamp of date format as described in the <a href='http://codex.wordpress.org/Formatting_Date_and_Time'>Codex</a>. You can change the outputted date format at the <a href='{$admin_url}options-general.php'>general settings</a> page.</li>
|
2302 |
+
<li><strong>Post Titles</strong><br/>Value: can be one or more Post ID's (seperated by ',').</li>
|
2303 |
+
</ul>
|
2304 |
+
"
|
2305 |
+
)
|
2306 |
+
);
|
2307 |
+
|
2308 |
+
foreach ( $tabs as $k => $tab ) {
|
2309 |
+
$screen->add_help_tab(array(
|
2310 |
+
'id' => 'cpac-tab-'.$k, // unique id
|
2311 |
+
'title' => $tab['title'], // label
|
2312 |
+
'content' => $tab['content'], // body
|
2313 |
+
));
|
2314 |
+
}
|
2315 |
+
}
|
2316 |
+
|
2317 |
+
/**
|
2318 |
+
* Plugin Settings
|
2319 |
+
*
|
2320 |
+
* @since 1.3.1
|
2321 |
+
*/
|
2322 |
+
private function plugin_settings()
|
2323 |
+
{
|
2324 |
+
$class_current_settings = $this->is_menu_type_current('plugin_settings') ? ' current' : ' hidden'; '';
|
2325 |
+
|
2326 |
+
/** Sortable */
|
2327 |
+
$masked_key = '';
|
2328 |
+
$class_sortorder_activate = '';
|
2329 |
+
$class_sortorder_deactivate = ' hidden';
|
2330 |
+
|
2331 |
+
// is unlocked
|
2332 |
+
$licence = new cpac_licence('sortable');
|
2333 |
+
|
2334 |
+
if ( $licence->is_unlocked() ) {
|
2335 |
+
$masked_key = $licence->get_masked_license_key('sortable');
|
2336 |
+
$class_sortorder_activate = ' hidden';
|
2337 |
+
$class_sortorder_deactivate = '';
|
2338 |
+
}
|
2339 |
+
|
2340 |
+
// find out more
|
2341 |
+
$find_out_more = "<a href='{$this->codepress_url}/sortorder-addon/' class='button-primary alignright' target='_blank'>".__('find out more', CPAC_TEXTDOMAIN)." »</a>";
|
2342 |
+
|
2343 |
+
// info box
|
2344 |
+
$sortable_tooltip = "
|
2345 |
+
<p>".__('This will make all of the new columns support sorting', CPAC_TEXTDOMAIN).".</p>
|
2346 |
+
<p>".__('By default WordPress let\'s you sort by title, date, comments and author. This will make you be able to <strong>sort by any column of any type!</strong>', CPAC_TEXTDOMAIN)."</p>
|
2347 |
+
<p>".__('Perfect for sorting your articles, media files, comments, links and users', CPAC_TEXTDOMAIN).".</p>
|
2348 |
+
<p class='description'>".__('(columns that are added by other plugins are not supported)', CPAC_TEXTDOMAIN).".</p>
|
2349 |
+
<img src='" . CPAC_URL.'/assets/images/addon_sortable_1.png' . "' alt='' />
|
2350 |
+
{$find_out_more}
|
2351 |
+
";
|
2352 |
+
|
2353 |
+
// addons
|
2354 |
+
$addons = "
|
2355 |
+
<tr>
|
2356 |
+
<td colspan='2'>
|
2357 |
+
<h2>".__('Activate Add-ons', CPAC_TEXTDOMAIN)."</h2>
|
2358 |
+
<p>".__('Add-ons can be unlocked by purchasing a license key. Each key can be used on multiple sites', CPAC_TEXTDOMAIN)." <a target='_blank' href='{$this->codepress_url}/sortorder-addon/'>Visit the Plugin Store</a>.</p>
|
2359 |
+
<table class='widefat addons'>
|
2360 |
+
<thead>
|
2361 |
+
<tr>
|
2362 |
+
<th class='activation_type'>".__('Addon', CPAC_TEXTDOMAIN)."</th>
|
2363 |
+
<th class='activation_status'>".__('Status', CPAC_TEXTDOMAIN)."</th>
|
2364 |
+
<th class='activation_code'>".__('Activation Code', CPAC_TEXTDOMAIN)."</th>
|
2365 |
+
<th class='activation_more'></th>
|
2366 |
+
</tr>
|
2367 |
+
</thead>
|
2368 |
+
<tbody>
|
2369 |
+
<tr id='cpac-activation-sortable' class='last'>
|
2370 |
+
<td class='activation_type'>
|
2371 |
+
<span>" . __('Sortorder', CPAC_TEXTDOMAIN) . "</span>
|
2372 |
+
<div class='cpac-tooltip hidden'>
|
2373 |
+
<div class='qtip_title'>" . __('Sortorder', CPAC_TEXTDOMAIN) . "</div>
|
2374 |
+
<div class='qtip_content'>
|
2375 |
+
<p>" . __($sortable_tooltip, CPAC_TEXTDOMAIN) . "</p>
|
2376 |
+
</div>
|
2377 |
+
</div>
|
2378 |
+
</td>
|
2379 |
+
<td class='activation_status'>
|
2380 |
+
<div class='activate{$class_sortorder_activate}'>
|
2381 |
+
" . __('Inactive', CPAC_TEXTDOMAIN) . "
|
2382 |
+
</div>
|
2383 |
+
<div class='deactivate{$class_sortorder_deactivate}'>
|
2384 |
+
" . __('Active', CPAC_TEXTDOMAIN) . "
|
2385 |
+
</div>
|
2386 |
+
</td>
|
2387 |
+
<td class='activation_code'>
|
2388 |
+
<div class='activate{$class_sortorder_activate}'>
|
2389 |
+
<input type='text' value='" . __('Fill in your activation code', CPAC_TEXTDOMAIN) . "' name='cpac-sortable-key'>
|
2390 |
+
<a href='javascript:;' class='button'>" . __('Activate', CPAC_TEXTDOMAIN) . "<span></span></a>
|
2391 |
+
</div>
|
2392 |
+
<div class='deactivate{$class_sortorder_deactivate}'>
|
2393 |
+
<span class='masked_key'>{$masked_key}</span>
|
2394 |
+
<a href='javascript:;' class='button'>" . __('Deactivate', CPAC_TEXTDOMAIN) . "<span></span></a>
|
2395 |
+
</div>
|
2396 |
+
<div class='activation-error-msg'></div>
|
2397 |
+
</td>
|
2398 |
+
<td class='activation_more'>{$find_out_more}</td>
|
2399 |
+
</tr><!-- #cpac-activation-sortable -->
|
2400 |
+
</tbody>
|
2401 |
+
</table>
|
2402 |
+
<div class='addon-translation-string hidden'>
|
2403 |
+
<span class='tstring-fill-in'>" . __('Enter your activation code', CPAC_TEXTDOMAIN) . "</span>
|
2404 |
+
<span class='tstring-unrecognised'>" . __('Activation code unrecognised', CPAC_TEXTDOMAIN) . "</span>
|
2405 |
+
</div>
|
2406 |
+
</td>
|
2407 |
+
</tr>
|
2408 |
+
";
|
2409 |
+
|
2410 |
+
// general options
|
2411 |
+
$general_options = "
|
2412 |
+
<!--
|
2413 |
+
<tr class='last'>
|
2414 |
+
<td colspan='2'>
|
2415 |
+
<h2>Options</h2>
|
2416 |
+
<ul class='cpac-options'>
|
2417 |
+
<li>
|
2418 |
+
<div class='cpac-option-label'>Thumbnail size</div>
|
2419 |
+
<div class='cpac-option-inputs'>
|
2420 |
+
<input type='text' id='thumbnail_size_w' class='small-text' name='cpac_options[settings][thumb_width]' value='80'/>
|
2421 |
+
<label for='thumbnail_size_w'>Width</label>
|
2422 |
+
<br/>
|
2423 |
+
<input type='text' id='thumbnail_size_h' class='small-text' name='cpac_options[settings][thumb_height]' value='80'/>
|
2424 |
+
<label for='thumbnail_size_h'>Height</label>
|
2425 |
+
</div>
|
2426 |
+
</li>
|
2427 |
+
<li>
|
2428 |
+
<div class='cpac-option-label'>Excerpt length</div>
|
2429 |
+
<div class='cpac-option-inputs'>
|
2430 |
+
|
2431 |
+
<input type='text' id='excerpt_length' class='small-text' name='cpac_options[settings][excerpt_length]' value='15'/>
|
2432 |
+
<label for='excerpt_length'>Number of words</label>
|
2433 |
+
</div>
|
2434 |
+
</li>
|
2435 |
+
</ul>
|
2436 |
+
</td>
|
2437 |
+
</tr>
|
2438 |
+
-->
|
2439 |
+
";
|
2440 |
+
|
2441 |
+
// settings
|
2442 |
+
$row = "
|
2443 |
+
<tr id='cpac-box-plugin_settings' valign='top' class='cpac-box-row {$class_current_settings}'>
|
2444 |
+
<td colspan='2'>
|
2445 |
+
<table class='nopadding'>
|
2446 |
+
{$addons}
|
2447 |
+
{$general_options}
|
2448 |
+
</table>
|
2449 |
+
</td>
|
2450 |
+
</tr><!-- #cpac-box-plugin_settings -->
|
2451 |
+
";
|
2452 |
+
|
2453 |
+
return $row;
|
2454 |
+
}
|
2455 |
+
|
2456 |
+
/**
|
2457 |
+
* Get post count
|
2458 |
+
*
|
2459 |
+
* @since 1.3.1
|
2460 |
+
*/
|
2461 |
+
public static function get_post_count( $post_type, $user_id )
|
2462 |
+
{
|
2463 |
+
global $wpdb;
|
2464 |
+
|
2465 |
+
if ( ! post_type_exists($post_type) || empty($user_id) )
|
2466 |
+
return false;
|
2467 |
+
|
2468 |
+
$sql = "
|
2469 |
+
SELECT COUNT(ID)
|
2470 |
+
FROM {$wpdb->posts}
|
2471 |
+
WHERE post_status = 'publish'
|
2472 |
+
AND post_author = %d
|
2473 |
+
AND post_type = %s
|
2474 |
+
";
|
2475 |
+
|
2476 |
+
return $wpdb->get_var( $wpdb->prepare($sql, $user_id, $post_type) );
|
2477 |
+
}
|
2478 |
+
|
2479 |
+
/**
|
2480 |
+
* Settings Page Template.
|
2481 |
+
*
|
2482 |
+
* This function in conjunction with others uses the WordPress
|
2483 |
+
* Settings API to create a settings page where users can adjust
|
2484 |
+
* the behaviour of this plugin.
|
2485 |
+
*
|
2486 |
+
* @since 1.0
|
2487 |
+
*/
|
2488 |
+
public function plugin_settings_page()
|
2489 |
+
{
|
2490 |
+
// loop through post types
|
2491 |
+
$rows = '';
|
2492 |
+
foreach ( $this->get_types() as $type ) {
|
2493 |
+
|
2494 |
+
// post type label
|
2495 |
+
$label = $this->get_singular_name($type);
|
2496 |
+
|
2497 |
+
// id
|
2498 |
+
$id = $this->sanitize_string($type);
|
2499 |
+
|
2500 |
+
// build draggable boxes
|
2501 |
+
$boxes = $this->get_column_boxes($type);
|
2502 |
+
|
2503 |
+
// class
|
2504 |
+
$class = $this->is_menu_type_current($type) ? ' current' : ' hidden';
|
2505 |
+
|
2506 |
+
$rows .= "
|
2507 |
+
<tr id='cpac-box-{$id}' valign='top' class='cpac-box-row{$class}'>
|
2508 |
+
<th class='cpac_post_type' scope='row'>
|
2509 |
+
{$label}
|
2510 |
+
</th>
|
2511 |
+
<td>
|
2512 |
+
<h3 class='cpac_post_type hidden'>{$label}</h3>
|
2513 |
+
{$boxes}
|
2514 |
+
</td>
|
2515 |
+
</tr>
|
2516 |
+
";
|
2517 |
+
}
|
2518 |
+
|
2519 |
+
// General Setttings
|
2520 |
+
$general_settings = $this->plugin_settings();
|
2521 |
+
|
2522 |
+
// Post Type Menu
|
2523 |
+
$menu = $this->get_menu();
|
2524 |
+
|
2525 |
+
// Help screen message
|
2526 |
+
$help_text = '';
|
2527 |
+
if ( version_compare( get_bloginfo('version'), '3.2', '>' ) )
|
2528 |
+
$help_text = '<p>'.__('You will find a short overview at the <strong>Help</strong> section in the top-right screen.', CPAC_TEXTDOMAIN).'</p>';
|
2529 |
+
|
2530 |
+
// find out more
|
2531 |
+
$find_out_more = "<a href='{$this->codepress_url}/sortorder-addon/' class='alignright green' target='_blank'>".__('find out more', CPAC_TEXTDOMAIN)." »</a>";
|
2532 |
+
|
2533 |
+
?>
|
2534 |
+
<div id="cpac" class="wrap">
|
2535 |
+
<?php screen_icon(CPAC_SLUG) ?>
|
2536 |
+
<h2><?php _e('Codepress Admin Columns', CPAC_TEXTDOMAIN); ?></h2>
|
2537 |
+
<?php echo $menu ?>
|
2538 |
+
|
2539 |
+
<div class="postbox-container cpac-col-right">
|
2540 |
+
<div class="metabox-holder">
|
2541 |
+
<div class="meta-box-sortables">
|
2542 |
+
|
2543 |
+
<div id="addons-cpac-settings" class="postbox">
|
2544 |
+
<div title="Click to toggle" class="handlediv"><br></div>
|
2545 |
+
<h3 class="hndle">
|
2546 |
+
<span><?php _e('Get the Addon', CPAC_TEXTDOMAIN) ?></span>
|
2547 |
+
</h3>
|
2548 |
+
<div class="inside">
|
2549 |
+
<p><?php _e('By default WordPress let\'s you only sort by title, date, comments and author.', CPAC_TEXTDOMAIN) ?></p>
|
2550 |
+
<p><?php _e('Make <strong>all columns</strong> of <strong>all types</strong> within the plugin support sorting — with the sorting addon.', CPAC_TEXTDOMAIN) ?></p>
|
2551 |
+
<p class="description"><?php _e('(columns that are added by other plugins are not supported)', CPAC_TEXTDOMAIN) ?>.</p>
|
2552 |
+
<?php echo $find_out_more ?>
|
2553 |
+
</div>
|
2554 |
+
</div><!-- addons-cpac-settings -->
|
2555 |
+
|
2556 |
+
<div id="likethisplugin-cpac-settings" class="postbox">
|
2557 |
+
<div title="Click to toggle" class="handlediv"><br></div>
|
2558 |
+
<h3 class="hndle">
|
2559 |
+
<span><?php _e('Like this plugin?', CPAC_TEXTDOMAIN) ?></span>
|
2560 |
+
</h3>
|
2561 |
+
<div class="inside">
|
2562 |
+
<p><?php _e('Why not do any or all of the following', CPAC_TEXTDOMAIN) ?>:</p>
|
2563 |
+
<ul>
|
2564 |
+
<li><a href="<?php echo $this->plugins_url ?>"><?php _e('Give it a 5 star rating on WordPress.org.', CPAC_TEXTDOMAIN) ?></a></li>
|
2565 |
+
<li><a href="<?php echo $this->codepress_url ?>/"><?php _e('Link to it so other folks can find out about it.', CPAC_TEXTDOMAIN) ?></a></li>
|
2566 |
+
<li class="donate_link"><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=ZDZRSYLQ4Z76J"><?php _e('Donate a token of your appreciation.', CPAC_TEXTDOMAIN) ?></a></li>
|
2567 |
+
</ul>
|
2568 |
+
</div>
|
2569 |
+
</div><!-- likethisplugin-cpac-settings -->
|
2570 |
+
|
2571 |
+
<div id="latest-news-cpac-settings" class="postbox">
|
2572 |
+
<div title="Click to toggle" class="handlediv"><br></div>
|
2573 |
+
<h3 class="hndle">
|
2574 |
+
<span><?php _e('Follow us', CPAC_TEXTDOMAIN) ?></span>
|
2575 |
+
</h3>
|
2576 |
+
<div class="inside">
|
2577 |
+
<ul>
|
2578 |
+
<li class="twitter"><a href="http://twitter.com/codepressNL"><?php _e('Follow Codepress on Twitter.', CPAC_TEXTDOMAIN) ?></a></li>
|
2579 |
+
<li class="facebook"><a href="https://www.facebook.com/codepressNL"><?php _e('Like Codepress on Facebook.', CPAC_TEXTDOMAIN) ?></a></li>
|
2580 |
+
|
2581 |
+
</ul>
|
2582 |
+
</div>
|
2583 |
+
</div><!-- latest-news-cpac-settings -->
|
2584 |
+
|
2585 |
+
<div id="side-cpac-settings" class="postbox">
|
2586 |
+
<div title="Click to toggle" class="handlediv"><br></div>
|
2587 |
+
<h3 class="hndle">
|
2588 |
+
<span><?php _e('Need support?', CPAC_TEXTDOMAIN) ?></span>
|
2589 |
+
</h3>
|
2590 |
+
<div class="inside">
|
2591 |
+
<?php echo $help_text ?>
|
2592 |
+
<p><?php printf(__('If you are having problems with this plugin, please talk about them in the <a href="%s">Support forums</a> or send me an email %s.', CPAC_TEXTDOMAIN), $this->wordpress_url, '<a href="mailto:info@codepress.nl">info@codepress.nl</a>' );?></p>
|
2593 |
+
<p><?php printf(__("If you're sure you've found a bug, or have a feature request, please <a href='%s'>submit your feedback</a>.", CPAC_TEXTDOMAIN), "{$this->codepress_url}/feedback");?></p>
|
2594 |
+
</div>
|
2595 |
+
</div><!-- side-cpac-settings -->
|
2596 |
+
|
2597 |
+
</div>
|
2598 |
+
</div>
|
2599 |
+
</div><!-- .postbox-container -->
|
2600 |
+
|
2601 |
+
<div class="postbox-container cpac-col-left">
|
2602 |
+
<div class="metabox-holder">
|
2603 |
+
<div class="meta-box-sortables">
|
2604 |
+
|
2605 |
+
<div id="general-cpac-settings" class="postbox">
|
2606 |
+
<div title="Click to toggle" class="handlediv"><br></div>
|
2607 |
+
<h3 class="hndle">
|
2608 |
+
<span><?php _e('Admin Columns', CPAC_TEXTDOMAIN ); ?></span>
|
2609 |
+
</h3>
|
2610 |
+
<div class="inside">
|
2611 |
+
<form method="post" action="options.php">
|
2612 |
+
|
2613 |
+
<?php settings_fields( 'cpac-settings-group' ); ?>
|
2614 |
+
|
2615 |
+
<table class="form-table">
|
2616 |
+
<!-- columns -->
|
2617 |
+
<?php echo $rows; ?>
|
2618 |
+
|
2619 |
+
<!-- activation -->
|
2620 |
+
<?php echo $general_settings; ?>
|
2621 |
+
|
2622 |
+
<tr class="bottom" valign="top">
|
2623 |
+
<th scope="row"></th>
|
2624 |
+
<td>
|
2625 |
+
<p class="submit">
|
2626 |
+
<input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
|
2627 |
+
</p>
|
2628 |
+
</td>
|
2629 |
+
</tr>
|
2630 |
+
</table>
|
2631 |
+
</form>
|
2632 |
+
</div>
|
2633 |
+
</div><!-- general-settings -->
|
2634 |
+
|
2635 |
+
<div id="restore-cpac-settings" class="postbox">
|
2636 |
+
<div title="Click to toggle" class="handlediv"><br></div>
|
2637 |
+
<h3 class="hndle">
|
2638 |
+
<span><?php _e('Restore defaults', CPAC_TEXTDOMAIN) ?></span>
|
2639 |
+
</h3>
|
2640 |
+
<div class="inside">
|
2641 |
+
<form method="post" action="">
|
2642 |
+
<input type="submit" class="button" name="cpac-restore-defaults" value="<?php _e('Restore default settings', CPAC_TEXTDOMAIN ) ?>" onclick="return confirm('<?php _e("Warning! ALL saved admin columns data will be deleted. This cannot be undone. \'OK\' to delete, \'Cancel\' to stop", CPAC_TEXTDOMAIN); ?>');" />
|
2643 |
+
</form>
|
2644 |
+
<p class="description"><?php _e('This will delete all column settings and restore the default settings.', CPAC_TEXTDOMAIN); ?></p>
|
2645 |
+
</div>
|
2646 |
+
</div><!-- restore-cpac-settings -->
|
2647 |
+
|
2648 |
+
</div>
|
2649 |
+
</div>
|
2650 |
+
</div><!-- .postbox-container -->
|
2651 |
+
</div>
|
2652 |
+
<?php
|
2653 |
+
}
|
2654 |
+
}
|
2655 |
+
|
2656 |
+
/**
|
2657 |
+
* Init Class Codepress_Admin_Columns
|
2658 |
+
*
|
2659 |
+
* @since 1.0
|
2660 |
+
*/
|
2661 |
+
new Codepress_Admin_Columns();
|
2662 |
+
|
2663 |
+
|
2664 |
+
/**
|
2665 |
+
* Init Class Codepress_Sortable_Columns
|
2666 |
+
*
|
2667 |
+
* @since 1.3
|
2668 |
+
*/
|
2669 |
+
new Codepress_Sortable_Columns();
|
2670 |
+
|
2671 |
?>
|
readme.txt
CHANGED
@@ -1,398 +1,409 @@
|
|
1 |
-
=== Codepress Admin Columns ===
|
2 |
-
Contributors: codepress, tschutter, davidmosterd
|
3 |
-
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=ZDZRSYLQ4Z76J
|
4 |
-
Tags: plugins, wordpress, admin, column, columns, custom columns, custom fields, image, dashboard, sortable, filters, posts, media, users, pages, posttypes, manage columns, wp-admin
|
5 |
-
Requires at least: 3.1
|
6 |
-
Tested up to: 3.
|
7 |
-
Stable tag: 1.4.
|
8 |
-
|
9 |
-
Customise columns on the administration screens for post(types), pages, media, comments, links and users with an easy to use drag-and-drop interface.
|
10 |
-
|
11 |
-
== Description ==
|
12 |
-
|
13 |
-
Completely customise the columns on the administration screens with a nice drag and drop interface.
|
14 |
-
|
15 |
-
By default, WordPress only shows a few built-in columns. This plugin will give you many additional columns. You will have full control over all columns for pages, posts, posttypes, media, links, comments and users.
|
16 |
-
|
17 |
-
Add or remove columns, change their label, change their width and reorder them.
|
18 |
-
|
19 |
-
= Post Types Columns =
|
20 |
-
|
21 |
-
The following custom columns are added:
|
22 |
-
|
23 |
-
* Featured Image
|
24 |
-
* Excerpt
|
25 |
-
* Post Attachments
|
26 |
-
* Page Order
|
27 |
-
* Page Templates
|
28 |
-
* Post Formats
|
29 |
-
* Taxonomies
|
30 |
-
* ID
|
31 |
-
* Slug
|
32 |
-
* Sticky
|
33 |
-
* Word count
|
34 |
-
* Roles
|
35 |
-
* Status
|
36 |
-
* Number of Attachments
|
37 |
-
* Last Modified
|
38 |
-
* Comment count
|
39 |
-
* Before More Tag Content
|
40 |
-
* Custom Fields
|
41 |
-
|
42 |
-
= User Columns =
|
43 |
-
|
44 |
-
You can also change the User Columns. The following user columns are added:
|
45 |
-
|
46 |
-
* User ID
|
47 |
-
* First name
|
48 |
-
* Last name
|
49 |
-
* Url
|
50 |
-
* Register date
|
51 |
-
* Biographical Info ( description )
|
52 |
-
* Number of Posts Types
|
53 |
-
* User Custom Fields
|
54 |
-
|
55 |
-
Some of the user custom fields that are included: user level, capabilities, admin color, nickname... many more.
|
56 |
-
|
57 |
-
= Media Columns =
|
58 |
-
|
59 |
-
Customise the Media Library Columns. The following media columns are added:
|
60 |
-
|
61 |
-
* Media ID
|
62 |
-
* File name
|
63 |
-
* Height
|
64 |
-
* Width
|
65 |
-
* Dimensions ( width x height )
|
66 |
-
* EXIF and IPTC image data
|
67 |
-
* Description, Caption and Alternate tekst
|
68 |
-
* Mime-Type
|
69 |
-
* Media Custom Fields
|
70 |
-
* Filesize
|
71 |
-
|
72 |
-
= Comment Columns =
|
73 |
-
|
74 |
-
A lot more comment colums are added, here are a few examples:
|
75 |
-
|
76 |
-
* Avatar
|
77 |
-
* Author IP
|
78 |
-
* Agent
|
79 |
-
* ID
|
80 |
-
* Comment excerpt
|
81 |
-
* Comment Meta data
|
82 |
-
|
83 |
-
= Link Columns =
|
84 |
-
|
85 |
-
A few examples of added Link columns:
|
86 |
-
|
87 |
-
* ID
|
88 |
-
* Target
|
89 |
-
* Description
|
90 |
-
* Notes
|
91 |
-
* Owner
|
92 |
-
|
93 |
-
= Custom Fields =
|
94 |
-
|
95 |
-
With the custom field column you can display any custom field values. It can show its default value but also handle it as an image or icon. Thsese types are added:
|
96 |
-
|
97 |
-
* Image thumbnails
|
98 |
-
* Icons for Media Library items
|
99 |
-
* Excerpt
|
100 |
-
* Multiple Values
|
101 |
-
* Numeric value ( this also works for sorting by meta_value_num )
|
102 |
-
* Post Titles
|
103 |
-
* Usernames
|
104 |
-
* Checkmark Image ( for true or false values )
|
105 |
-
|
106 |
-
= Sortable Custom Columns for all Screens =
|
107 |
-
|
108 |
-
All of the new columns will have support for sorting with the <a href="http://www.codepress.nl/plugins/codepress-admin-columns/sortorder-addon/">sorting addon</a>.
|
109 |
-
|
110 |
-
By default WordPress let's you only sort by Title, Date, Comments and Author. This will make you be able to <strong>sort by ALL columns of ANY type</strong>. (columns that are added by other plugins are not supported)
|
111 |
-
|
112 |
-
= Third party plugin support =
|
113 |
-
|
114 |
-
It will work nice with other plugins and support their additional custom columns. A few examples of plugins that are supported: WordPress SEO by Yoast (Robots Meta), Post Admin Shortcuts (Pin), WP Show IDs (ID) and User Access Manager (Access), Co-Authors Plus and Advanced Custom Fields.
|
115 |
-
|
116 |
-
= Translations =
|
117 |
-
|
118 |
-
If you like to contrinute a language, please send them to <a href="mailto:info@codepress.nl">info@codepress.nl</a>.
|
119 |
-
|
120 |
-
* Danish (da_DK) - Thanks for contributing the danish language goes to Morten Dalgaard Johansen
|
121 |
-
* German (de_DE) - Thanks for contributing the german language goes to Uli
|
122 |
-
* Polish (pl_PL) - Thanks for contributing the polish language goes to Bartosz
|
123 |
-
* French (fr_FR) - Thanks for contributing the french language goes to Alexandre Girard
|
124 |
-
|
125 |
-
= Upcoming releases =
|
126 |
-
|
127 |
-
* support for default sorting for users, links and comments
|
128 |
-
|
129 |
-
**Feedback**
|
130 |
-
|
131 |
-
You can leave any <a href='http://www.codepress.nl/plugins/codepress-admin-columns/feedback'>requests or feedback</a>.
|
132 |
-
|
133 |
-
**Related Links:**
|
134 |
-
|
135 |
-
* http://www.codepress.nl/plugins/codepress-admin-columns/
|
136 |
-
|
137 |
-
== Installation ==
|
138 |
-
|
139 |
-
1. Upload codepress-admin-columns to the /wp-content/plugins/ directory
|
140 |
-
2. Activate Codepress Admin Columns through the 'Plugins' menu in WordPress
|
141 |
-
3. Configure the plugin by going to the Admin Column settings that appears under the Settings menu.
|
142 |
-
|
143 |
-
== Frequently Asked Questions ==
|
144 |
-
|
145 |
-
= I have an idea for a great way to improve this plugin =
|
146 |
-
|
147 |
-
Great! I'd love to hear from you.
|
148 |
-
Leave your feedback at http://www.codepress.nl/plugins/codepress-admin-columns/feedback.
|
149 |
-
|
150 |
-
= How can I change the thumbnail size of images? =
|
151 |
-
|
152 |
-
You can use the build in filter to set your own thumbnail size. Just add this piece of code to your
|
153 |
-
theme's functions.php.
|
154 |
-
|
155 |
-
To set a custom size use, for example 194 width by 63 height pixels:
|
156 |
-
|
157 |
-
`
|
158 |
-
<?php
|
159 |
-
|
160 |
-
// edit here: fill in your thumbnail height and width
|
161 |
-
$my_height = 63;
|
162 |
-
$my_width = 194;
|
163 |
-
// stop editing
|
164 |
-
|
165 |
-
add_image_size( 'admin-columns', $my_width, $my_height, true );
|
166 |
-
add_filter('cpac_thumbnail_size',
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
this
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
* **$
|
208 |
-
* **$
|
209 |
-
* **$
|
210 |
-
* **$
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
$
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
*
|
251 |
-
*
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
*
|
256 |
-
*
|
257 |
-
*
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
* bug fix
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
*
|
268 |
-
*
|
269 |
-
*
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
* added
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
*
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
* added
|
287 |
-
*
|
288 |
-
* added
|
289 |
-
* fix
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
*
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
* added
|
298 |
-
*
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
* added
|
303 |
-
* added
|
304 |
-
* added
|
305 |
-
*
|
306 |
-
* added
|
307 |
-
* added
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
* added
|
316 |
-
*
|
317 |
-
* added
|
318 |
-
* added
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
*
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
* added
|
328 |
-
*
|
329 |
-
*
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
* added
|
334 |
-
* added
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
* added
|
339 |
-
*
|
340 |
-
*
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
* added
|
345 |
-
* added
|
346 |
-
*
|
347 |
-
*
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
* added
|
352 |
-
* added
|
353 |
-
* added
|
354 |
-
* added
|
355 |
-
*
|
356 |
-
*
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
* added
|
363 |
-
*
|
364 |
-
*
|
365 |
-
*
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
* added
|
372 |
-
*
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
*
|
377 |
-
|
378 |
-
= 1.
|
379 |
-
|
380 |
-
* added
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
*
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
398 |
* Initial release.
|
1 |
+
=== Codepress Admin Columns ===
|
2 |
+
Contributors: codepress, tschutter, davidmosterd
|
3 |
+
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=ZDZRSYLQ4Z76J
|
4 |
+
Tags: plugins, wordpress, admin, column, columns, custom columns, custom fields, image, dashboard, sortable, filters, posts, media, users, pages, posttypes, manage columns, wp-admin
|
5 |
+
Requires at least: 3.1
|
6 |
+
Tested up to: 3.5
|
7 |
+
Stable tag: 1.4.7
|
8 |
+
|
9 |
+
Customise columns on the administration screens for post(types), pages, media, comments, links and users with an easy to use drag-and-drop interface.
|
10 |
+
|
11 |
+
== Description ==
|
12 |
+
|
13 |
+
Completely customise the columns on the administration screens with a nice drag and drop interface.
|
14 |
+
|
15 |
+
By default, WordPress only shows a few built-in columns. This plugin will give you many additional columns. You will have full control over all columns for pages, posts, posttypes, media, links, comments and users.
|
16 |
+
|
17 |
+
Add or remove columns, change their label, change their width and reorder them.
|
18 |
+
|
19 |
+
= Post Types Columns =
|
20 |
+
|
21 |
+
The following custom columns are added:
|
22 |
+
|
23 |
+
* Featured Image
|
24 |
+
* Excerpt
|
25 |
+
* Post Attachments
|
26 |
+
* Page Order
|
27 |
+
* Page Templates
|
28 |
+
* Post Formats
|
29 |
+
* Taxonomies
|
30 |
+
* ID
|
31 |
+
* Slug
|
32 |
+
* Sticky
|
33 |
+
* Word count
|
34 |
+
* Roles
|
35 |
+
* Status
|
36 |
+
* Number of Attachments
|
37 |
+
* Last Modified
|
38 |
+
* Comment count
|
39 |
+
* Before More Tag Content
|
40 |
+
* Custom Fields
|
41 |
+
|
42 |
+
= User Columns =
|
43 |
+
|
44 |
+
You can also change the User Columns. The following user columns are added:
|
45 |
+
|
46 |
+
* User ID
|
47 |
+
* First name
|
48 |
+
* Last name
|
49 |
+
* Url
|
50 |
+
* Register date
|
51 |
+
* Biographical Info ( description )
|
52 |
+
* Number of Posts Types
|
53 |
+
* User Custom Fields
|
54 |
+
|
55 |
+
Some of the user custom fields that are included: user level, capabilities, admin color, nickname... many more.
|
56 |
+
|
57 |
+
= Media Columns =
|
58 |
+
|
59 |
+
Customise the Media Library Columns. The following media columns are added:
|
60 |
+
|
61 |
+
* Media ID
|
62 |
+
* File name
|
63 |
+
* Height
|
64 |
+
* Width
|
65 |
+
* Dimensions ( width x height )
|
66 |
+
* EXIF and IPTC image data
|
67 |
+
* Description, Caption and Alternate tekst
|
68 |
+
* Mime-Type
|
69 |
+
* Media Custom Fields
|
70 |
+
* Filesize
|
71 |
+
|
72 |
+
= Comment Columns =
|
73 |
+
|
74 |
+
A lot more comment colums are added, here are a few examples:
|
75 |
+
|
76 |
+
* Avatar
|
77 |
+
* Author IP
|
78 |
+
* Agent
|
79 |
+
* ID
|
80 |
+
* Comment excerpt
|
81 |
+
* Comment Meta data
|
82 |
+
|
83 |
+
= Link Columns =
|
84 |
+
|
85 |
+
A few examples of added Link columns:
|
86 |
+
|
87 |
+
* ID
|
88 |
+
* Target
|
89 |
+
* Description
|
90 |
+
* Notes
|
91 |
+
* Owner
|
92 |
+
|
93 |
+
= Custom Fields =
|
94 |
+
|
95 |
+
With the custom field column you can display any custom field values. It can show its default value but also handle it as an image or icon. Thsese types are added:
|
96 |
+
|
97 |
+
* Image thumbnails
|
98 |
+
* Icons for Media Library items
|
99 |
+
* Excerpt
|
100 |
+
* Multiple Values
|
101 |
+
* Numeric value ( this also works for sorting by meta_value_num )
|
102 |
+
* Post Titles
|
103 |
+
* Usernames
|
104 |
+
* Checkmark Image ( for true or false values )
|
105 |
+
|
106 |
+
= Sortable Custom Columns for all Screens =
|
107 |
+
|
108 |
+
All of the new columns will have support for sorting with the <a href="http://www.codepress.nl/plugins/codepress-admin-columns/sortorder-addon/">sorting addon</a>.
|
109 |
+
|
110 |
+
By default WordPress let's you only sort by Title, Date, Comments and Author. This will make you be able to <strong>sort by ALL columns of ANY type</strong>. (columns that are added by other plugins are not supported)
|
111 |
+
|
112 |
+
= Third party plugin support =
|
113 |
+
|
114 |
+
It will work nice with other plugins and support their additional custom columns. A few examples of plugins that are supported: WordPress SEO by Yoast (Robots Meta), Post Admin Shortcuts (Pin), WP Show IDs (ID) and User Access Manager (Access), Co-Authors Plus and Advanced Custom Fields.
|
115 |
+
|
116 |
+
= Translations =
|
117 |
+
|
118 |
+
If you like to contrinute a language, please send them to <a href="mailto:info@codepress.nl">info@codepress.nl</a>.
|
119 |
+
|
120 |
+
* Danish (da_DK) - Thanks for contributing the danish language goes to Morten Dalgaard Johansen
|
121 |
+
* German (de_DE) - Thanks for contributing the german language goes to Uli
|
122 |
+
* Polish (pl_PL) - Thanks for contributing the polish language goes to Bartosz
|
123 |
+
* French (fr_FR) - Thanks for contributing the french language goes to Alexandre Girard
|
124 |
+
|
125 |
+
= Upcoming releases =
|
126 |
+
|
127 |
+
* support for default sorting for users, links and comments
|
128 |
+
|
129 |
+
**Feedback**
|
130 |
+
|
131 |
+
You can leave any <a href='http://www.codepress.nl/plugins/codepress-admin-columns/feedback'>requests or feedback</a>.
|
132 |
+
|
133 |
+
**Related Links:**
|
134 |
+
|
135 |
+
* http://www.codepress.nl/plugins/codepress-admin-columns/
|
136 |
+
|
137 |
+
== Installation ==
|
138 |
+
|
139 |
+
1. Upload codepress-admin-columns to the /wp-content/plugins/ directory
|
140 |
+
2. Activate Codepress Admin Columns through the 'Plugins' menu in WordPress
|
141 |
+
3. Configure the plugin by going to the Admin Column settings that appears under the Settings menu.
|
142 |
+
|
143 |
+
== Frequently Asked Questions ==
|
144 |
+
|
145 |
+
= I have an idea for a great way to improve this plugin =
|
146 |
+
|
147 |
+
Great! I'd love to hear from you.
|
148 |
+
Leave your feedback at http://www.codepress.nl/plugins/codepress-admin-columns/feedback.
|
149 |
+
|
150 |
+
= How can I change the thumbnail size of images? =
|
151 |
+
|
152 |
+
You can use the build in filter to set your own thumbnail size. Just add this piece of code to your
|
153 |
+
theme's functions.php.
|
154 |
+
|
155 |
+
To set a custom size use, for example 194 width by 63 height pixels:
|
156 |
+
|
157 |
+
`
|
158 |
+
<?php
|
159 |
+
|
160 |
+
// edit here: fill in your thumbnail height and width
|
161 |
+
$my_height = 63;
|
162 |
+
$my_width = 194;
|
163 |
+
// stop editing
|
164 |
+
|
165 |
+
add_image_size( 'admin-columns', $my_width, $my_height, true );
|
166 |
+
add_filter('cpac_thumbnail_size', 'cb_cpac_thumbnail_size' );
|
167 |
+
function cb_cpac_thumbnail_size() {
|
168 |
+
return 'admin-columns';
|
169 |
+
};
|
170 |
+
?>
|
171 |
+
`
|
172 |
+
|
173 |
+
**my columns thumbnails still have the wrong size**
|
174 |
+
|
175 |
+
If you want your already uploaded images to display the newly added size you will need to regenerate the thumbnail for them. Use this plugin to generate the newly added sized thumbnails: http://wordpress.org/extend/plugins/regenerate-thumbnails/.
|
176 |
+
|
177 |
+
= How can I enable the use of Hidden Custom Fields? =
|
178 |
+
|
179 |
+
I am currently working on settings page where you can enable this feature. In the meanwhile you can enable this by adding
|
180 |
+
this piece of code to your theme's functions.php:
|
181 |
+
|
182 |
+
`
|
183 |
+
<?php
|
184 |
+
add_filter('cpac_use_hidden_custom_fields', '__return_true'); // enables the use hidden custom fields
|
185 |
+
?>
|
186 |
+
`
|
187 |
+
|
188 |
+
Now you can select your HIDDEN custom fields in de dropdown menu under "Custom Field:".
|
189 |
+
|
190 |
+
= How can I add the dropdown menu for taxonomy filtering? =
|
191 |
+
|
192 |
+
This will also be included in the upcoming settings page, in the meanwhile you can enable this by adding
|
193 |
+
this piece of code to your theme's functions.php:
|
194 |
+
|
195 |
+
`
|
196 |
+
<?php
|
197 |
+
add_filter( 'cpac-remove-filtering-columns', '__return_false' ); // add dropdown taxonomy filtering to the overview pages
|
198 |
+
?>
|
199 |
+
`
|
200 |
+
|
201 |
+
= How can I display a custom value in the Custom Fields Column? =
|
202 |
+
|
203 |
+
With this filter 'cpac_get_column_value_custom_field' you can control what the value will be for any Custom Field Column.
|
204 |
+
|
205 |
+
Filter explained:
|
206 |
+
|
207 |
+
* **$value** is the original value which would otherwise be displayed
|
208 |
+
* **$internal_field_key** is only used internally to store the column
|
209 |
+
* **$custom_field** is the name of your custom field
|
210 |
+
* **$type** will return either the posttype or if it is any other type it will return wp-comments, wp-links, wp-users, wp-media.
|
211 |
+
* **$object_id** will return the ID of the object.
|
212 |
+
|
213 |
+
For example if you have a custom posttype 'Demo' with a custom_field that is called 'city' and the result would be an integer '33'. You can change that integer '33' to Amsterdam.
|
214 |
+
|
215 |
+
`
|
216 |
+
<?php
|
217 |
+
function my_custom_field_value( $value, $internal_field_key, $custom_field, $type, $object_id )
|
218 |
+
{
|
219 |
+
$my_post_type = 'demo';
|
220 |
+
$my_field_name = 'city';
|
221 |
+
|
222 |
+
// make sure we have the correct posttype and fieldname
|
223 |
+
if ( $my_post_type == $type && $my_field_name == $custom_field ) {
|
224 |
+
|
225 |
+
if ( '33' == $value )
|
226 |
+
$value = 'Amsterdam';
|
227 |
+
|
228 |
+
elseif ( '34' == $value )
|
229 |
+
$value = 'New York';
|
230 |
+
}
|
231 |
+
return $value;
|
232 |
+
}
|
233 |
+
add_filter( 'cpac_get_column_value_custom_field', 'my_custom_field_value', 10, 5 );
|
234 |
+
?>
|
235 |
+
`
|
236 |
+
|
237 |
+
== Screenshots ==
|
238 |
+
|
239 |
+
1. Settings page for Post(type) columns.
|
240 |
+
2. Posts Screen with the customized sortable columns.
|
241 |
+
3. Settings page for the Media Library columns.
|
242 |
+
4. Media Screen with the customized sortable columns.
|
243 |
+
5. Settings page for Users columns.
|
244 |
+
6. Users Screen with the customized sortable columns.
|
245 |
+
7. Settings page showing the different displaying types for custom field.
|
246 |
+
|
247 |
+
== Changelog ==
|
248 |
+
|
249 |
+
= 1.4.7 =
|
250 |
+
* ready for WP 3.5
|
251 |
+
* added support for custom fields for Media
|
252 |
+
* added color to the custom field types
|
253 |
+
* fixed default sorting for Post(types) and Media
|
254 |
+
* fixed problem with different date formats in custom fields. all dates will parsed by strtotime() now.
|
255 |
+
* fixed bug which could trigger a conflict when saving the setting on other plugins
|
256 |
+
* fixed bug when returning an admin class atrribute
|
257 |
+
* improved perfomance on post count on user overview screen
|
258 |
+
|
259 |
+
= 1.4.6.4 =
|
260 |
+
* Added 'before more tag' column, which will show the content which is placed before the more-tag
|
261 |
+
* bug fix: file images will now also be displayed when they can not be resized.
|
262 |
+
* bug fix: the checkbox disappeared when resetting columns and resaving them.
|
263 |
+
|
264 |
+
= 1.4.6.3 =
|
265 |
+
|
266 |
+
* Added new custom field type: User by User ID
|
267 |
+
* Added values to filter 'cpac_get_column_value_custom_field' for better control of the output
|
268 |
+
* Added an example for above filter to FAQ section
|
269 |
+
* Added fix where trash posts did not show with the sorting addon activated
|
270 |
+
|
271 |
+
= 1.4.6.2 =
|
272 |
+
|
273 |
+
* bug fix with a static function which could cause an error in some cases
|
274 |
+
* added filter to enable taxonomy filtering. add this to your functions.php to enable taxonomy filtering: `add_filter( 'cpac-remove-filtering-columns', '__return_false' );`
|
275 |
+
|
276 |
+
= 1.4.6.1 =
|
277 |
+
|
278 |
+
* bug fix for possible warning when using Custompress ( props to scottsalisbury for the fix! )
|
279 |
+
* bug fix for sorting by postcount for users
|
280 |
+
* added 'Display Author As' column for post(types)
|
281 |
+
* added sorting support for 'Display Author As' column
|
282 |
+
|
283 |
+
= 1.4.6 =
|
284 |
+
|
285 |
+
* added german language ( thanks to Uli )
|
286 |
+
* added danish language ( thanks to Morten Dalgaard Johansen )
|
287 |
+
* added filter for setting thumbnail size ( see FAQ on how to use it )
|
288 |
+
* added support for hidden custom fields ( see FAQ on how to enable this )
|
289 |
+
* added fix for WordPress SEO by Yoast Columns
|
290 |
+
|
291 |
+
= 1.4.5.1 =
|
292 |
+
|
293 |
+
* removed taxonomy filtering ( will implement show/hide option )
|
294 |
+
|
295 |
+
= 1.4.5 =
|
296 |
+
|
297 |
+
* added french language ( thanks to Alexandre Girard )
|
298 |
+
* filtering by taxonomy ( only displays when column is used )
|
299 |
+
* added compatibility with woocommerce
|
300 |
+
* fix value media meta column ID
|
301 |
+
* fixed bug with sorting users by postcount
|
302 |
+
* added Actions column for Media (delete, view etc.)
|
303 |
+
* added Actions column for Link (delete, view etc.)
|
304 |
+
* added Actions column for Comments (delete, view etc.)
|
305 |
+
* added Wordcount column for Comments
|
306 |
+
* added Filesize column for Media ( supports sorting )
|
307 |
+
* added default sorting for posts ( remembers your last sorting, only with addon )
|
308 |
+
* added default sorting for media ( remembers your last sorting, only with addon )
|
309 |
+
* added filters to the result output
|
310 |
+
|
311 |
+
= 1.4.4 =
|
312 |
+
|
313 |
+
* added posts columns Last Modified and Comment count
|
314 |
+
* added media columns for EXIF and IPTC image data
|
315 |
+
* added custom fields columns to the Media Library
|
316 |
+
* given column values it's own class
|
317 |
+
* added bug fix for sorting bookmarks/links
|
318 |
+
* added fix for possible php warning
|
319 |
+
|
320 |
+
= 1.4.3 =
|
321 |
+
|
322 |
+
* removed taxonomy filtering
|
323 |
+
|
324 |
+
= 1.4.2 =
|
325 |
+
|
326 |
+
* added fix for unexpected output in the column value
|
327 |
+
* added fix for better 3rd party plugin support
|
328 |
+
* added column for Comment status
|
329 |
+
* added column for Ping/Trackback status
|
330 |
+
* added column for Posts Actions (delete, view etc.)
|
331 |
+
* added column for Users Actions (delete, view etc.)
|
332 |
+
* added sorting taxonomies ( only on first one )
|
333 |
+
* added bug fix for sorting
|
334 |
+
* added taxonomy filtering
|
335 |
+
|
336 |
+
= 1.4.1 =
|
337 |
+
|
338 |
+
* added polish translation, thanks to Bartosz.
|
339 |
+
* changed the license key validation proces
|
340 |
+
* removed non-breaking-space-character from column output
|
341 |
+
|
342 |
+
= 1.4 =
|
343 |
+
|
344 |
+
* added support for comment columns
|
345 |
+
* added support for link columns
|
346 |
+
* added links to taxonomies
|
347 |
+
* added sorting user custom fields
|
348 |
+
* added sorting to links columns
|
349 |
+
* added user columns so you can see how many articles an author has published of a certain post type
|
350 |
+
* added Textual help
|
351 |
+
* added the option to specify column width
|
352 |
+
* added role column to all posts screens
|
353 |
+
* added posts status column to all posts screens
|
354 |
+
* added image path to media library
|
355 |
+
* added added apply_filters('cpac-get-post-types', $post_types) to filter out certain post types
|
356 |
+
* added option to enter license key for activating sorting on ALL columns
|
357 |
+
* fixed a php5 warning
|
358 |
+
* fixed a conflict with the Co-Authors plugin
|
359 |
+
|
360 |
+
= 1.3 =
|
361 |
+
|
362 |
+
* added support for Media columns
|
363 |
+
* added Media columns: filename, width, height, dimensions, description, alt, caption and mime-type
|
364 |
+
* added date type to posts custom fields
|
365 |
+
* added title type to posts custom fields
|
366 |
+
* sorting has changed. when sorting; only results are shown which contain a value
|
367 |
+
* str_word_count is used for excerpts
|
368 |
+
|
369 |
+
= 1.2.1 =
|
370 |
+
|
371 |
+
* added word count sorting
|
372 |
+
* added attachment count sorting
|
373 |
+
* added template name sorting
|
374 |
+
* minor styling changes
|
375 |
+
* bug fix with sorting by slug
|
376 |
+
* bug fix with sorting by attachment
|
377 |
+
|
378 |
+
= 1.2 =
|
379 |
+
|
380 |
+
* added support for third party plugins
|
381 |
+
* added user custom fields
|
382 |
+
* added extra image check
|
383 |
+
* bug fix with javascript (jquery) enqueue
|
384 |
+
|
385 |
+
= 1.1.3 =
|
386 |
+
|
387 |
+
* added bug fix for WP3.3beta ( thanks to raonip and ronbme for pointing this out )
|
388 |
+
|
389 |
+
= 1.1.2 =
|
390 |
+
|
391 |
+
* added dutch translation
|
392 |
+
|
393 |
+
= 1.1.1 =
|
394 |
+
|
395 |
+
* Bug fix: path separator for require_once
|
396 |
+
* Added word count
|
397 |
+
|
398 |
+
= 1.1 =
|
399 |
+
|
400 |
+
* Added User Columns.
|
401 |
+
* Added before / after text for custom fields
|
402 |
+
* Added custom field type 'Numeric'.
|
403 |
+
* Added custom field sortables.
|
404 |
+
* Fixed domain path
|
405 |
+
* Fixed settings link
|
406 |
+
|
407 |
+
= 1.0 =
|
408 |
+
|
409 |
* Initial release.
|