* @package Duplicate Post
namespace Yoast\WP\Duplicate_Post\Admin;
* Registers the settings.
public function register_settings() {
foreach ( \array_keys( $this->get_options() ) as $option ) {
\register_setting( 'duplicate_post_group', $option );
* Gets the options for the specified tab.
* Also allows filtering on a particular fieldset.
* @param string $tab The tab to get the options for.
* @param string $fieldset The fieldset to get the options for. Optional.
* @return array The options for the specified tab.
public function get_options_for_tab( $tab, $fieldset = '' ) {
$options = $this->get_options();
$options = \array_filter(
function ( $option ) use ( $tab ) {
return \array_key_exists( 'tab', $option ) && $option['tab'] === $tab;
if ( empty( $options ) ) {
// If a fieldset is specified, filter out the corresponding options.
if ( ! empty( $fieldset ) ) {
$options = \array_filter(
function ( $option ) use ( $fieldset ) {
return \array_key_exists( 'fieldset', $option ) && $option['fieldset'] === $fieldset;
* Gets an option from the options array, based on its name.
* @param string $name The name of the option to retrieve.
* @return array The option. Empty array if it does not exist.
public function get_option( $name ) {
$options = $this->get_options();
return \array_key_exists( $name, $options ) ? [ $name => $options[ $name ] ] : [];
* Gets the list of registered options.
* @return array The options.
public function get_options() {
'duplicate_post_copytitle' => [
'fieldset' => 'elements-to-copy',
'label' => \__( 'Title', 'default' ),
'duplicate_post_copydate' => [
'fieldset' => 'elements-to-copy',
'label' => \__( 'Date', 'default' ),
'duplicate_post_copystatus' => [
'fieldset' => 'elements-to-copy',
'label' => \__( 'Status', 'default' ),
'duplicate_post_copyslug' => [
'fieldset' => 'elements-to-copy',
'label' => \__( 'Slug', 'default' ),
'duplicate_post_copyexcerpt' => [
'fieldset' => 'elements-to-copy',
'label' => \__( 'Excerpt', 'default' ),
'duplicate_post_copycontent' => [
'fieldset' => 'elements-to-copy',
'label' => \__( 'Content', 'default' ),
'duplicate_post_copythumbnail' => [
'fieldset' => 'elements-to-copy',
'label' => \__( 'Featured Image', 'default' ),
'duplicate_post_copytemplate' => [
'fieldset' => 'elements-to-copy',
'label' => \__( 'Template', 'default' ),
'duplicate_post_copyformat' => [
'fieldset' => 'elements-to-copy',
'label' => \__( 'Post format', 'default' ),
'duplicate_post_copyauthor' => [
'fieldset' => 'elements-to-copy',
'label' => \__( 'Author', 'default' ),
'duplicate_post_copypassword' => [
'fieldset' => 'elements-to-copy',
'label' => \__( 'Password', 'default' ),
'duplicate_post_copyattachments' => [
'fieldset' => 'elements-to-copy',
'label' => \__( 'Attachments', 'default' ),
'description' => \__( 'you probably want this unchecked, unless you have very special requirements', 'duplicate-post' ),
'duplicate_post_copychildren' => [
'fieldset' => 'elements-to-copy',
'label' => \__( 'Children', 'default' ),
'duplicate_post_copycomments' => [
'fieldset' => 'elements-to-copy',
'label' => \__( 'Comments', 'default' ),
'description' => \__( 'except pingbacks and trackbacks', 'duplicate-post' ),
'duplicate_post_copymenuorder' => [
'fieldset' => 'elements-to-copy',
'label' => \__( 'Menu order', 'default' ),
'duplicate_post_title_prefix' => [
'label' => \__( 'Title prefix', 'duplicate-post' ),
'value' => \get_option( 'duplicate_post_title_prefix' ),
'description' => [ \__( 'Prefix to be added before the title, e.g. "Copy of" (blank for no prefix)', 'duplicate-post' ) ],
'duplicate_post_title_suffix' => [
'label' => \__( 'Title suffix', 'duplicate-post' ),
'value' => \get_option( 'duplicate_post_title_suffix' ),
'description' => [ \__( 'Suffix to be added after the title, e.g. "(dup)" (blank for no suffix)', 'duplicate-post' ) ],
'duplicate_post_increase_menu_order_by' => [
'label' => \__( 'Increase menu order by', 'duplicate-post' ),
'value' => \get_option( 'duplicate_post_increase_menu_order_by' ),
'description' => [ \__( 'Add this number to the original menu order (blank or zero to retain the value)', 'duplicate-post' ) ],
'duplicate_post_blacklist' => [
'label' => \__( 'Do not copy these fields', 'duplicate-post' ),
'value' => \get_option( 'duplicate_post_blacklist' ),
__( 'Comma-separated list of meta fields that must not be copied.', 'duplicate-post' ),
__( 'You can use * to match zero or more alphanumeric characters or underscores: e.g. field*', 'duplicate-post' ),
'duplicate_post_taxonomies_blacklist' => [
'callback' => 'generate_taxonomy_exclusion_list',
'duplicate_post_roles' => [
'callback' => 'generate_roles_permission_list',
'duplicate_post_types_enabled' => [
'callback' => 'generate_post_types_list',
'duplicate_post_show_original_meta_box' => [
'fieldset' => 'show-original',
'label' => \__( 'In a metabox in the Edit screen', 'duplicate-post' ),
__( "You'll also be able to delete the reference to the original item with a checkbox", 'duplicate-post' ),
'duplicate_post_show_original_column' => [
'fieldset' => 'show-original',
'label' => \__( 'In a column in the Post list', 'duplicate-post' ),
__( "You'll also be able to delete the reference to the original item with a checkbox in Quick Edit", 'duplicate-post' ),
'duplicate_post_show_original_in_post_states' => [
'fieldset' => 'show-original',
'label' => \__( 'After the title in the Post list', 'duplicate-post' ),
'duplicate_post_show_notice' => [
'label' => \__( 'Show update notice', 'duplicate-post' ),
'duplicate_post_show_link' => [
'fieldset' => 'show-links',
'label' => \__( 'New Draft', 'duplicate-post' ),
'label' => \__( 'Clone', 'duplicate-post' ),
'label' => \__( 'Rewrite & Republish', 'duplicate-post' ),
'duplicate_post_show_link_in' => [
'fieldset' => 'show-links-in',
'label' => \__( 'Post list', 'duplicate-post' ),
'label' => \__( 'Admin bar', 'duplicate-post' ),
'label' => \__( 'Edit screen', 'duplicate-post' ),
'label' => \__( 'Bulk Actions', 'default' ),