Admin Columns - Version 2.2.4

Version Description

  • [Added] New filter cpac/storage_model/columns_default for filtering the columns that should be loaded if there are no stored columns
  • [Added] Option (column property hidden) to hide column types from the dropdown list of column types
  • [Added] Use tooltip library for enhanced column value representation
  • [Added] Box for direct feedback on Admin Columns settings screen
  • [Added] Added method for retrieving current storage model (for overview pages such as the posts and page overviews)
  • [Added] Added WooCommerce add-on to list of add-ons
  • [Updated] Hide ACF5 field group post type from list of post types columns settings
  • [Updated] Updated structure of scripts and styles and way of enqueuing them
Download this release

Release Info

Developer engelen
Plugin Icon 128x128 Admin Columns
Version 2.2.4
Comparing to
See all releases

Code changes from version 2.2.3 to 2.2.4

assets/css/admin-column.css CHANGED
@@ -367,6 +367,9 @@ h2.cpac-nav-tab-wrapper {
367
-webkit-border-radius: 3px;
368
border-radius: 3px;
369
}
370
.cpac-column .column-form table tr.column_width div.description {
371
font-size: 11px;
372
width: 12%;
@@ -714,7 +717,7 @@ h2.cpac-nav-tab-wrapper {
714
text-align: center;
715
line-height: 64px;
716
font-weight: bold;
717
- color: #CCC;
718
display: inline-block;
719
text-decoration: none;
720
}
@@ -775,6 +778,9 @@ h2.cpac-nav-tab-wrapper {
775
.columns-right .sidebox#direct-feedback .inside ul.share li:first-child {
776
margin-left: 0;
777
}
778
/**
779
* Setting Tab
780
* ----------------------------------------------------------------------------
367
-webkit-border-radius: 3px;
368
border-radius: 3px;
369
}
370
+ .cpac-column .column-form table tr td.input .section {
371
+ padding: 12px;
372
+ }
373
.cpac-column .column-form table tr.column_width div.description {
374
font-size: 11px;
375
width: 12%;
717
text-align: center;
718
line-height: 64px;
719
font-weight: bold;
720
+ color: #222;
721
display: inline-block;
722
text-decoration: none;
723
}
778
.columns-right .sidebox#direct-feedback .inside ul.share li:first-child {
779
margin-left: 0;
780
}
781
+ .columns-right .sidebox#direct-feedback #feedback-support .inside ul.share li {
782
+ width: 48%;
783
+ }
784
/**
785
* Setting Tab
786
* ----------------------------------------------------------------------------
assets/css/column.css CHANGED
@@ -70,3 +70,29 @@ div.cpac-color span {
70
div.sizes span.not-available {
71
color: #999;
72
}
70
div.sizes span.not-available {
71
color: #999;
72
}
73
+ /* =Actions column
74
+ -------------------------------------------------------------- */
75
+ .button.cpac-button-action {
76
+ position: relative;
77
+ text-indent: 9999px;
78
+ margin-right: 4px;
79
+ padding: 0 13px;
80
+ }
81
+ .button.cpac-button-action:before {
82
+ position: absolute;
83
+ top: 0;
84
+ left: 0;
85
+ width: 100%;
86
+ height: 100%;
87
+ text-indent: 0;
88
+ }
89
+ /* =qTip2
90
+ -------------------------------------------------------------- */
91
+ .cpac-tip {
92
+ display: inline-block;
93
+ }
94
+ .qtip.qtip-tipsy {
95
+ background: rgba(0, 0, 0, 0.75);
96
+ font-weight: normal;
97
+ min-width: 25px;
98
+ }
assets/images/addon_sortable_1.png CHANGED
File without changes
assets/images/addons/woocommerce.png ADDED
Binary file
assets/images/arrows.png CHANGED
File without changes
assets/images/checkbox.png CHANGED
File without changes
assets/images/checkmark.png CHANGED
File without changes
assets/images/checkmark_single.png CHANGED
File without changes
assets/images/comment_edit.png CHANGED
File without changes
assets/images/cross.png CHANGED
File without changes
assets/images/facebook.png CHANGED
File without changes
assets/images/icon.png CHANGED
File without changes
assets/images/import_export.png CHANGED
File without changes
assets/images/information.png CHANGED
File without changes
assets/images/loading.gif CHANGED
File without changes
assets/images/no.png CHANGED
File without changes
assets/images/settings.png CHANGED
File without changes
assets/images/sort.png CHANGED
File without changes
assets/images/square.png CHANGED
File without changes
assets/images/trash.png CHANGED
File without changes
assets/images/twitter.png CHANGED
File without changes
assets/js/admin-columns.js CHANGED
@@ -1,648 +1,43 @@
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
- // General
11
- cpac_pointer();
12
- cpac_submit_form();
13
-
14
- // Settings Page
15
- cpac_clear_input_defaults();
16
-
17
- // Columns Page
18
- cpac_sortable();
19
- cpac_menu();
20
- cpac_help();
21
- cpac_add_column();
22
- cpac_sidebar_scroll();
23
- cpac_addons();
24
- cpac_importexport();
25
- cpac_sidebar_feedback();
26
-
27
- // we start by binding the toggle and remove events.
28
- jQuery('.cpac-column').each( function( i, col ) {
29
- jQuery( col ).column_bind_toggle();
30
- jQuery( col ).column_bind_remove();
31
- jQuery( col ).cpac_bind_container_addon_events();
32
- });
33
- });
34
-
35
- function cpac_importexport() {
36
- jQuery( '#php-export-results textarea' ).on( 'focus, mouseup', function() {
37
- jQuery( this ).select();
38
- } ).select().focus();
39
- }
40
41
/**
42
- * Handle addons settings screen
43
- *
44
- * @since 2.2
45
- */
46
- function cpac_addons() {
47
-
48
-
49
- }
50
-
51
- /*
52
- * Submit Form
53
- *
54
- * @since 2.0.2
55
- */
56
- function cpac_submit_form() {
57
- jQuery('.form-update a.submit-update').click( function(e){
58
- e.preventDefault();
59
-
60
- jQuery(this).closest('.columns-container').find('.cpac-columns form').submit();
61
- });
62
- }
63
-
64
- /*
65
- * Column: bind toggle events
66
- *
67
- * For performance we bind all other events after the click event.
68
- *
69
- * @since 2.0
70
- */
71
- jQuery.fn.column_bind_toggle = function() {
72
-
73
- var column = jQuery(this);
74
-
75
- column.find( 'td.column_type a, td.column_edit, td.column_label a.toggle, td.column_label .edit-button' ).click( function( e ) {
76
- e.preventDefault();
77
-
78
- column.toggleClass( 'opened' ).find( '.column-form' ).slideToggle( 150 );
79
-
80
- if ( ! column.hasClass( 'events-binded' ) ) {
81
- column.column_bind_events();
82
- }
83
-
84
- column.addClass('events-binded');
85
-
86
- // hook for addons
87
- jQuery( document ).trigger( 'column_init', column );
88
- } );
89
- };
90
-
91
- /*
92
- * Column: bind remove events
93
- *
94
- * @since 2.0
95
- */
96
- jQuery.fn.column_bind_remove = function() {
97
-
98
- jQuery(this).find('.remove-button').click( function(e) {
99
- jQuery(this).closest('.cpac-column').column_remove();
100
-
101
- e.preventDefault();
102
- });
103
- };
104
-
105
- jQuery.fn.cpac_column_refresh = function() {
106
- var el = jQuery( this );
107
-
108
- // Mark column as loading
109
- el.addClass( 'loading' );
110
- el.find( '.column-form' ).prepend( '<span class="spinner" />' );
111
-
112
- // Fetch new form HTML
113
- jQuery.post( ajaxurl, {
114
- action: 'cpac_column_refresh',
115
- column: jQuery( this ).find( 'input.column-name' ).val(),
116
- formdata: jQuery( this ).parents( 'form' ).serialize()
117
- }, function( data ) {
118
- // Replace current form by new form
119
- var newel = jQuery( '<div>' + data + '</div>' ).children();
120
- el.replaceWith( newel );
121
- el = newel;
122
-
123
- // Bind events
124
- el.column_bind_toggle();
125
- el.column_bind_remove();
126
- el.column_bind_events();
127
-
128
- // Remove "loading" marking from column
129
- el.removeClass( 'loading' ).addClass( 'opened' ).find( '.column-form' ).show();
130
-
131
- // Allow plugins to hook into this event
132
- jQuery( document ).trigger( 'column_change', el );
133
- } );
134
- };
135
-
136
- /*
137
- * Form Events
138
- *
139
- * @since 2.0
140
- */
141
- jQuery.fn.column_bind_events = function() {
142
-
143
- var column = jQuery( this );
144
- var container = column.closest( '.columns-container ');
145
- var storage_model = container.attr( 'data-type' );
146
-
147
- // Current column type
148
- var default_value = column.find( '.column_type select option:selected' ).val();
149
-
150
- column.find( '.column_type select' ).change( function() {
151
- var option = jQuery( 'optgroup', this ).children( ':selected' );
152
- var type = option.val();
153
- var label = option.text();
154
- var msg = jQuery( this ).next( '.msg' ).hide();
155
-
156
- // Find template element for this field type
157
- var template = container.find( '.for-cloning-only .cpac-column[data-type="' + type + '"]' );
158
-
159
- if ( template.length ) {
160
- if ( template.find( '.is-disabled' ).length ) {
161
- msg.html( template.find( '.is-disabled' ).html() ).show();
162
-
163
- // Set to default
164
- jQuery(this).find( 'option' ).removeAttr( 'selected' );
165
- jQuery(this).find( 'option[value="' + default_value + '"]' ).attr( 'selected', 'selected' );
166
- }
167
- // Prevent column types that do not allow it to have multiple instances
168
- else if ( typeof template.attr( 'data-clone' ) === 'undefined' && jQuery( '.cpac-columns', container ).find( '[data-type="' + type + '"]' ).length ) {
169
- msg.html( cpac_i18n.clone.replace( '%s', '<strong>' + label + '</strong>' ) ).show();
170
-
171
- // Set to default
172
- jQuery(this).find('option').removeAttr('selected');
173
- jQuery(this).find('option[value="' + default_value + '"]').attr('selected', 'selected');
174
-
175
- return;
176
- }
177
- else {
178
- var clone = template.clone();
179
-
180
- // Open settings
181
- clone.addClass('opened').find('.column-form').show();
182
- clone.find( '.column-meta' ).replaceWith( column.find( '.column-meta' ) );
183
- clone.find( '.column-form' ).replaceWith( column.find( '.column-form' ) );
184
-
185
- // Increment clone id
186
- clone.cpac_update_clone_id( storage_model );
187
-
188
- // Load clone
189
- column.replaceWith( clone );
190
- clone.cpac_column_refresh();
191
- }
192
}
193
} );
194
-
195
- /** change label */
196
- column.find('.column_label .input input').bind( 'keyup change', function() {
197
-
198
- var value = jQuery( this ).val();
199
- jQuery(this).closest('.cpac-column').find( 'td.column_label .inner > a.toggle' ).text( value );
200
- });
201
-
202
- /** width slider */
203
- column.find('.input-width-range').each( function(){
204
-
205
- var input = jQuery(this).closest('td').find('.input-width');
206
- var descr = jQuery(this).closest('td').find('.width-decription');
207
- var input_default = jQuery(input)[0].defaultValue;
208
- var translation_default = descr.attr('title');
209
-
210
- // add slider
211
- jQuery(this).slider({
212
- range: 'min',
213
- min: 0,
214
- max: 100,
215
- value: input_default,
216
- slide: function( event, ui ) {
217
-
218
- // set default
219
- var descr_value = ui.value > 0 ? ui.value + '%' : translation_default;
220
-
221
- // set input value
222
- jQuery(input).val( ui.value );
223
-
224
- // set description
225
- jQuery(descr).text( descr_value );
226
- }
227
- });
228
- });
229
-
230
- /** display custom image size */
231
- column.find('.column_image_size label.custom-size').click( function(){
232
-
233
- var parent = jQuery(this).closest('.input');
234
-
235
- if ( jQuery(this).hasClass('image-size-custom') ) {
236
- jQuery('.custom-size-w', parent).removeClass('hidden');
237
- jQuery('.custom-size-h', parent).removeClass('hidden');
238
- }
239
-
240
- else {
241
- jQuery('.custom-size-w', parent).addClass('hidden');
242
- jQuery('.custom-size-h', parent).addClass('hidden');
243
- }
244
- });
245
-
246
- /** tooltip */
247
- column.find('.column-form .label label').hover(function(){
248
- jQuery(this).find('p.description').show();
249
- },function(){
250
- jQuery(this).find('p.description').hide();
251
- });
252
-
253
- if ( column.find( '.column_type select' ).val() == 'column-meta' ) {
254
- column.find( '.column_field_type select' ).change( function() {
255
- column.cpac_column_refresh();
256
- } );
257
- }
258
- };
259
-
260
- /*
261
- * Column: remove from DOM
262
- *
263
- * @since 2.0
264
- */
265
- jQuery.fn.column_remove = function() {
266
- jQuery(this).addClass('deleting').animate({ opacity : 0, height: 0 }, 350, function(e) {
267
- jQuery(this).remove();
268
- });
269
- };
270
-
271
- /*
272
- * Update clone ID
273
- *
274
- * @since 2.0
275
- */
276
- jQuery.fn.cpac_update_clone_id = function( storage_model ) {
277
-
278
- var el = jQuery( this );
279
-
280
- var type = el.attr( 'data-type' );
281
- var all_columns = jQuery( '.columns-container[data-type="' + storage_model + '"]').find( '.cpac-columns' );
282
- var columns = jQuery( all_columns ).find( '*[data-type="' + type + '"]' ).not( el );
283
-
284
- /* var type = el.attr( 'data-type' );
285
- var all_columns = el.closest( '.cpac-boxes' ).find( '.cpac-columns' );
286
- var columns = jQuery( all_columns ).find( '*[data-type="' + type + '"]' ).not( el );*/
287
-
288
- // get clone ID
289
- var ids = jQuery.map( columns, function( e, i ) {
290
- if ( jQuery(e).attr('data-clone') ){
291
- return parseInt( jQuery( e ).attr( 'data-clone' ), 10 );
292
- }
293
- return 0;
294
- });
295
- ids.sort();
296
- var max_id = Math.max.apply( null, ids ) + 1;
297
- for ( var id=0; id<=max_id; id++ ) {
298
- if ( -1 === jQuery.inArray( id, ids ) )
299
- break;
300
- }
301
-
302
- // only increment when needed
303
- if ( 0 === id )
304
- return;
305
-
306
- // set clone ID
307
- el.attr( 'data-clone', id );
308
- el.find( 'input.clone' ).val( id );
309
- el.find( 'input.column-name' ).val( type + '-' + id );
310
-
311
- // update input names with clone ID
312
- var inputs = el.find( 'input, select, label' );
313
- jQuery( inputs ).each( function( i, v ) {
314
-
315
- var new_name = type + '-' + id;
316
-
317
- // name
318
- if( jQuery(v).attr( 'name' ) ) {
319
- jQuery(v).attr( 'name', jQuery(v).attr( 'name' ).replace( type, new_name) );
320
- }
321
-
322
- // for
323
- if( jQuery(v).attr( 'for' ) ) {
324
- jQuery(v).attr( 'for', jQuery(v).attr( 'for' ).replace( type, new_name ) );
325
- }
326
-
327
- // id
328
- if( jQuery(v).attr( 'id' ) ) {
329
- jQuery(v).attr( 'id', jQuery(v).attr( 'id' ).replace( type, new_name ) );
330
- }
331
- });
332
- };
333
-
334
- /*
335
- * Add Column
336
- *
337
- * @since 2.0
338
- */
339
- function cpac_add_column() {
340
-
341
- jQuery('#cpac .add_column').click( function(e){
342
-
343
- var container = jQuery(this).closest('.columns-container');
344
-
345
- var clone = jQuery('.for-cloning-only .cpac-column', container ).first().clone();
346
-
347
- var storage_model = container.attr('data-type');
348
-
349
- if ( clone.length > 0 ) {
350
-
351
- // increment clone id ( before adding to DOM, otherwise radio buttons will reset )
352
- clone.cpac_update_clone_id( storage_model );
353
-
354
- // add to DOM
355
- jQuery('.cpac-columns form', container).append( clone );
356
-
357
- // rebind toggle events
358
- clone.column_bind_toggle();
359
-
360
- // rebind remove events
361
- clone.column_bind_remove();
362
-
363
- // rebind all other events
364
- clone.column_bind_events();
365
-
366
- // open settings
367
- clone.addClass('opened').find('.column-form').slideDown(150, function(){
368
- jQuery('html, body').animate({ scrollTop: clone.offset().top - 58 }, 300);
369
- });
370
-
371
- cpac_sortable();
372
-
373
- // hook for addons
374
- jQuery(document).trigger( 'column_add', clone );
375
- }
376
-
377
- e.preventDefault();
378
- });
379
}
380
381
/**
382
- * @since 2.2.1
383
*/
384
- function cpac_sidebar_feedback() {
385
- jQuery( function( $ ) {
386
- var sidebox = $( '.sidebox#direct-feedback' );
387
-
388
- sidebox.find( '#feedback-choice a.no' ).click( function( e ) {
389
- e.preventDefault();
390
-
391
- sidebox.find( '#feedback-choice' ).slideUp();
392
- sidebox.find( '#feedback-support' ).slideDown();
393
- } );
394
-
395
- sidebox.find( '#feedback-choice a.yes' ).click( function( e ) {
396
- e.preventDefault();
397
398
- sidebox.find( '#feedback-choice' ).slideUp();
399
- sidebox.find( '#feedback-rate' ).slideDown();
400
- } );
401
- } );
402
- }
403
-
404
- /*
405
- * Sidebar Scroll
406
- *
407
- * @since 1.5
408
- */
409
- function cpac_sidebar_scroll() {
410
-
411
- if( jQuery('.columns-right-inside').length === 0 )
412
- return;
413
-
414
- if ( jQuery('.columns-right-inside:visible').offset() ) {
415
-
416
- // top position of the sidebar on loading
417
- var top = jQuery('.columns-right-inside:visible').offset().top - parseFloat( jQuery('.columns-right-inside:visible').css('margin-top').replace(/auto/, 0) ) - 70;
418
-
419
- jQuery(window).scroll(function (event) {
420
- // y position of the scroll
421
- var y = jQuery(this).scrollTop();
422
-
423
- // top position of div#cpac is calculated everytime incase of an opened help screen
424
- var offset = jQuery('#cpac').offset().top - parseFloat( jQuery('#cpac').css('margin-top').replace(/auto/, 0) );
425
-
426
- // whether that's below
427
- if (y >= top + offset ) {
428
- // if so, ad the fixed class
429
- jQuery('.columns-right-inside:visible').addClass('fixed');
430
- } else {
431
- // otherwise remove it
432
- jQuery('.columns-right-inside:visible').removeClass('fixed');
433
- }
434
- });
435
}
436
- }
437
-
438
- /*
439
- * Clear Input Defaults
440
- *
441
- */
442
- function cpac_clear_input_defaults() {
443
- jQuery.fn.cleardefault = function() {
444
- return this.focus(function() {
445
- if( this.value == this.defaultValue ) {
446
- this.value = "";
447
- }
448
- }).blur(function() {
449
- if( !this.value.length ) {
450
- this.value = this.defaultValue;
451
- }
452
- });
453
- };
454
- jQuery("#cpac-box-plugin_settings .addons input").cleardefault();
455
- }
456
-
457
- /*
458
- * Help
459
- *
460
- * usage: <a href="javascript:;" class="help" data-help="tab-2"></a>
461
- */
462
- function cpac_help() {
463
- jQuery('#cpac a.help').click( function(e) {
464
- e.preventDefault();
465
-
466
- var panel = jQuery('#contextual-help-wrap');
467
-
468
- panel.parent().show();
469
- jQuery('a[href="#tab-panel-cpac-' + jQuery(this).attr('data-help') + '"]', panel).trigger('click');
470
- panel.slideDown( 'fast', function() {
471
- panel.focus();
472
- });
473
- });
474
- }
475
-
476
- /*
477
- * WP Pointer
478
- *
479
- */
480
- function cpac_pointer() {
481
- jQuery('.cpac-pointer').each(function(){
482
483
- // vars
484
- var el = jQuery(this),
485
- html = el.attr('rel'),
486
- pos = el.attr('data-pos');
487
-
488
- var position = {
489
- at: 'left top', // position of wp-pointer relative to the element which triggers the pointer event
490
- my: 'right top', // position of wp-pointer relative to the at-coordinates
491
- edge: 'right', // position of arrow
492
- offset: '0 0' // offset for wp-pointer
493
- };
494
-
495
- if ( 'right' == pos ) {
496
- position = {
497
- at: 'right middle',
498
- my: 'left middle',
499
- edge: 'left'
500
- };
501
- }
502
-
503
- // create pointer
504
- el.pointer({
505
- content: jQuery('#' + html).html(),
506
- position: position,
507
- pointerWidth: 250,
508
- close: function() {
509
- el.removeClass('open');
510
- },
511
-
512
- // bug fix. with an arrow on the right side the position of wp-pointer is incorrect. it does not take
513
- // into account the padding of the arrow. adding "wp-pointer-' + position.edge" will fix that.
514
- pointerClass: 'wp-pointer wp-pointer-' + position.edge
515
- });
516
-
517
- // click
518
- el.click( function() {
519
- if( el.hasClass('open') ) {
520
- el.removeClass('open');
521
- }
522
- else {
523
- el.addClass('open');
524
- }
525
- });
526
-
527
- // show on hover
528
- el.hover( function() {
529
- jQuery(this).pointer('open');
530
- }, function() {
531
- if( ! el.hasClass('open') ) {
532
- jQuery(this).pointer('close');
533
- }
534
-
535
- });
536
- });
537
- }
538
-
539
- /*
540
- * Sortable
541
- *
542
- * @since 1.5
543
- */
544
- function cpac_sortable() {
545
- jQuery( 'div.cpac-columns' ).each( function() {
546
- if ( jQuery( this ).hasClass( 'ui-sortable' ) ) {
547
- jQuery( this ).sortable( 'refresh' );
548
- }
549
- else {
550
- jQuery( this ).sortable( {
551
- items : '.cpac-column'
552
- } );
553
- }
554
} );
555
- }
556
-
557
- /*
558
- * Menu
559
- *
560
- * @since 1.5
561
- */
562
- function cpac_menu() {
563
-
564
- var menu = jQuery('#cpac div.cpac-menu');
565
- // click
566
- menu.find('a').click( function(e, el) {
567
-
568
- var id = jQuery(this).attr('href');
569
-
570
- if ( id ) {
571
-
572
- var type = id.replace('#cpac-box-','');
573
-
574
- // remove current
575
- jQuery('.cpac-menu a').removeClass('current');
576
- jQuery('.columns-container').hide();
577
-
578
- // set current
579
- jQuery(this).addClass('current');
580
- var container = jQuery('.columns-container[data-type="' + type + '"]').show();
581
- var columns = container.find( '.cpac-columns' );
582
583
- // hook for addons
584
- jQuery( document ).trigger( 'cac_menu_change', columns );
585
- }
586
-
587
- e.preventDefault();
588
- });
589
-
590
- // activate first menu
591
- menu.find('a.current').trigger('click');
592
- }
593
-
594
- /*
595
- * Bind events: triggered after column is init, changed or added
596
- *
597
- */
598
- jQuery( document ).bind('column_init column_change column_add', function( e, column ){
599
- jQuery( column ).cpac_bind_column_addon_events();
600
- jQuery( column ).cpac_bind_container_addon_events();
601
- });
602
-
603
- /*
604
- * Radio Click events
605
- *
606
- */
607
- jQuery.fn.cpac_bind_column_addon_events = function() {
608
-
609
- var column = jQuery( this );
610
- var inputs = column.find('[data-toggle-id] label');
611
-
612
- // Enable editing: radio button
613
- inputs.click( function(){
614
-
615
- var id = jQuery( this ).closest('td.input').data('toggle-id');
616
- var label = column.find('[data-indicator-id="' + id + '"]' ).removeClass( 'on' );
617
- var status = jQuery( 'input', this ).val();
618
-
619
- if ( 'on' == status ) {
620
- label.addClass( 'on' );
621
- }
622
- });
623
- };
624
-
625
- /*
626
- * Indicator Click Events
627
- *
628
- */
629
- jQuery.fn.cpac_bind_container_addon_events = function() {
630
-
631
- var column = jQuery( this );
632
- var indicator = column.find('[data-indicator-id]');
633
-
634
- indicator.unbind('click').click( function() {
635
-
636
- var id = jQuery( this ).data('indicator-id');
637
- var radio = column.find('[data-toggle-id="' + id + '"] input' );
638
-
639
- if ( jQuery( this ).hasClass('on') ) {
640
- jQuery( this ).removeClass('on').addClass('off');
641
- radio.filter('[value=off]').prop('checked', true);
642
- }
643
- else {
644
- jQuery( this ).removeClass('off').addClass('on');
645
- radio.filter('[value=on]').prop('checked', true);
646
- }
647
- });
648
- };
1
+ jQuery( document ).ready( function( $ ) {
2
+ cpac_tooltips();
3
+
4
+ if ( typeof CPAC.storage_model !== 'undefined' && CPAC.storage_model.is_table_header_fixed ) {
5
+ cpac_floatingheader();
6
+ }
7
+ } );
8
9
/**
10
+ * @since 2.2.4
11
+ */
12
+ function cpac_tooltips() {
13
+ jQuery( '.cpac-tip' ).qtip( {
14
+ content: {
15
+ attr: 'data-tip'
16
+ },
17
+ position: {
18
+ my: 'top center',
19
+ at: 'bottom center'
20
+ },
21
+ style: {
22
+ tip: true,
23
+ classes: 'qtip-tipsy'
24
}
25
} );
26
}
27
28
/**
29
+ * @since 2.2.4
30
*/
31
+ function cpac_floatingheader() {
32
+ var table = jQuery( 'table.wp-list-table.widefat' );
33
+ var topscroll = 0;
34
35
+ if ( jQuery( '#wpadminbar' ) ) {
36
+ topscroll = 32;
37
}
38
39
+ table.floatThead( {
40
+ scrollingTop: topscroll
41
} );
42
43
+ }
assets/js/admin-columns.min.js CHANGED
@@ -1,4 +1 @@
1
- /*
2
- * Fires when the dom is ready
3
- *
4
- */function cpac_importexport(){jQuery("#php-export-results textarea").on("focus, mouseup",function(){jQuery(this).select()}).select().focus()}function cpac_addons(){}function cpac_submit_form(){jQuery(".form-update a.submit-update").click(function(e){e.preventDefault();jQuery(this).closest(".columns-container").find(".cpac-columns form").submit()})}function cpac_add_column(){jQuery("#cpac .add_column").click(function(e){var t=jQuery(this).closest(".columns-container"),n=jQuery(".for-cloning-only .cpac-column",t).first().clone(),r=t.attr("data-type");if(n.length>0){n.cpac_update_clone_id(r);jQuery(".cpac-columns form",t).append(n);n.column_bind_toggle();n.column_bind_remove();n.column_bind_events();n.addClass("opened").find(".column-form").slideDown(150,function(){jQuery("html, body").animate({scrollTop:n.offset().top-58},300)});cpac_sortable();jQuery(document).trigger("column_add",n)}e.preventDefault()})}function cpac_sidebar_feedback(){jQuery(function(e){var t=e(".sidebox#direct-feedback");t.find("#feedback-choice a.no").click(function(e){e.preventDefault();t.find("#feedback-choice").slideUp();t.find("#feedback-support").slideDown()});t.find("#feedback-choice a.yes").click(function(e){e.preventDefault();t.find("#feedback-choice").slideUp();t.find("#feedback-rate").slideDown()})})}function cpac_sidebar_scroll(){if(jQuery(".columns-right-inside").length===0)return;if(jQuery(".columns-right-inside:visible").offset()){var e=jQuery(".columns-right-inside:visible").offset().top-parseFloat(jQuery(".columns-right-inside:visible").css("margin-top").replace(/auto/,0))-70;jQuery(window).scroll(function(t){var n=jQuery(this).scrollTop(),r=jQuery("#cpac").offset().top-parseFloat(jQuery("#cpac").css("margin-top").replace(/auto/,0));n>=e+r?jQuery(".columns-right-inside:visible").addClass("fixed"):jQuery(".columns-right-inside:visible").removeClass("fixed")})}}function cpac_clear_input_defaults(){jQuery.fn.cleardefault=function(){return this.focus(function(){this.value==this.defaultValue&&(this.value="")}).blur(function(){this.value.length||(this.value=this.defaultValue)})};jQuery("#cpac-box-plugin_settings .addons input").cleardefault()}function cpac_help(){jQuery("#cpac a.help").click(function(e){e.preventDefault();var t=jQuery("#contextual-help-wrap");t.parent().show();jQuery('a[href="#tab-panel-cpac-'+jQuery(this).attr("data-help")+'"]',t).trigger("click");t.slideDown("fast",function(){t.focus()})})}function cpac_pointer(){jQuery(".cpac-pointer").each(function(){var e=jQuery(this),t=e.attr("rel"),n=e.attr("data-pos"),r={at:"left top",my:"right top",edge:"right",offset:"0 0"};"right"==n&&(r={at:"right middle",my:"left middle",edge:"left"});e.pointer({content:jQuery("#"+t).html(),position:r,pointerWidth:250,close:function(){e.removeClass("open")},pointerClass:"wp-pointer wp-pointer-"+r.edge});e.click(function(){e.hasClass("open")?e.removeClass("open"):e.addClass("open")});e.hover(function(){jQuery(this).pointer("open")},function(){e.hasClass("open")||jQuery(this).pointer("close")})})}function cpac_sortable(){jQuery("div.cpac-columns").each(function(){jQuery(this).hasClass("ui-sortable")?jQuery(this).sortable("refresh"):jQuery(this).sortable({items:".cpac-column"})})}function cpac_menu(){var e=jQuery("#cpac div.cpac-menu");e.find("a").click(function(e,t){var n=jQuery(this).attr("href");if(n){var r=n.replace("#cpac-box-","");jQuery(".cpac-menu a").removeClass("current");jQuery(".columns-container").hide();jQuery(this).addClass("current");var i=jQuery('.columns-container[data-type="'+r+'"]').show(),s=i.find(".cpac-columns");jQuery(document).trigger("cac_menu_change",s)}e.preventDefault()});e.find("a.current").trigger("click")}jQuery(document).ready(function(){if(jQuery("#cpac").length===0)return!1;cpac_pointer();cpac_submit_form();cpac_clear_input_defaults();cpac_sortable();cpac_menu();cpac_help();cpac_add_column();cpac_sidebar_scroll();cpac_addons();cpac_importexport();cpac_sidebar_feedback();jQuery(".cpac-column").each(function(e,t){jQuery(t).column_bind_toggle();jQuery(t).column_bind_remove();jQuery(t).cpac_bind_container_addon_events()})});jQuery.fn.column_bind_toggle=function(){var e=jQuery(this);e.find("td.column_type a, td.column_edit, td.column_label a.toggle, td.column_label .edit-button").click(function(t){t.preventDefault();e.toggleClass("opened").find(".column-form").slideToggle(150);e.hasClass("events-binded")||e.column_bind_events();e.addClass("events-binded");jQuery(document).trigger("column_init",e)})};jQuery.fn.column_bind_remove=function(){jQuery(this).find(".remove-button").click(function(e){jQuery(this).closest(".cpac-column").column_remove();e.preventDefault()})};jQuery.fn.cpac_column_refresh=function(){var e=jQuery(this);e.addClass("loading");e.find(".column-form").prepend('<span class="spinner" />');jQuery.post(ajaxurl,{action:"cpac_column_refresh",column:jQuery(this).find("input.column-name").val(),formdata:jQuery(this).parents("form").serialize()},function(t){var n=jQuery("<div>"+t+"</div>").children();e.replaceWith(n);e=n;e.column_bind_toggle();e.column_bind_remove();e.column_bind_events();e.removeClass("loading").addClass("opened").find(".column-form").show();jQuery(document).trigger("column_change",e)})};jQuery.fn.column_bind_events=function(){var e=jQuery(this),t=e.closest(".columns-container "),n=t.attr("data-type"),r=e.find(".column_type select option:selected").val();e.find(".column_type select").change(function(){var i=jQuery("optgroup",this).children(":selected"),s=i.val(),o=i.text(),u=jQuery(this).next(".msg").hide(),a=t.find('.for-cloning-only .cpac-column[data-type="'+s+'"]');if(a.length)if(a.find(".is-disabled").length){u.html(a.find(".is-disabled").html()).show();jQuery(this).find("option").removeAttr("selected");jQuery(this).find('option[value="'+r+'"]').attr("selected","selected")}else{if(typeof a.attr("data-clone")=="undefined"&&jQuery(".cpac-columns",t).find('[data-type="'+s+'"]').length){u.html(cpac_i18n.clone.replace("%s","<strong>"+o+"</strong>")).show();jQuery(this).find("option").removeAttr("selected");jQuery(this).find('option[value="'+r+'"]').attr("selected","selected");return}var f=a.clone();f.addClass("opened").find(".column-form").show();f.find(".column-meta").replaceWith(e.find(".column-meta"));f.find(".column-form").replaceWith(e.find(".column-form"));f.cpac_update_clone_id(n);e.replaceWith(f);f.cpac_column_refresh()}});e.find(".column_label .input input").bind("keyup change",function(){var e=jQuery(this).val();jQuery(this).closest(".cpac-column").find("td.column_label .inner > a.toggle").text(e)});e.find(".input-width-range").each(function(){var e=jQuery(this).closest("td").find(".input-width"),t=jQuery(this).closest("td").find(".width-decription"),n=jQuery(e)[0].defaultValue,r=t.attr("title");jQuery(this).slider({range:"min",min:0,max:100,value:n,slide:function(n,i){var s=i.value>0?i.value+"%":r;jQuery(e).val(i.value);jQuery(t).text(s)}})});e.find(".column_image_size label.custom-size").click(function(){var e=jQuery(this).closest(".input");if(jQuery(this).hasClass("image-size-custom")){jQuery(".custom-size-w",e).removeClass("hidden");jQuery(".custom-size-h",e).removeClass("hidden")}else{jQuery(".custom-size-w",e).addClass("hidden");jQuery(".custom-size-h",e).addClass("hidden")}});e.find(".column-form .label label").hover(function(){jQuery(this).find("p.description").show()},function(){jQuery(this).find("p.description").hide()});e.find(".column_type select").val()=="column-meta"&&e.find(".column_field_type select").change(function(){e.cpac_column_refresh()})};jQuery.fn.column_remove=function(){jQuery(this).addClass("deleting").animate({opacity:0,height:0},350,function(e){jQuery(this).remove()})};jQuery.fn.cpac_update_clone_id=function(e){var t=jQuery(this),n=t.attr("data-type"),r=jQuery('.columns-container[data-type="'+e+'"]').find(".cpac-columns"),i=jQuery(r).find('*[data-type="'+n+'"]').not(t),s=jQuery.map(i,function(e,t){return jQuery(e).attr("data-clone")?parseInt(jQuery(e).attr("data-clone"),10):0});s.sort();var o=Math.max.apply(null,s)+1;for(var u=0;u<=o;u++)if(-1===jQuery.inArray(u,s))break;if(0===u)return;t.attr("data-clone",u);t.find("input.clone").val(u);t.find("input.column-name").val(n+"-"+u);var a=t.find("input, select, label");jQuery(a).each(function(e,t){var r=n+"-"+u;jQuery(t).attr("name")&&jQuery(t).attr("name",jQuery(t).attr("name").replace(n,r));jQuery(t).attr("for")&&jQuery(t).attr("for",jQuery(t).attr("for").replace(n,r));jQuery(t).attr("id")&&jQuery(t).attr("id",jQuery(t).attr("id").replace(n,r))})};jQuery(document).bind("column_init column_change column_add",function(e,t){jQuery(t).cpac_bind_column_addon_events();jQuery(t).cpac_bind_container_addon_events()});jQuery.fn.cpac_bind_column_addon_events=function(){var e=jQuery(this),t=e.find("[data-toggle-id] label");t.click(function(){var t=jQuery(this).closest("td.input").data("toggle-id"),n=e.find('[data-indicator-id="'+t+'"]').removeClass("on"),r=jQuery("input",this).val();"on"==r&&n.addClass("on")})};jQuery.fn.cpac_bind_container_addon_events=function(){var e=jQuery(this),t=e.find("[data-indicator-id]");t.unbind("click").click(function(){var t=jQuery(this).data("indicator-id"),n=e.find('[data-toggle-id="'+t+'"] input');if(jQuery(this).hasClass("on")){jQuery(this).removeClass("on").addClass("off");n.filter("[value=off]").prop("checked",!0)}else{jQuery(this).removeClass("off").addClass("on");n.filter("[value=on]").prop("checked",!0)}})};
1
+ function cpac_tooltips(){jQuery(".cpac-tip").qtip({content:{attr:"data-tip"},position:{my:"top center",at:"bottom center"},style:{tip:!0,classes:"qtip-tipsy"}})}function cpac_floatingheader(){var e=jQuery("table.wp-list-table.widefat"),t=0;jQuery("#wpadminbar")&&(t=32);e.floatThead({scrollingTop:t})}jQuery(document).ready(function(e){cpac_tooltips();typeof CPAC.storage_model!="undefined"&&CPAC.storage_model.is_table_header_fixed&&cpac_floatingheader()});
assets/js/admin-settings.js ADDED
@@ -0,0 +1,652 @@
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
+ // General
11
+ cpac_pointer();
12
+ cpac_submit_form();
13
+
14
+ // Settings Page
15
+ cpac_clear_input_defaults();
16
+
17
+ // Columns Page
18
+ cpac_sortable();
19
+ cpac_menu();
20
+ cpac_help();
21
+ cpac_add_column();
22
+ cpac_addons();
23
+ cpac_importexport();
24
+ cpac_sidebar_feedback();
25
+ //cpac_sidebar_scroll();
26
+
27
+ // we start by binding the toggle and remove events.
28
+ jQuery('.cpac-column').each( function( i, col ) {
29
+ jQuery( col ).column_bind_toggle();
30
+ jQuery( col ).column_bind_remove();
31
+ jQuery( col ).cpac_bind_container_addon_events();
32
+ });
33
+ });
34
+
35
+ function cpac_importexport() {
36
+ jQuery( '#php-export-results textarea' ).on( 'focus, mouseup', function() {
37
+ jQuery( this ).select();
38
+ } ).select().focus();
39
+ }
40
+
41
+ /**
42
+ * Handle addons settings screen
43
+ *
44
+ * @since 2.2
45
+ */
46
+ function cpac_addons() {
47
+
48
+
49
+ }
50
+
51
+ /*
52
+ * Submit Form
53
+ *
54
+ * @since 2.0.2
55
+ */
56
+ function cpac_submit_form() {
57
+ jQuery('.form-update a.submit-update').click( function(e){
58
+ e.preventDefault();
59
+
60
+ jQuery(this).closest('.columns-container').find('.cpac-columns form').submit();
61
+ });
62
+ }
63
+
64
+ /*
65
+ * Column: bind toggle events
66
+ *
67
+ * For performance we bind all other events after the click event.
68
+ *
69
+ * @since 2.0
70
+ */
71
+ jQuery.fn.column_bind_toggle = function() {
72
+
73
+ var column = jQuery(this);
74
+
75
+ column.find( 'td.column_type a, td.column_edit, td.column_label a.toggle, td.column_label .edit-button' ).click( function( e ) {
76
+ e.preventDefault();
77
+
78
+ column.toggleClass( 'opened' ).find( '.column-form' ).slideToggle( 150 );
79
+
80
+ if ( ! column.hasClass( 'events-binded' ) ) {
81
+ column.column_bind_events();
82
+ }
83
+
84
+ column.addClass('events-binded');
85
+
86
+ // hook for addons
87
+ jQuery( document ).trigger( 'column_init', column );
88
+ } );
89
+ };
90
+
91
+ /*
92
+ * Column: bind remove events
93
+ *
94
+ * @since 2.0
95
+ */
96
+ jQuery.fn.column_bind_remove = function() {
97
+
98
+ jQuery(this).find('.remove-button').click( function(e) {
99
+ jQuery(this).closest('.cpac-column').column_remove();
100
+
101
+ e.preventDefault();
102
+ });
103
+ };
104
+
105
+ jQuery.fn.cpac_column_refresh = function() {
106
+ var el = jQuery( this );
107
+
108
+ // Mark column as loading
109
+ el.addClass( 'loading' );
110
+ el.find( '.column-form' ).prepend( '<span class="spinner" />' );
111
+
112
+ // Fetch new form HTML
113
+ jQuery.post( ajaxurl, {
114
+ action: 'cpac_column_refresh',
115
+ column: jQuery( this ).find( 'input.column-name' ).val(),
116
+ formdata: jQuery( this ).parents( 'form' ).serialize()
117
+ }, function( data ) {
118
+ console.log(data);
119
+ // Replace current form by new form
120
+ var newel = jQuery( '<div>' + data + '</div>' ).children();
121
+ el.replaceWith( newel );
122
+ el = newel;
123
+
124
+ // Bind events
125
+ el.column_bind_toggle();
126
+ el.column_bind_remove();
127
+ el.column_bind_events();
128
+
129
+ // Remove "loading" marking from column
130
+ el.removeClass( 'loading' ).addClass( 'opened' ).find( '.column-form' ).show();
131
+
132
+ // Allow plugins to hook into this event
133
+ jQuery( document ).trigger( 'column_change', el );
134
+ } );
135
+ };
136
+
137
+ /*
138
+ * Form Events
139
+ *
140
+ * @since 2.0
141
+ */
142
+ jQuery.fn.column_bind_events = function() {
143
+
144
+ var column = jQuery( this );
145
+ var container = column.closest( '.columns-container ');
146
+ var storage_model = container.attr( 'data-type' );
147
+
148
+ // Current column type
149
+ var default_value = column.find( '.column_type select option:selected' ).val();
150
+
151
+ column.find( '.column_type select' ).change( function() {
152
+ var option = jQuery( 'optgroup', this ).children( ':selected' );
153
+ var type = option.val();
154
+ var label = option.text();
155
+ var msg = jQuery( this ).next( '.msg' ).hide();
156
+
157
+ // Find template element for this field type
158
+ var template = container.find( '.for-cloning-only .cpac-column[data-type="' + type + '"]' );
159
+
160
+ if ( template.length ) {
161
+ if ( template.find( '.is-disabled' ).length ) {
162
+ msg.html( template.find( '.is-disabled' ).html() ).show();
163
+
164
+ // Set to default
165
+ jQuery(this).find( 'option' ).removeAttr( 'selected' );
166
+ jQuery(this).find( 'option[value="' + default_value + '"]' ).attr( 'selected', 'selected' );
167
+ }
168
+ // Prevent column types that do not allow it to have multiple instances
169
+ else if ( typeof template.attr( 'data-clone' ) === 'undefined' && jQuery( '.cpac-columns', container ).find( '[data-type="' + type + '"]' ).length ) {
170
+ msg.html( cpac_i18n.clone.replace( '%s', '<strong>' + label + '</strong>' ) ).show();
171
+
172
+ // Set to default
173
+ jQuery(this).find('option').removeAttr('selected');
174
+ jQuery(this).find('option[value="' + default_value + '"]').attr('selected', 'selected');
175
+
176
+ return;
177
+ }
178
+ else {
179
+ var clone = template.clone();
180
+
181
+ // Open settings
182
+ clone.addClass('opened').find('.column-form').show();
183
+ clone.find( '.column-meta' ).replaceWith( column.find( '.column-meta' ) );
184
+ clone.find( '.column-form' ).replaceWith( column.find( '.column-form' ) );
185
+
186
+ // Increment clone id
187
+ clone.cpac_update_clone_id( storage_model );
188
+
189
+ // Load clone
190
+ column.replaceWith( clone );
191
+ clone.cpac_column_refresh();
192
+ }
193
+ }
194
+ } );
195
+
196
+ /** change label */
197
+ column.find('.column_label .input input').bind( 'keyup change', function() {
198
+
199
+ var value = jQuery( this ).val();
200
+ jQuery(this).closest('.cpac-column').find( 'td.column_label .inner > a.toggle' ).text( value );
201
+ });
202
+
203
+ /** width slider */
204
+ column.find('.input-width-range').each( function(){
205
+
206
+ var input = jQuery(this).closest('td').find('.input-width');
207
+ var descr = jQuery(this).closest('td').find('.width-decription');
208
+ var input_default = jQuery(input)[0].defaultValue;
209
+ var translation_default = descr.attr('title');
210
+
211
+ // add slider
212
+ jQuery(this).slider({
213
+ range: 'min',
214
+ min: 0,
215
+ max: 100,
216
+ value: input_default,
217
+ slide: function( event, ui ) {
218
+
219
+ // set default
220
+ var descr_value = ui.value > 0 ? ui.value + '%' : translation_default;
221
+
222
+ // set input value
223
+ jQuery(input).val( ui.value );
224
+
225
+ // set description
226
+ jQuery(descr).text( descr_value );
227
+ }
228
+ });
229
+ });
230
+
231
+ /** display custom image size */
232
+ column.find('.column_image_size label.custom-size').click( function(){
233
+
234
+ var parent = jQuery(this).closest('.input');
235
+
236
+ if ( jQuery(this).hasClass('image-size-custom') ) {
237
+ jQuery('.custom-size-w', parent).removeClass('hidden');
238
+ jQuery('.custom-size-h', parent).removeClass('hidden');
239
+ }
240
+
241
+ else {
242
+ jQuery('.custom-size-w', parent).addClass('hidden');
243
+ jQuery('.custom-size-h', parent).addClass('hidden');
244
+ }
245
+ });
246
+
247
+ /** tooltip */
248
+ column.find('.column-form .label label').hover(function(){
249
+ jQuery(this).find('p.description').show();
250
+ },function(){
251
+ jQuery(this).find('p.description').hide();
252
+ });
253
+
254
+ if ( column.find( '.column_type select' ).val() == 'column-meta' ) {
255
+ column.find( '.column_field_type select' ).change( function() {
256
+ column.cpac_column_refresh();
257
+ } );
258
+ }
259
+ };
260
+
261
+ /*
262
+ * Column: remove from DOM
263
+ *
264
+ * @since 2.0
265
+ */
266
+ jQuery.fn.column_remove = function() {
267
+ jQuery(this).addClass('deleting').animate({ opacity : 0, height: 0 }, 350, function(e) {
268
+ jQuery(this).remove();
269
+ });
270
+ };
271
+
272
+ /*
273
+ * Update clone ID
274
+ *
275
+ * @since 2.0
276
+ */
277
+ jQuery.fn.cpac_update_clone_id = function( storage_model ) {
278
+
279
+ var el = jQuery( this );
280
+
281
+ var type = el.attr( 'data-type' );
282
+ var all_columns = jQuery( '.columns-container[data-type="' + storage_model + '"]').find( '.cpac-columns' );
283
+ var columns = jQuery( all_columns ).find( '*[data-type="' + type + '"]' ).not( el );
284
+
285
+ /* var type = el.attr( 'data-type' );
286
+ var all_columns = el.closest( '.cpac-boxes' ).find( '.cpac-columns' );
287
+ var columns = jQuery( all_columns ).find( '*[data-type="' + type + '"]' ).not( el );*/
288
+
289
+ // get clone ID
290
+ var ids = jQuery.map( columns, function( e, i ) {
291
+ if ( jQuery(e).attr('data-clone') ){
292
+ return parseInt( jQuery( e ).attr( 'data-clone' ), 10 );
293
+ }
294
+ return 0;
295
+ });
296
+ ids.sort();
297
+ var max_id = Math.max.apply( null, ids ) + 1;
298
+ for ( var id=0; id<=max_id; id++ ) {
299
+ if ( -1 === jQuery.inArray( id, ids ) )
300
+ break;
301
+ }
302
+
303
+ // only increment when needed
304
+ if ( 0 === id )
305
+ return;
306
+
307
+ // set clone ID
308
+ el.attr( 'data-clone', id );
309
+ el.find( 'input.clone' ).val( id );
310
+ el.find( 'input.column-name' ).val( type + '-' + id );
311
+
312
+ // update input names with clone ID
313
+ var inputs = el.find( 'input, select, label' );
314
+ jQuery( inputs ).each( function( i, v ) {
315
+
316
+ var new_name = type + '-' + id;
317
+
318
+ // name
319
+ if( jQuery(v).attr( 'name' ) ) {
320
+ jQuery(v).attr( 'name', jQuery(v).attr( 'name' ).replace( type, new_name) );
321
+ }
322
+
323
+ // for
324
+ if( jQuery(v).attr( 'for' ) ) {
325
+ jQuery(v).attr( 'for', jQuery(v).attr( 'for' ).replace( type, new_name ) );
326
+ }
327
+
328
+ // id
329
+ if( jQuery(v).attr( 'id' ) ) {
330
+ jQuery(v).attr( 'id', jQuery(v).attr( 'id' ).replace( type, new_name ) );
331
+ }
332
+ });
333
+ };
334
+
335
+ /*
336
+ * Add Column
337
+ *
338
+ * @since 2.0
339
+ */
340
+ function cpac_add_column() {
341
+
342
+ jQuery('#cpac .add_column').click( function(e){
343
+
344
+ var container = jQuery(this).closest('.columns-container');
345
+
346
+ var clone = jQuery('.for-cloning-only .cpac-column', container ).first().clone();
347
+
348
+ var storage_model = container.attr('data-type');
349
+
350
+ if ( clone.length > 0 ) {
351
+
352
+ // increment clone id ( before adding to DOM, otherwise radio buttons will reset )
353
+ clone.cpac_update_clone_id( storage_model );
354
+
355
+ // add to DOM
356
+ jQuery('.cpac-columns form', container).append( clone );
357
+
358
+ // rebind toggle events
359
+ clone.column_bind_toggle();
360
+
361
+ // rebind remove events
362
+ clone.column_bind_remove();
363
+
364
+ // rebind all other events
365
+ clone.column_bind_events();
366
+
367
+ // open settings
368
+ clone.addClass('opened').find('.column-form').slideDown(150, function(){
369
+ jQuery('html, body').animate({ scrollTop: clone.offset().top - 58 }, 300);
370
+ });
371
+
372
+ cpac_sortable();
373
+
374
+ // hook for addons
375
+ jQuery(document).trigger( 'column_add', clone );
376
+ }
377
+
378
+ e.preventDefault();
379
+ });
380
+ }
381
+
382
+ /**
383
+ * @since 2.2.1
384
+ */
385
+ function cpac_sidebar_feedback() {
386
+ jQuery( function( $ ) {
387
+ var sidebox = $( '.sidebox#direct-feedback' );
388
+
389
+ sidebox.find( '#feedback-choice a.no' ).click( function( e ) {
390
+ e.preventDefault();
391
+
392
+ sidebox.find( '#feedback-choice' ).slideUp();
393
+ sidebox.find( '#feedback-support' ).slideDown();
394
+ } );
395
+
396
+ sidebox.find( '#feedback-choice a.yes' ).click( function( e ) {
397
+ e.preventDefault();
398
+
399
+ sidebox.find( '#feedback-choice' ).slideUp();
400
+ sidebox.find( '#feedback-rate' ).slideDown();
401
+ } );
402
+ } );
403
+ }
404
+
405
+ /*
406
+ * Sidebar Scroll
407
+ *
408
+ * @since 1.5
409
+ */
410
+ /*function cpac_sidebar_scroll() {
411
+
412
+ if ( jQuery('.columns-right-inside').length === 0 ) {
413
+ return;
414
+ }
415
+
416
+ if ( jQuery('.columns-right-inside:visible').offset() ) {
417
+ var sidebar = jQuery('.columns-right-inside:visible');
418
+ var top = sidebar.offset().top - parseFloat( sidebar.css('margin-top').replace(/auto/, 0) ) - 70;
419
+ var viewport_height = jQuery(window).height();
420
+ var sidebar_height = sidebar.height();
421
+
422
+ jQuery(window).scroll(function (event) {
423
+ var y = jQuery(this).scrollTop();
424
+
425
+ // top position of div#cpac is calculated everytime incase of an opened help screen
426
+ var offset = jQuery('#cpac').offset().top - parseFloat( jQuery('#cpac').css('margin-top').replace(/auto/, 0) );
427
+ var sidebar_fits_on_screen = sidebar_height < ( viewport_height - 32 ); // adminbar
428
+
429
+ // whether that's below
430
+ if ( ( y >= top + offset ) && sidebar_fits_on_screen ) {
431
+ jQuery('.columns-right-inside:visible').addClass('fixed');
432
+ } else {
433
+ jQuery('.columns-right-inside:visible').removeClass('fixed');
434
+ }
435
+ });
436
+ }
437
+ }*/
438
+
439
+ /*
440
+ * Clear Input Defaults
441
+ *
442
+ */
443
+ function cpac_clear_input_defaults() {
444
+ jQuery.fn.cleardefault = function() {
445
+ return this.focus(function() {
446
+ if( this.value == this.defaultValue ) {
447
+ this.value = "";
448
+ }
449
+ }).blur(function() {
450
+ if( !this.value.length ) {
451
+ this.value = this.defaultValue;
452
+ }
453
+ });
454
+ };
455
+ jQuery("#cpac-box-plugin_settings .addons input").cleardefault();
456
+ }
457
+
458
+ /*
459
+ * Help
460
+ *
461
+ * usage: <a href="javascript:;" class="help" data-help="tab-2"></a>
462
+ */
463
+ function cpac_help() {
464
+ jQuery('#cpac a.help').click( function(e) {
465
+ e.preventDefault();
466
+
467
+ var panel = jQuery('#contextual-help-wrap');
468
+
469
+ panel.parent().show();
470
+ jQuery('a[href="#tab-panel-cpac-' + jQuery(this).attr('data-help') + '"]', panel).trigger('click');
471
+ panel.slideDown( 'fast', function() {
472
+ panel.focus();
473
+ });
474
+ });
475
+ }
476
+
477
+ /*
478
+ * WP Pointer
479
+ *
480
+ */
481
+ function cpac_pointer() {
482
+ jQuery('.cpac-pointer').each(function(){
483
+
484
+ // vars
485
+ var el = jQuery(this),
486
+ html = el.attr('rel'),
487
+ pos = el.attr('data-pos');
488
+
489
+ var position = {
490
+ at: 'left top', // position of wp-pointer relative to the element which triggers the pointer event
491
+ my: 'right top', // position of wp-pointer relative to the at-coordinates
492
+ edge: 'right', // position of arrow
493
+ offset: '0 0' // offset for wp-pointer
494
+ };
495
+
496
+ if ( 'right' == pos ) {
497
+ position = {
498
+ at: 'right middle',
499
+ my: 'left middle',
500
+ edge: 'left'
501
+ };
502
+ }
503
+
504
+ // create pointer
505
+ el.pointer({
506
+ content: jQuery('#' + html).html(),
507
+ position: position,
508
+ pointerWidth: 250,
509
+ close: function() {
510
+ el.removeClass('open');
511
+ },
512
+
513
+ // bug fix. with an arrow on the right side the position of wp-pointer is incorrect. it does not take
514
+ // into account the padding of the arrow. adding "wp-pointer-' + position.edge" will fix that.
515
+ pointerClass: 'wp-pointer wp-pointer-' + position.edge
516
+ });
517
+
518
+ // click
519
+ el.click( function() {
520
+ if( el.hasClass('open') ) {
521
+ el.removeClass('open');
522
+ }
523
+ else {
524
+ el.addClass('open');
525
+ }
526
+ });
527
+
528
+ // show on hover
529
+ el.hover( function() {
530
+ jQuery(this).pointer('open');
531
+ }, function() {
532
+ if( ! el.hasClass('open') ) {
533
+ jQuery(this).pointer('close');
534
+ }
535
+
536
+ });
537
+ });
538
+ }
539
+
540
+ /*
541
+ * Sortable
542
+ *
543
+ * @since 1.5
544
+ */
545
+ function cpac_sortable() {
546
+ jQuery( 'div.cpac-columns' ).each( function() {
547
+ if ( jQuery( this ).hasClass( 'ui-sortable' ) ) {
548
+ jQuery( this ).sortable( 'refresh' );
549
+ }
550
+ else {
551
+ jQuery( this ).sortable( {
552
+ items : '.cpac-column'
553
+ } );
554
+ }
555
+ } );
556
+ }
557
+
558
+ /*
559
+ * Menu
560
+ *
561
+ * @since 1.5
562
+ */
563
+ function cpac_menu() {
564
+
565
+ var menu = jQuery('#cpac div.cpac-menu');
566
+ // click
567
+ menu.find('a').click( function(e, el) {
568
+
569
+ var id = jQuery(this).attr('href');
570
+
571
+ if ( id ) {
572
+
573
+ var type = id.replace('#cpac-box-','');
574
+
575
+ // remove current
576
+ jQuery('.cpac-menu a').removeClass('current');
577
+ jQuery('.columns-container').hide();
578
+
579
+ // set current
580
+ jQuery(this).addClass('current');
581
+ var container = jQuery('.columns-container[data-type="' + type + '"]').show();
582
+ var columns = container.find( '.cpac-columns' );
583
+
584
+ // hook for addons
585
+ jQuery( document ).trigger( 'cac_menu_change', columns );
586
+ }
587
+
588
+ // re init sidebar scroll
589
+ //cpac_sidebar_scroll();
590
+
591
+ e.preventDefault();
592
+ });
593
+
594
+ // activate first menu
595
+ menu.find('a.current').trigger('click');
596
+ }
597
+
598
+ /*
599
+ * Bind events: triggered after column is init, changed or added
600
+ *
601
+ */
602
+ jQuery( document ).bind('column_init column_change column_add', function( e, column ){
603
+ jQuery( column ).cpac_bind_column_addon_events();
604
+ jQuery( column ).cpac_bind_container_addon_events();
605
+ });
606
+
607
+ /*
608
+ * Radio Click events
609
+ *
610
+ */
611
+ jQuery.fn.cpac_bind_column_addon_events = function() {
612
+
613
+ var column = jQuery( this );
614
+ var inputs = column.find('[data-toggle-id] label');
615
+
616
+ // Enable editing: radio button
617
+ inputs.click( function(){
618
+
619
+ var id = jQuery( this ).closest('td.input').data('toggle-id');
620
+ var label = column.find('[data-indicator-id="' + id + '"]' ).removeClass( 'on' );
621
+ var status = jQuery( 'input', this ).val();
622
+
623
+ if ( 'on' == status ) {
624
+ label.addClass( 'on' );
625
+ }
626
+ });
627
+ };
628
+
629
+ /*
630
+ * Indicator Click Events
631
+ *
632
+ */
633
+ jQuery.fn.cpac_bind_container_addon_events = function() {
634
+
635
+ var column = jQuery( this );
636
+ var indicator = column.find('[data-indicator-id]');
637
+
638
+ indicator.unbind('click').click( function() {
639
+
640
+ var id = jQuery( this ).data('indicator-id');
641
+ var radio = column.find('[data-toggle-id="' + id + '"] input' );
642
+
643
+ if ( jQuery( this ).hasClass('on') ) {
644
+ jQuery( this ).removeClass('on').addClass('off');
645
+ radio.filter('[value=off]').prop('checked', true);
646
+ }
647
+ else {
648
+ jQuery( this ).removeClass('off').addClass('on');
649
+ radio.filter('[value=on]').prop('checked', true);
650
+ }
651
+ });
652
+ };
assets/js/admin-settings.min.js ADDED
@@ -0,0 +1,4 @@
1
+ /*
2
+ * Fires when the dom is ready
3
+ *
4
+ */function cpac_importexport(){jQuery("#php-export-results textarea").on("focus, mouseup",function(){jQuery(this).select()}).select().focus()}function cpac_addons(){}function cpac_submit_form(){jQuery(".form-update a.submit-update").click(function(e){e.preventDefault();jQuery(this).closest(".columns-container").find(".cpac-columns form").submit()})}function cpac_add_column(){jQuery("#cpac .add_column").click(function(e){var t=jQuery(this).closest(".columns-container"),n=jQuery(".for-cloning-only .cpac-column",t).first().clone(),r=t.attr("data-type");if(n.length>0){n.cpac_update_clone_id(r);jQuery(".cpac-columns form",t).append(n);n.column_bind_toggle();n.column_bind_remove();n.column_bind_events();n.addClass("opened").find(".column-form").slideDown(150,function(){jQuery("html, body").animate({scrollTop:n.offset().top-58},300)});cpac_sortable();jQuery(document).trigger("column_add",n)}e.preventDefault()})}function cpac_sidebar_feedback(){jQuery(function(e){var t=e(".sidebox#direct-feedback");t.find("#feedback-choice a.no").click(function(e){e.preventDefault();t.find("#feedback-choice").slideUp();t.find("#feedback-support").slideDown()});t.find("#feedback-choice a.yes").click(function(e){e.preventDefault();t.find("#feedback-choice").slideUp();t.find("#feedback-rate").slideDown()})})}function cpac_clear_input_defaults(){jQuery.fn.cleardefault=function(){return this.focus(function(){this.value==this.defaultValue&&(this.value="")}).blur(function(){this.value.length||(this.value=this.defaultValue)})};jQuery("#cpac-box-plugin_settings .addons input").cleardefault()}function cpac_help(){jQuery("#cpac a.help").click(function(e){e.preventDefault();var t=jQuery("#contextual-help-wrap");t.parent().show();jQuery('a[href="#tab-panel-cpac-'+jQuery(this).attr("data-help")+'"]',t).trigger("click");t.slideDown("fast",function(){t.focus()})})}function cpac_pointer(){jQuery(".cpac-pointer").each(function(){var e=jQuery(this),t=e.attr("rel"),n=e.attr("data-pos"),r={at:"left top",my:"right top",edge:"right",offset:"0 0"};"right"==n&&(r={at:"right middle",my:"left middle",edge:"left"});e.pointer({content:jQuery("#"+t).html(),position:r,pointerWidth:250,close:function(){e.removeClass("open")},pointerClass:"wp-pointer wp-pointer-"+r.edge});e.click(function(){e.hasClass("open")?e.removeClass("open"):e.addClass("open")});e.hover(function(){jQuery(this).pointer("open")},function(){e.hasClass("open")||jQuery(this).pointer("close")})})}function cpac_sortable(){jQuery("div.cpac-columns").each(function(){jQuery(this).hasClass("ui-sortable")?jQuery(this).sortable("refresh"):jQuery(this).sortable({items:".cpac-column"})})}function cpac_menu(){var e=jQuery("#cpac div.cpac-menu");e.find("a").click(function(e,t){var n=jQuery(this).attr("href");if(n){var r=n.replace("#cpac-box-","");jQuery(".cpac-menu a").removeClass("current");jQuery(".columns-container").hide();jQuery(this).addClass("current");var i=jQuery('.columns-container[data-type="'+r+'"]').show(),s=i.find(".cpac-columns");jQuery(document).trigger("cac_menu_change",s)}e.preventDefault()});e.find("a.current").trigger("click")}jQuery(document).ready(function(){if(jQuery("#cpac").length===0)return!1;cpac_pointer();cpac_submit_form();cpac_clear_input_defaults();cpac_sortable();cpac_menu();cpac_help();cpac_add_column();cpac_addons();cpac_importexport();cpac_sidebar_feedback();jQuery(".cpac-column").each(function(e,t){jQuery(t).column_bind_toggle();jQuery(t).column_bind_remove();jQuery(t).cpac_bind_container_addon_events()})});jQuery.fn.column_bind_toggle=function(){var e=jQuery(this);e.find("td.column_type a, td.column_edit, td.column_label a.toggle, td.column_label .edit-button").click(function(t){t.preventDefault();e.toggleClass("opened").find(".column-form").slideToggle(150);e.hasClass("events-binded")||e.column_bind_events();e.addClass("events-binded");jQuery(document).trigger("column_init",e)})};jQuery.fn.column_bind_remove=function(){jQuery(this).find(".remove-button").click(function(e){jQuery(this).closest(".cpac-column").column_remove();e.preventDefault()})};jQuery.fn.cpac_column_refresh=function(){var e=jQuery(this);e.addClass("loading");e.find(".column-form").prepend('<span class="spinner" />');jQuery.post(ajaxurl,{action:"cpac_column_refresh",column:jQuery(this).find("input.column-name").val(),formdata:jQuery(this).parents("form").serialize()},function(t){console.log(t);var n=jQuery("<div>"+t+"</div>").children();e.replaceWith(n);e=n;e.column_bind_toggle();e.column_bind_remove();e.column_bind_events();e.removeClass("loading").addClass("opened").find(".column-form").show();jQuery(document).trigger("column_change",e)})};jQuery.fn.column_bind_events=function(){var e=jQuery(this),t=e.closest(".columns-container "),n=t.attr("data-type"),r=e.find(".column_type select option:selected").val();e.find(".column_type select").change(function(){var i=jQuery("optgroup",this).children(":selected"),s=i.val(),o=i.text(),u=jQuery(this).next(".msg").hide(),a=t.find('.for-cloning-only .cpac-column[data-type="'+s+'"]');if(a.length)if(a.find(".is-disabled").length){u.html(a.find(".is-disabled").html()).show();jQuery(this).find("option").removeAttr("selected");jQuery(this).find('option[value="'+r+'"]').attr("selected","selected")}else{if(typeof a.attr("data-clone")=="undefined"&&jQuery(".cpac-columns",t).find('[data-type="'+s+'"]').length){u.html(cpac_i18n.clone.replace("%s","<strong>"+o+"</strong>")).show();jQuery(this).find("option").removeAttr("selected");jQuery(this).find('option[value="'+r+'"]').attr("selected","selected");return}var f=a.clone();f.addClass("opened").find(".column-form").show();f.find(".column-meta").replaceWith(e.find(".column-meta"));f.find(".column-form").replaceWith(e.find(".column-form"));f.cpac_update_clone_id(n);e.replaceWith(f);f.cpac_column_refresh()}});e.find(".column_label .input input").bind("keyup change",function(){var e=jQuery(this).val();jQuery(this).closest(".cpac-column").find("td.column_label .inner > a.toggle").text(e)});e.find(".input-width-range").each(function(){var e=jQuery(this).closest("td").find(".input-width"),t=jQuery(this).closest("td").find(".width-decription"),n=jQuery(e)[0].defaultValue,r=t.attr("title");jQuery(this).slider({range:"min",min:0,max:100,value:n,slide:function(n,i){var s=i.value>0?i.value+"%":r;jQuery(e).val(i.value);jQuery(t).text(s)}})});e.find(".column_image_size label.custom-size").click(function(){var e=jQuery(this).closest(".input");if(jQuery(this).hasClass("image-size-custom")){jQuery(".custom-size-w",e).removeClass("hidden");jQuery(".custom-size-h",e).removeClass("hidden")}else{jQuery(".custom-size-w",e).addClass("hidden");jQuery(".custom-size-h",e).addClass("hidden")}});e.find(".column-form .label label").hover(function(){jQuery(this).find("p.description").show()},function(){jQuery(this).find("p.description").hide()});e.find(".column_type select").val()=="column-meta"&&e.find(".column_field_type select").change(function(){e.cpac_column_refresh()})};jQuery.fn.column_remove=function(){jQuery(this).addClass("deleting").animate({opacity:0,height:0},350,function(e){jQuery(this).remove()})};jQuery.fn.cpac_update_clone_id=function(e){var t=jQuery(this),n=t.attr("data-type"),r=jQuery('.columns-container[data-type="'+e+'"]').find(".cpac-columns"),i=jQuery(r).find('*[data-type="'+n+'"]').not(t),s=jQuery.map(i,function(e,t){return jQuery(e).attr("data-clone")?parseInt(jQuery(e).attr("data-clone"),10):0});s.sort();var o=Math.max.apply(null,s)+1;for(var u=0;u<=o;u++)if(-1===jQuery.inArray(u,s))break;if(0===u)return;t.attr("data-clone",u);t.find("input.clone").val(u);t.find("input.column-name").val(n+"-"+u);var a=t.find("input, select, label");jQuery(a).each(function(e,t){var r=n+"-"+u;jQuery(t).attr("name")&&jQuery(t).attr("name",jQuery(t).attr("name").replace(n,r));jQuery(t).attr("for")&&jQuery(t).attr("for",jQuery(t).attr("for").replace(n,r));jQuery(t).attr("id")&&jQuery(t).attr("id",jQuery(t).attr("id").replace(n,r))})};jQuery(document).bind("column_init column_change column_add",function(e,t){jQuery(t).cpac_bind_column_addon_events();jQuery(t).cpac_bind_container_addon_events()});jQuery.fn.cpac_bind_column_addon_events=function(){var e=jQuery(this),t=e.find("[data-toggle-id] label");t.click(function(){var t=jQuery(this).closest("td.input").data("toggle-id"),n=e.find('[data-indicator-id="'+t+'"]').removeClass("on"),r=jQuery("input",this).val();"on"==r&&n.addClass("on")})};jQuery.fn.cpac_bind_container_addon_events=function(){var e=jQuery(this),t=e.find("[data-indicator-id]");t.unbind("click").click(function(){var t=jQuery(this).data("indicator-id"),n=e.find('[data-toggle-id="'+t+'"] input');if(jQuery(this).hasClass("on")){jQuery(this).removeClass("on").addClass("off");n.filter("[value=off]").prop("checked",!0)}else{jQuery(this).removeClass("off").addClass("on");n.filter("[value=on]").prop("checked",!0)}})};
assets/less/admin-column.less CHANGED
@@ -433,6 +433,7 @@ h2.cpac-nav-tab-wrapper {
433
padding-left: 10px;
434
padding-right: 0;
435
}
436
div.msg {
437
margin-top: 5px;
438
display: none;
@@ -444,6 +445,10 @@ h2.cpac-nav-tab-wrapper {
444
-webkit-border-radius: 3px;
445
border-radius: 3px;
446
}
447
}
448
}
449
@@ -796,6 +801,7 @@ h2.cpac-nav-tab-wrapper {
796
&#pro-version {
797
.cta {
798
background: transparent url(../images/get_the_addon.png) no-repeat 0 0;
799
}
800
.padding-box {
801
padding: 8px 15px 0;
@@ -860,7 +866,7 @@ h2.cpac-nav-tab-wrapper {
860
text-align: center;
861
line-height: 64px;
862
font-weight: bold;
863
- color: #CCC;
864
display: inline-block;
865
text-decoration: none;
866
@@ -936,6 +942,10 @@ h2.cpac-nav-tab-wrapper {
936
}
937
}
938
}
939
}
940
}
941
}
@@ -1241,4 +1251,4 @@ body.rtl {
1241
margin-right: 3px;
1242
}
1243
}
1244
- }
433
padding-left: 10px;
434
padding-right: 0;
435
}
436
+
437
div.msg {
438
margin-top: 5px;
439
display: none;
445
-webkit-border-radius: 3px;
446
border-radius: 3px;
447
}
448
+
449
+ .section {
450
+ padding: 12px;
451
+ }
452
}
453
}
454
801
&#pro-version {
802
.cta {
803
background: transparent url(../images/get_the_addon.png) no-repeat 0 0;
804
+ background-size: cover;
805
}
806
.padding-box {
807
padding: 8px 15px 0;
866
text-align: center;
867
line-height: 64px;
868
font-weight: bold;
869
+ color: #222;
870
display: inline-block;
871
text-decoration: none;
872
942
}
943
}
944
}
945
+
946
+ #feedback-support .inside ul.share li {
947
+ width: 48%;
948
+ }
949
}
950
}
951
}
1251
margin-right: 3px;
1252
}
1253
}
1254
+ }
assets/less/column.less CHANGED
@@ -74,3 +74,35 @@ div.cpac-color span {
74
div.sizes span.not-available {
75
color: #999;
76
}
74
div.sizes span.not-available {
75
color: #999;
76
}
77
+
78
+ /* =Actions column
79
+ -------------------------------------------------------------- */
80
+
81
+
82
+ .button.cpac-button-action {
83
+ position: relative;
84
+ text-indent: 9999px;
85
+ margin-right: 4px;
86
+ padding: 0 13px;
87
+
88
+ &:before {
89
+ position: absolute;
90
+ top: 0;
91
+ left: 0;
92
+ width: 100%;
93
+ height: 100%;
94
+ text-indent: 0;
95
+ }
96
+ }
97
+
98
+ /* =qTip2
99
+ -------------------------------------------------------------- */
100
+ .cpac-tip {
101
+ display: inline-block;
102
+ }
103
+
104
+ .qtip.qtip-tipsy {
105
+ background: rgba( 0, 0, 0, .75 );
106
+ font-weight: normal;
107
+ min-width: 25px;
108
+ }
classes/addons.php CHANGED
@@ -136,6 +136,12 @@ class CPAC_Addons {
136
'description' => __( 'Display and edit Advanced Custom Fields fields in the posts overview in seconds!', 'cpac' ),
137
'group' => 'integration',
138
'image' => CPAC_URL . 'assets/images/addons/acf.png'
139
)
140
);
141
136
'description' => __( 'Display and edit Advanced Custom Fields fields in the posts overview in seconds!', 'cpac' ),
137
'group' => 'integration',
138
'image' => CPAC_URL . 'assets/images/addons/acf.png'
139
+ ),
140
+ 'cac-addon-woocommerce' => array(
141
+ 'title' => __( 'WooCommerce', 'cpac' ),
142
+ 'description' => __( 'Enhance the products, orders and coupons overviews with new columns and inline editing.', 'cpac' ),
143
+ 'group' => 'integration',
144
+ 'image' => CPAC_URL . 'assets/images/addons/woocommerce.png'
145
)
146
);
147
classes/column.php CHANGED
@@ -129,7 +129,8 @@ class CPAC_Column {
129
'is_registered' => true, // Should the column be registered based on conditional logic, example usage see: 'post/page-template.php'
130
'is_cloneable' => true, // Should the column be cloneable
131
'default' => false, // Is this a WP default column,
132
- 'group' => 'custom'
133
);
134
135
foreach ( $default_properties as $property => $value ) {
@@ -879,9 +880,15 @@ class CPAC_Column {
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;
884
}
885
asort( $_columns );
886
887
$list = "<optgroup label='{$label}'>";
129
'is_registered' => true, // Should the column be registered based on conditional logic, example usage see: 'post/page-template.php'
130
'is_cloneable' => true, // Should the column be cloneable
131
'default' => false, // Is this a WP default column,
132
+ 'group' => 'custom',
133
+ 'hidden' => false
134
);
135
136
foreach ( $default_properties as $property => $value ) {
880
881
// sort by alphabet
882
$_columns = array();
883
+
884
foreach ( $columns as $column ) {
885
+ if ( $column->properties->hidden ) {
886
+ continue;
887
+ }
888
+
889
+ $_columns[ $column->properties->type ] = ( 0 === strlen( strip_tags( $column->properties->label ) ) ) ? ucfirst( $column->properties->type ) : $column->properties->label;
890
}
891
+
892
asort( $_columns );
893
894
$list = "<optgroup label='{$label}'>";
classes/column/link/actions.php CHANGED
@@ -50,4 +50,4 @@ class CPAC_Column_Link_Actions extends CPAC_Column {
50
51
return implode( ' | ', $actions );
52
}
53
- }
50
51
return implode( ' | ', $actions );
52
}
53
+ }
classes/settings.php CHANGED
@@ -196,10 +196,10 @@ class CPAC_Settings {
196
197
$minified = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
198
199
- wp_enqueue_script( 'cpac-admin-columns', CPAC_URL . "assets/js/admin-columns{$minified}.js", array( 'jquery', 'dashboard', 'jquery-ui-slider', 'jquery-ui-sortable' ), CPAC_VERSION );
200
201
// javascript translations
202
- wp_localize_script( 'cpac-admin-columns', 'cpac_i18n', array(
203
'clone' => __( '%s column is already present and can not be duplicated.', 'cpac' ),
204
));
205
}
@@ -717,7 +717,7 @@ class CPAC_Settings {
717
</p>
718
</div>
719
</div>
720
-
721
722
<?php
723
// @todo: add newsletter
@@ -740,7 +740,76 @@ class CPAC_Settings {
740
</form>
741
</div>
742
<?php */ ?>
743
- </div><!--pro-version-->
744
<?php endif; ?>
745
746
<div class="sidebox" id="plugin-support">
196
197
$minified = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
198
199
+ wp_enqueue_script( 'cpac-admin-settings', CPAC_URL . "assets/js/admin-settings{$minified}.js", array( 'jquery', 'dashboard', 'jquery-ui-slider', 'jquery-ui-sortable' ), CPAC_VERSION );
200
201
// javascript translations
202
+ wp_localize_script( 'cpac-admin-settings', 'cpac_i18n', array(
203
'clone' => __( '%s column is already present and can not be duplicated.', 'cpac' ),
204
));
205
}
717
</p>
718
</div>
719
</div>
720
+ </div>
721
722
<?php
723
// @todo: add newsletter
740
</form>
741
</div>
742
<?php */ ?>
743
+
744
+
745
+ <div class="sidebox" id="direct-feedback">
746
+ <div id="feedback-choice">
747
+ <h3><?php _e( 'Are you happy with Admin Columns?', 'cpac' ); ?></h3>
748
+ <div class="inside">
749
+ <a href="#" class="yes">Yes</a>
750
+ <a href="#" class="no">No</a>
751
+ </div>
752
+ </div>
753
+ <div id="feedback-support">
754
+ <div class="inside">
755
+ <p><?php _e( "What's wrong? Need help? Let us know!", 'cpac' ); ?></p>
756
+ <p><?php _e( 'Check out our extensive documentation, or you can open a support topic on WordPress.org!', 'cpac' ); ?></p>
757
+ <ul class="share">
758
+ <li>
759
+ <a href="<?php echo add_query_arg( array(
760
+ 'utm_source' => 'plugin-installation',
761
+ 'utm_medium' => 'feedback-docs-button',
762
+ 'utm_campaign' => 'plugin-installation'
763
+ ), $this->get_url( 'documentation' ) ); ?>" target="_blank">
764
+ <div class="dashicons dashicons-editor-help"></div> <?php _e( 'Docs', 'cpac' ); ?>
765
+ </a>
766
+ </li>
767
+ <li>
768
+ <a href="https://wordpress.org/support/plugin/codepress-admin-columns" target="_blank">
769
+ <div class="dashicons dashicons-wordpress"></div> <?php _e( 'Forums', 'cpac' ); ?>
770
+ </a>
771
+ </li>
772
+ </ul>
773
+ <div class="clear"></div>
774
+ </div>
775
+ </div>
776
+ <div id="feedback-rate">
777
+ <div class="inside">
778
+ <p><?php _e( "Woohoo! We're glad to hear that!", 'cpac' ); ?></p>
779
+ <p><?php _e( 'We would really love it if you could show your appreciation by giving us a rating on WordPress.org or tweet about Admin Columns!', 'cpac' ); ?></p>
780
+ <ul class="share">
781
+ <li>
782
+ <a href="http://wordpress.org/support/view/plugin-reviews/codepress-admin-columns#postform" target="_blank">
783
+ <div class="dashicons dashicons-star-empty"></div> <?php _e( 'Rate', 'cpac' ); ?>
784
+ </a>
785
+ </li>
786
+
787
+ <li>
788
+ <a href="<?php echo add_query_arg( array(
789
+ 'hashtags' => 'wordpress',
790
+ 'text' => urlencode( "I'm using Admin Columns for WordPress!" ),
791
+ 'url' => urlencode( 'http://wordpress.org/plugins/codepress-admin-columns/' ),
792
+ 'via' => 'wpcolumns'
793
+ ), 'https://twitter.com/intent/tweet' ); ?>" target="_blank">
794
+ <div class="dashicons dashicons-twitter"></div> <?php _e( 'Tweet', 'cpac' ); ?>
795
+ </a>
796
+ </li>
797
+
798
+ <li>
799
+ <a href="<?php echo add_query_arg( array(
800
+ 'utm_source' => 'plugin-installation',
801
+ 'utm_medium' => 'feedback-purchase-button',
802
+ 'utm_campaign' => 'plugin-installation'
803
+ ), $this->get_url( 'admincolumnspro' ) ); ?>" target="_blank">
804
+ <div class="dashicons dashicons-cart"></div> <?php _e( 'Buy Pro', 'cpac' ); ?>
805
+ </a>
806
+ </li>
807
+ </ul>
808
+ <div class="clear"></div>
809
+ </div>
810
+ </div>
811
+ </div>
812
+
813
<?php endif; ?>
814
815
<div class="sidebox" id="plugin-support">
classes/storage_model.php CHANGED
@@ -606,6 +606,16 @@ abstract class CPAC_Storage_Model {
606
$columns[ $name ] = clone $registered_columns[ $name ];
607
}
608
}
609
}
610
611
do_action( "cac/columns", $columns );
@@ -792,4 +802,17 @@ abstract class CPAC_Storage_Model {
792
793
return $options[ $option ];
794
}
795
}
606
$columns[ $name ] = clone $registered_columns[ $name ];
607
}
608
}
609
+
610
+ /**
611
+ * Filter the columns that should be loaded if there were no stored columns
612
+ *
613
+ * @since 2.2.4
614
+ *
615
+ * @param array $columns List of columns ([column name] => [column instance])
616
+ * @param CPAC_Storage_Model $storage_model_instance Storage model class instance
617
+ */
618
+ $columns = apply_filters( 'cpac/storage_model/columns_default', $columns, $this );
619
}
620
621
do_action( "cac/columns", $columns );
802
803
return $options[ $option ];
804
}
805
+
806
+ /**
807
+ * @since 2.2.4
808
+ */
809
+ public function is_table_header_fixed() {
810
+
811
+ /**
812
+ * @since 2.2.4
813
+ */
814
+ $fixed = apply_filters( 'cpac/storage_model/table_header_fixed', false, $this );
815
+
816
+ return $fixed;
817
+ }
818
}
classes/third_party.php CHANGED
@@ -70,6 +70,7 @@ add_action( 'cac/get_columns', 'cac_add_wpml_columns' );
70
function cpac_remove_acf_from_cpac_post_types( $post_types ) {
71
if ( class_exists('Acf') ) {
72
unset( $post_types['acf'] );
73
}
74
75
return $post_types;
70
function cpac_remove_acf_from_cpac_post_types( $post_types ) {
71
if ( class_exists('Acf') ) {
72
unset( $post_types['acf'] );
73
+ unset( $post_types['acf-field-group'] );
74
}
75
76
return $post_types;
codepress-admin-columns.php CHANGED
@@ -2,7 +2,7 @@
2
/*
3
4
Plugin Name: Codepress Admin Columns
5
- Version: 2.2.3
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
@@ -33,7 +33,7 @@ if ( ! defined( 'ABSPATH' ) ) {
33
}
34
35
// Plugin information
36
- define( 'CPAC_VERSION', '2.2.3' ); // current plugin version
37
define( 'CPAC_UPGRADE_VERSION', '2.0.0' ); // this is the latest version which requires an upgrade
38
define( 'CPAC_URL', plugin_dir_url( __FILE__ ) );
39
define( 'CPAC_DIR', plugin_dir_path( __FILE__ ) );
@@ -105,8 +105,8 @@ class CPAC {
105
// Add settings link
106
add_filter( 'plugin_action_links', array( $this, 'add_settings_link' ), 1, 2 );
107
108
- // Load scripts
109
- $this->init_scripts();
110
111
// Settings
112
include_once CPAC_DIR . 'classes/settings.php';
@@ -228,16 +228,31 @@ class CPAC {
228
}
229
230
/**
231
- * @since 2.1.1
232
*/
233
- public function init_scripts() {
234
235
add_action( 'admin_head', array( $this, 'global_head_scripts') );
236
237
if ( $this->is_columns_screen() ) {
238
- add_action( 'admin_enqueue_scripts' , array( $this, 'column_styles') );
239
add_filter( 'admin_body_class', array( $this, 'admin_class' ) );
240
add_action( 'admin_head', array( $this, 'admin_scripts') );
241
}
242
}
243
@@ -315,6 +330,20 @@ class CPAC {
315
return false;
316
}
317
318
/**
319
* @since 1.0
320
* @return array Posttypes
@@ -361,7 +390,13 @@ class CPAC {
361
*/
362
public function column_styles() {
363
364
- wp_enqueue_style( 'cpac-columns', CPAC_URL . 'assets/css/column.css', array(), CPAC_VERSION, 'all' );
365
}
366
367
/**
2
/*
3
4
Plugin Name: Codepress Admin Columns
5
+ Version: 2.2.4
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
33
}
34
35
// Plugin information
36
+ define( 'CPAC_VERSION', '2.2.4' ); // current plugin version
37
define( 'CPAC_UPGRADE_VERSION', '2.0.0' ); // this is the latest version which requires an upgrade
38
define( 'CPAC_URL', plugin_dir_url( __FILE__ ) );
39
define( 'CPAC_DIR', plugin_dir_path( __FILE__ ) );
105
// Add settings link
106
add_filter( 'plugin_action_links', array( $this, 'add_settings_link' ), 1, 2 );
107
108
+ // Scripts
109
+ add_action( 'admin_enqueue_scripts', array( $this, 'scripts' ) );
110
111
// Settings
112
include_once CPAC_DIR . 'classes/settings.php';
228
}
229
230
/**
231
+ * @since 2.2.4
232
*/
233
+ public function scripts() {
234
235
add_action( 'admin_head', array( $this, 'global_head_scripts') );
236
237
+ wp_register_script( 'cpac-admin-columns', CPAC_URL . 'assets/js/admin-columns.js', array( 'jquery', 'jquery-qtip2' ), CPAC_VERSION );
238
+
239
if ( $this->is_columns_screen() ) {
240
add_filter( 'admin_body_class', array( $this, 'admin_class' ) );
241
add_action( 'admin_head', array( $this, 'admin_scripts') );
242
+
243
+ wp_enqueue_script( 'cpac-admin-columns' );
244
+
245
+ $data = array();
246
+
247
+ if ( $storage_model = $this->get_current_storage_model() ) {
248
+ $data['storage_model'] = array(
249
+ 'is_table_header_fixed' => $storage_model->is_table_header_fixed()
250
+ );
251
+ }
252
+
253
+ wp_localize_script( 'cpac-admin-columns', 'CPAC', $data );
254
+
255
+ $this->column_styles();
256
}
257
}
258
330
return false;
331
}
332
333
+ /**
334
+ * @since 2.2.4
335
+ */
336
+ public function get_current_storage_model() {
337
+
338
+ if ( $this->storage_models ) {
339
+ foreach ( $this->storage_models as $storage_model ) {
340
+ if ( $storage_model->is_columns_screen() ) {
341
+ return $storage_model;
342
+ }
343
+ }
344
+ }
345
+ }
346
+
347
/**
348
* @since 1.0
349
* @return array Posttypes
390
*/
391
public function column_styles() {
392
393
+ wp_register_script( 'jquery-qtip2', CPAC_URL . 'external/qtip2/jquery.qtip.min.js', array( 'jquery' ), CPAC_VERSION );
394
+ wp_register_style( 'jquery-qtip2', CPAC_URL . 'external/qtip2/jquery.qtip.min.css', array(), CPAC_VERSION, 'all' );
395
+ wp_register_style( 'cpac-columns', CPAC_URL . 'assets/css/column.css', array(), CPAC_VERSION, 'all' );
396
+
397
+ wp_enqueue_script( 'jquery-qtip2' );
398
+ wp_enqueue_style( 'jquery-qtip2' );
399
+ wp_enqueue_style( 'cpac-columns' );
400
}
401
402
/**
external/qtip2/jquery.qtip.css ADDED
@@ -0,0 +1,490 @@