Changeset 637026
- Timestamp:
- 12/11/2012 01:30:09 PM (13 years ago)
- Location:
- codepress-admin-columns
- Files:
-
- 79 added
- 9 edited
-
tags/1.4.7 (added)
-
tags/1.4.7/assets (added)
-
tags/1.4.7/assets/css (added)
-
tags/1.4.7/assets/css/admin-column.css (added)
-
tags/1.4.7/assets/css/column.css (added)
-
tags/1.4.7/assets/images (added)
-
tags/1.4.7/assets/images/addon_sortable_1.png (added)
-
tags/1.4.7/assets/images/arrows.png (added)
-
tags/1.4.7/assets/images/checkbox.png (added)
-
tags/1.4.7/assets/images/checkmark.png (added)
-
tags/1.4.7/assets/images/checkmark_single.png (added)
-
tags/1.4.7/assets/images/comment_edit.png (added)
-
tags/1.4.7/assets/images/cross.png (added)
-
tags/1.4.7/assets/images/facebook.png (added)
-
tags/1.4.7/assets/images/icon.png (added)
-
tags/1.4.7/assets/images/import_export.png (added)
-
tags/1.4.7/assets/images/information.png (added)
-
tags/1.4.7/assets/images/loading.gif (added)
-
tags/1.4.7/assets/images/no.png (added)
-
tags/1.4.7/assets/images/reorder.png (added)
-
tags/1.4.7/assets/images/reorder_arrow.png (added)
-
tags/1.4.7/assets/images/settings.png (added)
-
tags/1.4.7/assets/images/sort.png (added)
-
tags/1.4.7/assets/images/square.png (added)
-
tags/1.4.7/assets/images/trash.png (added)
-
tags/1.4.7/assets/images/twitter.png (added)
-
tags/1.4.7/assets/js (added)
-
tags/1.4.7/assets/js/admin-column.js (added)
-
tags/1.4.7/assets/js/jquery.qtip.js (added)
-
tags/1.4.7/assets/ui-theme (added)
-
tags/1.4.7/assets/ui-theme/images (added)
-
tags/1.4.7/assets/ui-theme/images/ui-bg_flat_0_aaaaaa_40x100.png (added)
-
tags/1.4.7/assets/ui-theme/images/ui-bg_flat_75_ffffff_40x100.png (added)
-
tags/1.4.7/assets/ui-theme/images/ui-bg_glass_55_fbf9ee_1x400.png (added)
-
tags/1.4.7/assets/ui-theme/images/ui-bg_glass_65_ffffff_1x400.png (added)
-
tags/1.4.7/assets/ui-theme/images/ui-bg_glass_75_dadada_1x400.png (added)
-
tags/1.4.7/assets/ui-theme/images/ui-bg_glass_75_e6e6e6_1x400.png (added)
-
tags/1.4.7/assets/ui-theme/images/ui-bg_glass_95_fef1ec_1x400.png (added)
-
tags/1.4.7/assets/ui-theme/images/ui-bg_highlight-soft_75_cccccc_1x100.png (added)
-
tags/1.4.7/assets/ui-theme/images/ui-icons_222222_256x240.png (added)
-
tags/1.4.7/assets/ui-theme/images/ui-icons_2e83ff_256x240.png (added)
-
tags/1.4.7/assets/ui-theme/images/ui-icons_454545_256x240.png (added)
-
tags/1.4.7/assets/ui-theme/images/ui-icons_888888_256x240.png (added)
-
tags/1.4.7/assets/ui-theme/images/ui-icons_cd0a0a_256x240.png (added)
-
tags/1.4.7/assets/ui-theme/jquery-ui-1.8.18.custom.css (added)
-
tags/1.4.7/classes (added)
-
tags/1.4.7/classes/license.php (added)
-
tags/1.4.7/classes/sortable.php (added)
-
tags/1.4.7/classes/utility.php (added)
-
tags/1.4.7/classes/values (added)
-
tags/1.4.7/classes/values.php (added)
-
tags/1.4.7/classes/values/comments.php (added)
-
tags/1.4.7/classes/values/link.php (added)
-
tags/1.4.7/classes/values/media.php (added)
-
tags/1.4.7/classes/values/posts.php (added)
-
tags/1.4.7/classes/values/users.php (added)
-
tags/1.4.7/codepress-admin-columns.php (added)
-
tags/1.4.7/languages (added)
-
tags/1.4.7/languages/codepress-admin-columns-da_DK.mo (added)
-
tags/1.4.7/languages/codepress-admin-columns-da_DK.po (added)
-
tags/1.4.7/languages/codepress-admin-columns-de_DE.mo (added)
-
tags/1.4.7/languages/codepress-admin-columns-de_DE.po (added)
-
tags/1.4.7/languages/codepress-admin-columns-fr_FR.mo (added)
-
tags/1.4.7/languages/codepress-admin-columns-fr_FR.po (added)
-
tags/1.4.7/languages/codepress-admin-columns-nl_NL.mo (added)
-
tags/1.4.7/languages/codepress-admin-columns-nl_NL.po (added)
-
tags/1.4.7/languages/codepress-admin-columns-pl_PL.mo (added)
-
tags/1.4.7/languages/codepress-admin-columns-pl_PL.po (added)
-
tags/1.4.7/languages/codepress-admin-columns.po (added)
-
tags/1.4.7/readme.txt (added)
-
tags/1.4.7/screenshot-1.png (added)
-
tags/1.4.7/screenshot-2.png (added)
-
tags/1.4.7/screenshot-3.png (added)
-
tags/1.4.7/screenshot-4.png (added)
-
tags/1.4.7/screenshot-5.png (added)
-
tags/1.4.7/screenshot-6.png (added)
-
tags/1.4.7/screenshot-7.png (added)
-
trunk/assets/css/admin-column.css (modified) (5 diffs)
-
trunk/assets/css/column.css (modified) (1 diff)
-
trunk/assets/images/import_export.png (added)
-
trunk/assets/js/admin-column.js (modified) (1 diff)
-
trunk/classes/license.php (added)
-
trunk/classes/sortable.php (modified) (17 diffs)
-
trunk/classes/utility.php (modified) (2 diffs)
-
trunk/classes/values.php (modified) (6 diffs)
-
trunk/classes/values/media.php (modified) (1 diff)
-
trunk/codepress-admin-columns.php (modified) (42 diffs)
-
trunk/readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
codepress-admin-columns/trunk/assets/css/admin-column.css
r585114 r637026 215 215 #general-cpac-settings .cpac-option-list li .cpac-type-inside input, 216 216 #general-cpac-settings .cpac-option-list li .cpac-type-inside select { 217 min-width: 184px;217 width: 184px; 218 218 } 219 219 #general-cpac-settings .cpac-option-list li .cpac-type-inside input.input-width { … … 302 302 border-top: none; 303 303 } 304 #cpac-box-plugin_settings table.addons { 305 /* max-width: 620px; */ 306 } 307 #cpac-box-plugin_settings table.addons th.activation_type { 308 width: 110px; 309 } 310 #cpac-box-plugin_settings table.addons th.activation_status { 311 width: 90px; 312 } 313 #cpac-box-plugin_settings table.addons th.activation_code { 314 /* width: auto; */ 315 min-width: 260px; 316 } 317 #cpac-box-plugin_settings table.addons th.activation_more { 318 /* min-width: 120px; */ 319 text-align: left; 320 width: auto; 321 } 322 #cpac-box-plugin_settings table.addons td.activation_type span { 323 font-size: 14px; 324 display: inline-block; 325 background: transparent url('../images/information.png') no-repeat right 50%; 326 padding-right: 20px; 327 } 328 #cpac-box-plugin_settings table.addons td { 329 background: #ffffff; 330 /* vertical-align: middle; */ 331 padding: 18px 10px; 332 } 333 #cpac-box-plugin_settings table.addons td.activation_code input { 334 width: 176px; 335 color: #555555; 336 font-family: Arial; 337 font-size: 12px; 338 } 339 #cpac-box-plugin_settings table.addons td.activation_more { 340 text-align: left; 341 } 342 #cpac-box-plugin_settings table.addons td.activation_more a{ 343 float: none; 344 display: inline-block; 345 margin-top: 1px; 346 } 347 #cpac-box-plugin_settings table.addons tr.last td { 348 border-bottom: none; 349 } 350 #cpac-box-plugin_settings table.addons .masked_key { 351 padding: 0; 352 } 353 #cpac-box-plugin_settings .cpac-options {} 354 #cpac-box-plugin_settings .cpac-options li { 355 overflow: hidden; 356 } 357 #cpac-box-plugin_settings .cpac-option-label { 358 float: left; 359 width: 140px; 360 } 361 #cpac-box-plugin_settings .cpac-option-inputs { 362 float: left; 363 width: 220px; 364 } 365 #cpac-box-plugin_settings table.addons .button { 304 #cpac-box-plugin_settings .button { 366 305 position: relative; 367 306 } 368 #cpac-box-plugin_settings table.addons.button.loading {307 #cpac-box-plugin_settings .button.loading { 369 308 padding-right: 25px; 370 309 } 371 #cpac-box-plugin_settings table.addons.button.loading span {310 #cpac-box-plugin_settings .button.loading span { 372 311 position: absolute; 373 312 top: 2px; … … 378 317 display: inline-block; 379 318 } 319 #cpac-box-plugin_settings td.first-col { 320 width: 18%; 321 } 322 323 /* =Addon settings 324 -------------------------------------------------------------- */ 325 #cpac-box-plugin_settings table.addons { 326 /* max-width: 620px; */ 327 } 328 #cpac-box-plugin_settings table.addons th.activation_type { 329 width: 110px; 330 } 331 #cpac-box-plugin_settings table.addons th.activation_status { 332 width: 90px; 333 } 334 #cpac-box-plugin_settings table.addons th.activation_code { 335 /* width: auto; */ 336 min-width: 260px; 337 } 338 #cpac-box-plugin_settings table.addons th.activation_more { 339 /* min-width: 120px; */ 340 text-align: left; 341 width: auto; 342 } 343 #cpac-box-plugin_settings table.addons td.activation_type span { 344 font-size: 14px; 345 display: inline-block; 346 background: transparent url('../images/information.png') no-repeat right 50%; 347 padding-right: 20px; 348 } 349 #cpac-box-plugin_settings table.addons td { 350 background: #ffffff; 351 /* vertical-align: middle; */ 352 padding: 18px 10px; 353 } 354 #cpac-box-plugin_settings table.addons td.activation_code input { 355 width: 176px; 356 color: #555555; 357 font-family: Arial; 358 font-size: 12px; 359 } 360 #cpac-box-plugin_settings table.addons td.activation_more { 361 text-align: left; 362 } 363 #cpac-box-plugin_settings table.addons td.activation_more a{ 364 float: none; 365 display: inline-block; 366 margin-top: 1px; 367 } 368 #cpac-box-plugin_settings table.addons tr.last td { 369 border-bottom: none; 370 } 371 #cpac-box-plugin_settings table.addons .masked_key { 372 padding: 0; 373 } 374 #cpac-box-plugin_settings .cpac-options {} 375 #cpac-box-plugin_settings .cpac-options li { 376 overflow: hidden; 377 } 378 #cpac-box-plugin_settings .cpac-option-label { 379 float: left; 380 width: 140px; 381 } 382 #cpac-box-plugin_settings .cpac-option-inputs { 383 float: left; 384 width: 220px; 385 } 380 386 381 387 /* =Restore settings … … 406 412 #addons-cpac-settings { 407 413 overflow: hidden; 408 background-color: #CCFFCC; 409 background-image: -moz-linear-gradient(center top , #c3f5c2, #CCFFCC ); 414 background: #ccffcc; 415 background: -moz-linear-gradient(top, #c3f5c2 1%, #ccffcc 100%); /* FF3.6+ */ 416 background: -webkit-gradient(linear, left top, left bottom, color-stop(1%,#c3f5c2), color-stop(100%,#ccffcc)); /* Chrome,Safari4+ */ 417 background: -webkit-linear-gradient(top, #c3f5c2 1%,#ccffcc 100%); /* Chrome10+,Safari5.1+ */ 418 background: -o-linear-gradient(top, #c3f5c2 1%,#ccffcc 100%); /* Opera 11.10+ */ 419 background: -ms-linear-gradient(top, #c3f5c2 1%,#ccffcc 100%); /* IE10+ */ 420 background: linear-gradient(to bottom, #c3f5c2 1%,#ccffcc 100%); /* W3C */ 421 filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#c3f5c2', endColorstr='#ccffcc',GradientType=0 ); /* IE6-9 */ 410 422 border-color: green; 411 423 } … … 500 512 line-height: 20px; 501 513 padding: 0 6px; 514 } 515 516 /* =Import / Export 517 -------------------------------------------------------------- */ 518 div.cpac_export { 519 width: 20%; 520 float: left; 521 } 522 #cpac_export_output { 523 width: 80%; 524 float: left; 525 display: none; 526 } 527 #cpac_export_output textarea { 528 width: 100%; 529 height: 80%; 530 } 531 #cpac_export_submit { 532 display: inline-block; 533 margin: 10px 0; 534 } 535 #cpac_import_input {} 536 #cpac_import_input textarea { 537 width: 100%; 538 height: 80%; 539 } 540 #cpac_import_submit { 541 display: inline-block; 542 margin: 10px 0; 543 } 544 .export-message, 545 .import-message { 546 background-color: #FFFFE0; 547 border: 1px solid #E6DB55; 548 padding: 4px 6px; 549 border-radius: 3px; 550 display: none; 551 } 552 553 /* =WP Pointer 554 -------------------------------------------------------------- */ 555 .wp-pointer-content ol { 556 margin-left: 1.5em; 557 padding: 0 15px; 502 558 } 503 559 -
codepress-admin-columns/trunk/assets/css/column.css
r538566 r637026 13 13 span.status-closed { 14 14 color: red; 15 } 16 17 /* =Color Column 18 -------------------------------------------------------------- */ 19 div.cpac-color { 20 line-height: 26px; 21 } 22 div.cpac-color span { 23 border: 1px solid #CCCCCC; 24 display: block; 25 -webkit-border-radius: 3px; 26 border-radius: 3px; 27 color: #ffffff; 28 float: left; 29 height: 16px; 30 margin-right: 12px; 31 min-width: 30px; 32 overflow: hidden; 33 padding: 4px 5px; 15 34 } 16 35 -
codepress-admin-columns/trunk/assets/js/admin-column.js
r529755 r637026 1 /** 2 * fires when the dom is ready 3 * 4 */ 5 jQuery(document).ready(function() 6 { 7 if (jQuery('#cpac').length == 0) 8 return false; 9 10 cpac_sortable(); 11 cpac_checked(); 12 cpac_box_events(); 13 cpac_menu(); 14 cpac_add_custom_column(); 15 cpac_clear_input_defaults(); 16 cpac_tooltips(); 17 cpac_addon_activation(); 18 cpac_width_range(); 19 }); 20 21 /** 22 * sortable 23 * 24 */ 25 function cpac_sortable() 26 { 27 jQuery('ul.cpac-option-list').sortable({ 28 handle: 'div.cpac-sort-handle', 29 placeholder: 'cpac-placeholder', 30 forcePlaceholderSize: true 1 (function($){ 2 3 /** 4 * fires when the dom is ready 5 * 6 */ 7 $(document).ready(function() 8 { 9 if ($('#cpac').length == 0) 10 return false; 11 12 cpac_sortable(); 13 cpac_checked(); 14 cpac_box_events(); 15 cpac_menu(); 16 cpac_add_custom_column(); 17 cpac_clear_input_defaults(); 18 cpac_tooltips(); 19 cpac_addon_activation(); 20 cpac_width_range(); 21 cpac_export(); 22 cpac_import(); 23 cpac_pointer(); 31 24 }); 32 } 33 34 /** 35 * checked 36 * 37 */ 38 function cpac_checked() 39 { 40 jQuery('#cpac .cpac-option-list li .cpac-type-options').live({ 41 click: function() { 42 var li = jQuery(this).closest('li'); 43 var state = jQuery('.cpac-state', li); 44 var value = state.attr('value'); 45 46 // toggle on 47 if ( value != 'on') { 48 li.addClass('active'); 49 state.attr('value', 'on'); 50 } 51 52 // toggle off 53 else { 54 li.removeClass('active'); 55 state.attr('value', ''); 56 } 57 } 58 }); 59 } 60 61 /** 62 * Open and close box 63 * 64 */ 65 function cpac_box_events() 66 { 67 // fold in/out 68 jQuery('#cpac .cpac-option-list .cpac-action').unbind('click').click(function(e){ 69 e.preventDefault(); 70 var li = jQuery(this).closest('li'); 71 li.find('.cpac-type-inside').slideToggle(150, function() { 72 li.toggleClass('opened'); 73 }); 74 }); 75 76 // remove custom field box 77 jQuery('#cpac .cpac-delete-custom-field-box').unbind('click').click(function(e){ 78 e.preventDefault(); 79 var el = jQuery(this).closest('li'); 25 26 /** 27 * sortable 28 * 29 */ 30 function cpac_sortable() 31 { 32 $('ul.cpac-option-list').sortable({ 33 handle: 'div.cpac-sort-handle', 34 placeholder: 'cpac-placeholder', 35 forcePlaceholderSize: true 36 }); 37 } 38 39 /** 40 * checked 41 * 42 */ 43 function cpac_checked() 44 { 45 $('#cpac .cpac-option-list li .cpac-type-options').live({ 46 click: function() { 47 var li = $(this).closest('li'); 48 var state = $('.cpac-state', li); 49 var value = state.attr('value'); 50 51 // toggle on 52 if ( value != 'on') { 53 li.addClass('active'); 54 state.attr('value', 'on'); 55 } 56 57 // toggle off 58 else { 59 li.removeClass('active'); 60 state.attr('value', ''); 61 } 62 } 63 }); 64 } 65 66 /** 67 * Open and close box 68 * 69 */ 70 function cpac_box_events() 71 { 72 // fold in/out 73 $('#cpac .cpac-option-list .cpac-action').unbind('click').click(function(e){ 74 e.preventDefault(); 75 var li = $(this).closest('li'); 76 li.find('.cpac-type-inside').slideToggle(150, function() { 77 li.toggleClass('opened'); 78 }); 79 }); 80 80 81 el.addClass('deleting').animate({ 82 opacity : 0, 83 height: 0 84 }, 350, function() { 85 el.remove(); 86 }); 87 }); 88 } 89 90 /** 91 * Menu 92 * 93 */ 94 function cpac_menu() 95 { 96 // referer 97 var referer = jQuery("input[type='hidden'][name='_wp_http_referer']"); 98 var referer_value = referer.attr('value'); 99 100 // click 101 jQuery('#cpac .cpac-menu a').click( function(e, el) { 102 e.preventDefault(); 103 var id = jQuery(this).attr('href'); 104 105 if ( id ) { 106 // remove current 107 jQuery('#cpac .cpac-menu a').removeClass('current'); 108 jQuery('#cpac .cpac-box-row').hide().removeClass('current'); 109 110 // set current 111 jQuery(this).addClass('current'); 112 jQuery(id).show().addClass('current'); 113 114 // set refere 115 var querystring = '&cpac_type=' + id.replace('#',''); 116 referer.attr('value', referer_value + querystring ); 117 } 118 }); 119 } 120 121 /** 122 * add custom columns 123 * 124 */ 125 function cpac_add_custom_column() 126 { 127 jQuery('.cpac-add-customfield-column').click(function(e){ 128 e.preventDefault(); 129 130 var list = jQuery(this).closest('td').find('ul.cpac-option-list'); 131 var metafields = jQuery('li.cpac-box-metafield', list); 81 // remove custom field box 82 $('#cpac .cpac-delete-custom-field-box').unbind('click').click(function(e){ 83 e.preventDefault(); 84 var el = $(this).closest('li'); 85 86 el.addClass('deleting').animate({ 87 opacity : 0, 88 height: 0 89 }, 350, function() { 90 el.remove(); 91 }); 92 }); 93 } 94 95 /** 96 * Menu 97 * 98 */ 99 function cpac_menu() 100 { 101 // referer 102 var referer = $("input[type='hidden'][name='_wp_http_referer']"); 103 var referer_value = referer.attr('value'); 132 104 133 // get unique ID number... 134 var ids = []; 135 metafields.each(function(k,v) { 136 var _class = jQuery(v).attr('class'); 137 var classes = _class.split(' '); 138 jQuery.each(classes, function(kc,vc){ 139 if ( vc.indexOf('cpac-box-column-meta-') === 0 ) { 140 var id = vc.replace('cpac-box-column-meta-',''); 141 if ( id ) 142 ids.push(id); 105 // click 106 $('#cpac .cpac-menu a').click( function(e, el) { 107 e.preventDefault(); 108 var id = $(this).attr('href'); 109 110 if ( id ) { 111 // remove current 112 $('#cpac .cpac-menu a').removeClass('current'); 113 $('#cpac .cpac-box-row').hide().removeClass('current'); 114 115 // set current 116 $(this).addClass('current'); 117 $(id).show().addClass('current'); 118 119 // set refere 120 var querystring = '&cpac_type=' + id.replace('#',''); 121 referer.attr('value', referer_value + querystring ); 122 } 123 }); 124 } 125 126 /** 127 * add custom columns 128 * 129 */ 130 function cpac_add_custom_column() 131 { 132 $('.cpac-add-customfield-column').click(function(e){ 133 e.preventDefault(); 134 135 var list = $(this).closest('td').find('ul.cpac-option-list'); 136 var metafields = $('li.cpac-box-metafield', list); 137 138 // get unique ID number... 139 var ids = []; 140 metafields.each(function(k,v) { 141 var _class = $(v).attr('class'); 142 var classes = _class.split(' '); 143 $.each(classes, function(kc,vc){ 144 if ( vc.indexOf('cpac-box-column-meta-') === 0 ) { 145 var id = vc.replace('cpac-box-column-meta-',''); 146 if ( id ) 147 ids.push(id); 148 } 149 }); 150 }); 151 152 // ...and sort them 153 ids.sort(sortNumber); 154 155 if ( !ids ) 156 return; 157 158 function sortNumber(a,b) { 159 return b - a; 160 } 161 162 // ID's 163 var id = parseFloat(ids[0]); 164 var new_id = id + 1; 165 166 // Clone 167 var clone = $( '.cpac-box-column-meta-' + id, list ).clone(); 168 169 // Toggle class 170 $(clone).removeClass('cpac-box-column-meta-' + id ); 171 $(clone).addClass('cpac-box-column-meta-' + new_id ); 172 173 // Replace inputs ID's 174 var inputs = $(clone).find('input, select'); 175 $(inputs).each(function(ik, iv){ 176 $(iv).attr('name', $(iv).attr('name').replace(id, new_id) ); 177 }); 178 179 // Replace label ID's 180 var labels = $(clone).find('label'); 181 $(labels).each(function(ik, iv){ 182 var attr_for = $(iv).attr('for'); 183 if ( attr_for ) { 184 $(iv).attr('for', attr_for.replace(id, new_id) ); 143 185 } 144 }); 145 }); 146 147 // ...and sort them 148 ids.sort(sortNumber); 149 150 if ( !ids ) 151 return; 152 153 function sortNumber(a,b) { 154 return b - a; 155 } 156 157 // ID's 158 var id = parseFloat(ids[0]); 159 var new_id = id + 1; 160 161 // Clone 162 var clone = jQuery( '.cpac-box-column-meta-' + id, list ).clone(); 163 164 // Toggle class 165 jQuery(clone).removeClass('cpac-box-column-meta-' + id ); 166 jQuery(clone).addClass('cpac-box-column-meta-' + new_id ); 167 168 // Replace inputs ID's 169 var inputs = jQuery(clone).find('input, select'); 170 jQuery(inputs).each(function(ik, iv){ 171 jQuery(iv).attr('name', jQuery(iv).attr('name').replace(id, new_id) ); 172 }); 173 174 // Replace label ID's 175 var labels = jQuery(clone).find('label'); 176 jQuery(labels).each(function(ik, iv){ 177 var attr_for = jQuery(iv).attr('for'); 178 if ( attr_for ) { 179 jQuery(iv).attr('for', attr_for.replace(id, new_id) ); 186 }); 187 188 // remove description 189 clone.find('.remove-description').remove(); 190 191 // change label text 192 clone.find('label.main-label, .cpac-type-inside input.text').text('Custom Field'); 193 clone.find('.cpac-type-inside input.text').val('Custom Field'); 194 195 // add remove button 196 if ( clone.find('.cpac-delete-custom-field-box').length == 0 ) { 197 var remove = '<p><a href="javascript:;" class="cpac-delete-custom-field-box">Remove</a>'; 198 clone.find('.cpac-type-inside').append(remove); 180 199 } 181 }); 182 183 // remove description 184 clone.find('.remove-description').remove(); 185 186 // change label text 187 clone.find('label.main-label, .cpac-type-inside input.text').text('Custom Field'); 188 clone.find('.cpac-type-inside input.text').val('Custom Field'); 189 190 // add remove button 191 if ( clone.find('.cpac-delete-custom-field-box').length == 0 ) { 192 var remove = '<p><a href="javascript:;" class="cpac-delete-custom-field-box">Remove</a>'; 193 clone.find('.cpac-type-inside').append(remove); 194 } 195 196 // add cloned box to the list 197 list.append(clone); 198 199 // retrigger click events 200 cpac_box_events(); 201 }); 202 } 203 204 /** 205 * Clear Input Defaults 206 * 207 */ 208 function cpac_clear_input_defaults() 209 { 210 jQuery.fn.cleardefault = function() { 211 return this.focus(function() { 212 if( this.value == this.defaultValue ) { 213 this.value = ""; 214 } 215 }).blur(function() { 216 if( !this.value.length ) { 217 this.value = this.defaultValue; 218 } 219 }); 220 }; 221 jQuery("#cpac-box-plugin_settings .addons input").cleardefault(); 222 } 223 224 225 /** 226 * Tooltip 227 * 228 */ 229 function cpac_tooltips() 230 { 231 jQuery('#cpac .activation_type span').each(function() { 232 var info = jQuery(this).next('.cpac-tooltip').html(); 233 234 if ( ! info ) 200 201 // add cloned box to the list 202 list.append(clone); 203 204 // retrigger click events 205 cpac_box_events(); 206 207 // re-init width range slider 208 cpac_width_range(); 209 }); 210 } 211 212 /** 213 * Clear Input Defaults 214 * 215 */ 216 function cpac_clear_input_defaults() 217 { 218 $.fn.cleardefault = function() { 219 return this.focus(function() { 220 if( this.value == this.defaultValue ) { 221 this.value = ""; 222 } 223 }).blur(function() { 224 if( !this.value.length ) { 225 this.value = this.defaultValue; 226 } 227 }); 228 }; 229 $("#cpac-box-plugin_settings .addons input").cleardefault(); 230 } 231 232 233 /** 234 * Tooltip 235 * 236 */ 237 function cpac_tooltips() 238 { 239 $('#cpac .activation_type span').each(function() { 240 var info = $(this).next('.cpac-tooltip').html(); 241 242 if ( ! info ) 243 return; 244 245 $('#cpac .activation_type span').qtip({ 246 content: info, 247 title: 'title', 248 style: { 249 width: 400, 250 padding: 0, 251 background: 'transparent', 252 color: 'black', 253 textAlign: 'left', 254 border: { 255 width: 0, 256 radius: 0 257 }, 258 tip: { 259 corner: 'topMiddle', 260 color: '#8cc1e9', 261 size: { 262 x: 32, 263 y : 15 264 } 265 } 266 }, 267 position: { 268 corner: { 269 target: 'bottomRight' 270 }, 271 adjust: { 272 x: -80, 273 y: 0 274 } 275 }, 276 hide: { 277 when: 'mouseout', 278 fixed: true , 279 delay: 100 280 } 281 }); 282 }); 283 } 284 285 /** 286 * Width range 287 * 288 */ 289 function cpac_width_range() 290 { 291 if ( $('.input-width-range').length == false ) 235 292 return; 236 293 237 jQuery('#cpac .activation_type span').qtip({ 238 content: info, 239 title: 'title', 240 style: { 241 width: 400, 242 padding: 0, 243 background: 'transparent', 244 color: 'black', 245 textAlign: 'left', 246 border: { 247 width: 0, 248 radius: 0 249 }, 250 tip: { 251 corner: 'topMiddle', 252 color: '#8cc1e9', 253 size: { 254 x: 32, 255 y : 15 294 // loop through all width-range-sliders 295 $('.input-width-range').each( function(){ 296 297 var input = $(this).closest('.cpac-type-inside').find('.input-width'); 298 var descr = $(this).closest('.cpac-type-inside').find('.width-decription'); 299 var input_default = $(input)[0].defaultValue; 300 var translation_default = descr.attr('title'); 301 302 // add slider 303 $(this).slider({ 304 range: 'min', 305 value: 1, 306 min: 0, 307 max: 100, 308 value: input_default, 309 slide: function( event, ui ) { 310 311 // set default 312 var descr_value = ui.value > 0 ? ui.value + '%' : translation_default; 313 314 // set input value 315 $(input).val( ui.value ); 316 317 // set description 318 $(descr).text( descr_value ); 319 } 320 }); 321 }); 322 } 323 324 /** 325 * Addon actviate/deactivate 326 * 327 */ 328 function cpac_addon_activation() 329 { 330 $('#cpac-box-plugin_settings .addons .activation_code a.button').click(function(e) { 331 e.preventDefault(); 332 333 // get input values 334 var row = $(this).closest('tr'); 335 var type = $(row).attr('id').replace('cpac-activation-',''); 336 var parent_class = $(this).parent('div'); 337 var msg = $(row).find('.activation-error-msg'); 338 339 // get translated string 340 var translations = $('#cpac-box-plugin_settings .addon-translation-string'); 341 var msg_fillin = $('.tstring-fill-in',translations).text(); 342 var msg_unrecognised = $('.tstring-unrecognised',translations).text(); 343 344 // reset 345 $(msg).empty(); 346 347 // Activate 348 if ( parent_class.hasClass('activate') ) { 349 350 // get input values 351 var input = $('.activate input', row); 352 var button = $('.activate .button', row); 353 var key = input.val(); 354 var default_val = $(input)[0].defaultValue; 355 356 // make sure the input value has changed 357 if ( key == default_val ) { 358 $(msg).text(msg_fillin).hide().fadeIn(); 359 return false; 360 } 361 362 // set loading icon 363 button.addClass('loading'); 364 365 // update key 366 $.ajax({ 367 url : ajaxurl, 368 type : 'POST', 369 dataType : 'json', 370 data : { 371 action : 'cpac_addon_activation', 372 type : 'sortable', 373 key : key 374 }, 375 success: function(data) { 376 if ( data != null ) { 377 $('div.activate', row).hide(); // hide activation button 378 $('div.deactivate', row).show(); // show deactivation button 379 $('div.deactivate span.masked_key', row).text(data); // display the returned masked key 380 } else { 381 $(msg).text(msg_unrecognised).hide().fadeIn(); 382 } 383 }, 384 error: function(xhr, ajaxOptions, thrownError) { 385 //console.log(xhr); 386 //console.log(ajaxOptions); 387 //console.log(thrownError); 388 $(msg).text(msg_unrecognised).hide().fadeIn(); 389 }, 390 complete: function() { 391 button.removeClass('loading'); 256 392 } 257 } 258 }, 259 position: { 260 corner: { 261 target: 'bottomRight' 262 }, 263 adjust: { 264 x: -80, 265 y: 0 266 } 267 }, 268 hide: { 269 when: 'mouseout', 270 fixed: true , 271 delay: 100 393 }); 272 394 } 273 }); 274 }); 275 } 276 277 /** 278 * Width range 279 * 280 */ 281 function cpac_width_range() 282 { 283 if ( jQuery('.input-width-range').length == false ) 284 return; 395 396 // Deactivate 397 if ( parent_class.hasClass('deactivate') ) { 398 399 var button = $('.deactivate .button', row); 400 var input = $('.activate input', row); 401 402 // set loading icon 403 button.addClass('loading'); 404 405 // update key 406 $.ajax({ 407 url : ajaxurl, 408 type : 'POST', 409 dataType : 'json', 410 data : { 411 action : 'cpac_addon_activation', 412 type : 'sortable', 413 key : 'remove' 414 }, 415 success: function(data) { 416 $('div.activate', row).show(); // show activation button 417 $('div.deactivate', row).hide(); // hide deactivation button 418 $('div.deactivate span.masked_key', row).empty(); // remove masked key 419 input.val(''); 420 }, 421 error: function(xhr, ajaxOptions, thrownError) { 422 //console.log(xhr); 423 //console.log(ajaxOptions); 424 //console.log(thrownError); 425 }, 426 complete: function() { 427 button.removeClass('loading'); 428 } 429 }); 430 } 431 }); 432 } 433 434 /** 435 * Export Settings 436 * 437 */ 438 function cpac_export() 439 { 440 // Submit Export 441 $('#cpac_export_submit').click( function(e){ 442 443 var values = []; 444 445 // get selected values 446 $('#cpac_export_types :selected').each(function(i, selected){ 447 values[i] = $(selected).val(); 448 }); 449 450 var btn = $(this); 451 var export_container = $('#cpac_export_output'); 452 var export_textarea = $('textarea', export_container); 453 var msg = btn.next('.export-message'); 454 455 // reset 456 export_container.hide(); 457 export_textarea.empty(); 458 msg.hide(); 459 460 // get export code 461 if ( values ) { 462 463 // set loading icon 464 btn.addClass('loading'); 465 466 $.ajax({ 467 url : ajaxurl, 468 type : 'POST', 469 dataType : 'json', 470 data : { 471 action : 'cpac_get_export', 472 types : values 473 }, 474 success: function(data) { 475 if ( data != null ) { 476 477 // succes 478 if ( 1 == data.status ) { 479 export_textarea.text(data.msg); 480 export_container.show(); 481 } 482 483 // fail 484 else if ( data.msg ) { 485 msg.text(data.msg).show(); 486 } 487 488 } else { 489 // error msg 490 } 491 }, 492 error: function(xhr, ajaxOptions, thrownError) {}, 493 complete: function() { 494 btn.removeClass('loading'); 495 } 496 }); 497 } 498 499 e.preventDefault; 500 }); 501 502 // Select Export Code 503 $('#cpac_export_output textarea').focus(function() { 504 var t = $(this); 505 t.select(); 506 507 t.mouseup(function() { // Work around Chrome's little problem 508 509 t.unbind("mouseup"); // Prevent further mouseup intervention 510 return false; 511 }); 512 }); 513 } 514 515 /** 516 * Import Settings 517 * 518 */ 519 function cpac_import() 520 { 521 $('#cpac_import_submit'). click( function(e){ 522 523 var btn = $(this); 524 var import_code = $('#cpac_import_input textarea').val(); 525 var msg = btn.next('.import-message'); 526 527 btn.addClass('loading'); 528 msg.hide(); 529 530 if ( import_code ) { 531 532 $.ajax({ 533 url : ajaxurl, 534 type : 'POST', 535 dataType : 'json', 536 data : { 537 action : 'cpac_import', 538 import_code : import_code 539 }, 540 success: function(data) { 541 if ( data != null ) { 542 543 // succes 544 if ( 1 == data.status ) { 545 msg.html(data.msg).show(); 546 } 547 548 // fail 549 else if ( data.msg ) { 550 msg.text(data.msg).show(); 551 } 552 } 553 554 else { 555 msg.text('error').show(); 556 } 557 }, 558 error: function(xhr, ajaxOptions, thrownError) {}, 559 complete: function() { 560 btn.removeClass('loading'); 561 } 562 }); 563 } 564 565 else { 566 btn.removeClass('loading'); 567 msg.text('empty').show(); 568 } 569 570 e.preventDefault; 571 }); 572 573 // Select Import Code 574 $('#cpac_import_input textarea').focus(function() { 575 var t = $(this); 576 t.select(); 577 578 t.mouseup(function() { // Work around Chrome's little problem 579 580 t.unbind("mouseup"); // Prevent further mouseup intervention 581 return false; 582 }); 583 }); 584 } 285 585 286 // loop through all width-range-sliders 287 jQuery('.input-width-range').each( function(){ 288 289 var input = jQuery(this).closest('.cpac-type-inside').find('.input-width'); 290 var descr = jQuery(this).closest('.cpac-type-inside').find('.width-decription'); 291 var input_default = jQuery(input)[0].defaultValue; 292 var translation_default = descr.attr('title'); 293 294 // add slider 295 jQuery(this).slider({ 296 range: 'min', 297 value: 1, 298 min: 0, 299 max: 100, 300 value: input_default, 301 slide: function( event, ui ) { 302 303 // set default 304 var descr_value = ui.value > 0 ? ui.value + '%' : translation_default; 305 306 // set input value 307 jQuery(input).val( ui.value ); 308 309 // set description 310 jQuery(descr).text( descr_value ); 311 } 312 }); 313 }); 314 } 315 316 /** 317 * Addon actviate/deactivate 318 * 319 */ 320 function cpac_addon_activation() 321 { 322 jQuery('#cpac-box-plugin_settings .addons .activation_code a.button').click(function(e) { 323 e.preventDefault(); 324 325 // get input values 326 var row = jQuery(this).closest('tr'); 327 var type = jQuery(row).attr('id').replace('cpac-activation-',''); 328 var parent_class = jQuery(this).parent('div'); 329 var msg = jQuery(row).find('.activation-error-msg'); 330 331 // get translated string 332 var translations = jQuery('#cpac-box-plugin_settings .addon-translation-string'); 333 var msg_fillin = jQuery('.tstring-fill-in',translations).text(); 334 var msg_unrecognised = jQuery('.tstring-unrecognised',translations).text(); 335 336 // reset 337 jQuery(msg).empty(); 338 339 // Activate 340 if ( parent_class.hasClass('activate') ) { 341 342 // get input values 343 var input = jQuery('.activate input', row); 344 var button = jQuery('.activate .button', row); 345 var key = input.val(); 346 var default_val = jQuery(input)[0].defaultValue; 347 348 // make sure the input value has changed 349 if ( key == default_val ) { 350 jQuery(msg).text(msg_fillin).hide().fadeIn(); 351 return false; 352 } 353 354 // set loading icon 355 button.addClass('loading'); 356 357 // update key 358 jQuery.ajax({ 359 url : ajaxurl, 360 type : 'POST', 361 dataType : 'json', 362 data : { 363 action : 'cpac_addon_activation', 364 type : 'sortable', 365 key : key 366 }, 367 success: function(data) { 368 if ( data != null ) { 369 jQuery('div.activate', row).hide(); // hide activation button 370 jQuery('div.deactivate', row).show(); // show deactivation button 371 jQuery('div.deactivate span.masked_key', row).text(data); // display the returned masked key 372 } else { 373 jQuery(msg).text(msg_unrecognised).hide().fadeIn(); 374 } 375 }, 376 error: function(xhr, ajaxOptions, thrownError) { 377 //console.log(xhr); 378 //console.log(ajaxOptions); 379 //console.log(thrownError); 380 jQuery(msg).text(msg_unrecognised).hide().fadeIn(); 381 }, 382 complete: function() { 383 button.removeClass('loading'); 384 } 385 }); 386 } 387 388 // Deactivate 389 if ( parent_class.hasClass('deactivate') ) { 390 391 var button = jQuery('.deactivate .button', row); 392 var input = jQuery('.activate input', row); 393 394 // set loading icon 395 button.addClass('loading'); 396 397 // update key 398 jQuery.ajax({ 399 url : ajaxurl, 400 type : 'POST', 401 dataType : 'json', 402 data : { 403 action : 'cpac_addon_activation', 404 type : 'sortable', 405 key : 'remove' 406 }, 407 success: function(data) { 408 jQuery('div.activate', row).show(); // show activation button 409 jQuery('div.deactivate', row).hide(); // hide deactivation button 410 jQuery('div.deactivate span.masked_key', row).empty(); // remove masked key 411 input.val(''); 412 }, 413 error: function(xhr, ajaxOptions, thrownError) { 414 //console.log(xhr); 415 //console.log(ajaxOptions); 416 //console.log(thrownError); 417 }, 418 complete: function() { 419 button.removeClass('loading'); 420 } 421 }); 422 } 423 }); 424 } 586 /** 587 * WP Pointer 588 * 589 * credits to ACF ( Elliot Condon ) 590 */ 591 function cpac_pointer() 592 { 593 $('a.cpac-pointer').each(function(){ 594 595 // vars 596 var a = $(this), 597 html = a.attr('rel'); 598 599 // create pointer 600 a.pointer({ 601 content: $('#' + html).html(), 602 position: { 603 my: 'left bottom', 604 at: 'left top', 605 edge: 'bottom', 606 }, 607 close: function() { 608 a.removeClass('open'); 609 } 610 }); 611 612 // click 613 a.click( function() { 614 if( a.hasClass('open') ) { 615 a.removeClass('open'); 616 } 617 else { 618 a.addClass('open'); 619 } 620 }); 621 622 // show on hover 623 a.hover( function() { 624 $(this).pointer('open'); 625 }, function() { 626 if( ! a.hasClass('open') ) { 627 $(this).pointer('close'); 628 } 629 630 }); 631 }); 632 } 633 634 })(jQuery); -
codepress-admin-columns/trunk/classes/sortable.php
r601892 r637026 11 11 private $post_types, 12 12 $unlocked, 13 $show_all_results; 13 $show_all_results, 14 $current_user_id; 14 15 15 16 /** … … 30 31 public function init() 31 32 { 33 $licence = new cpac_licence('sortable'); 34 32 35 // vars 33 $this->unlocked = $ this->is_unlocked('sortable');36 $this->unlocked = $licence->is_unlocked(); 34 37 $this->post_types = Codepress_Admin_Columns::get_post_types(); 35 38 $this->show_all_results = false; 39 $this->current_user_id = get_current_user_id(); 36 40 37 41 // init sorting … … 61 65 62 66 /** Posts */ 63 foreach ( $this->post_types as $post_type ) 67 foreach ( $this->post_types as $post_type ) { 64 68 add_filter( "manage_edit-{$post_type}_sortable_columns", array($this, 'callback_add_sortable_posts_column')); 69 } 65 70 66 71 /** Users */ … … 86 91 global $post_type; 87 92 93 // in some cases post_type is an array ( when clicking a tag inside the overview screen icm CCTM ), then we use this as a fallback so we get a string 94 if ( is_array($post_type) ) 95 $post_type = $_REQUEST['post_type']; 96 88 97 return $this->add_managed_sortable_columns($post_type, $columns); 89 98 } … … 135 144 */ 136 145 private function add_managed_sortable_columns( $type = 'post', $columns ) 137 { 146 { 138 147 $display_columns = $this->get_merged_columns($type); 139 148 … … 178 187 return $vars; 179 188 } 180 181 /**182 * Get the default sorting of the column183 *184 * The default sorting of the column is saved to it's property default_order.185 * We will overwrite the requested 'order' and 'orderby' variables with the default_order.186 *187 * @since 1.4.5188 */189 function get_default_sorting_vars( $type, $vars )190 {191 // retrieve the default_order of this type192 $db_columns = Codepress_Admin_Columns::get_stored_columns($type);193 194 if ( $db_columns ) {195 foreach ( $db_columns as $column ) {196 if ( empty($column['default_order'] ) )197 continue;198 199 // overwrite with the new defaults200 $vars['orderby'] = $this->sanitize_string($column['label']);201 $vars['order'] = $column['default_order'];202 }203 }204 205 return $vars;206 }207 189 208 190 /** … … 212 194 */ 213 195 public function handle_requests_orderby_users_column($user_query) 214 { 196 { 215 197 // query vars 216 $vars = $user_query->query_vars; 198 $vars = $user_query->query_vars; 217 199 218 200 // Column … … 336 318 endswitch; 337 319 338 // save the order you last used as the default339 // $this->save_sorting_preference( 'wp-users', $type, strtolower($vars['order']) );340 341 320 if ( isset($sort_flag) ) { 342 321 $user_query = $this->get_users_query_vars( $user_query, $cusers, $sort_flag ); … … 368 347 { 369 348 global $wpdb; 349 350 // apply sorting preference 351 $this->apply_sorting_preference( $vars, 'wp-links' ); 370 352 371 353 // Column … … 573 555 */ 574 556 private function get_orderby_media_vars($vars) 575 { 576 // apply default sorting when it has been set 577 if ( empty( $vars['orderby'] ) ) { 578 $vars = $this->get_default_sorting_vars( 'wp-media', $vars ); 579 580 // when sorting still isn't set we will just return the requested vars 581 if ( empty( $vars['orderby'] ) ) 582 return $vars; 583 } 557 { 558 // apply sorting preference 559 $this->apply_sorting_preference( $vars, 'wp-media' ); 560 561 // when sorting still isn't set we will just return the requested vars 562 if ( empty( $vars['orderby'] ) ) 563 return $vars; 584 564 585 565 // Column … … 693 673 endswitch; 694 674 695 // save the order you last used as the default696 $this->save_sorting_preference( 'wp-media', $id, $vars['order'] );697 698 675 // we will add the sorted post ids to vars['post__in'] and remove unused vars 699 676 if ( isset($sort_flag) ) { … … 710 687 */ 711 688 private function get_orderby_posts_vars($vars) 712 { 689 { 713 690 $post_type = $vars['post_type']; 714 691 715 // todo: fix default sorting 716 // apply default sorting when it has been set 717 if ( empty( $vars['orderby'] ) ) { 718 $vars = $this->get_default_sorting_vars( $post_type, $vars ); 719 720 // when sorting still isn't set we will just return the requested vars 721 if ( empty( $vars['orderby'] ) ) 722 return $vars; 692 // apply sorting preference 693 $this->apply_sorting_preference( $vars, $post_type ); 694 695 // no sorting 696 if ( empty( $vars['orderby'] ) ) { 697 return $vars; 723 698 } 724 699 … … 736 711 $type = 'column-taxonomy'; 737 712 738 // custom fields713 // Check for Custom Field 739 714 if ( Codepress_Admin_Columns::is_column_meta($type) ) 740 715 $type = 'column-post-meta'; 741 742 // attachments 743 if ( $type == 'column-attachment-count' ) 744 $type = 'column-attachment'; 745 716 746 717 // var 747 718 $cposts = array(); … … 809 780 810 781 case 'column-attachment' : 782 case 'column-attachment-count' : 811 783 $sort_flag = SORT_NUMERIC; 812 784 foreach ( $this->get_any_posts_by_posttype($post_type) as $p ) { … … 919 891 break; 920 892 921 endswitch; 922 923 // save the order you last used as the default 924 $this->save_sorting_preference( $post_type, $type, $vars['order'] ); 925 893 endswitch; 894 926 895 // we will add the sorted post ids to vars['post__in'] and remove unused vars 927 896 if ( isset($sort_flag) ) { 928 897 $vars = $this->get_vars_post__in( $vars, $cposts, $sort_flag ); 929 898 } 930 899 931 900 return $vars; 932 901 } 933 902 934 903 /** 935 * S avesorting preference904 * Set sorting preference 936 905 * 937 906 * after sorting we will save this sorting preference to the column item … … 939 908 * only ONE column item PER type can have a default_order 940 909 * 941 * @since 1.4.5 942 */ 943 function save_sorting_preference( $type, $column_type, $order = 'asc' ) 944 { 945 $options = get_option('cpac_options'); 946 if ( isset($options['columns'][$type][$column_type]) ) { 947 948 // remove the old default_order 949 foreach ($options['columns'][$type] as $k => $v) { 950 if ( isset( $options['columns'][$type][$k]['default_order'] ) ) { 951 unset($options['columns'][$type][$k]['default_order']); 952 } 910 * @since 1.4.6.5 911 */ 912 function set_sorting_preference( $type, $orderby = '', $order = 'asc' ) 913 { 914 if ( !$orderby ) 915 return false; 916 917 $options = get_user_meta( $this->current_user_id, 'cpac_sorting_preference', true ); 918 919 $options[$type] = array( 920 'orderby' => $orderby, 921 'order' => $order 922 ); 923 924 update_user_meta( $this->current_user_id, 'cpac_sorting_preference', $options ); 925 } 926 927 /** 928 * Get sorting preference 929 * 930 * The default sorting of the column is saved to it's property default_order. 931 * Returns the orderby and order value of that column. 932 * 933 * @since 1.4.6.5 934 */ 935 function get_sorting_preference( $type ) 936 { 937 $options = get_user_meta( $this->current_user_id, 'cpac_sorting_preference', true ); 938 939 if ( empty($options[$type]) ) 940 return false; 941 942 return $options[$type]; 943 } 944 945 /** 946 * Apply sorting preference 947 * 948 * @since 1.4.6.5 949 */ 950 function apply_sorting_preference( &$vars, $type ) 951 { 952 // user has not sorted 953 if ( empty( $vars['orderby'] ) ) { 954 955 // did the user sorted this column some other time? 956 if ( $preference = $this->get_sorting_preference($type) ) { 957 $vars['orderby'] = $preference['orderby']; 958 $vars['order'] = $preference['order']; 959 960 // used by active state in column header 961 $_GET['orderby'] = $preference['orderby']; 962 $_GET['order'] = $preference['order']; 953 963 } 954 955 // set the new default order 956 $options['columns'][$type][$column_type]['default_order'] = $order; 957 958 // save to DB 959 update_option('cpac_options', $options); 964 } 965 966 // save the order preference 967 if ( !empty( $vars['orderby'] ) ) { 968 $this->set_sorting_preference( $type, $vars['orderby'], $vars['order'] ); 960 969 } 961 970 } … … 1020 1029 */ 1021 1030 private function get_orderby_type($orderby, $type) 1022 { 1031 { 1023 1032 $db_columns = Codepress_Admin_Columns::get_stored_columns($type); 1024 1033 -
codepress-admin-columns/trunk/classes/utility.php
r601892 r637026 5 5 * 6 6 * The added columns from WordPress SEO by Yoast weren't available on 7 * the admin columns settings page. The eason was that class-metabox.php was prevented7 * the admin columns settings page. The reason was that class-metabox.php was prevented 8 8 * from loading. This fix will also load this class when admin columns is loaded. 9 9 * … … 15 15 16 16 if ( 17 isset( $_REQUEST['page']) &&17 isset( $_REQUEST['page'] ) && 18 18 'codepress-admin-columns' == $_REQUEST['page'] && 19 19 'options-general.php' == $pagenow && 20 defined('WPSEO_PATH') && 21 file_exists(WPSEO_PATH.'admin/class-metabox.php') 20 defined('WPSEO_PATH') && file_exists(WPSEO_PATH.'admin/class-metabox.php') 22 21 ) { 23 22 require_once WPSEO_PATH.'admin/class-metabox.php'; -
codepress-admin-columns/trunk/classes/values.php
r601892 r637026 20 20 // number of words 21 21 $this->excerpt_length = 20; 22 $this->thumbnail_size = apply_filters( 'cpac_thumbnail_size', array(80,80) ); 22 $this->thumbnail_size = apply_filters( 'cpac_thumbnail_size', array(80,80) ); 23 23 } 24 24 … … 239 239 } 240 240 241 /** Media */ 242 if ( $meta_type == 'media' ) { 243 $type = 'wp-media'; 244 $meta_type = 'post'; 245 } 246 241 247 /** Posts */ 242 248 else { … … 273 279 274 280 // Image 275 case "image" : 281 case "image" : 276 282 $meta = $this->get_thumbnail($meta); 277 283 break; … … 317 323 break; 318 324 325 // Color 326 case "color" : 327 if ( !empty($meta) ) { 328 $meta = "<div class='cpac-color'><span style='background-color:{$meta}'></span>{$meta}</div>"; 329 } 330 break; 331 319 332 endswitch; 320 333 … … 323 336 324 337 // add before and after string 325 $meta = "{$before}{$meta}{$after}"; 338 if ( $meta ) { 339 $meta = "{$before}{$meta}{$after}"; 340 } 326 341 327 342 return $meta; … … 493 508 return false; 494 509 510 return date_i18n( get_option('date_format'), strtotime($date) ); 511 } 512 513 /** 514 * Get time 515 * 516 * @since 1.3.1 517 */ 518 protected function get_time($date) 519 { 520 if ( ! $date ) 521 return false; 522 495 523 if ( ! is_numeric($date) ) 496 524 $date = strtotime($date); 497 498 return date_i18n( get_option('date_format'), $date );499 }500 501 /**502 * Get time503 *504 * @since 1.3.1505 */506 protected function get_time($date)507 {508 if ( ! $date )509 return false;510 511 if ( ! is_numeric($date) )512 $date = strtotime($date);513 525 514 526 return date_i18n( get_option('time_format'), $date ); -
codepress-admin-columns/trunk/classes/values/media.php
r585114 r637026 125 125 // Custom Field 126 126 case "column-meta" : 127 $result = $this->get_column_value_custom_field($media_id, $column_name, ' post');127 $result = $this->get_column_value_custom_field($media_id, $column_name, 'media'); 128 128 break; 129 129 -
codepress-admin-columns/trunk/codepress-admin-columns.php
r601892 r637026 3 3 4 4 Plugin Name: Codepress Admin Columns 5 Version: 1.4. 6.45 Version: 1.4.7 6 6 Description: Customise columns on the administration screens for post(types), pages, media, comments, links and users with an easy to use drag-and-drop interface. 7 7 Author: Codepress … … 28 28 */ 29 29 30 define( 'CPAC_VERSION', '1.4. 6.4' );30 define( 'CPAC_VERSION', '1.4.7' ); 31 31 define( 'CPAC_TEXTDOMAIN', 'codepress-admin-columns' ); 32 32 define( 'CPAC_SLUG', 'codepress-admin-columns' ); … … 50 50 require_once dirname( __FILE__ ) . '/classes/values/link.php'; 51 51 require_once dirname( __FILE__ ) . '/classes/values/comments.php'; 52 require_once dirname( __FILE__ ) . '/classes/license.php'; 52 53 53 54 /** … … 117 118 // action ajax 118 119 add_action( 'wp_ajax_cpac_addon_activation', array( $this, 'ajax_activation')); 119 120 120 121 // handle requests gets a low priority so it will trigger when all other plugins have loaded their columns 121 122 add_action( 'admin_init', array( $this, 'handle_requests' ), 1000 ); … … 161 162 * Add Settings link to plugin page 162 163 * 163 * @since 1.0 164 * @since 1.0 165 * @param $links string - all settings links 166 * @param $file string - plugin filename 167 * @return string - link to settings page 164 168 */ 165 169 function add_settings_link( $links, $file ) … … 267 271 } 268 272 273 274 275 /** 276 * Add managed columns by Type 277 * 278 * @since 1.4.6.5 279 */ 280 private function get_comment_icon() 281 { 282 return "<span class='vers'><img src='" . trailingslashit( get_admin_url() ) . 'images/comment-grey-bubble.png' . "' alt='Comments'></span>"; 283 } 284 269 285 /** 270 286 * Add managed columns by Type … … 288 304 if ( isset($values['state']) && $values['state'] == 'on' ){ 289 305 306 $label = $values['label']; 307 308 // exception for comments 309 if( 'comments' == $id ) { 310 $label = $this->get_comment_icon(); 311 } 312 290 313 // register format 291 $set_columns[$id] = $ values['label'];314 $set_columns[$id] = $label; 292 315 } 293 316 } … … 342 365 foreach ( $display_columns as $id => $values ) { 343 366 344 // add items to the list 345 $list .= $this->get_box($type, $id, $values); 346 367 $classes = array(); 368 369 // set state 370 $state = isset($values['state']) ? $values['state'] : ''; 371 372 // class 373 $classes[] = "cpac-box-{$id}"; 374 if ( $state ) { 375 $classes[] = 'active'; 376 } 377 if ( ! empty($values['options']['class']) ) { 378 $classes[] = $values['options']['class']; 379 } 380 $class = implode(' ', $classes); 381 382 // more box options 383 $more_options = $this->get_additional_box_options($type, $id, $values); 384 $action = "<a class='cpac-action' href='#open'>open</a>"; 385 386 // type label 387 $type_label = isset($values['options']['type_label']) ? $values['options']['type_label'] : ''; 388 389 // label 390 $label = isset($values['label']) ? str_replace("'", '"', $values['label']) : ''; 391 392 // main label 393 $main_label = $values['label']; 394 395 // main label exception for comments 396 if ( 'comments' == $id ) { 397 $main_label = $this->get_comment_icon(); 398 } 399 400 // width 401 $width = isset($values['width']) ? $values['width'] : 0; 402 $width_descr = isset($values['width']) && $values['width'] > 0 ? $values['width'] . '%' : __('default', CPAC_TEXTDOMAIN); 403 404 // hide box options 405 $label_hidden = ''; 406 if ( ! empty($values['options']['hide_options']) || strpos($label, '<img') !== false ) { 407 $label_hidden = ' style="display:none"'; 408 } 409 410 $list .= " 411 <li class='{$class}'> 412 <div class='cpac-sort-handle'></div> 413 <div class='cpac-type-options'> 414 <div class='cpac-checkbox'></div> 415 <input type='hidden' class='cpac-state' name='cpac_options[columns][{$type}][{$id}][state]' value='{$state}'/> 416 <label class='main-label'>{$main_label}</label> 417 </div> 418 <div class='cpac-meta-title'> 419 {$action} 420 <span>{$type_label}</span> 421 </div> 422 <div class='cpac-type-inside'> 423 <label for='cpac_options-{$type}-{$id}-label'{$label_hidden}>Label: </label> 424 <input type='text' name='cpac_options[columns][{$type}][{$id}][label]' id='cpac_options-{$type}-{$id}-label' value='{$label}' class='text'{$label_hidden}/> 425 <label for='cpac_options-{$type}-{$id}-width'>" . __('Width', CPAC_TEXTDOMAIN) . ":</label> 426 <input type='hidden' maxlength='4' class='input-width' name='cpac_options[columns][{$type}][{$id}][width]' id='cpac_options-{$type}-{$id}-width' value='{$width}' /> 427 <div class='description width-decription' title='" . __('default', CPAC_TEXTDOMAIN) . "'>{$width_descr}</div> 428 <div class='input-width-range'></div> 429 <br/> 430 {$more_options} 431 </div> 432 </li> 433 "; 347 434 } 348 435 } … … 483 570 // class 484 571 $classes[] = "cpac-box-{$id}"; 485 if ( $state ) 572 if ( $state ) { 486 573 $classes[] = 'active'; 487 if ( ! empty($values['options']['class']) ) 574 } 575 if ( ! empty($values['options']['class']) ) { 488 576 $classes[] = $values['options']['class']; 577 } 489 578 $class = implode(' ', $classes); 490 579 … … 498 587 // label 499 588 $label = isset($values['label']) ? str_replace("'", '"', $values['label']) : ''; 589 590 // main label 591 $main_label = $values['label']; 592 593 // main label exception for comments 594 if ( 'comments' == $id ) { 595 $main_label = $this->get_comment_icon(); 596 } 500 597 501 598 // width … … 515 612 <div class='cpac-checkbox'></div> 516 613 <input type='hidden' class='cpac-state' name='cpac_options[columns][{$type}][{$id}][state]' value='{$state}'/> 517 <label class='main-label'>{$ values['label']}</label>614 <label class='main-label'>{$main_label}</label> 518 615 </div> 519 616 <div class='cpac-meta-title'> … … 524 621 <label for='cpac_options-{$type}-{$id}-label'{$label_hidden}>Label: </label> 525 622 <input type='text' name='cpac_options[columns][{$type}][{$id}][label]' id='cpac_options-{$type}-{$id}-label' value='{$label}' class='text'{$label_hidden}/> 526 <label for='cpac_options-{$type}-{$id}-width'>" .__('Width', CPAC_TEXTDOMAIN).":</label>623 <label for='cpac_options-{$type}-{$id}-width'>" . __('Width', CPAC_TEXTDOMAIN) . ":</label> 527 624 <input type='hidden' maxlength='4' class='input-width' name='cpac_options[columns][{$type}][{$id}][width]' id='cpac_options-{$type}-{$id}-width' value='{$width}' /> 528 <div class='description width-decription' title='" .__('default', CPAC_TEXTDOMAIN)."'>{$width_descr}</div>625 <div class='description width-decription' title='" . __('default', CPAC_TEXTDOMAIN) . "'>{$width_descr}</div> 529 626 <div class='input-width-range'></div> 530 627 <br/> … … 602 699 'user_by_id' => __('Username (User ID\'s)', CPAC_TEXTDOMAIN), 603 700 'checkmark' => __('Checkmark (true/false)', CPAC_TEXTDOMAIN), 701 'color' => __('Color', CPAC_TEXTDOMAIN), 604 702 ); 605 703 … … 709 807 /** Media */ 710 808 elseif ( $type == 'wp-media') { 711 $sql = $wpdb->prepare( "SELECT DISTINCT meta_key FROM {$wpdb->postmeta} pm JOIN {$wpdb->posts} p ON pm.post_id = p.ID WHERE p.post_type = 'attachment' ORDER BY 1");809 $sql = "SELECT DISTINCT meta_key FROM {$wpdb->postmeta} pm JOIN {$wpdb->posts} p ON pm.post_id = p.ID WHERE p.post_type = 'attachment' ORDER BY 1"; 712 810 } 713 811 … … 750 848 public function admin_scripts() 751 849 { 850 wp_enqueue_script( 'wp-pointer' ); 752 851 wp_enqueue_script( 'jquery-ui-slider' ); 753 852 wp_enqueue_script( 'cpac-qtip2', CPAC_URL.'/assets/js/jquery.qtip.js', array('jquery'), CPAC_VERSION ); … … 760 859 * @since 1.1 761 860 */ 762 private function get_types() 861 private function get_types() 763 862 { 764 863 $types = $this->post_types; … … 794 893 public function admin_styles() 795 894 { 895 wp_enqueue_style( 'wp-pointer' ); 796 896 wp_enqueue_style( 'jquery-ui-lightness', CPAC_URL.'/assets/ui-theme/jquery-ui-1.8.18.custom.css', array(), CPAC_VERSION, 'all' ); 797 897 wp_enqueue_style( 'cpac-admin', CPAC_URL.'/assets/css/admin-column.css', array(), CPAC_VERSION, 'all' ); … … 816 916 { 817 917 // If we have no options in the database, let's add them now. 818 if ( false === get_option('cpac_options') ) 819 add_option( 'cpac_options', array($this, 'get_default_plugin_options') ); 918 if ( false === get_option('cpac_options') ) { 919 add_option( 'cpac_options', $this->get_default_plugin_options() ); 920 } 820 921 821 922 register_setting( 'cpac-settings-group', 'cpac_options', array($this, 'options_callback') ); … … 829 930 public function get_default_plugin_options() 830 931 { 831 $default_plugin_options = array( 832 'post' => '', 833 'page' => '' 834 ); 835 return apply_filters( 'cpac_default_plugin_options', $default_plugin_options ); 932 return apply_filters( 'cpac_default_plugin_options', array() ); 836 933 } 837 934 … … 852 949 */ 853 950 public function handle_requests() 854 { 855 // settings updated 856 if ( ! empty($_REQUEST['settings-updated']) ) 857 $this->store_wp_default_columns(); 858 859 // restore defaults 860 if ( ! empty($_REQUEST['cpac-restore-defaults']) ) 861 $this->restore_defaults(); 862 951 { 952 // only handle updates from the admin columns page 953 if ( isset($_REQUEST['page']) && CPAC_SLUG == $_REQUEST['page'] ) { 954 955 // settings updated 956 if ( ! empty($_REQUEST['settings-updated']) ) { 957 $this->store_wp_default_columns(); 958 } 959 960 // restore defaults 961 if ( ! empty($_REQUEST['cpac-restore-defaults']) ) { 962 $this->restore_defaults(); 963 } 964 } 863 965 } 864 966 … … 967 1069 */ 968 1070 private function get_wp_default_posts_columns($post_type = 'post') 969 { 1071 { 1072 // we need to change the current screen 1073 global $current_screen; 1074 970 1075 // some plugins depend on settings the $_GET['post_type'] variable such as ALL in One SEO 971 1076 $_GET['post_type'] = $post_type; 972 1077 1078 // to prevent possible warning from initializing load-edit.php 1079 // we will set a dummy screen object 1080 if ( empty($current_screen->post_type) ) { 1081 $current_screen = (object) array( 'post_type' => $post_type, 'id' => '', 'base' => '' ); 1082 } 1083 973 1084 // for 3rd party plugin support we will call load-edit.php so all the 974 // additional columns that are set by them will be avaible for us 1085 // additional columns that are set by them will be avaible for us 975 1086 do_action('load-edit.php'); 976 1087 … … 993 1104 require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php'); 994 1105 if ( file_exists(ABSPATH . 'wp-admin/includes/class-wp-posts-list-table.php') ) 995 require_once(ABSPATH . 'wp-admin/includes/class-wp-posts-list-table.php'); 996 997 // we need to change the current screen 998 global $current_screen; 999 1000 // save original 1001 $org_current_screen = $current_screen; 1002 1003 // prevent php warning 1004 if ( !isset($current_screen) ) $current_screen = new stdClass; 1005 1006 // overwrite current_screen global with our post type of choose... 1007 $current_screen->post_type = $post_type; 1008 1009 // ...so we can get its columns 1010 $columns = WP_Posts_List_Table::get_columns(); 1011 1012 // reset current screen 1013 $current_screen = $org_current_screen; 1014 1106 require_once(ABSPATH . 'wp-admin/includes/class-wp-posts-list-table.php'); 1107 1108 // As of WP Release 3.5 we can use the following. 1109 if ( version_compare( get_bloginfo('version'), '3.4.10', '>=' ) ) { 1110 1111 $table = new WP_Posts_List_Table( array( 'screen' => $post_type ) ); 1112 $columns = $table->get_columns(); 1113 } 1114 1115 // WP versions older then 3.5 1116 // @todo: make this deprecated 1117 else { 1118 1119 // we need to change the current screen... first lets save original 1120 $org_current_screen = $current_screen; 1121 1122 // prevent php warning 1123 if ( !isset($current_screen) ) $current_screen = new stdClass; 1124 1125 // overwrite current_screen global with our post type of choose... 1126 $current_screen->post_type = $post_type; 1127 1128 // ...so we can get its columns 1129 $columns = WP_Posts_List_Table::get_columns(); 1130 1131 // reset current screen 1132 $current_screen = $org_current_screen; 1133 } 1015 1134 } 1016 1135 … … 1062 1181 // get users columns 1063 1182 $columns = WP_Users_List_Table::get_columns(); 1064 1183 1065 1184 // change to uniform format 1066 1185 $columns = $this->get_uniform_format($columns); 1067 1186 1068 // add sorting to some of the default users columns1069 $columns = $this->set_sorting_to_default_users_columns($columns);1070 1071 1187 return apply_filters('cpac-default-users-columns', $columns); 1072 }1073 1074 /**1075 * Add Sorting to WP default Users columns1076 *1077 * @since 1.41078 */1079 private function set_sorting_to_default_users_columns($columns)1080 {1081 // Comment1082 if ( !empty($columns['role']) ) {1083 $columns['role']['options']['sortorder'] = 'on';1084 }1085 return $columns;1086 1188 } 1087 1189 … … 1099 1201 require_once(ABSPATH . 'wp-admin/includes/class-wp-media-list-table.php'); 1100 1202 1101 global $current_screen; 1102 1103 // save original 1104 $org_current_screen = $current_screen; 1105 1106 // prevent php warning 1107 if ( !isset($current_screen) ) $current_screen = new stdClass; 1108 1109 // overwrite current_screen global with our media id... 1110 $current_screen->id = 'upload'; 1111 1112 // init media class 1113 $wp_media = new WP_Media_List_Table; 1114 1115 // get media columns 1116 $columns = $wp_media->get_columns(); 1117 1118 // reset current screen 1119 $current_screen = $org_current_screen; 1203 // As of WP Release 3.5 we can use the following. 1204 if ( version_compare( get_bloginfo('version'), '3.4.10', '>=' ) ) { 1205 1206 $table = new WP_Media_List_Table(array( 'screen' => 'upload' )); 1207 $columns = $table->get_columns(); 1208 } 1209 1210 // WP versions older then 3.5 1211 // @todo: make this deprecated 1212 else { 1213 1214 global $current_screen; 1215 1216 // save original 1217 $org_current_screen = $current_screen; 1218 1219 // prevent php warning 1220 if ( !isset($current_screen) ) $current_screen = new stdClass; 1221 1222 // overwrite current_screen global with our media id... 1223 $current_screen->id = 'upload'; 1224 1225 // init media class 1226 $wp_media = new WP_Media_List_Table; 1227 1228 // get media columns 1229 $columns = $wp_media->get_columns(); 1230 1231 // reset current screen 1232 $current_screen = $org_current_screen; 1233 } 1120 1234 1121 1235 // change to uniform format 1122 return $this->get_uniform_format($columns); 1236 $columns = $this->get_uniform_format($columns); 1237 1238 return apply_filters('cpac-default-media-columns', $columns); 1123 1239 } 1124 1240 … … 1175 1291 require_once(ABSPATH . 'wp-admin/includes/class-wp-comments-list-table.php'); 1176 1292 1177 global $current_screen; 1178 1179 // save original 1180 $org_current_screen = $current_screen; 1181 1182 // prevent php warning 1183 if ( !isset($current_screen) ) $current_screen = new stdClass; 1184 1185 // overwrite current_screen global with our media id... 1186 $current_screen->id = 'edit-comments'; 1187 1188 // init table object 1189 $wp_comment = new WP_Comments_List_Table; 1190 1191 // get comments 1192 $columns = $wp_comment->get_columns(); 1193 1194 // reset current screen 1195 $current_screen = $org_current_screen; 1293 // As of WP Release 3.5 we can use the following. 1294 if ( version_compare( get_bloginfo('version'), '3.4.10', '>=' ) ) { 1295 1296 $table = new WP_Comments_List_Table( array( 'screen' => 'edit-comments' ) ); 1297 $columns = $table->get_columns(); 1298 } 1299 1300 // WP versions older then 3.5 1301 // @todo: make this deprecated 1302 else { 1303 1304 global $current_screen; 1305 1306 // save original 1307 $org_current_screen = $current_screen; 1308 1309 // prevent php warning 1310 if ( !isset($current_screen) ) $current_screen = new stdClass; 1311 1312 // overwrite current_screen global with our media id... 1313 $current_screen->id = 'edit-comments'; 1314 1315 // init table object 1316 $wp_comment = new WP_Comments_List_Table; 1317 1318 // get comments 1319 $columns = $wp_comment->get_columns(); 1320 1321 // reset current screen 1322 $current_screen = $org_current_screen; 1323 } 1196 1324 1197 1325 // change to uniform format … … 1235 1363 $type_label = $label; 1236 1364 1237 // comment exception 1238 if ( strpos( $label, 'comment-grey-bubble.png') ) { 1365 // comment exception 1366 if ( 'comments' == $id ) { 1367 $label = ''; 1239 1368 $type_label = __('Comments', CPAC_TEXTDOMAIN); 1240 1369 $hide_options = true; … … 1246 1375 } 1247 1376 1248 $uniform_colum s[$id] = array(1377 $uniform_columns[$id] = array( 1249 1378 'label' => $label, 1250 1379 'state' => 'on', … … 1256 1385 ); 1257 1386 } 1258 return $uniform_colum s;1387 return $uniform_columns; 1259 1388 } 1260 1389 … … 1748 1877 'label' => '', // custom label 1749 1878 'state' => '', // display state 1750 'width' => '', // column width 1751 'default_order' => '', // set default sorting: asc, desc or empty 1879 'width' => '', // column width 1752 1880 1753 1881 // static values … … 2022 2150 * @since 1.4 2023 2151 */ 2024 function admin_class( )2152 function admin_class( $classes ) 2025 2153 { 2026 2154 global $current_screen; … … 2044 2172 // match against screen or wp-screen 2045 2173 if ( $type == $screen || $type == "wp-{$screen}" ) 2046 return "cp-{$type}"; 2047 } 2048 return false; 2049 } 2174 $classes .= " cp-{$type}"; 2175 } 2176 2177 return $classes; 2178 } 2179 2050 2180 2051 2181 /** … … 2076 2206 echo "<style type='text/css'>{$css}</style>"; 2077 2207 } 2078 2079 /**2080 * Unlocks2081 *2082 * @since 1.32083 */2084 protected function is_unlocked($type)2085 {2086 return preg_match('/^[a-f0-9]{40}$/i', $this->get_license_key($type));2087 }2088 2089 /**2090 * Check license key with API2091 *2092 * @since 1.3.32093 */2094 private function check_remote_key($type, $key)2095 {2096 if ( empty($type) || empty($key) )2097 return false;2098 2099 // check key with remote API2100 $response = wp_remote_post( $this->api_url, array(2101 'body' => array(2102 'api' => 'addon',2103 'key' => $key,2104 'type' => $type2105 )2106 ));2107 2108 // license will be valid in case of WP error or succes2109 if ( is_wp_error($response) || ( isset($response['body']) && json_decode($response['body']) == 'valid' ) )2110 return true;2111 2112 return false;2113 }2114 2115 /**2116 * Set masked license key2117 *2118 * @since 1.3.12119 */2120 private function get_masked_license_key($type)2121 {2122 return '**************************'.substr( $this->get_license_key($type), -4 );2123 }2124 2208 2125 2209 /** … … 2134 2218 $type = $_POST['type']; 2135 2219 2220 $licence = new cpac_licence( $type ); 2221 2136 2222 // update key 2137 2223 if ( $key == 'remove' ) { 2138 $ this->remove_license_key($type);2224 $licence->remove_license_key(); 2139 2225 } 2140 2226 2141 2227 // set license key 2142 elseif ( $ this->check_remote_key($type, $key) ) {2228 elseif ( $licence->check_remote_key( $key ) ) { 2143 2229 2144 2230 // set key 2145 $ this->set_license_key($type, $key);2231 $licence->set_license_key( $key ); 2146 2232 2147 2233 // returned masked key 2148 echo json_encode( $ this->get_masked_license_key($type) );2234 echo json_encode( $licence->get_masked_license_key() ); 2149 2235 } 2150 2236 2151 2237 exit; 2152 }2153 2154 /**2155 * Get license key2156 *2157 * @since 1.32158 */2159 private function get_license_key($type)2160 {2161 return get_option("cpac_{$type}_ac");2162 }2163 2164 /**2165 * Set license key2166 *2167 * @since 1.32168 */2169 private function set_license_key($type, $key)2170 {2171 update_option( "cpac_{$type}_ac", trim($key) );2172 }2173 2174 /**2175 * Remove license key2176 *2177 * @since 1.3.12178 */2179 private function remove_license_key($type)2180 {2181 delete_option( "cpac_{$type}_ac" );2182 delete_transient("cpac_{$type}_trnsnt");2183 2238 } 2184 2239 … … 2261 2316 2262 2317 /** 2263 * Activation settings2318 * Plugin Settings 2264 2319 * 2265 2320 * @since 1.3.1 2266 2321 */ 2267 private function activation_settings()2322 private function plugin_settings() 2268 2323 { 2269 2324 $class_current_settings = $this->is_menu_type_current('plugin_settings') ? ' current' : ' hidden'; ''; … … 2275 2330 2276 2331 // is unlocked 2277 if ( $this->is_unlocked('sortable') ) { 2278 $masked_key = $this->get_masked_license_key('sortable'); 2332 $licence = new cpac_licence('sortable'); 2333 2334 if ( $licence->is_unlocked() ) { 2335 $masked_key = $licence->get_masked_license_key('sortable'); 2279 2336 $class_sortorder_activate = ' hidden'; 2280 2337 $class_sortorder_deactivate = ''; … … 2294 2351 "; 2295 2352 2296 // markup 2297 $sortable = " 2298 <tr id='cpac-activation-sortable' class='last'> 2299 <td class='activation_type'> 2300 <span>" . __('Sortorder', CPAC_TEXTDOMAIN) . "</span> 2301 <div class='cpac-tooltip hidden'> 2302 <div class='qtip_title'>" . __('Sortorder', CPAC_TEXTDOMAIN) . "</div> 2303 <div class='qtip_content'> 2304 <p>" . __($sortable_tooltip, CPAC_TEXTDOMAIN) . "</p> 2353 // addons 2354 $addons = " 2355 <tr> 2356 <td colspan='2'> 2357 <h2>".__('Activate Add-ons', CPAC_TEXTDOMAIN)."</h2> 2358 <p>".__('Add-ons can be unlocked by purchasing a license key. Each key can be used on multiple sites', CPAC_TEXTDOMAIN)." <a target='_blank' href='{$this->codepress_url}/sortorder-addon/'>Visit the Plugin Store</a>.</p> 2359 <table class='widefat addons'> 2360 <thead> 2361 <tr> 2362 <th class='activation_type'>".__('Addon', CPAC_TEXTDOMAIN)."</th> 2363 <th class='activation_status'>".__('Status', CPAC_TEXTDOMAIN)."</th> 2364 <th class='activation_code'>".__('Activation Code', CPAC_TEXTDOMAIN)."</th> 2365 <th class='activation_more'></th> 2366 </tr> 2367 </thead> 2368 <tbody> 2369 <tr id='cpac-activation-sortable' class='last'> 2370 <td class='activation_type'> 2371 <span>" . __('Sortorder', CPAC_TEXTDOMAIN) . "</span> 2372 <div class='cpac-tooltip hidden'> 2373 <div class='qtip_title'>" . __('Sortorder', CPAC_TEXTDOMAIN) . "</div> 2374 <div class='qtip_content'> 2375 <p>" . __($sortable_tooltip, CPAC_TEXTDOMAIN) . "</p> 2376 </div> 2377 </div> 2378 </td> 2379 <td class='activation_status'> 2380 <div class='activate{$class_sortorder_activate}'> 2381 " . __('Inactive', CPAC_TEXTDOMAIN) . " 2382 </div> 2383 <div class='deactivate{$class_sortorder_deactivate}'> 2384 " . __('Active', CPAC_TEXTDOMAIN) . " 2385 </div> 2386 </td> 2387 <td class='activation_code'> 2388 <div class='activate{$class_sortorder_activate}'> 2389 <input type='text' value='" . __('Fill in your activation code', CPAC_TEXTDOMAIN) . "' name='cpac-sortable-key'> 2390 <a href='javascript:;' class='button'>" . __('Activate', CPAC_TEXTDOMAIN) . "<span></span></a> 2391 </div> 2392 <div class='deactivate{$class_sortorder_deactivate}'> 2393 <span class='masked_key'>{$masked_key}</span> 2394 <a href='javascript:;' class='button'>" . __('Deactivate', CPAC_TEXTDOMAIN) . "<span></span></a> 2395 </div> 2396 <div class='activation-error-msg'></div> 2397 </td> 2398 <td class='activation_more'>{$find_out_more}</td> 2399 </tr><!-- #cpac-activation-sortable --> 2400 </tbody> 2401 </table> 2402 <div class='addon-translation-string hidden'> 2403 <span class='tstring-fill-in'>" . __('Enter your activation code', CPAC_TEXTDOMAIN) . "</span> 2404 <span class='tstring-unrecognised'>" . __('Activation code unrecognised', CPAC_TEXTDOMAIN) . "</span> 2305 2405 </div> 2306 </div> 2307 </td> 2308 <td class='activation_status'> 2309 <div class='activate{$class_sortorder_activate}'> 2310 " . __('Inactive', CPAC_TEXTDOMAIN) . " 2311 </div> 2312 <div class='deactivate{$class_sortorder_deactivate}'> 2313 " . __('Active', CPAC_TEXTDOMAIN) . " 2314 </div> 2315 </td> 2316 <td class='activation_code'> 2317 <div class='activate{$class_sortorder_activate}'> 2318 <input type='text' value='" . __('Fill in your activation code', CPAC_TEXTDOMAIN) . "' name='cpac-sortable-key'> 2319 <a href='javascript:;' class='button'>" . __('Activate', CPAC_TEXTDOMAIN) . "<span></span></a> 2320 </div> 2321 <div class='deactivate{$class_sortorder_deactivate}'> 2322 <span class='masked_key'>{$masked_key}</span> 2323 <a href='javascript:;' class='button'>" . __('Deactivate', CPAC_TEXTDOMAIN) . "<span></span></a> 2324 </div> 2325 <div class='activation-error-msg'></div> 2326 </td> 2327 <td class='activation_more'>{$find_out_more}</td> 2328 </tr><!-- #cpac-activation-sortable --> 2406 </td> 2407 </tr> 2408 "; 2409 2410 // general options 2411 $general_options = " 2412 <!-- 2413 <tr class='last'> 2414 <td colspan='2'> 2415 <h2>Options</h2> 2416 <ul class='cpac-options'> 2417 <li> 2418 <div class='cpac-option-label'>Thumbnail size</div> 2419 <div class='cpac-option-inputs'> 2420 <input type='text' id='thumbnail_size_w' class='small-text' name='cpac_options[settings][thumb_width]' value='80'/> 2421 <label for='thumbnail_size_w'>Width</label> 2422 <br/> 2423 <input type='text' id='thumbnail_size_h' class='small-text' name='cpac_options[settings][thumb_height]' value='80'/> 2424 <label for='thumbnail_size_h'>Height</label> 2425 </div> 2426 </li> 2427 <li> 2428 <div class='cpac-option-label'>Excerpt length</div> 2429 <div class='cpac-option-inputs'> 2430 2431 <input type='text' id='excerpt_length' class='small-text' name='cpac_options[settings][excerpt_length]' value='15'/> 2432 <label for='excerpt_length'>Number of words</label> 2433 </div> 2434 </li> 2435 </ul> 2436 </td> 2437 </tr> 2438 --> 2329 2439 "; 2330 2440 … … 2334 2444 <td colspan='2'> 2335 2445 <table class='nopadding'> 2336 <tr class='last'> 2337 <td> 2338 <h2>".__('Activate Add-ons', CPAC_TEXTDOMAIN)."</h2> 2339 <p>".__('Add-ons can be unlocked by purchasing a license key. Each key can be used on multiple sites', CPAC_TEXTDOMAIN)." <a target='_blank' href='{$this->codepress_url}/sortorder-addon/'>Visit the Plugin Store</a>.</p> 2340 <table class='widefat addons'> 2341 <thead> 2342 <tr> 2343 <th class='activation_type'>".__('Addon', CPAC_TEXTDOMAIN)."</th> 2344 <th class='activation_status'>".__('Status', CPAC_TEXTDOMAIN)."</th> 2345 <th class='activation_code'>".__('Activation Code', CPAC_TEXTDOMAIN)."</th> 2346 <th class='activation_more'></th> 2347 </tr> 2348 </thead> 2349 <tbody> 2350 {$sortable} 2351 </tbody> 2352 </table> 2353 <div class='addon-translation-string hidden'> 2354 <span class='tstring-fill-in'>" . __('Enter your activation code', CPAC_TEXTDOMAIN) . "</span> 2355 <span class='tstring-unrecognised'>" . __('Activation code unrecognised', CPAC_TEXTDOMAIN) . "</span> 2356 </div> 2357 </td> 2358 </tr> 2359 <!-- 2360 <tr class='last'> 2361 <td colspan='2'> 2362 <h2>Options</h2> 2363 <ul class='cpac-options'> 2364 <li> 2365 <div class='cpac-option-label'>Thumbnail size</div> 2366 <div class='cpac-option-inputs'> 2367 <input type='text' id='thumbnail_size_w' class='small-text' name='cpac_options[settings][thumb_width]' value='80'/> 2368 <label for='thumbnail_size_w'>Width</label> 2369 <br/> 2370 <input type='text' id='thumbnail_size_h' class='small-text' name='cpac_options[settings][thumb_height]' value='80'/> 2371 <label for='thumbnail_size_h'>Height</label> 2372 </div> 2373 </li> 2374 <li> 2375 <div class='cpac-option-label'>Excerpt length</div> 2376 <div class='cpac-option-inputs'> 2377 2378 <input type='text' id='excerpt_length' class='small-text' name='cpac_options[settings][excerpt_length]' value='15'/> 2379 <label for='excerpt_length'>Number of words</label> 2380 </div> 2381 </li> 2382 </ul> 2383 </td> 2384 </tr> 2385 --> 2446 {$addons} 2447 {$general_options} 2386 2448 </table> 2387 2449 </td> … … 2399 2461 public static function get_post_count( $post_type, $user_id ) 2400 2462 { 2401 if ( ! post_type_exists($post_type) || ! get_userdata($user_id) ) 2463 global $wpdb; 2464 2465 if ( ! post_type_exists($post_type) || empty($user_id) ) 2402 2466 return false; 2403 2404 $user_posts = get_posts(array( 2405 'post_type' => $post_type, 2406 'numberposts' => -1, 2407 'author' => $user_id, 2408 'post_status' => 'publish' 2409 )); 2410 return count($user_posts); 2467 2468 $sql = " 2469 SELECT COUNT(ID) 2470 FROM {$wpdb->posts} 2471 WHERE post_status = 'publish' 2472 AND post_author = %d 2473 AND post_type = %s 2474 "; 2475 2476 return $wpdb->get_var( $wpdb->prepare($sql, $user_id, $post_type) ); 2411 2477 } 2412 2478 … … 2427 2493 2428 2494 // post type label 2429 $label = $this->get_singular_name($type); 2430 2431 // screen link 2432 $screen_link = ''; 2433 //$screen_link = $this->get_type_screen_link($type); 2434 //$screen_link = "<a href='{$screen_link}' class='go-to-screen'>" . sprintf( __('go to %s screen'), strtolower($label) ) . "</a>"; 2495 $label = $this->get_singular_name($type); 2435 2496 2436 2497 // id … … 2446 2507 <tr id='cpac-box-{$id}' valign='top' class='cpac-box-row{$class}'> 2447 2508 <th class='cpac_post_type' scope='row'> 2448 {$label} {$screen_link}2509 {$label} 2449 2510 </th> 2450 2511 <td> … … 2456 2517 } 2457 2518 2458 // Activation2459 $ activation_settings = $this->activation_settings();2519 // General Setttings 2520 $general_settings = $this->plugin_settings(); 2460 2521 2461 2522 // Post Type Menu … … 2557 2618 2558 2619 <!-- activation --> 2559 <?php echo $ activation_settings; ?>2620 <?php echo $general_settings; ?> 2560 2621 2561 2622 <tr class="bottom" valign="top"> -
codepress-admin-columns/trunk/readme.txt
r601892 r637026 4 4 Tags: plugins, wordpress, admin, column, columns, custom columns, custom fields, image, dashboard, sortable, filters, posts, media, users, pages, posttypes, manage columns, wp-admin 5 5 Requires at least: 3.1 6 Tested up to: 3. 4.27 Stable tag: 1.4. 6.46 Tested up to: 3.5 7 Stable tag: 1.4.7 8 8 9 9 Customise columns on the administration screens for post(types), pages, media, comments, links and users with an easy to use drag-and-drop interface. … … 164 164 165 165 add_image_size( 'admin-columns', $my_width, $my_height, true ); 166 add_filter('cpac_thumbnail_size', function() { 166 add_filter('cpac_thumbnail_size', 'cb_cpac_thumbnail_size' ); 167 function cb_cpac_thumbnail_size() { 167 168 return 'admin-columns'; 168 } );169 }; 169 170 ?> 170 171 ` … … 246 247 == Changelog == 247 248 249 = 1.4.7 = 250 * ready for WP 3.5 251 * added support for custom fields for Media 252 * added color to the custom field types 253 * fixed default sorting for Post(types) and Media 254 * fixed problem with different date formats in custom fields. all dates will parsed by strtotime() now. 255 * fixed bug which could trigger a conflict when saving the setting on other plugins 256 * fixed bug when returning an admin class atrribute 257 * improved perfomance on post count on user overview screen 258 248 259 = 1.4.6.4 = 249 260 * Added 'before more tag' column, which will show the content which is placed before the more-tag
Note: See TracChangeset
for help on using the changeset viewer.