settings(); $settings->add_tab( self::TAB, __( 'Content', 'all-in-one-utilities' ), __( 'Tools for working with posts, pages, and other content.', 'all-in-one-utilities' ), 44 ); $this->register_settings( $settings ); ( new Cloner() )->register(); } /** * The section. * * @param SettingsRegistry $settings The settings registry. * @return void */ private function register_settings( SettingsRegistry $settings ): void { $section = Cloner::SECTION; $settings->add_section( self::TAB, $section, __( 'Duplicate Posts & Pages', 'all-in-one-utilities' ), __( 'Copy a post or page -- with its categories, tags, custom fields, and featured image -- as a new draft, from the list screens, the toolbar, or the classic editor.', 'all-in-one-utilities' ), 10 ); $fields = array( new Field( id: 'enabled', label: __( 'Duplicate link', 'all-in-one-utilities' ), type: 'checkbox', default: 0, args: array( 'toggle_label' => __( 'Add a "Duplicate" link and bulk action', 'all-in-one-utilities' ) ), doc: new Doc( title: __( 'Duplicating content', 'all-in-one-utilities' ), short: __( 'The copy belongs to whoever made it. Comments, revisions, and the original\'s address (slug) are not copied.', 'all-in-one-utilities' ), detailed: __( 'Users can only copy content they can edit, of a type they can create. A copy is never published by someone who couldn\'t publish it themselves -- it becomes "Pending review" instead. Scheduled originals are copied as drafts.', 'all-in-one-utilities' ) ), priority: 10 ), new Field( id: 'post_types', label: __( 'Content types', 'all-in-one-utilities' ), type: 'checklist', default: array( 'post', 'page' ), args: array( 'choices' => static fn(): array => Cloner::post_type_choices(), 'depends_on' => 'enabled', ), priority: 20 ), new Field( id: 'status', label: __( 'Status of the copy', 'all-in-one-utilities' ), type: 'select', default: 'draft', args: array( 'depends_on' => 'enabled', 'choices' => array( 'draft' => __( 'Draft', 'all-in-one-utilities' ), 'pending' => __( 'Pending review', 'all-in-one-utilities' ), 'private' => __( 'Private', 'all-in-one-utilities' ), 'same' => __( 'Same as the original', 'all-in-one-utilities' ), ), ), priority: 30 ), new Field( id: 'title_suffix', label: __( 'Add to the title', 'all-in-one-utilities' ), type: 'text', default: __( '(Copy)', 'all-in-one-utilities' ), args: array( 'depends_on' => 'enabled', 'description' => __( 'Added after the original title. Leave empty to keep the title as it is.', 'all-in-one-utilities' ), ), priority: 40 ), new Field( id: 'open_editor', label: __( 'After duplicating', 'all-in-one-utilities' ), type: 'checkbox', default: 0, args: array( 'depends_on' => 'enabled', 'toggle_label' => __( 'Open the copy in the editor (otherwise stay on the list)', 'all-in-one-utilities' ), ), priority: 50 ), ); foreach ( $fields as $field ) { $settings->add_field( self::TAB, $section, $field ); } } }