File "form-gutenberg.php"
Full path: /home/kosmetik/public_html/wp-content/plugins/advanced-custom-fields/includes/forms/form-gutenberg.php
File
size: 2.8 B
MIME-type: text/x-php
Charset: utf-8
Download Open Edit Advanced Editor Back
<?php
if (!defined('ABSPATH')) {
exit;
}
if (!class_exists('ACF_Form_Gutenberg')) {
class ACF_Form_Gutenberg
{
function __construct()
{
add_action('enqueue_block_editor_assets', array($this, 'enqueue_block_editor_assets'));
add_action('acf/validate_save_post', array($this, 'acf_validate_save_post'), 999);
}
function enqueue_block_editor_assets()
{
add_action('add_meta_boxes', array($this, 'add_meta_boxes'), 20, 0);
add_action('block_editor_meta_box_hidden_fields', array($this, 'block_editor_meta_box_hidden_fields'));
add_filter('filter_block_editor_meta_boxes', array($this, 'filter_block_editor_meta_boxes'));
}
function add_meta_boxes()
{
remove_action('edit_form_after_title', array(acf_get_instance('ACF_Form_Post'), 'edit_form_after_title'));
}
function block_editor_meta_box_hidden_fields()
{
acf_get_instance('ACF_Form_Post')->edit_form_after_title();
}
function filter_block_editor_meta_boxes($wp_meta_boxes)
{
global $current_screen;
if (isset($wp_meta_boxes[$current_screen->id]['acf_after_title'])) {
$locations = $wp_meta_boxes[$current_screen->id];
if (!isset($locations['normal'])) {
$locations['normal'] = array();
}
if (!isset($locations['normal']['high'])) {
$locations['normal']['high'] = array();
}
foreach ($locations['acf_after_title'] as $priority => $meta_boxes) {
$locations['normal']['high'] = array_merge($meta_boxes, $locations['normal']['high']);
}
$wp_meta_boxes[$current_screen->id] = $locations;
unset($wp_meta_boxes[$current_screen->id]['acf_after_title']);
add_filter('get_user_option_meta-box-order_' . $current_screen->id, array($this, 'modify_user_option_meta_box_order'));
}
return $wp_meta_boxes;
}
function modify_user_option_meta_box_order($locations)
{
if (!empty($locations['acf_after_title'])) {
if (!empty($locations['normal'])) {
$locations['normal'] = $locations['acf_after_title'] . ',' . $locations['normal'];
} else {
$locations['normal'] = $locations['acf_after_title'];
}
unset($locations['acf_after_title']);
}
return $locations;
}
function acf_validate_save_post()
{
if (isset($_GET['meta-box-loader'])) {
acf_reset_validation_errors();
}
}
}
acf_new_instance('ACF_Form_Gutenberg');
}