Admin Columns - Version 2.0.3

Version Description

  • [Updated] Danish translation - thanks to iosoftgame
  • [Updated] Spanish translation - thanks to redywebs
  • [Added] Chinese translation - thanks to
  • [Fixed] Solved bug with before and after field
  • [Added] Fieldtype "Counter" to Custom Fields
  • [Added] Column type ID when you hover over the column type label
  • [Added] Support for raw values
  • [Updated] Changed filter for cac/column/value. See: http://www.codepresshq.com/documentation.
Download this release

Release Info

Developer tschutter
Plugin Icon 128x128 Admin Columns
Version 2.0.3
Comparing to
See all releases

Code changes from version 2.0.2 to 2.0.3

Files changed (71) hide show
  1. README.md +0 -0
  2. assets/css/admin-column.css +7 -1
  3. assets/js/admin-columns.js +37 -21
  4. classes/api.php +0 -8
  5. classes/column.php +19 -5
  6. classes/column/custom-field.php +96 -41
  7. classes/column/post/ID.php +8 -0
  8. classes/column/post/attachment-count.php +9 -0
  9. classes/column/post/attachment.php +12 -3
  10. classes/column/post/author-name.php +14 -4
  11. classes/column/post/before-moretag.php +9 -0
  12. classes/column/post/comment-count.php +21 -4
  13. classes/column/post/comment-status.php +16 -6
  14. classes/column/post/excerpt.php +12 -2
  15. classes/column/post/featured-image.php +20 -4
  16. classes/column/post/formats.php +13 -1
  17. classes/column/post/modified.php +12 -1
  18. classes/column/post/order.php +9 -0
  19. classes/column/post/page-template.php +9 -2
  20. classes/column/post/parent.php +19 -5
  21. classes/column/post/ping-status.php +16 -7
  22. classes/column/post/roles.php +11 -2
  23. classes/column/post/slug.php +9 -0
  24. classes/column/post/status.php +15 -2
  25. classes/column/post/sticky.php +10 -1
  26. classes/column/post/taxonomy.php +10 -4
  27. classes/column/post/word-count.php +9 -0
  28. classes/column/user/ID.php +9 -0
  29. classes/column/user/actions.php +9 -0
  30. classes/column/user/comment-count.php +10 -3
  31. classes/column/user/description.php +9 -0
  32. classes/column/user/first-name.php +9 -0
  33. classes/column/user/last-name.php +9 -0
  34. classes/column/user/nickname.php +9 -0
  35. classes/column/user/post-count.php +12 -5
  36. classes/column/user/registered.php +12 -1
  37. classes/column/user/url.php +9 -0
  38. classes/settings.php +40 -21
  39. classes/storage_model.php +44 -10
  40. classes/storage_model/comment.php +8 -3
  41. classes/storage_model/link.php +7 -1
  42. classes/storage_model/media.php +13 -4
  43. classes/storage_model/post.php +14 -16
  44. classes/storage_model/user.php +27 -8
  45. classes/utility.php +2 -9
  46. codepress-admin-columns.php +11 -16
  47. languages/cac-addon-pro.po +0 -265
  48. languages/cpac-ar.mo +0 -0
  49. languages/cpac-ar.po +203 -272
  50. languages/cpac-da_DK.mo +0 -0
  51. languages/cpac-da_DK.po +354 -620
  52. languages/cpac-de_DE.mo +0 -0
  53. languages/cpac-de_DE.po +234 -505
  54. languages/cpac-es_ES.mo +0 -0
  55. languages/cpac-es_ES.po +1170 -0
  56. languages/cpac-fr_FR.mo +0 -0
  57. languages/cpac-fr_FR.po +232 -447
  58. languages/cpac-it_IT.mo +0 -0
  59. languages/cpac-it_IT.po +1170 -0
  60. languages/cpac-nl_NL.mo +0 -0
  61. languages/cpac-nl_NL.po +207 -492
  62. languages/cpac-pl_PL.mo +0 -0
  63. languages/cpac-pl_PL.po +344 -629
  64. languages/cpac-pt_BR.mo +0 -0
  65. languages/{cpac.po → cpac-pt_BR.po} +54 -47
  66. languages/cpac-sv_SE.mo +0 -0
  67. languages/cpac-sv_SE.po +352 -628
  68. languages/cpac-zh_CN.mo +0 -0
  69. languages/cpac-zh_CN.po +1170 -0
  70. languages/cpac.mo +0 -0
  71. readme.txt +30 -12
README.md ADDED
File without changes
assets/css/admin-column.css CHANGED
@@ -430,6 +430,10 @@ tr.column_image_size.hidden {
430
padding: 5px 8px !important;
431
font-weight: normal;
432
}
433
.rtl .column-form tr td.label p.description {
434
right: 0;
435
left: auto;
@@ -596,14 +600,16 @@ tr.column_image_size.hidden {
596
padding: 8px;
597
}
598
#form-actions .submit-update {
599
width: 100%;
600
height: 28px;
601
line-height: 28px;
602
}
603
604
/* =Sidebar: Pro
605
--------------------------------*/
606
- #pro-version {
607
background: transparent url(../images/get_the_addon.png) no-repeat 0 0;
608
}
609
#pro-version .padding-box {
430
padding: 5px 8px !important;
431
font-weight: normal;
432
}
433
+ .column-form tr td.label p.description em {
434
+ display: block;
435
+ color: #999;
436
+ }
437
.rtl .column-form tr td.label p.description {
438
right: 0;
439
left: auto;
600
padding: 8px;
601
}
602
#form-actions .submit-update {
603
+ display: block;
604
width: 100%;
605
height: 28px;
606
line-height: 28px;
607
+ text-align: center;
608
}
609
610
/* =Sidebar: Pro
611
--------------------------------*/
612
+ #pro-version .cta {
613
background: transparent url(../images/get_the_addon.png) no-repeat 0 0;
614
}
615
#pro-version .padding-box {
assets/js/admin-columns.js CHANGED
@@ -10,6 +10,7 @@ jQuery(document).ready(function() {
10
11
// General
12
cpac_pointer();
13
14
// Settings Page
15
cpac_clear_input_defaults();
@@ -28,6 +29,21 @@ jQuery(document).ready(function() {
28
});
29
});
30
31
/*
32
* Column: bind toggle events
33
*
@@ -270,7 +286,7 @@ function cpac_add_column() {
270
if ( clone.length > 0 ) {
271
272
// add to DOM
273
- jQuery('.cpac-columns', container).append( clone );
274
275
// increment clone id
276
clone.cpac_update_clone_id();
@@ -303,32 +319,31 @@ function cpac_add_column() {
303
* @since 1.5
304
*/
305
function cpac_sidebar_scroll() {
306
- var msie6 = jQuery.browser == 'msie' && jQuery.browser.version < 7;
307
308
- if (!msie6 && jQuery('.columns-right-inside').length !== 0 ) {
309
310
- if ( jQuery('.columns-right-inside:visible').offset() ) {
311
312
- // top position of the sidebar on loading
313
- var top = jQuery('.columns-right-inside:visible').offset().top - parseFloat( jQuery('.columns-right-inside:visible').css('margin-top').replace(/auto/, 0) ) - 70;
314
315
- jQuery(window).scroll(function (event) {
316
- // y position of the scroll
317
- var y = jQuery(this).scrollTop();
318
319
- // top position of div#cpac is calculated everytime incase of an opened help screen
320
- var offset = jQuery('#cpac').offset().top - parseFloat( jQuery('#cpac').css('margin-top').replace(/auto/, 0) );
321
322
- // whether that's below
323
- if (y >= top + offset ) {
324
- // if so, ad the fixed class
325
- jQuery('.columns-right-inside:visible').addClass('fixed');
326
- } else {
327
- // otherwise remove it
328
- jQuery('.columns-right-inside:visible').removeClass('fixed');
329
- }
330
- });
331
- }
332
}
333
}
334
@@ -440,6 +455,7 @@ function cpac_pointer() {
440
*/
441
function cpac_sortable() {
442
jQuery('div.cpac-columns').sortable({
443
revert : 250,
444
handle : 'td.column_sort',
445
placeholder : 'cpac-placeholder',
10
11
// General
12
cpac_pointer();
13
+ cpac_submit_form();
14
15
// Settings Page
16
cpac_clear_input_defaults();
29
});
30
});
31
32
+
33
+
34
+ /*
35
+ * Submit Form
36
+ *
37
+ * @since 2.0.2
38
+ */
39
+ function cpac_submit_form() {
40
+ jQuery('.form-update a.submit-update').click( function(e){
41
+ e.preventDefault();
42
+
43
+ jQuery(this).closest('.columns-container').find('.cpac-columns form').submit();
44
+ });
45
+ }
46
+
47
/*
48
* Column: bind toggle events
49
*
286
if ( clone.length > 0 ) {
287
288
// add to DOM
289
+ jQuery('.cpac-columns form', container).append( clone );
290
291
// increment clone id
292
clone.cpac_update_clone_id();
319
* @since 1.5
320
*/
321
function cpac_sidebar_scroll() {
322
323
+ if( jQuery('.columns-right-inside').length === 0 )
324
+ return;
325
326
+ if ( jQuery('.columns-right-inside:visible').offset() ) {
327
328
+ // top position of the sidebar on loading
329
+ var top = jQuery('.columns-right-inside:visible').offset().top - parseFloat( jQuery('.columns-right-inside:visible').css('margin-top').replace(/auto/, 0) ) - 70;
330
331
+ jQuery(window).scroll(function (event) {
332
+ // y position of the scroll
333
+ var y = jQuery(this).scrollTop();
334
335
+ // top position of div#cpac is calculated everytime incase of an opened help screen
336
+ var offset = jQuery('#cpac').offset().top - parseFloat( jQuery('#cpac').css('margin-top').replace(/auto/, 0) );
337
338
+ // whether that's below
339
+ if (y >= top + offset ) {
340
+ // if so, ad the fixed class
341
+ jQuery('.columns-right-inside:visible').addClass('fixed');
342
+ } else {
343
+ // otherwise remove it
344
+ jQuery('.columns-right-inside:visible').removeClass('fixed');
345
+ }
346
+ });
347
}
348
}
349
455
*/
456
function cpac_sortable() {
457
jQuery('div.cpac-columns').sortable({
458
+ items : '.cpac-column',
459
revert : 250,
460
handle : 'td.column_sort',
461
placeholder : 'cpac-placeholder',
classes/api.php DELETED
@@ -1,8 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Admin Columns - API
5
- *
6
- * @since 2.0.0
7
- * @todo: build API
8
- */
classes/column.php CHANGED
@@ -53,6 +53,16 @@ class CPAC_Column {
53
*/
54
public function get_value( $id ) {}
55
56
/**
57
* Display_settings
58
*
@@ -863,10 +873,11 @@ class CPAC_Column {
863
public function get_column_list( $columns = array(), $label = '' ) {
864
865
if ( empty( $columns ) )
866
- return array();
867
868
$list = '';
869
870
$_columns = array();
871
foreach ( $columns as $column ) {
872
$_columns[ $column->properties->type ] = 0 === strlen( strip_tags( $column->properties->label ) ) ? ucfirst( $column->properties->type ) : $column->properties->label;
@@ -894,7 +905,7 @@ class CPAC_Column {
894
$classes = implode( ' ', array_filter( array ( "cpac-box-{$this->properties->type}", $this->properties->classes ) ) );
895
896
// column list
897
- $column_list = $this->get_column_list( $this->storage_model->get_custom_registered_columns(), __( 'Custom', 'cpac' ) );
898
$column_list .= $this->get_column_list( $this->storage_model->get_default_registered_columns(), __( 'Default', 'cpac' ) );
899
900
// clone attribute
@@ -913,7 +924,7 @@ class CPAC_Column {
913
<div class="inner">
914
<div class="meta">
915
916
- <?php do_action( 'cac/column/label', $this ); ?>
917
918
</div>
919
<a class="toggle" href="javascript:;">
@@ -939,7 +950,7 @@ class CPAC_Column {
939
<table class="widefat">
940
<tbody>
941
<tr class="column_type">
942
- <?php $this->label_view( __( 'Type', 'cpac' ), __( 'Choose a column type.', 'cpac' ), 'type' ); ?>
943
<td class="input">
944
<select name="<?php $this->attr_name( 'type' ); ?>" id="<?php $this->attr_id( 'type' ); ?>">
945
<?php echo $column_list; ?>
@@ -981,7 +992,10 @@ class CPAC_Column {
981
982
<tr class="column_action">
983
<td colspan="2">
984
- <p><a href="javascript:;" class="remove-button"><?php _e( 'Remove' );?></a></p>
985
</td>
986
</tr>
987
53
*/
54
public function get_value( $id ) {}
55
56
+ /**
57
+ * Get the raw, underlying value for the column
58
+ * Not suitable for direct display, use get_value() for that
59
+ *
60
+ * @since 2.0.3
61
+ * @param int $id ID
62
+ * @return mixed Value
63
+ */
64
+ public function get_raw_value( $id ) {}
65
+
66
/**
67
* Display_settings
68
*
873
public function get_column_list( $columns = array(), $label = '' ) {
874
875
if ( empty( $columns ) )
876
+ return false;
877
878
$list = '';
879
880
+ // sort by alphabet
881
$_columns = array();
882
foreach ( $columns as $column ) {
883
$_columns[ $column->properties->type ] = 0 === strlen( strip_tags( $column->properties->label ) ) ? ucfirst( $column->properties->type ) : $column->properties->label;
905
$classes = implode( ' ', array_filter( array ( "cpac-box-{$this->properties->type}", $this->properties->classes ) ) );
906
907
// column list
908
+ $column_list = $this->get_column_list( $this->storage_model->get_custom_registered_columns(), __( 'Custom', 'cpac' ) );
909
$column_list .= $this->get_column_list( $this->storage_model->get_default_registered_columns(), __( 'Default', 'cpac' ) );
910
911
// clone attribute
924
<div class="inner">
925
<div class="meta">
926
927
+ <?php do_action( 'cac/column/label', $this ); ?>
928
929
</div>
930
<a class="toggle" href="javascript:;">
950
<table class="widefat">
951
<tbody>
952
<tr class="column_type">
953
+ <?php $this->label_view( __( 'Type', 'cpac' ), __( 'Choose a column type.', 'cpac' ) . '<em>' . __('ID','cpac') . ': ' . $this->properties->type . '</em>', 'type' ); ?>
954
<td class="input">
955
<select name="<?php $this->attr_name( 'type' ); ?>" id="<?php $this->attr_id( 'type' ); ?>">
956
<?php echo $column_list; ?>
992
993
<tr class="column_action">
994
<td colspan="2">
995
+ <p>
996
+ <a href="javascript:;" class="remove-button"><?php _e( 'Remove' );?></a>
997
+ <!--<span class="description alignright"><?php _e('type','cpac'); ?>: <em><?php echo $this->properties->type; ?></em></span>-->
998
+ </p>
999
</td>
1000
</tr>
1001
classes/column/custom-field.php CHANGED
@@ -34,7 +34,7 @@ class CPAC_Column_Custom_Field extends CPAC_Column {
34
// for retireving sorting preference
35
$this->user_settings = get_option( 'cpac_general_options' );
36
37
- // call contruct
38
parent::__construct( $storage_model );
39
}
40
@@ -44,13 +44,11 @@ class CPAC_Column_Custom_Field extends CPAC_Column {
44
*/
45
function sanitize_options( $options ) {
46
47
- if ( ! empty( $options['before'] ) ) {
48
- $options['before'] = trim( $options['before'] );
49
- }
50
51
- if ( ! empty( $options['after'] ) ) {
52
- $options['after'] = trim( $options['after'] );
53
- }
54
55
if ( empty( $options['date_format'] ) ) {
56
$options['date_format'] = get_option( 'date_format' );
@@ -70,36 +68,43 @@ class CPAC_Column_Custom_Field extends CPAC_Column {
70
71
$custom_field_types = array(
72
'' => __( 'Default'),
73
'image' => __( 'Image', 'cpac' ),
74
'library_id' => __( 'Media Library', 'cpac' ),
75
- 'excerpt' => __( 'Excerpt'),
76
'array' => __( 'Multiple Values', 'cpac' ),
77
'numeric' => __( 'Numeric', 'cpac' ),
78
- 'date' => __( 'Date', 'cpac' ),
79
'title_by_id' => __( 'Post Title (Post ID\'s)', 'cpac' ),
80
'user_by_id' => __( 'Username (User ID\'s)', 'cpac' ),
81
- 'checkmark' => __( 'Checkmark (true/false)', 'cpac' ),
82
- 'color' => __( 'Color', 'cpac' ),
83
);
84
85
- return apply_filters( 'cpac_custom_field_types', $custom_field_types );
86
}
87
88
/**
89
- * Get Title by ID - Value method
90
*
91
* @since 1.0
92
*
93
* @param string $meta
94
* @return string Titles
95
*/
96
- private function get_titles_by_id( $meta ) {
97
98
//remove white spaces and strip tags
99
$meta = $this->strip_trim( str_replace( ' ','', $meta ) );
100
101
// var
102
- $ids = $titles = array();
103
104
// check for multiple id's
105
if ( strpos( $meta, ',' ) !== false )
@@ -107,12 +112,28 @@ class CPAC_Column_Custom_Field extends CPAC_Column {
107
elseif ( is_numeric( $meta ) )
108
$ids[] = $meta;
109
110
// display title with link
111
if ( $ids && is_array( $ids ) ) {
112
foreach ( $ids as $id ) {
113
- $title = is_numeric( $id ) ? get_the_title( $id ) : '';
114
$link = get_edit_post_link( $id );
115
- if ( $title )
116
$titles[] = $link ? "<a href='{$link}'>{$title}</a>" : $title;
117
}
118
}
@@ -130,25 +151,12 @@ class CPAC_Column_Custom_Field extends CPAC_Column {
130
*/
131
private function get_users_by_id( $meta ) {
132
133
- //remove white spaces and strip tags
134
- $meta = $this->strip_trim( str_replace( ' ', '', $meta ) );
135
-
136
- // var
137
- $ids = $names = array();
138
-
139
- // check for multiple id's
140
- if ( strpos( $meta, ',' ) !== false ) {
141
- $ids = explode( ',',$meta );
142
- }
143
- elseif ( is_numeric( $meta ) ) {
144
- $ids[] = $meta;
145
- }
146
147
// display username
148
if ( $ids && is_array( $ids ) ) {
149
foreach ( $ids as $id ) {
150
- if ( ! is_numeric( $id ) )
151
- continue;
152
153
$userdata = get_userdata( $id );
154
if ( is_object( $userdata ) && ! empty( $userdata->display_name ) ) {
@@ -169,10 +177,11 @@ class CPAC_Column_Custom_Field extends CPAC_Column {
169
*
170
* @since 2.0.0
171
*
172
- * @param string $meta
173
* @return string Users
174
*/
175
- function get_value_by_meta( $meta ) {
176
177
switch ( $this->options->field_type ) :
178
@@ -220,6 +229,11 @@ class CPAC_Column_Custom_Field extends CPAC_Column {
220
}
221
break;
222
223
endswitch;
224
225
return $meta;
@@ -259,21 +273,30 @@ class CPAC_Column_Custom_Field extends CPAC_Column {
259
return $rgb;
260
}
261
262
/**
263
* Get meta by ID
264
*
265
- * @since 1.0
266
*
267
* @param int $id ID
268
* @return string Meta Value
269
*/
270
public function get_meta_by_id( $id ) {
271
272
- // rename hidden custom fields to their original name
273
- $field = substr( $this->options->field, 0, 10 ) == "cpachidden" ? str_replace( 'cpachidden', '', $this->options->field ) : $this->options->field;
274
-
275
// get metadata
276
- $meta = get_metadata( $this->storage_model->type, $id, $field, true );
277
278
// try to turn any array into a comma seperated string for further use
279
if ( ( 'array' == $this->options->field_type && is_array( $meta ) ) || is_array( $meta ) ) {
@@ -286,6 +309,35 @@ class CPAC_Column_Custom_Field extends CPAC_Column {
286
return $meta;
287
}
288
289
/**
290
* @see CPAC_Column::get_value()
291
* @since 1.0
@@ -297,14 +349,17 @@ class CPAC_Column_Custom_Field extends CPAC_Column {
297
if ( $meta = $this->get_meta_by_id( $id ) ) {
298
299
// get value by meta
300
- $value = $this->get_value_by_meta( $meta );
301
}
302
303
$value = apply_filters( 'cac/column/meta/value', $value, $id, $this );
304
305
// add before and after string
306
if ( $value ) {
307
- $value = "{$this->options->before}{$value}{$this->options->after}";
308
}
309
310
return $value;
34
// for retireving sorting preference
35
$this->user_settings = get_option( 'cpac_general_options' );
36
37
+ // call construct
38
parent::__construct( $storage_model );
39
}
40
44
*/
45
function sanitize_options( $options ) {
46
47
+ //if ( ! empty( $options['before'] ) )
48
+ // $options['before'] = trim( $options['before'] );
49
50
+ //if ( ! empty( $options['after'] ) )
51
+ // $options['after'] = trim( $options['after'] );
52
53
if ( empty( $options['date_format'] ) ) {
54
$options['date_format'] = get_option( 'date_format' );
68
69
$custom_field_types = array(
70
'' => __( 'Default'),
71
+ 'checkmark' => __( 'Checkmark (true/false)', 'cpac' ),
72
+ 'color' => __( 'Color', 'cpac' ),
73
+ 'count' => __( 'Counter', 'cpac' ),
74
+ 'date' => __( 'Date', 'cpac' ),
75
+ 'excerpt' => __( 'Excerpt'),
76
'image' => __( 'Image', 'cpac' ),
77
'library_id' => __( 'Media Library', 'cpac' ),
78
'array' => __( 'Multiple Values', 'cpac' ),
79
'numeric' => __( 'Numeric', 'cpac' ),
80
'title_by_id' => __( 'Post Title (Post ID\'s)', 'cpac' ),
81
'user_by_id' => __( 'Username (User ID\'s)', 'cpac' ),
82
);
83
84
+ // deprecated. do not use, will be removed.
85
+ $custom_field_types = apply_filters( 'cpac_custom_field_types', $custom_field_types );
86
+
87
+ // Filter
88
+ $custom_field_types = apply_filters( 'cac/column/meta/types', $custom_field_types );
89
+
90
+ return $custom_field_types;
91
}
92
93
/**
94
+ * Get First ID from array
95
*
96
* @since 1.0
97
*
98
* @param string $meta
99
* @return string Titles
100
*/
101
+ public function get_ids_from_meta( $meta ) {
102
103
//remove white spaces and strip tags
104
$meta = $this->strip_trim( str_replace( ' ','', $meta ) );
105
106
// var
107
+ $ids = array();
108
109
// check for multiple id's
110
if ( strpos( $meta, ',' ) !== false )
112
elseif ( is_numeric( $meta ) )
113
$ids[] = $meta;
114
115
+ return $ids;
116
+ }
117
+
118
+ /**
119
+ * Get Title by ID - Value method
120
+ *
121
+ * @since 1.0
122
+ *
123
+ * @param string $meta
124
+ * @return string Titles
125
+ */
126
+ private function get_titles_by_id( $meta ) {
127
+
128
+ $ids = $this->get_ids_from_meta( $meta );
129
+
130
// display title with link
131
if ( $ids && is_array( $ids ) ) {
132
foreach ( $ids as $id ) {
133
+ if ( ! is_numeric( $id ) ) continue;
134
+
135
$link = get_edit_post_link( $id );
136
+ if ( $title = get_the_title( $id ) )
137
$titles[] = $link ? "<a href='{$link}'>{$title}</a>" : $title;
138
}
139
}
151
*/
152
private function get_users_by_id( $meta ) {
153
154
+ $ids = $this->get_ids_from_meta( $meta );
155
156
// display username
157
if ( $ids && is_array( $ids ) ) {
158
foreach ( $ids as $id ) {
159
+ if ( ! is_numeric( $id ) ) continue;
160
161
$userdata = get_userdata( $id );
162
if ( is_object( $userdata ) && ! empty( $userdata->display_name ) ) {
177
*
178
* @since 2.0.0
179
*
180
+ * @param string $meta Contains Meta Value
181
+ * @param int $id Optional Object ID
182
* @return string Users
183
*/
184
+ function get_value_by_meta( $meta, $id = null ) {
185
186
switch ( $this->options->field_type ) :
187
229
}
230
break;
231
232
+ case "count" :
233
+ if ( $count = $this->get_raw_value( $id, false ) )
234
+ $meta = count( $count );
235
+ break;
236
+
237
endswitch;
238
239
return $meta;
273
return $rgb;
274
}
275
276
+ /**
277
+ * Get Field key
278
+ *
279
+ * @since 2.0.3
280
+ *
281
+ * @param string Custom Field Key
282
+ */
283
+ function get_field_key() {
284
+
285
+ return substr( $this->options->field, 0, 10 ) == "cpachidden" ? str_replace( 'cpachidden', '', $this->options->field ) : $this->options->field;
286
+ }
287
+
288
/**
289
* Get meta by ID
290
*
291
+ * @since 1.0.0
292
*
293
* @param int $id ID
294
* @return string Meta Value
295
*/
296
public function get_meta_by_id( $id ) {
297
298
// get metadata
299
+ $meta = $this->get_raw_value( $id );
300
301
// try to turn any array into a comma seperated string for further use
302
if ( ( 'array' == $this->options->field_type && is_array( $meta ) ) || is_array( $meta ) ) {
309
return $meta;
310
}
311
312
+ /**
313
+ * Get before value
314
+ *
315
+ * @since 1.0
316
+ */
317
+ function get_before() {
318
+
319
+ return stripslashes( $this->options->before );
320
+ }
321
+
322
+ /**
323
+ * Get after value
324
+ *
325
+ * @since 1.0
326
+ */
327
+ function get_after() {
328
+
329
+ return stripslashes( $this->options->after );
330
+ }
331
+
332
+ /**
333
+ * @see CPAC_Column::get_raw_value()
334
+ * @since 2.0.3
335
+ */
336
+ function get_raw_value( $id, $single = true ) {
337
+
338
+ return get_metadata( $this->storage_model->type, $id, $this->get_field_key(), $single );
339
+ }
340
+
341
/**
342
* @see CPAC_Column::get_value()
343
* @since 1.0
349
if ( $meta = $this->get_meta_by_id( $id ) ) {
350
351
// get value by meta
352
+ $value = $this->get_value_by_meta( $meta, $id );
353
}
354
355
$value = apply_filters( 'cac/column/meta/value', $value, $id, $this );
356
357
+ $before = $this->get_before();
358
+ $after = $this->get_after();
359
+
360
// add before and after string
361
if ( $value ) {
362
+ $value = "{$before}{$value}{$after}";
363
}
364
365
return $value;
classes/column/post/ID.php CHANGED
@@ -19,6 +19,14 @@ class CPAC_Column_Post_ID extends CPAC_Column {
19
* @since 2.0.0
20
*/
21
function get_value( $post_id ) {
22
return $post_id;
23
}
24
}
19
* @since 2.0.0
20
*/
21
function get_value( $post_id ) {
22
+ return $this->get_raw_value( $post_id );
23
+ }
24
+
25
+ /**
26
+ * @see CPAC_Column::get_value()
27
+ * @since 2.0.3
28
+ */
29
+ function get_raw_value( $post_id ) {
30
return $post_id;
31
}
32
}
classes/column/post/attachment-count.php CHANGED
@@ -20,6 +20,15 @@ class CPAC_Column_Post_Attachment_Count extends CPAC_Column {
20
*/
21
function get_value( $post_id ) {
22
23
$attachment_ids = get_posts( array(
24
'post_type' => 'attachment',
25
'numberposts' => -1,
20
*/
21
function get_value( $post_id ) {
22
23
+ return $this->get_raw_value( $post_id );
24
+ }
25
+
26
+ /**
27
+ * @see CPAC_Column::get_raw_value()
28
+ * @since 2.0.3
29
+ */
30
+ function get_raw_value( $post_id ) {
31
+
32
$attachment_ids = get_posts( array(
33
'post_type' => 'attachment',
34
'numberposts' => -1,
classes/column/post/attachment.php CHANGED
@@ -25,15 +25,24 @@ class CPAC_Column_Post_Attachment extends CPAC_Column {
25
*/
26
function get_value( $post_id ) {
27
28
- $attachment_ids = get_posts( array(
29
'post_type' => 'attachment',
30
'numberposts' => -1,
31
'post_status' => null,
32
'post_parent' => $post_id,
33
'fields' => 'ids'
34
));
35
-
36
- return implode( $this->get_thumbnails( $attachment_ids, $this->options ) );
37
}
38
39
/**
25
*/
26
function get_value( $post_id ) {
27
28
+ $attachment_ids = $this->get_raw_value( $post_id );
29
+
30
+ return implode( $this->get_thumbnails( $attachment_ids, $this->options ) );
31
+ }
32
+
33
+ /**
34
+ * @see CPAC_Column::get_raw_value()
35
+ * @since 2.0.3
36
+ */
37
+ function get_raw_value( $post_id ) {
38
+
39
+ return get_posts( array(
40
'post_type' => 'attachment',
41
'numberposts' => -1,
42
'post_status' => null,
43
'post_parent' => $post_id,
44
'fields' => 'ids'
45
));
46
}
47
48
/**
classes/column/post/author-name.php CHANGED
@@ -8,9 +8,10 @@ class CPAC_Column_Post_Author_Name extends CPAC_Column {
8
9
function __construct( $storage_model ) {
10
11
- $this->properties['type'] = 'column-author_name';
12
- $this->properties['label'] = __( 'Display Author As', 'cpac' );
13
- $this->properties['is_cloneable'] = true;
14
15
// define additional options
16
$this->options['display_author_as'] = '';
@@ -84,7 +85,7 @@ class CPAC_Column_Post_Author_Name extends CPAC_Column {
84
85
$nametypes = $this->get_nametypes();
86
if ( isset( $nametypes[ $this->options->display_author_as ] ) ) {
87
- if( $author = get_post_field( 'post_author', $post_id ) ) {
88
$value = $this->get_display_name( $author );
89
}
90
}
@@ -92,6 +93,15 @@ class CPAC_Column_Post_Author_Name extends CPAC_Column {
92
return $value;
93
}
94
95
/**
96
* Display Settings
97
*
8
9
function __construct( $storage_model ) {
10
11
+ $this->properties['type'] = 'column-author_name';
12
+ $this->properties['label'] = __( 'Display Author As', 'cpac' );
13
+ $this->properties['is_cloneable'] = true;
14
+ $this->properties['object_property'] = 'post_author';
15
16
// define additional options
17
$this->options['display_author_as'] = '';
85
86
$nametypes = $this->get_nametypes();
87
if ( isset( $nametypes[ $this->options->display_author_as ] ) ) {
88
+ if( $author = $this->get_raw_value( $post_id ) ) {
89
$value = $this->get_display_name( $author );
90
}
91
}
93
return $value;
94
}
95
96
+ /**
97
+ * @see CPAC_Column::get_raw_value()
98
+ * @since 2.0.3
99
+ */
100
+ function get_raw_value( $post_id ) {
101
+
102
+ return get_post_field( 'post_author', $post_id );
103
+ }
104
+
105
/**
106
* Display Settings
107
*
classes/column/post/before-moretag.php CHANGED
@@ -25,6 +25,15 @@ class CPAC_Column_Post_Before_Moretag extends CPAC_Column {
25
*/
26
function get_value( $post_id ) {
27
28
$value = '';
29
30
$p = get_post( $post_id );
25
*/
26
function get_value( $post_id ) {
27
28
+ return $this->get_raw_value( $post_id );
29
+ }
30
+
31
+ /**
32
+ * @see CPAC_Column::get_raw_value()
33
+ * @since 2.0.3
34
+ */
35
+ function get_raw_value( $post_id ) {
36
+
37
$value = '';
38
39
$p = get_post( $post_id );
classes/column/post/comment-count.php CHANGED
@@ -44,14 +44,31 @@ class CPAC_Column_Post_Comment_Count extends CPAC_Column {
44
$value = '';
45
46
$status = $this->options->comment_status;
47
- $count = wp_count_comments( $post_id );
48
-
49
- if ( isset( $count->{$status} ) ) {
50
51
$names = $this->get_comment_stati();
52
53
$url = esc_url( add_query_arg( array( 'p' => $post_id, 'comment_status' => $status ), admin_url( 'edit-comments.php' ) ) );
54
- $value = "<a href='{$url}' class='cp-{$status}' title='" . $names[ $status ] . "'>{$count->approved}</a>";
55
}
56
57
return $value;
44
$value = '';
45
46
$status = $this->options->comment_status;
47
+ $count = $this->get_raw_value( $post_id );
48
49
+ if ( $count !== '' ) {
50
$names = $this->get_comment_stati();
51
52
$url = esc_url( add_query_arg( array( 'p' => $post_id, 'comment_status' => $status ), admin_url( 'edit-comments.php' ) ) );
53
+ $value = "<a href='{$url}' class='cp-{$status}' title='" . $names[ $status ] . "'>{$count}</a>";
54
+ }
55
+
56
+ return $value;
57
+ }
58
+
59
+ /**
60
+ * @see CPAC_Column::get_raw_value()
61
+ * @since 2.0.3
62
+ */
63
+ function get_raw_value( $post_id ) {
64
+
65
+ $value = '';
66
+
67
+ $status = $this->options->comment_status;
68
+ $count = wp_count_comments( $post_id );
69
+
70
+ if ( isset( $count->{$status} ) ) {
71
+ $value = $count->{$status};
72
}
73
74
return $value;
classes/column/post/comment-status.php CHANGED
@@ -10,8 +10,9 @@ class CPAC_Column_Post_Comment_Status extends CPAC_Column {
10
function __construct( $storage_model ) {
11
12
// define properties
13
- $this->properties['type'] = 'column-comment_status';
14
- $this->properties['label'] = __( 'Comment status', 'cpac' );
15
16
parent::__construct( $storage_model );
17
}
@@ -22,12 +23,21 @@ class CPAC_Column_Post_Comment_Status extends CPAC_Column {
22
*/
23
function get_value( $post_id ) {
24
25
- $p = get_post( $post_id );
26
27
- $value = $this->get_asset_image( 'no.png', $p->comment_status );
28
- if ( 'open' == $p->comment_status )
29
- $value = $this->get_asset_image( 'checkmark.png', $p->comment_status );
30
31
return $value;
32
}
33
}
10
function __construct( $storage_model ) {
11
12
// define properties
13
+ $this->properties['type'] = 'column-comment_status';
14
+ $this->properties['label'] = __( 'Comment status', 'cpac' );
15
+ $this->properties['object_property'] = 'comment_status';
16
17
parent::__construct( $storage_model );
18
}
23
*/
24
function get_value( $post_id ) {
25
26
+ $comment_status = $this->get_raw_value( $post_id );
27
28
+ $value = $this->get_asset_image( 'no.png', $comment_status );
29
+ if ( 'open' == $comment_status )
30
+ $value = $this->get_asset_image( 'checkmark.png', $comment_status );
31
32
return $value;
33
}
34
+
35
+ /**
36
+ * @see CPAC_Column::get_raw_value()
37
+ * @since 2.0.3
38
+ */
39
+ function get_raw_value( $post_id ) {
40
+
41
+ return get_post_field( 'comment_status', $post_id, 'raw' );
42
+ }
43
}
classes/column/post/excerpt.php CHANGED
@@ -9,8 +9,9 @@ class CPAC_Column_Post_Excerpt extends CPAC_Column {
9
function __construct( $storage_model ) {
10
11
// define properties
12
- $this->properties['type'] = 'column-excerpt';
13
- $this->properties['label'] = __( 'Excerpt', 'cpac' );
14
15
// define additional options
16
$this->options['excerpt_length'] = 30;
@@ -27,6 +28,15 @@ class CPAC_Column_Post_Excerpt extends CPAC_Column {
27
return $this->get_post_excerpt( $post_id, $this->options->excerpt_length );
28
}
29
30
/**
31
* @see CPAC_Column::display_settings()
32
* @since 2.0.0
9
function __construct( $storage_model ) {
10
11
// define properties
12
+ $this->properties['type'] = 'column-excerpt';
13
+ $this->properties['label'] = __( 'Excerpt', 'cpac' );
14
+ $this->properties['object_property'] = 'post_excerpt';
15
16
// define additional options
17
$this->options['excerpt_length'] = 30;
28
return $this->get_post_excerpt( $post_id, $this->options->excerpt_length );
29
}
30
31
+ /**
32
+ * @see CPAC_Column::get_raw_value()
33
+ * @since 2.0.3
34
+ */
35
+ function get_raw_value( $post_id ) {
36
+
37
+ return get_post_field( 'post_excerpt', $post_id, 'raw' );
38
+ }
39
+
40
/**
41
* @see CPAC_Column::display_settings()
42
* @since 2.0.0
classes/column/post/featured-image.php CHANGED
@@ -10,8 +10,8 @@ class CPAC_Column_Post_Featured_Image extends CPAC_Column {
10
function __construct( $storage_model ) {
11
12
// define properties
13
- $this->properties['type'] = 'column-featured_image';
14
- $this->properties['label'] = __( 'Featured Image', 'cpac' );
15
16
// define additional options
17
$this->options['image_size'] = '';
@@ -26,15 +26,31 @@ class CPAC_Column_Post_Featured_Image extends CPAC_Column {
26
* @since 2.0.0
27
*/
28
function get_value( $post_id ) {
29
- if ( ! has_post_thumbnail( $post_id ) )
30
return false;
31
32
- $thumb = implode( $this->get_thumbnails( get_post_thumbnail_id( $post_id ), (array) $this->options ) );
33
$link = get_edit_post_link( $post_id );
34
35
return $link ? "<a href='{$link}#postimagediv'>{$thumb}</a>" : $thumb;
36
}
37
38
/**
39
* @see CPAC_Column::display_settings()
40
* @since 2.0.0
10
function __construct( $storage_model ) {
11
12
// define properties
13
+ $this->properties['type'] = 'column-featured_image';
14
+ $this->properties['label'] = __( 'Featured Image', 'cpac' );
15
16
// define additional options
17
$this->options['image_size'] = '';
26
* @since 2.0.0
27
*/
28
function get_value( $post_id ) {
29
+
30
+ $thumbnail_id = $this->get_raw_value( $post_id );
31
+
32
+ if ( !$thumbnail_id ) {
33
return false;
34
+ }
35
36
+ $thumb = implode( $this->get_thumbnails( $thumbnail_id, (array) $this->options ) );
37
$link = get_edit_post_link( $post_id );
38
39
return $link ? "<a href='{$link}#postimagediv'>{$thumb}</a>" : $thumb;
40
}
41
42
+ /**
43
+ * @see CPAC_Column::get_raw_value()
44
+ * @since 2.0.3
45
+ */
46
+ function get_raw_value( $post_id ) {
47
+
48
+ if ( ! has_post_thumbnail( $post_id ) )
49
+ return false;
50
+
51
+ return get_post_thumbnail_id( $post_id );
52
+ }
53
+
54
/**
55
* @see CPAC_Column::display_settings()
56
* @since 2.0.0
classes/column/post/formats.php CHANGED
@@ -34,9 +34,21 @@ class CPAC_Column_Post_Formats extends CPAC_Column {
34
*/
35
function get_value( $post_id ) {
36
37
- if ( ! $format = get_post_format( $post_id ) )
38
return false;
39
40
return esc_html( get_post_format_string( $format ) );
41
}
42
}
34
*/
35
function get_value( $post_id ) {
36
37
+ if ( ! $format = $this->get_raw_value( $post_id ) )
38
return false;
39
40
return esc_html( get_post_format_string( $format ) );
41
}
42
+
43
+ /**
44
+ * @see CPAC_Column::get_raw_value()
45
+ * @since 2.0.3
46
+ */
47
+ function get_raw_value( $post_id ) {
48
+
49
+ if ( ! $format = get_post_format( $post_id ) )
50
+ return false;
51
+
52
+ return $format;
53
+ }
54
}
classes/column/post/modified.php CHANGED
@@ -22,8 +22,19 @@ class CPAC_Column_Post_Modified extends CPAC_Column {
22
*/
23
function get_value( $post_id ) {
24
25
$p = get_post( $post_id );
26
27
- return $this->get_date( $p->post_modified ) . ' ' . $this->get_time( $p->post_modified );
28
}
29
}
22
*/
23
function get_value( $post_id ) {
24
25
+ $modified = $this->get_raw_value( $post_id );
26
+
27
+ return $this->get_date( $modified ) . ' ' . $this->get_time( $modified );
28
+ }
29
+
30
+ /**
31
+ * @see CPAC_Column::get_raw_value()
32
+ * @since 2.0.3
33
+ */
34
+ function get_raw_value( $post_id ) {
35
+
36
$p = get_post( $post_id );
37
38
+ return $p->post_modified;
39
}
40
}
classes/column/post/order.php CHANGED
@@ -34,6 +34,15 @@ class CPAC_Column_Post_Order extends CPAC_Column {
34
*/
35
function get_value( $post_id ) {
36
37
return get_post_field( 'menu_order', $post_id );
38
}
39
}
34
*/
35
function get_value( $post_id ) {
36
37
+ return $this->get_raw_value( $post_id );
38
+ }
39
+
40
+ /**
41
+ * @see CPAC_Column::get_raw_value()
42
+ * @since 2.0.3
43
+ */
44
+ function get_raw_value( $post_id ) {
45
+
46
return get_post_field( 'menu_order', $post_id );
47
}
48
}
classes/column/post/page-template.php CHANGED
@@ -20,9 +20,16 @@ class CPAC_Column_Post_Page_Template extends CPAC_Column {
20
*/
21
function get_value( $post_id ) {
22
23
- $page_template = get_post_meta( $post_id, '_wp_page_template', true );
24
25
- return array_search( $page_template, get_page_templates() );
26
}
27
28
/**
20
*/
21
function get_value( $post_id ) {
22
23
+ return array_search( $this->get_raw_value( $post_id ), get_page_templates() );
24
+ }
25
+
26
+ /**
27
+ * @see CPAC_Column::get_raw_value()
28
+ * @since 2.0.3
29
+ */
30
+ function get_raw_value( $post_id ) {
31
32
+ return get_post_meta( $post_id, '_wp_page_template', true );
33
}
34
35
/**
classes/column/post/parent.php CHANGED
@@ -8,8 +8,9 @@ class CPAC_Column_Post_Parent extends CPAC_Column {
8
9
function __construct( $storage_model ) {
10
11
- $this->properties['type'] = 'column-parent';
12
- $this->properties['label'] = __( 'Parent', 'cpac' );
13
14
parent::__construct( $storage_model );
15
}
@@ -20,10 +21,9 @@ class CPAC_Column_Post_Parent extends CPAC_Column {
20
*/
21
function get_value( $post_id ) {
22
23
- $parent_id = get_post_field( 'post_parent', $post_id );
24
-
25
- if ( !$parent_id || !is_numeric( $parent_id ) )
26
return false;
27
28
$title = get_the_title( $parent_id );
29
$link = get_edit_post_link( $parent_id );
@@ -31,6 +31,20 @@ class CPAC_Column_Post_Parent extends CPAC_Column {
31
return $link ? "<a href='{$link}'>{$title}</a>" : $title;
32
}
33
34
/**
35
* @see CPAC_Column::apply_conditional()
36
* @since 2.0.0
8
9
function __construct( $storage_model ) {
10
11
+ $this->properties['type'] = 'column-parent';
12
+ $this->properties['label'] = __( 'Parent', 'cpac' );
13
+ $this->properties['object_property'] = 'post_parent';
14
15
parent::__construct( $storage_model );
16
}
21
*/
22
function get_value( $post_id ) {
23
24
+ if ( !( $parent_id = $this->get_raw_value( $post_id ) ) ) {
25
return false;
26
+ }
27
28
$title = get_the_title( $parent_id );
29
$link = get_edit_post_link( $parent_id );
31
return $link ? "<a href='{$link}'>{$title}</a>" : $title;
32
}
33
34
+ /**
35
+ * @see CPAC_Column::get_raw_value()
36
+ * @since 2.0.3
37
+ */
38
+ function get_raw_value( $post_id ) {
39
+
40
+ $parent_id = get_post_field( 'post_parent', $post_id );
41
+
42
+ if ( !$parent_id || !is_numeric( $parent_id ) )
43
+ return false;
44
+
45
+ return $parent_id;
46
+ }
47
+
48
/**
49
* @see CPAC_Column::apply_conditional()
50
* @since 2.0.0
classes/column/post/ping-status.php CHANGED
@@ -10,8 +10,9 @@ class CPAC_Column_Post_Ping_Status extends CPAC_Column {
10
function __construct( $storage_model ) {
11
12
// define properties
13
- $this->properties['type'] = 'column-ping_status';
14
- $this->properties['label'] = __( 'Ping status', 'cpac' );
15
16
parent::__construct( $storage_model );
17
}
@@ -22,13 +23,21 @@ class CPAC_Column_Post_Ping_Status extends CPAC_Column {
22
*/
23
function get_value( $post_id ) {
24
25
- $p = get_post( $post_id );
26
27
- $value = $this->get_asset_image( 'no.png', $p->ping_status );
28
-
29
- if ( 'open' == $p->ping_status )
30
- $value = $this->get_asset_image( 'checkmark.png', $p->ping_status );
31
32
return $value;
33
}
34
}
10
function __construct( $storage_model ) {
11
12
// define properties
13
+ $this->properties['type'] = 'column-ping_status';
14
+ $this->properties['label'] = __( 'Ping status', 'cpac' );
15
+ $this->properties['object_property'] = 'ping_status';
16
17
parent::__construct( $storage_model );
18
}
23
*/
24
function get_value( $post_id ) {
25
26
+ $ping_status = $this->get_raw_value( $post_id );
27
28
+ $value = $this->get_asset_image( 'no.png', $ping_status );
29
+ if ( 'open' == $ping_status )
30
+ $value = $this->get_asset_image( 'checkmark.png', $ping_status );
31
32
return $value;
33
}
34
+
35
+ /**
36
+ * @see CPAC_Column::get_raw_value()
37
+ * @since 2.0.3
38
+ */
39
+ function get_raw_value( $post_id ) {
40
+
41
+ return get_post_field( 'ping_status', $post_id, 'raw' );
42
+ }
43
}
classes/column/post/roles.php CHANGED
@@ -22,11 +22,20 @@ class CPAC_Column_Post_Roles extends CPAC_Column {
22
*/
23
function get_value( $post_id ) {
24
25
$userdata = get_userdata( get_post_field( 'post_author', $post_id ) );
26
27
if ( empty( $userdata->roles[0] ) )
28
- return false;
29
30
- return implode( ', ',$userdata->roles );
31
}
32
}
22
*/
23
function get_value( $post_id ) {
24
25
+ return implode( ', ', $this->get_raw_value( $post_id ) );
26
+ }
27
+
28
+ /**
29
+ * @see CPAC_Column::get_raw_value()
30
+ * @since 2.0.3
31
+ */
32
+ function get_raw_value( $post_id ) {
33
+
34
$userdata = get_userdata( get_post_field( 'post_author', $post_id ) );
35
36
if ( empty( $userdata->roles[0] ) )
37
+ return array();
38
39
+ return $userdata->roles;
40
}
41
}
classes/column/post/slug.php CHANGED
@@ -20,6 +20,15 @@ class CPAC_Column_Post_Slug extends CPAC_Column {
20
*/
21
function get_value( $post_id ) {
22
23
return get_post_field( 'post_name', $post_id );
24
}
25
}
20
*/
21
function get_value( $post_id ) {
22
23
+ return $this->get_raw_value( $post_id );
24
+ }
25
+
26
+ /**
27
+ * @see CPAC_Column::get_raw_value()
28
+ * @since 2.0.3
29
+ */
30
+ function get_raw_value( $post_id ) {
31
+
32
return get_post_field( 'post_name', $post_id );
33
}
34
}
classes/column/post/status.php CHANGED
@@ -24,6 +24,8 @@ class CPAC_Column_Post_Status extends CPAC_Column {
24
25
$value = '';
26
27
$p = get_post( $post_id );
28
29
$builtin_status = array(
@@ -35,9 +37,20 @@ class CPAC_Column_Post_Status extends CPAC_Column {
35
'trash' => __( 'Trash', 'cpac' ),
36
);
37
38
- if ( isset( $builtin_status[ $p->post_status ] ) )
39
- $value = $builtin_status[ $p->post_status ];
40
41
return $value;
42
}
43
}
24
25
$value = '';
26
27
+ $post_status = $this->get_raw_value( $post_id );
28
+
29
$p = get_post( $post_id );
30
31
$builtin_status = array(
37
'trash' => __( 'Trash', 'cpac' ),
38
);
39
40
+ if ( isset( $builtin_status[ $post_status ] ) )
41
+ $value = $builtin_status[ $post_status ];
42
43
return $value;
44
}
45
+
46
+ /**
47
+ * @see CPAC_Column::get_raw_value()
48
+ * @since 2.0.3
49
+ */
50
+ function get_raw_value( $post_id ) {
51
+
52
+ $p = get_post( $post_id );
53
+
54
+ return $p->post_status;
55
+ }
56
}
classes/column/post/sticky.php CHANGED
@@ -33,9 +33,18 @@ class CPAC_Column_Post_Sticky extends CPAC_Column {
33
* @since 2.0.0
34
*/
35
function get_value( $post_id ) {
36
- if ( ! is_sticky( $post_id ) )
37
return false;
38
39
return $this->get_asset_image( 'checkmark.png' );
40
}
41
}
33
* @since 2.0.0
34
*/
35
function get_value( $post_id ) {
36
+ if ( ! ( $sticky = $this->get_raw_value( $post_id ) ) )
37
return false;
38
39
return $this->get_asset_image( 'checkmark.png' );
40
}
41
+
42
+ /**
43
+ * @see CPAC_Column::get_raw_value()
44
+ * @since 2.0.3
45
+ */
46
+ function get_raw_value( $post_id ) {
47
+
48
+ return is_sticky( $post_id );
49
+ }
50
}
classes/column/post/taxonomy.php CHANGED
@@ -26,20 +26,26 @@ class CPAC_Column_Post_Taxonomy extends CPAC_Column {
26
27
$values = array();
28
29
- if ( $terms = get_the_terms( $post_id, $this->options->taxonomy ) ) {
30
- $values = array();
31
-
32
foreach ( $terms as $term ) {
33
34
$title = esc_html( sanitize_term_field( 'name', $term->name, $term->term_id, $term->taxonomy, 'edit' ) );
35
$values[] = "<a href='edit.php?post_type={$this->storage_model->key}&{$term->taxonomy}={$term->slug}'>{$title}</a>";
36
}
37
- $value = implode( ', ', $values );
38
}
39
40
return implode( ', ', $values );
41
}
42
43
/**
44
* @see CPAC_Column::apply_conditional()
45
* @since 2.0.0
26
27
$values = array();
28
29
+ if ( $terms = $this->get_raw_value( $post_id ) ) {
30
foreach ( $terms as $term ) {
31
32
$title = esc_html( sanitize_term_field( 'name', $term->name, $term->term_id, $term->taxonomy, 'edit' ) );
33
$values[] = "<a href='edit.php?post_type={$this->storage_model->key}&{$term->taxonomy}={$term->slug}'>{$title}</a>";
34
}
35
}
36
37
return implode( ', ', $values );
38
}
39
40
+ /**
41
+ * @see CPAC_Column::get_raw_value()
42
+ * @since 2.0.3
43
+ */
44
+ function get_raw_value( $post_id ) {
45
+
46
+ return get_the_terms( $post_id, $this->options->taxonomy );
47
+ }
48
+
49
/**
50
* @see CPAC_Column::apply_conditional()
51
* @since 2.0.0
classes/column/post/word-count.php CHANGED
@@ -20,6 +20,15 @@ class CPAC_Column_Post_Word_Count extends CPAC_Column {
20
*/
21
function get_value( $post_id ) {
22
23
return str_word_count( $this->strip_trim( get_post_field( 'post_content', $post_id ) ) );
24
}
25
20
*/
21
function get_value( $post_id ) {
22
23
+ return $this->get_raw_value( $post_id );
24
+ }
25
+
26
+ /**
27
+ * @see CPAC_Column::get_raw_value()
28
+ * @since 2.0.3
29
+ */
30
+ function get_raw_value( $post_id ) {
31
+
32
return str_word_count( $this->strip_trim( get_post_field( 'post_content', $post_id ) ) );
33
}
34
classes/column/user/ID.php CHANGED
@@ -22,6 +22,15 @@ class CPAC_Column_User_ID extends CPAC_Column {
22
*/
23
function get_value( $user_id ) {
24
25
return $user_id;
26
}
27
}
22
*/
23
function get_value( $user_id ) {
24
25
+ return $this->get_raw_value( $user_id );
26
+ }
27
+
28
+ /**
29
+ * @see CPAC_Column::get_raw_value()
30
+ * @since 2.0.3
31
+ */
32
+ function get_raw_value( $user_id ) {
33
+
34
return $user_id;
35
}
36
}
classes/column/user/actions.php CHANGED
@@ -22,6 +22,15 @@ class CPAC_Column_User_Actions extends CPAC_Column {
22
*/
23
function get_value( $user_id ) {
24
25
return $this->get_column_value_actions( $user_id );
26
}
27
22
*/
23
function get_value( $user_id ) {
24
25
+ return $this->get_raw_value( $user_id );
26
+ }
27
+
28
+ /**
29
+ * @see CPAC_Column::get_raw_value()
30
+ * @since 2.0.3
31
+ */
32
+ function get_raw_value( $user_id ) {
33
+
34
return $this->get_column_value_actions( $user_id );
35
}
36
classes/column/user/comment-count.php CHANGED
@@ -22,11 +22,18 @@ class CPAC_Column_User_Comment_Count extends CPAC_Column {
22
*/
23
function get_value( $user_id ) {
24
25
- $value = get_comments( array(
26
'user_id' => $user_id,
27
'count' => true
28
));
29
-
30
- return $value;
31
}
32
}
22
*/
23
function get_value( $user_id ) {
24
25
+ return $this->get_raw_value( $user_id );
26
+ }
27
+
28
+ /**
29
+ * @see CPAC_Column::get_raw_value()
30
+ * @since 2.0.3
31
+ */
32
+ function get_raw_value( $user_id ) {
33
+
34
+ return get_comments( array(
35
'user_id' => $user_id,
36
'count' => true
37
));
38
}
39
}
classes/column/user/description.php CHANGED
@@ -25,6 +25,15 @@ class CPAC_Column_User_Description extends CPAC_Column {
25
*/
26
function get_value( $user_id ) {
27
28
return $this->get_shortened_string( get_the_author_meta( 'user_description', $user_id ), $this->options->excerpt_length );
29
}
30
25
*/
26
function get_value( $user_id ) {
27
28
+ return $this->get_raw_value( $user_id );
29
+ }
30
+
31
+ /**
32
+ * @see CPAC_Column::get_raw_value()
33
+ * @since 2.0.3
34
+ */
35
+ function get_raw_value( $user_id ) {
36
+
37
return $this->get_shortened_string( get_the_author_meta( 'user_description', $user_id ), $this->options->excerpt_length );
38
}
39
classes/column/user/first-name.php CHANGED
@@ -22,6 +22,15 @@ class CPAC_Column_User_First_Name extends CPAC_Column {
22
*/
23
function get_value( $user_id ) {
24
25
$userdata = get_userdata( $user_id );
26
27
return $userdata->first_name;
22
*/
23
function get_value( $user_id ) {
24
25
+ return $this->get_raw_value( $user_id );
26
+ }
27
+
28
+ /**
29
+ * @see CPAC_Column::get_raw_value()
30
+ * @since 2.0.3
31
+ */
32
+ function get_raw_value( $user_id ) {
33
+
34
$userdata = get_userdata( $user_id );
35
36
return $userdata->first_name;
classes/column/user/last-name.php CHANGED
@@ -22,6 +22,15 @@ class CPAC_Column_User_Last_Name extends CPAC_Column {
22
*/
23
function get_value( $user_id ) {
24
25
$userdata = get_userdata( $user_id );
26
27
return $userdata->last_name;
22
*/
23
function get_value( $user_id ) {
24
25
+ return $this->get_raw_value( $user_id );
26
+ }
27
+
28
+ /**
29
+ * @see CPAC_Column::get_raw_value()
30
+ * @since 2.0.3
31
+ */
32
+ function get_raw_value( $user_id ) {
33
+
34
$userdata = get_userdata( $user_id );
35
36
return $userdata->last_name;
classes/column/user/nickname.php CHANGED
@@ -22,6 +22,15 @@ class CPAC_Column_User_Nickname extends CPAC_Column {
22
*/
23
function get_value( $user_id ) {
24
25
$userdata = get_userdata( $user_id );
26
27
return $userdata->nickname;
22
*/
23
function get_value( $user_id ) {
24
25
+ return $this->get_raw_value( $user_id );
26
+ }
27
+
28
+ /**
29
+ * @see CPAC_Column::get_raw_value()
30
+ * @since 2.0.3
31
+ */
32
+ function get_raw_value( $user_id ) {
33
+
34
$userdata = get_userdata( $user_id );
35
36
return $userdata->nickname;
classes/column/user/post-count.php CHANGED
@@ -47,19 +47,26 @@ class CPAC_Column_User_Post_Count extends CPAC_Column {
47
* @see CPAC_Column::get_value()
48
* @since 2.0.0
49
*/
50
- public function get_value( $user_id ) {
51
-
52
- global $wpdb;
53
54
$value = '0';
55
56
- $count = $this->get_count( $user_id );
57
if ( $count > 0 )
58
$value = "<a href='edit.php?post_type={$this->options->post_type}&author={$user_id}'>{$count}</a>";
59
60
return $value;
61
}
62
63
/**
64
* Display Settings
65
*
@@ -84,7 +91,7 @@ class CPAC_Column_User_Post_Count extends CPAC_Column {
84
$post_types = array();
85
foreach ( $ptypes as $type ) {
86
$obj = get_post_type_object( $type );
87
- $post_types[ $type ] = $obj->labels->singular_name;
88
}
89
90
?>
47
* @see CPAC_Column::get_value()
48
* @since 2.0.0
49
*/
50
+ function get_value( $user_id ) {
51
52
$value = '0';
53
54
+ $count = $this->get_raw_value( $user_id );
55
if ( $count > 0 )
56
$value = "<a href='edit.php?post_type={$this->options->post_type}&author={$user_id}'>{$count}</a>";
57
58
return $value;
59
}
60
61
+ /**
62
+ * @see CPAC_Column::get_raw_value()
63
+ * @since 2.0.3
64
+ */
65
+ function get_raw_value( $user_id ) {
66
+
67
+ return $this->get_count( $user_id );
68
+ }
69
+
70
/**
71
* Display Settings
72
*
91
$post_types = array();
92
foreach ( $ptypes as $type ) {
93
$obj = get_post_type_object( $type );
94
+ $post_types[ $type ] = $obj->labels->name;
95
}
96
97
?>
classes/column/user/registered.php CHANGED
@@ -24,9 +24,20 @@ class CPAC_Column_User_Registered extends CPAC_Column {
24
*/
25
function get_value( $user_id ) {
26
27
$userdata = get_userdata( $user_id );
28
29
- return $this->get_date( $userdata->user_registered, $this->options->date_format );
30
}
31
32
/**
24
*/
25
function get_value( $user_id ) {
26
27
+ $user_registered = $this->get_raw_value( $user_id );
28
+
29
+ return $this->get_date( $user_registered, $this->options->date_format );
30
+ }
31
+
32
+ /**
33
+ * @see CPAC_Column::get_raw_value()
34
+ * @since 2.0.3
35
+ */
36
+ function get_raw_value( $user_id ) {
37
+
38
$userdata = get_userdata( $user_id );
39
40
+ return $userdata->user_registered;
41
}
42
43
/**
classes/column/user/url.php CHANGED
@@ -22,6 +22,15 @@ class CPAC_Column_User_Url extends CPAC_Column {
22
*/
23
function get_value( $user_id ) {
24
25
$userdata = get_userdata( $user_id );
26
27
return $userdata->user_url;
22
*/
23
function get_value( $user_id ) {
24
25
+ return $this->get_raw_value( $user_id );
26
+ }
27
+
28
+ /**
29
+ * @see CPAC_Column::get_raw_value()
30
+ * @since 2.0.3
31
+ */
32
+ function get_raw_value( $user_id ) {
33
+
34
$userdata = get_userdata( $user_id );
35
36
return $userdata->user_url;
classes/settings.php CHANGED
@@ -60,10 +60,6 @@ class CPAC_Settings {
60
*/
61
public function settings_menu() {
62
63
- // add pages @remove
64
- //$this->admin_page = add_menu_page( __( 'Admin Columns Settings', 'cpac' ), __( 'Admin Columns', 'cpac' ), 'manage_admin_columns', 'codepress-admin-columns', array( $this, 'column_settings' ), false, 98 );
65
- //$settings_page = add_submenu_page( 'codepress-admin-columns', __( 'Settings', 'cpac' ), __( 'Settings', 'cpac' ), 'manage_admin_columns', 'cpac-settings', array( $this, 'general_settings' ) );
66
-
67
// add settings page
68
$settings_page = add_submenu_page( 'options-general.php', __( 'Admin Columns Settings', 'cpac' ), __( 'Admin Columns', 'cpac' ), 'manage_admin_columns', 'codepress-admin-columns', array( $this, 'display' ), false, 98 );
69
@@ -149,6 +145,7 @@ class CPAC_Settings {
149
switch ( $action ) :
150
151
case 'update_by_type' :
152
if ( wp_verify_nonce( $nonce, 'update-type' ) ) {
153
$storage_model = $this->cpac->get_storage_model( $key );
154
$storage_model->store();
@@ -231,6 +228,7 @@ class CPAC_Settings {
231
<li><strong>". __( "Usernames", 'cpac' ) . "</strong><br/>". __( "Value: can be one or more User ID's (seperated by ',').", 'cpac' ) . "</li>
232
<li><strong>". __( "Checkmark", 'cpac' ) . "</strong><br/>". __( "Value: should be a 1 (one) or 0 (zero).", 'cpac' ) . "</li>
233
<li><strong>". __( "Color", 'cpac' ) . "</strong><br/>". __( "Value: hex value color, such as #808080.", 'cpac' ) . "</li>
234
</ul>
235
"
236
)
@@ -559,10 +557,6 @@ class CPAC_Settings {
559
<?php foreach ( $this->cpac->storage_models as $storage_model ) : ?>
560
561
<div class="columns-container" data-type="<?php echo $storage_model->key ?>"<?php echo $storage_model->is_menu_type_current( $first ) ? '' : ' style="display:none"'; ?>>
562
- <form method="post" action="">
563
-
564
- <?php wp_nonce_field( 'update-type', '_cpac_nonce'); ?>
565
- <input type="hidden" name="cpac_key" value="<?php echo $storage_model->key; ?>" />
566
567
<div class="columns-left">
568
<div id="titlediv">
@@ -581,8 +575,7 @@ class CPAC_Settings {
581
</h3>
582
<?php $has_been_stored = $storage_model->get_stored_columns() ? true : false; ?>
583
<div class="form-update">
584
- <input type="hidden" name="cpac_action" value="update_by_type" />
585
- <input type="submit" class="button-primary submit-update" value="<?php echo $has_been_stored ? __( 'Update' ) : __('Publish'); ?> <?php echo $storage_model->label; ?>" accesskey="u" >
586
</div>
587
<?php if ( $has_been_stored ) : ?>
588
<div class="form-reset">
@@ -591,11 +584,14 @@ class CPAC_Settings {
591
</a>
592
</div>
593
<?php endif; ?>
594
</div><!--form-actions-->
595
596
<?php if ( ! class_exists( 'CAC_Addon_Pro' ) ) : ?>
597
<div class="sidebox" id="pro-version">
598
- <div class="padding-box">
599
<h3>
600
<a href="<?php echo $this->get_url('pro_addon'); ?>"><?php _e( 'Get the Pro Add-on', 'cpac' ) ?></a>
601
</h3>
@@ -610,6 +606,25 @@ class CPAC_Settings {
610
</p>
611
</div>
612
</div>
613
</div>
614
<?php endif; ?>
615
@@ -630,11 +645,18 @@ class CPAC_Settings {
630
<div class="cpac-boxes">
631
<div class="cpac-columns">
632
633
- <?php
634
- foreach ( $storage_model->get_columns() as $column ) {
635
- $column->display();
636
- }
637
- ?>
638
639
</div><!--.cpac-columns-->
640
@@ -650,8 +672,6 @@ class CPAC_Settings {
650
</div><!--.columns-left-->
651
<div class="clear"></div>
652
653
- </form>
654
-
655
<div class="for-cloning-only" style="display:none">
656
<?php
657
foreach ( $storage_model->get_registered_columns() as $column ) {
@@ -667,12 +687,11 @@ class CPAC_Settings {
667
<div class="clear"></div>
668
669
<?php
670
- break; // case: general
671
672
case 'settings' :
673
-
674
$this->display_settings();
675
- break; // case: settings
676
677
endswitch;
678
?>
60
*/
61
public function settings_menu() {
62
63
// add settings page
64
$settings_page = add_submenu_page( 'options-general.php', __( 'Admin Columns Settings', 'cpac' ), __( 'Admin Columns', 'cpac' ), 'manage_admin_columns', 'codepress-admin-columns', array( $this, 'display' ), false, 98 );
65
145
switch ( $action ) :
146
147
case 'update_by_type' :
148
+
149
if ( wp_verify_nonce( $nonce, 'update-type' ) ) {
150
$storage_model = $this->cpac->get_storage_model( $key );
151
$storage_model->store();
228
<li><strong>". __( "Usernames", 'cpac' ) . "</strong><br/>". __( "Value: can be one or more User ID's (seperated by ',').", 'cpac' ) . "</li>
229
<li><strong>". __( "Checkmark", 'cpac' ) . "</strong><br/>". __( "Value: should be a 1 (one) or 0 (zero).", 'cpac' ) . "</li>
230
<li><strong>". __( "Color", 'cpac' ) . "</strong><br/>". __( "Value: hex value color, such as #808080.", 'cpac' ) . "</li>
231
+ <li><strong>". __( "Counter", 'cpac' ) . "</strong><br/>". __( "Value: Can be either a string or array. This will display a count of the number of times the meta key is used by the item.", 'cpac' ) . "</li>
232
</ul>
233
"
234
)
557
<?php foreach ( $this->cpac->storage_models as $storage_model ) : ?>
558
559
<div class="columns-container" data-type="<?php echo $storage_model->key ?>"<?php echo $storage_model->is_menu_type_current( $first ) ? '' : ' style="display:none"'; ?>>
560
561
<div class="columns-left">
562
<div id="titlediv">
575
</h3>
576
<?php $has_been_stored = $storage_model->get_stored_columns() ? true : false; ?>
577
<div class="form-update">
578
+ <a href="javascript:;" class="button-primary submit-update"><?php echo $has_been_stored ? __( 'Update' ) : __('Publish'); ?> <?php echo $storage_model->label; ?></a>
579
</div>
580
<?php if ( $has_been_stored ) : ?>
581
<div class="form-reset">
584
</a>
585
</div>
586
<?php endif; ?>
587
+
588
+ <?php do_action( 'cac/settings/form_actions', $storage_model ); ?>
589
+
590
</div><!--form-actions-->
591
592
<?php if ( ! class_exists( 'CAC_Addon_Pro' ) ) : ?>
593
<div class="sidebox" id="pro-version">
594
+ <div class="padding-box cta">
595
<h3>
596
<a href="<?php echo $this->get_url('pro_addon'); ?>"><?php _e( 'Get the Pro Add-on', 'cpac' ) ?></a>
597
</h3>
606
</p>
607
</div>
608
</div>
609
+ <!--
610
+ <div class="padding-box newsletter">
611
+ <form action="http://codepress.us4.list-manage.com/subscribe/post?u=902ae7f162ce5bc38a0bc8a4f&amp;id=183e843a76" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" target="_blank">
612
+ <?php $user = wp_get_current_user(); ?>
613
+ <p>
614
+ <?php _e ( "Subscribe to receive news &amp; updates below.", 'cpac' ); ?>
615
+ </p>
616
+ <div class="mc-field-group">
617
+ <label for="mce-FNAME"><?php _e( 'First Name', 'cpac' ); ?></label>
618
+ <input type="text" value="<?php echo trim( esc_attr( $user->first_name ) ); ?>" name="FNAME" class="" id="mce-FNAME">
619
+ </div>
620
+ <div class="mc-field-group">
621
+ <label for="mce-EMAIL"><?php _e( 'Your Email', 'cpac' ); ?></label>
622
+ <input type="email" value="<?php echo trim( esc_attr( $user->user_email ) ); ?>" name="EMAIL" class="required email" id="mce-EMAIL">
623
+ </div>
624
+ <input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button">
625
+ </form>
626
+ </div>
627
+ -->
628
</div>
629
<?php endif; ?>
630
645
<div class="cpac-boxes">
646
<div class="cpac-columns">
647
648
+ <form method="post" action="">
649
+ <?php wp_nonce_field( 'update-type', '_cpac_nonce'); ?>
650
+
651
+ <input type="hidden" name="cpac_key" value="<?php echo $storage_model->key; ?>" />
652
+ <input type="hidden" name="cpac_action" value="update_by_type" />
653
+
654
+ <?php
655
+ foreach ( $storage_model->get_columns() as $column ) {
656
+ $column->display();
657
+ }
658
+ ?>
659
+ </form>
660
661
</div><!--.cpac-columns-->
662
672
</div><!--.columns-left-->
673
<div class="clear"></div>
674
675
<div class="for-cloning-only" style="display:none">
676
<?php
677
foreach ( $storage_model->get_registered_columns() as $column ) {
687
<div class="clear"></div>
688
689
<?php
690
+ break; // case: general
691
692
case 'settings' :
693
$this->display_settings();
694
+ break;
695
696
endswitch;
697
?>
classes/storage_model.php CHANGED
@@ -51,7 +51,7 @@ abstract class CPAC_Storage_Model {
51
*
52
* @since 2.0.1
53
*/
54
- protected $columns;
55
56
/**
57
* Get default columns
@@ -237,6 +237,11 @@ abstract class CPAC_Storage_Model {
237
$columns[ 'CPAC_Column_' . ucfirst( $this->type ) . '_' . $class_name ] = $leaf->getPathname();
238
}
239
240
$this->custom_columns = apply_filters( 'cac/columns/custom/type=' . $this->type, $columns, $this );
241
}
242
@@ -282,7 +287,7 @@ abstract class CPAC_Storage_Model {
282
*
283
* @return array Column Type | Column Instance
284
*/
285
- function get_default_registered_columns() {
286
287
$columns = array();
288
@@ -480,11 +485,6 @@ abstract class CPAC_Storage_Model {
480
*/
481
function get_column_by_name( $name ) {
482
483
- // @todo check if no issues come up by using $this->columns
484
- //$columns = $this->get_columns();
485
- //if ( ! isset( $columns[ $name ] ) )
486
- // return false;*/
487
-
488
if ( ! isset( $this->columns[ $name ] ) )
489
return false;
490
@@ -543,15 +543,12 @@ abstract class CPAC_Storage_Model {
543
// @todo: check if working properly. cuurently issues with woocommerce columns
544
/*
545
if ( $diff = array_diff( $this->get_default_stored_columns(), array_keys( $columns ) ) ) {
546
- //echo '<pre>'; print_r( $diff ); echo '</pre>';
547
foreach ( $diff as $column_name ) {
548
if( isset( $column_headings[ $column_name ] ) )
549
unset( $column_headings[ $column_name ] );
550
}
551
}*/
552
553
-
554
-
555
return $column_headings;
556
}
557
@@ -586,4 +583,41 @@ abstract class CPAC_Storage_Model {
586
587
return add_query_arg( array( 'page' => 'codepress-admin-columns', 'cpac_key' => $this->key ), admin_url( 'options-general.php' ) );
588
}
589
}
51
*
52
* @since 2.0.1
53
*/
54
+ public $columns;
55
56
/**
57
* Get default columns
237
$columns[ 'CPAC_Column_' . ucfirst( $this->type ) . '_' . $class_name ] = $leaf->getPathname();
238
}
239
240
+ // cac/columns/custom - filter to register column
241
+ $this->custom_columns = apply_filters( 'cac/columns/custom', $columns, $this );
242
+
243
+ // cac/columns/custom/type={$type} - filter to register column based on it's content type
244
+ // type can be either a posttype or wp-users/wp-comments/wp-links/wp-media
245
$this->custom_columns = apply_filters( 'cac/columns/custom/type=' . $this->type, $columns, $this );
246
}
247
287
*
288
* @return array Column Type | Column Instance
289
*/
290
+ public function get_default_registered_columns() {
291
292
$columns = array();
293
485
*/
486
function get_column_by_name( $name ) {
487
488
if ( ! isset( $this->columns[ $name ] ) )
489
return false;
490
543
// @todo: check if working properly. cuurently issues with woocommerce columns
544
/*
545
if ( $diff = array_diff( $this->get_default_stored_columns(), array_keys( $columns ) ) ) {
546
foreach ( $diff as $column_name ) {
547
if( isset( $column_headings[ $column_name ] ) )
548
unset( $column_headings[ $column_name ] );
549
}
550
}*/
551
552
return $column_headings;
553
}
554
583
584
return add_query_arg( array( 'page' => 'codepress-admin-columns', 'cpac_key' => $this->key ), admin_url( 'options-general.php' ) );
585
}
586
+
587
+ /**
588
+ * Is columns screen
589
+ *
590
+ * @since 2.0.3
591
+ *
592
+ * @global string $pagenow
593
+ * @global object $current_screen
594
+ * @return boolean
595
+ */
596
+ function is_columns_screen() {
597
+
598
+ global $pagenow, $current_screen;
599
+
600
+ if ( $this->page . '.php' != $pagenow )
601
+ return false;
602
+
603
+ if ( ! empty( $current_screen->post_type ) && $this->key != $current_screen->post_type )
604
+ return false;
605
+
606
+ return true;
607
+ }
608
+
609
+ /**
610
+ * Checks if the current page is the settings page
611
+ *
612
+ * @since 2.0.2
613
+ *
614
+ * @global string $pagenow
615
+ * @global string $plugin_page
616
+ * @return boolean
617
+ */
618
+ public function is_settings_page() {
619
+ global $pagenow, $plugin_page;
620
+
621
+ return 'options-general.php' == $pagenow && ! empty( $plugin_page ) && 'codepress-admin-columns' == $plugin_page;
622
+ }
623
}
classes/storage_model/comment.php CHANGED
@@ -37,12 +37,14 @@ class CPAC_Storage_Model_Comment extends CPAC_Storage_Model {
37
*/
38
public function get_default_columns() {
39
40
// You can use this filter to add thirdparty columns by hooking into this.
41
// See classes/third_party.php for an example.
42
do_action( "cac/columns/default/storage_key={$this->key}" );
43
44
// get columns
45
- $table = _get_list_table( 'WP_Comments_List_Table', array( 'screen' => 'link-manager' ) );
46
$columns = $table->get_columns();
47
48
return $columns;
@@ -78,8 +80,11 @@ class CPAC_Storage_Model_Comment extends CPAC_Storage_Model {
78
$value = $column->get_value( $comment_id );
79
}
80
81
- // add hook
82
- echo apply_filters( "cac/column/value/type={$this->key}", $value, $column );
83
}
84
85
}
37
*/
38
public function get_default_columns() {
39
40
+ if ( ! function_exists('_get_list_table') ) return array();
41
+
42
// You can use this filter to add thirdparty columns by hooking into this.
43
// See classes/third_party.php for an example.
44
do_action( "cac/columns/default/storage_key={$this->key}" );
45
46
// get columns
47
+ $table = _get_list_table( 'WP_Comments_List_Table', array( 'screen' => 'comments' ) );
48
$columns = $table->get_columns();
49
50
return $columns;
80
$value = $column->get_value( $comment_id );
81
}
82
83
+ // filters
84
+ $value = apply_filters( "cac/column/value", $value, $comment_id, $column, $this->key );
85
+ $value = apply_filters( "cac/column/value/{$this->type}", $value, $comment_id, $column, $this->key );
86
+
87
+ echo $value;
88
}
89
90
}
classes/storage_model/link.php CHANGED
@@ -35,6 +35,9 @@ class CPAC_Storage_Model_Link extends CPAC_Storage_Model {
35
* @return array
36
*/
37
public function get_default_columns() {
38
// You can use this filter to add thirdparty columns by hooking into this.
39
// See classes/third_party.php for an example.
40
do_action( "cac/columns/default/storage_key={$this->key}" );
@@ -73,7 +76,10 @@ class CPAC_Storage_Model_Link extends CPAC_Storage_Model {
73
}
74
75
// add hook
76
- echo apply_filters( "cac/column/value/type={$this->key}", $value, $column );
77
}
78
79
}
35
* @return array
36
*/
37
public function get_default_columns() {
38
+
39
+ if ( ! function_exists('_get_list_table') ) return array();
40
+
41
// You can use this filter to add thirdparty columns by hooking into this.
42
// See classes/third_party.php for an example.
43
do_action( "cac/columns/default/storage_key={$this->key}" );
76
}
77
78
// add hook
79
+ $value = apply_filters( "cac/column/value", $value, $link_id, $column, $this->key );
80
+ $value = apply_filters( "cac/column/value/{$this->type}", $value, $link_id, $column, $this->key );
81
+
82
+ echo $value;
83
}
84
85
}
classes/storage_model/media.php CHANGED
@@ -21,7 +21,8 @@ class CPAC_Storage_Model_Media extends CPAC_Storage_Model {
21
add_action( 'admin_init', array( $this, 'set_columns' ) );
22
23
// headings
24
- add_filter( "manage_{$this->page}_columns", array( $this, 'add_headings' ) );
25
26
// values
27
add_action( 'manage_media_custom_column', array( $this, 'manage_value' ), 10, 2 );
@@ -36,13 +37,18 @@ class CPAC_Storage_Model_Media extends CPAC_Storage_Model {
36
*/
37
public function get_default_columns() {
38
39
// You can use this filter to add thirdparty columns by hooking into this.
40
// See classes/third_party.php for an example.
41
do_action( "cac/columns/default/storage_key={$this->key}" );
42
43
// get columns
44
- $table = _get_list_table( 'WP_Media_List_Table', array( 'screen' => 'upload' ) );
45
- $columns = $table->get_columns();
46
47
return $columns;
48
}
@@ -78,7 +84,10 @@ class CPAC_Storage_Model_Media extends CPAC_Storage_Model {
78
}
79
80
// add hook
81
- echo apply_filters( "cac/column/value/type={$this->key}", $value, $column );
82
}
83
84
}
21
add_action( 'admin_init', array( $this, 'set_columns' ) );
22
23
// headings
24
+ // Increased the priority to overrule 3th party plugins such as Media Tags
25
+ add_filter( "manage_{$this->page}_columns", array( $this, 'add_headings' ), 15 );
26
27
// values
28
add_action( 'manage_media_custom_column', array( $this, 'manage_value' ), 10, 2 );
37
*/
38
public function get_default_columns() {
39
40
+ if ( ! function_exists('_get_list_table') ) return array();
41
+
42
// You can use this filter to add thirdparty columns by hooking into this.
43
// See classes/third_party.php for an example.
44
do_action( "cac/columns/default/storage_key={$this->key}" );
45
46
// get columns
47
+ $table = _get_list_table ( 'WP_Media_List_Table', array( 'screen' => 'upload' ) );
48
+ $columns = $table->get_columns();
49
+
50
+ if ( $this->is_settings_page() )
51
+ $columns = array_merge( get_column_headers( 'upload' ), $columns );
52
53
return $columns;
54
}
84
}
85
86
// add hook
87
+ $value = apply_filters( "cac/column/value", $value, $media_id, $column, $this->key );
88
+ $value = apply_filters( "cac/column/value/{$this->type}", $value, $media_id, $column, $this->key );
89
+
90
+ echo $value;
91
}
92
93
}
classes/storage_model/post.php CHANGED
@@ -73,30 +73,27 @@ class CPAC_Storage_Model_Post extends CPAC_Storage_Model {
73
* @return array
74
*/
75
public function get_default_columns() {
76
- global $pagenow;
77
78
// You can use this filter to add thirdparty columns by hooking into this.
79
// See classes/third_party.php for an example.
80
do_action( "cac/columns/default/posts" );
81
do_action( "cac/columns/default/storage_key={$this->key}" );
82
83
- // Get columns that have been set by other plugins. If a plugin use the hook "manage_edit-{$post_type}_columns"
84
// we know that the columns have been overwritten. Use these columns instead of the WP default ones.
85
- //
86
// We have to make sure this filter only loads on the Admin Columns settings page. To prevent a loop
87
// when it's being called by CPAC_Storage_Model::add_headings()
88
- $columns = array();
89
-
90
- if ( 'options-general.php' == $pagenow && isset( $_GET['page'] ) && 'codepress-admin-columns' == $_GET['page'] )
91
- $columns = get_column_headers( "edit-{$this->key}" );
92
-
93
- // Get the WP default columns
94
- $table = _get_list_table( 'WP_Posts_List_Table', array( 'screen' => $this->key ) );
95
-
96
- // Merge the available hooked columns with the WP default columns
97
- $columns = array_filter( array_merge( $columns, $table->get_columns() ) );
98
99
- return $columns;
100
}
101
102
/**
@@ -130,8 +127,9 @@ class CPAC_Storage_Model_Post extends CPAC_Storage_Model {
130
if ( $column )
131
$value = $column->get_value( $post_id );
132
133
- $value = apply_filters( "cac/column/value/posts", $value, $column );
134
- $value = apply_filters( "cac/column/value/type={$this->key}", $value, $column );
135
136
echo $value;
137
}
73
* @return array
74
*/
75
public function get_default_columns() {
76
+
77
+ if ( ! function_exists('_get_list_table') ) return array();
78
79
// You can use this filter to add thirdparty columns by hooking into this.
80
// See classes/third_party.php for an example.
81
do_action( "cac/columns/default/posts" );
82
do_action( "cac/columns/default/storage_key={$this->key}" );
83
84
+ // Get the WP default columns
85
+ $table = _get_list_table( 'WP_Posts_List_Table', array( 'screen' => $this->key ) );
86
+ $columns = $table->get_columns();
87
+
88
+ // Get columns that have been set by other plugins. If a plugin use the hook "manage_edit-{$post_type}_columns"
89
// we know that the columns have been overwritten. Use these columns instead of the WP default ones.
90
+ //
91
// We have to make sure this filter only loads on the Admin Columns settings page. To prevent a loop
92
// when it's being called by CPAC_Storage_Model::add_headings()
93
+ if ( $this->is_settings_page() )
94
+ $columns = array_merge( get_column_headers( 'edit-' . $this->key ), $columns );
95
96
+ return array_filter( $columns );
97
}
98
99
/**
127
if ( $column )
128
$value = $column->get_value( $post_id );
129
130
+ // Filters
131
+ $value = apply_filters( "cac/column/value", $value, $post_id, $column, $this->key );
132
+ $value = apply_filters( "cac/column/value/{$this->type}", $value, $post_id, $column, $this->key );
133
134
echo $value;
135
}
classes/storage_model/user.php CHANGED
@@ -24,7 +24,7 @@ class CPAC_Storage_Model_User extends CPAC_Storage_Model {
24
add_filter( "manage_{$this->page}_columns", array( $this, 'add_headings' ) );
25
26
// values
27
- add_filter( 'manage_users_custom_column', array( $this, 'manage_value' ), 10, 3 );
28
29
//@todo: remove parent::__construct();
30
}
@@ -39,6 +39,8 @@ class CPAC_Storage_Model_User extends CPAC_Storage_Model {
39
*/
40
public function get_default_columns() {
41
42
// You can use this filter to add third_party columns by hooking into this.
43
do_action( "cac/columns/default/storage_key={$this->key}" );
44
@@ -52,13 +54,13 @@ class CPAC_Storage_Model_User extends CPAC_Storage_Model {
52
/**
53
* Manage value
54
*
55
- * @since 2.0.0
56
*
57
- * @param string $value
58
* @param string $column_name
59
- * @param int $post_id
60
*/
61
- public function manage_value( $value, $column_name, $user_id ) {
62
63
// get column instance
64
$column = $this->get_column_by_name( $column_name );
@@ -69,13 +71,30 @@ class CPAC_Storage_Model_User extends CPAC_Storage_Model {
69
// get value
70
$custom_value = $column->get_value( $user_id );
71
72
- // get value
73
// make sure it absolutely empty and check for (string) 0
74
- if ( ! empty( $custom_value ) || $custom_value === '0' ) {
75
$value = $custom_value;
76
}
77
78
- return apply_filters( "cac/column/value/type={$this->key}", $value, $column );
79
}
80
81
/**
24
add_filter( "manage_{$this->page}_columns", array( $this, 'add_headings' ) );
25
26
// values
27
+ add_filter( 'manage_users_custom_column', array( $this, 'manage_value_callback' ), 10, 3 );
28
29
//@todo: remove parent::__construct();
30
}
39
*/
40
public function get_default_columns() {
41
42
+ if ( ! function_exists('_get_list_table') ) return array();
43
+
44
// You can use this filter to add third_party columns by hooking into this.
45
do_action( "cac/columns/default/storage_key={$this->key}" );
46
54
/**
55
* Manage value
56
*
57
+ * @since 2.0.2
58
*
59
* @param string $column_name
60
+ * @param int $user_id
61
+ * @param string $value
62
*/
63
+ function manage_value( $column_name, $user_id, $value = '' ) {
64
65
// get column instance
66
$column = $this->get_column_by_name( $column_name );
71
// get value
72
$custom_value = $column->get_value( $user_id );
73
74
// make sure it absolutely empty and check for (string) 0
75
+ if ( ! empty( $custom_value ) || '0' === $custom_value ) {
76
$value = $custom_value;
77
}
78
79
+ // filters
80
+ $value = apply_filters( "cac/column/value", $value, $user_id, $column, $this->key );
81
+ $value = apply_filters( "cac/column/value/{$this->type}", $value, $user_id, $column, $this->key );
82
+
83
+ return $value;
84
+ }
85
+
86
+ /**
87
+ * Callback Manage value
88
+ *
89
+ * @since 2.0.2
90
+ *
91
+ * @param string $value
92
+ * @param string $column_name
93
+ * @param int $user_id
94
+ */
95
+ public function manage_value_callback( $value, $column_name, $user_id ) {
96
+
97
+ return $this->manage_value( $column_name, $user_id, $value );
98
}
99
100
/**
classes/utility.php CHANGED
@@ -1,4 +1,5 @@
1
<?php
2
/**
3
* Admin message
4
*
@@ -24,15 +25,7 @@ function cpac_admin_message( $message = '', $type = 'updated' ) {
24
* @return string Message.
25
*/
26
function cpac_admin_notice() {
27
echo implode( $GLOBALS['cpac_messages'] );
28
}
29
30
- /**
31
- * Don't display unused licences
32
- *
33
- * @since 2.0.0
34
- */
35
- add_filter( 'cac/display_licence/addon=cac-filtering', '__return_false' );
36
- add_filter( 'cac/display_licence/addon=cac-custom-fields', '__return_false' );
37
-
38
-
1
<?php
2
+
3
/**
4
* Admin message
5
*
25
* @return string Message.
26
*/
27
function cpac_admin_notice() {
28
+
29
echo implode( $GLOBALS['cpac_messages'] );
30
}
31
codepress-admin-columns.php CHANGED
@@ -2,7 +2,7 @@
2
/*
3
4
Plugin Name: Codepress Admin Columns
5
- Version: 2.0.2
6
Description: Customize 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.codepresshq.com
@@ -29,7 +29,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29
30
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
31
32
- define( 'CPAC_VERSION', '2.0.2' ); // current plugin version
33
define( 'CPAC_UPGRADE_VERSION', '2.0.0' ); // this is the latest version which requires an upgrade
34
define( 'CPAC_URL', plugin_dir_url( __FILE__ ) );
35
define( 'CPAC_DIR', plugin_dir_path( __FILE__ ) );
@@ -44,9 +44,7 @@ if ( ! is_admin() )
44
* @since 1.3.0
45
*/
46
require_once CPAC_DIR . 'classes/utility.php';
47
- require_once CPAC_DIR . 'classes/deprecated.php';
48
require_once CPAC_DIR . 'classes/third_party.php';
49
- require_once CPAC_DIR . 'classes/api.php';
50
51
/**
52
* The Codepress Admin Columns Class
@@ -156,14 +154,14 @@ class CPAC {
156
*
157
* @since 2.0.0
158
*
159
- * @return array object Storage Model
160
*/
161
public function get_storage_model( $key ) {
162
163
- if ( ! isset( $this->storage_models[ $key ] ) )
164
- return false;
165
166
- return $this->storage_models[ $key ];
167
}
168
169
/**
@@ -253,21 +251,18 @@ class CPAC {
253
* @return string
254
*/
255
function admin_class( $classes ) {
256
-
257
global $current_screen;
258
259
// we dont need the 'edit-' part
260
$screen = str_replace( 'edit-', '', $current_screen->id );
261
262
// media library exception
263
- if ( $current_screen->base == 'upload' && $current_screen->id == 'upload' ) {
264
$screen = 'media';
265
- }
266
267
// link exception
268
- if ( $current_screen->base == 'link-manager' && $current_screen->id == 'link-manager' ) {
269
$screen = 'links';
270
- }
271
272
// loop the available types
273
foreach ( $this->storage_models as $storage_model ) {
@@ -287,14 +282,13 @@ class CPAC {
287
* @since 1.4.0
288
*/
289
function admin_scripts() {
290
-
291
global $pagenow, $current_screen;
292
293