name = 'acfe_tool_dop_import'; $this->title = __('Import Options Pages'); $this->icon = 'dashicons-upload'; } function html(){ ?>

__('Select File', 'acf'), 'type' => 'file', 'name' => 'acf_import_file', 'value' => false, 'uploader' => 'basic', )); ?>

$args){ // Check if already exists if(isset($dynamic_options_pages[$options_page_name])){ acf_add_admin_notice(__("Options page {$dynamic_options_pages[$options_page_name]['page_title']} already exists. Import aborted."), 'warning'); continue; } // Vars $title = $args['page_title']; $name = $options_page_name; // Insert post $post_id = wp_insert_post(array( 'post_title' => $title, 'post_name' => $name, 'post_type' => 'acfe-dop', 'post_status' => 'publish' )); // Insert error if(is_wp_error($post_id)){ acf_add_admin_notice(__("Something went wrong with the options page {$title}. Import aborted."), 'warning'); continue; } // Register Args update_field('page_title', $args['page_title'], $post_id); update_field('acfe_dop_name', $name, $post_id); update_field('menu_title', $args['menu_title'], $post_id); update_field('menu_slug', $args['menu_slug'], $post_id); update_field('capability', $args['capability'], $post_id); update_field('position', $args['position'], $post_id); update_field('parent_slug', $args['parent_slug'], $post_id); update_field('icon_url', $args['icon_url'], $post_id); update_field('redirect', $args['redirect'], $post_id); update_field('post_id', $args['post_id'], $post_id); update_field('autoload', $args['autoload'], $post_id); update_field('update_button', $args['update_button'], $post_id); update_field('updated_message', $args['updated_message'], $post_id); // Create ACFE option $dynamic_options_pages[$options_page_name] = $args; // Sort keys ASC ksort($dynamic_options_pages); // Update ACFE option update_option('acfe_dynamic_options_pages', $dynamic_options_pages); // append message $ids[] = $post_id; } if(empty($ids)) return; // Count total $total = count($ids); // Generate text $text = sprintf(_n('1 options page imported', '%s options pages imported', $total, 'acf'), $total); // Add links to text $links = array(); foreach($ids as $id){ $links[] = '' . get_the_title($id) . ''; } $text .= ': ' . implode(', ', $links); // Add notice acf_add_admin_notice($text, 'success'); // Flush permalinks flush_rewrite_rules(); } } acf_register_admin_tool('ACFE_Admin_Tool_Import_DOP'); endif;