screen-attachment.php
7 months ago
screen-options-page.php
7 months ago
screen-post.php
7 months ago
screen-settings.php
7 months ago
screen-taxonomy.php
3 months ago
screen-user.php
7 months ago
screen-post.php
202 lines
| 1 | <?php |
| 2 | |
| 3 | if(!defined('ABSPATH')){ |
| 4 | exit; |
| 5 | } |
| 6 | |
| 7 | if(!class_exists('acfe_screen_post')): |
| 8 | |
| 9 | class acfe_screen_post{ |
| 10 | |
| 11 | // vars |
| 12 | var $post_type; |
| 13 | var $post_id; |
| 14 | |
| 15 | /** |
| 16 | * construct |
| 17 | */ |
| 18 | function __construct(){ |
| 19 | |
| 20 | /** |
| 21 | * hooks: |
| 22 | * |
| 23 | * acfe/load_post $post_type, $post_id |
| 24 | * acfe/add_post_meta_boxes $post_type, $post |
| 25 | * |
| 26 | * acfe/load_posts $post_type |
| 27 | * acfe/add_posts_meta_boxes $post_type |
| 28 | */ |
| 29 | |
| 30 | // edit |
| 31 | add_action('load-post-new.php', array($this, 'post_load')); |
| 32 | add_action('load-post.php', array($this, 'post_load')); |
| 33 | |
| 34 | // list |
| 35 | add_action('load-edit.php', array($this, 'posts_load')); |
| 36 | |
| 37 | } |
| 38 | |
| 39 | |
| 40 | /** |
| 41 | * post_load |
| 42 | * |
| 43 | * load-post.php |
| 44 | */ |
| 45 | function post_load(){ |
| 46 | |
| 47 | // global |
| 48 | global $typenow; |
| 49 | |
| 50 | // exclude attachment |
| 51 | if($typenow === 'attachment'){ |
| 52 | return; |
| 53 | } |
| 54 | |
| 55 | // vars |
| 56 | $post_type = $typenow; |
| 57 | $post_id = (int) acfe_get_post_id(); |
| 58 | |
| 59 | // actions |
| 60 | do_action("acfe/load_post", $post_type, $post_id); |
| 61 | do_action("acfe/load_post/post_type={$post_type}", $post_type, $post_id); |
| 62 | |
| 63 | // hooks |
| 64 | add_action('add_meta_boxes', array($this, 'add_post_meta_boxes'), 10, 2); |
| 65 | |
| 66 | } |
| 67 | |
| 68 | |
| 69 | /** |
| 70 | * add_post_meta_boxes |
| 71 | * |
| 72 | * add_meta_boxes |
| 73 | * |
| 74 | * @param $post_type |
| 75 | * @param $post |
| 76 | */ |
| 77 | function add_post_meta_boxes($post_type, $post){ |
| 78 | |
| 79 | do_action("acfe/add_post_meta_boxes", $post_type, $post); |
| 80 | do_action("acfe/add_post_meta_boxes/post_type={$post_type}", $post_type, $post); |
| 81 | |
| 82 | } |
| 83 | |
| 84 | |
| 85 | /** |
| 86 | * posts_load |
| 87 | * |
| 88 | * load-edit.php |
| 89 | */ |
| 90 | function posts_load(){ |
| 91 | |
| 92 | // global |
| 93 | global $typenow; |
| 94 | |
| 95 | // vars |
| 96 | $post_type = $typenow; |
| 97 | |
| 98 | // set vars |
| 99 | $this->post_type = $post_type; |
| 100 | |
| 101 | // actions |
| 102 | do_action("acfe/load_posts", $post_type); |
| 103 | do_action("acfe/load_posts/post_type={$post_type}", $post_type); |
| 104 | |
| 105 | // hooks |
| 106 | add_action('admin_footer', array($this, 'posts_footer')); |
| 107 | |
| 108 | } |
| 109 | |
| 110 | |
| 111 | /** |
| 112 | * posts_footer |
| 113 | * |
| 114 | * admin_footer |
| 115 | */ |
| 116 | function posts_footer(){ |
| 117 | |
| 118 | do_action('acfe/add_posts_meta_boxes', $this->post_type); |
| 119 | |
| 120 | $this->posts_do_meta_boxes(); |
| 121 | |
| 122 | } |
| 123 | |
| 124 | |
| 125 | /** |
| 126 | * posts_do_meta_boxes |
| 127 | */ |
| 128 | function posts_do_meta_boxes(){ |
| 129 | |
| 130 | // check filter |
| 131 | if(!acf_is_filter_enabled('acfe/post_type_list')){ |
| 132 | return; |
| 133 | } |
| 134 | |
| 135 | // enqueue |
| 136 | acf_enqueue_scripts(); |
| 137 | |
| 138 | ?> |
| 139 | <template id="tmpl-acf-after-title"> |
| 140 | |
| 141 | <div id="poststuff" class="acfe-list-postboxes"> |
| 142 | <form method="post"> |
| 143 | <?php do_meta_boxes('edit', 'acf_after_title', $this->post_type); ?> |
| 144 | </form> |
| 145 | </div> |
| 146 | |
| 147 | </template> |
| 148 | |
| 149 | <template id="tmpl-acf-normal"> |
| 150 | |
| 151 | <div id="poststuff" class="acfe-list-postboxes"> |
| 152 | <form method="post"> |
| 153 | <?php do_meta_boxes('edit', 'normal', $this->post_type); ?> |
| 154 | </form> |
| 155 | </div> |
| 156 | |
| 157 | </template> |
| 158 | |
| 159 | <template id="tmpl-acf-side"> |
| 160 | |
| 161 | <div class="acf-column-2"> |
| 162 | |
| 163 | <div id="poststuff" class="acfe-list-postboxes -side"> |
| 164 | <form method="post"> |
| 165 | <?php do_meta_boxes('edit', 'side', $this->post_type); ?> |
| 166 | </form> |
| 167 | </div> |
| 168 | |
| 169 | </div> |
| 170 | |
| 171 | </template> |
| 172 | <script type="text/javascript"> |
| 173 | (function($){ |
| 174 | |
| 175 | // main form |
| 176 | var $main = $('#posts-filter'); |
| 177 | |
| 178 | $main.wrap('<div class="acf-columns-2" />'); |
| 179 | $main.prepend($('.subsubsub')); |
| 180 | $main.wrap('<div class="acf-column-1" />'); |
| 181 | |
| 182 | // field groups |
| 183 | var $column_1 = $('.acf-column-1'); |
| 184 | |
| 185 | $column_1.prepend($('#tmpl-acf-after-title').html()); |
| 186 | $column_1.append($('#tmpl-acf-normal').html()); |
| 187 | $column_1.after($('#tmpl-acf-side').html()); |
| 188 | |
| 189 | <?php if(!acf_is_filter_enabled('acfe/post_type_list/side')): ?> |
| 190 | $('.acf-columns-2').removeClass('acf-columns-2'); |
| 191 | <?php endif; ?> |
| 192 | |
| 193 | })(jQuery); |
| 194 | </script> |
| 195 | <?php |
| 196 | } |
| 197 | |
| 198 | } |
| 199 | |
| 200 | acf_new_instance('acfe_screen_post'); |
| 201 | |
| 202 | endif; |