form
6 years ago
author.php
6 years ago
autosync.php
6 years ago
dev.php
6 years ago
dynamic-block-type.php
6 years ago
dynamic-form.php
6 years ago
dynamic-options-page.php
6 years ago
dynamic-post-type.php
6 years ago
dynamic-taxonomy.php
6 years ago
taxonomy.php
6 years ago
taxonomy.php
172 lines
| 1 | <?php |
| 2 | |
| 3 | if(!defined('ABSPATH')) |
| 4 | exit; |
| 5 | |
| 6 | // Check setting |
| 7 | if(!acf_get_setting('acfe/modules/taxonomies')) |
| 8 | return; |
| 9 | |
| 10 | /** |
| 11 | * Terms List View |
| 12 | */ |
| 13 | add_action('admin_footer-edit-tags.php', 'acfe_better_taxonomy_admin_footer'); |
| 14 | function acfe_better_taxonomy_admin_footer(){ |
| 15 | |
| 16 | global $tax; |
| 17 | $can_edit_terms = current_user_can($tax->cap->edit_terms); |
| 18 | |
| 19 | ?> |
| 20 | <script type="text/html" id="tmpl-acfe-bt-admin-button-add"> |
| 21 | <?php if($can_edit_terms){ ?> |
| 22 | <a href="#" class="page-title-action acfe-bt-admin-button-add"><?php echo $tax->labels->add_new_item; ?></a> |
| 23 | <?php } ?> |
| 24 | </script> |
| 25 | |
| 26 | <script type="text/html" id="tmpl-acfe-bt-wrapper"> |
| 27 | <div id="poststuff"></div> |
| 28 | </script> |
| 29 | |
| 30 | <script type="text/javascript"> |
| 31 | (function($){ |
| 32 | // Add button |
| 33 | $('.wrap .wp-heading-inline').after($('#tmpl-acfe-bt-admin-button-add').html()); |
| 34 | |
| 35 | // Move form |
| 36 | $('#ajax-response').after($('#col-container #col-left').addClass('acfe-bt')); |
| 37 | |
| 38 | // Hide form |
| 39 | $('.acfe-bt').hide(); |
| 40 | |
| 41 | // Create wrapper |
| 42 | $('.acfe-bt .form-wrap').append($('#tmpl-acfe-bt-wrapper').html()); |
| 43 | |
| 44 | // Append form inside wrapper |
| 45 | $('.acfe-bt #poststuff').append($('.acfe-bt .form-wrap form')); |
| 46 | |
| 47 | $('.acfe-bt .form-wrap form').wrapInner('<div class="postbox" id="acfe-bt-form"><div class="inside"></div></div>'); |
| 48 | |
| 49 | // Append new title |
| 50 | $('.acfe-bt .postbox h2 span').append($('.acfe-bt .form-wrap > h2').text()); |
| 51 | $('.acfe-bt .form-wrap > h2').remove(); |
| 52 | |
| 53 | // Acf class |
| 54 | $('.acfe-bt .inside .form-field, .acfe-bt .inside .submit').addClass('acf-field'); |
| 55 | |
| 56 | $('.acfe-bt .inside .form-field, .acfe-bt .inside .submit').each(function(){ |
| 57 | |
| 58 | $(this).append('<div class="acf-input"></div>'); |
| 59 | $(this).find('.acf-input').append($(this).find('> :not("label")')); |
| 60 | |
| 61 | // Add spacing when a meta field has no label |
| 62 | var $label = $(this).find('> label'); |
| 63 | if($label.length){ |
| 64 | |
| 65 | $label.wrap('<div class="acf-label"></div>'); |
| 66 | |
| 67 | }else{ |
| 68 | |
| 69 | $(this).addClass('acfe-bt-no-label'); |
| 70 | |
| 71 | } |
| 72 | |
| 73 | }); |
| 74 | |
| 75 | // Remove ACF Fields id |
| 76 | $('#acf-term-fields').contents().unwrap(); |
| 77 | |
| 78 | $('.acfe-bt-admin-button-add').click(function(e){ |
| 79 | |
| 80 | e.preventDefault(); |
| 81 | |
| 82 | if($('.acfe-bt').is(':visible')) |
| 83 | $('.acfe-bt').hide(); |
| 84 | else |
| 85 | $('.acfe-bt').show(); |
| 86 | |
| 87 | }); |
| 88 | |
| 89 | // Label to left |
| 90 | if(typeof acf !== 'undefined'){ |
| 91 | acf.postbox.render({ |
| 92 | 'id': 'acfe-bt-form', |
| 93 | 'label': 'left' |
| 94 | }); |
| 95 | } |
| 96 | |
| 97 | $('#acfe-bt-form .acf-tab-wrap.-left').removeClass('-left').addClass('-top'); |
| 98 | |
| 99 | // Polylang Compatibility Fix |
| 100 | <?php if(isset($_GET['from_tag']) && !empty($_GET['from_tag']) && isset($_GET['new_lang']) && !empty($_GET['new_lang'])){ ?> |
| 101 | |
| 102 | $('.acfe-bt-admin-button-add').click(); |
| 103 | |
| 104 | <?php } ?> |
| 105 | |
| 106 | })(jQuery); |
| 107 | </script> |
| 108 | <?php |
| 109 | |
| 110 | } |
| 111 | |
| 112 | /** |
| 113 | * Term Edit View |
| 114 | */ |
| 115 | add_action('admin_footer-term.php', 'acfe_better_taxonomy_edit_admin_footer'); |
| 116 | function acfe_better_taxonomy_edit_admin_footer(){ |
| 117 | |
| 118 | ?> |
| 119 | <script type="text/html" id="tmpl-acf-column-2"> |
| 120 | <div class="acf-column-2"> |
| 121 | |
| 122 | <div id="poststuff" class="acfe-acfe-bt-admin-column"> |
| 123 | |
| 124 | <div class="postbox"> |
| 125 | |
| 126 | <h2 class="hndle ui-sortable-handle"><span><?php _e('Edit', 'acfe'); ?></span></h2> |
| 127 | |
| 128 | <div class="inside"> |
| 129 | <div class="submitbox"> |
| 130 | |
| 131 | <div id="major-publishing-actions"> |
| 132 | |
| 133 | <div id="publishing-action"> |
| 134 | |
| 135 | <div class="acfe-form-submit"> |
| 136 | <input type="submit" class="acf-button button button-primary button-large" value="<?php _e('Update', 'acfe'); ?>" /> |
| 137 | <span class="acf-spinner"></span> |
| 138 | </div> |
| 139 | |
| 140 | </div> |
| 141 | <div class="clear"></div> |
| 142 | |
| 143 | </div> |
| 144 | |
| 145 | </div> |
| 146 | |
| 147 | </div> |
| 148 | |
| 149 | </div> |
| 150 | |
| 151 | </div> |
| 152 | </div> |
| 153 | </script> |
| 154 | <script type="text/javascript"> |
| 155 | (function($){ |
| 156 | |
| 157 | // wrap form |
| 158 | $('#edittag').wrapInner('<div class="acf-columns-2"><div style="float:left; width:100%;"></div></div>'); |
| 159 | |
| 160 | // add column side |
| 161 | $('#edittag .acf-columns-2').append($('#tmpl-acf-column-2').html()); |
| 162 | |
| 163 | // Add acf-input |
| 164 | //$('#edittag .form-table td:not(".acf-input")').wrapInner('<div class="acf-input"></div>'); |
| 165 | |
| 166 | $('#edittag .edit-tag-actions').hide(); |
| 167 | |
| 168 | })(jQuery); |
| 169 | </script> |
| 170 | <?php |
| 171 | |
| 172 | } |