form-post-type-archive.php
1 month ago
form-post-type-list.php
2 months ago
form-post.php
2 months ago
form-taxonomy-list.php
2 months ago
form-post.php
76 lines
| 1 | <?php |
| 2 | |
| 3 | if(!defined('ABSPATH')){ |
| 4 | exit; |
| 5 | } |
| 6 | |
| 7 | if(!class_exists('acfe_form_post')): |
| 8 | |
| 9 | class acfe_form_post{ |
| 10 | |
| 11 | /** |
| 12 | * construct |
| 13 | */ |
| 14 | function __construct(){ |
| 15 | |
| 16 | // re-add sidebar submitdiv metabox |
| 17 | acfe_replace_action('load-post.php', array('ACF_Form_Post', 'initialize'), array($this, 'initialize')); |
| 18 | acfe_replace_action('load-post-new.php', array('ACF_Form_Post', 'initialize'), array($this, 'initialize')); |
| 19 | |
| 20 | } |
| 21 | |
| 22 | |
| 23 | /** |
| 24 | * initialize |
| 25 | * |
| 26 | * Rewrites ACF_Form_Post->initialize() which remove the submitdiv metabox in ACF Field Group since ACF 6.0+ |
| 27 | * |
| 28 | * advanced-custom-fields-pro/includes/forms/form-post.php:48 |
| 29 | */ |
| 30 | function initialize(){ |
| 31 | |
| 32 | // globals |
| 33 | global $typenow; |
| 34 | |
| 35 | // get restricted post types |
| 36 | $internal_post_types = $this->get_internal_posts_types(); |
| 37 | $restricted = array_merge($internal_post_types, array('acf-taxonomy', 'attachment')); |
| 38 | |
| 39 | // restrict specific post types |
| 40 | if(in_array($typenow, $restricted)){ |
| 41 | return; |
| 42 | } |
| 43 | |
| 44 | // enqueue scripts |
| 45 | acf_enqueue_scripts(array( |
| 46 | 'uploader' => true, |
| 47 | )); |
| 48 | |
| 49 | // actions |
| 50 | add_action('add_meta_boxes', array(acf_get_instance('ACF_Form_Post'), 'add_meta_boxes'), 10, 2); |
| 51 | |
| 52 | } |
| 53 | |
| 54 | |
| 55 | /** |
| 56 | * get_internal_posts_types |
| 57 | * |
| 58 | * @return array|string[] |
| 59 | */ |
| 60 | function get_internal_posts_types(){ |
| 61 | |
| 62 | // function was introduced in acf 6.1+ |
| 63 | if(function_exists('acf_get_internal_post_types')){ |
| 64 | return (array) acf_get_internal_post_types(); |
| 65 | } |
| 66 | |
| 67 | // fallback |
| 68 | return array('acf-field-group', 'acf-post-type', 'acf-taxonomy', 'acf-ui-options-page'); |
| 69 | |
| 70 | } |
| 71 | |
| 72 | } |
| 73 | |
| 74 | acf_new_instance('acfe_form_post'); |
| 75 | |
| 76 | endif; |