Edit File by line
/home/barbar84/www/wp-conte.../plugins/duplicat.../src/admin
File: class-options.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Options class
[2] Fix | Delete
*
[3] Fix | Delete
* @package Duplicate Post
[4] Fix | Delete
* @since 4.0
[5] Fix | Delete
*/
[6] Fix | Delete
[7] Fix | Delete
namespace Yoast\WP\Duplicate_Post\Admin;
[8] Fix | Delete
[9] Fix | Delete
/**
[10] Fix | Delete
* Class Options
[11] Fix | Delete
*/
[12] Fix | Delete
class Options {
[13] Fix | Delete
[14] Fix | Delete
/**
[15] Fix | Delete
* Registers the settings.
[16] Fix | Delete
*
[17] Fix | Delete
* @return void
[18] Fix | Delete
*/
[19] Fix | Delete
public function register_settings() {
[20] Fix | Delete
foreach ( \array_keys( $this->get_options() ) as $option ) {
[21] Fix | Delete
\register_setting( 'duplicate_post_group', $option );
[22] Fix | Delete
}
[23] Fix | Delete
}
[24] Fix | Delete
[25] Fix | Delete
/**
[26] Fix | Delete
* Gets the options for the specified tab.
[27] Fix | Delete
*
[28] Fix | Delete
* Also allows filtering on a particular fieldset.
[29] Fix | Delete
*
[30] Fix | Delete
* @param string $tab The tab to get the options for.
[31] Fix | Delete
* @param string $fieldset The fieldset to get the options for. Optional.
[32] Fix | Delete
*
[33] Fix | Delete
* @return array The options for the specified tab.
[34] Fix | Delete
*/
[35] Fix | Delete
public function get_options_for_tab( $tab, $fieldset = '' ) {
[36] Fix | Delete
$options = $this->get_options();
[37] Fix | Delete
[38] Fix | Delete
$options = \array_filter(
[39] Fix | Delete
$options,
[40] Fix | Delete
function ( $option ) use ( $tab ) {
[41] Fix | Delete
return \array_key_exists( 'tab', $option ) && $option['tab'] === $tab;
[42] Fix | Delete
}
[43] Fix | Delete
);
[44] Fix | Delete
[45] Fix | Delete
if ( empty( $options ) ) {
[46] Fix | Delete
return [];
[47] Fix | Delete
}
[48] Fix | Delete
[49] Fix | Delete
// If a fieldset is specified, filter out the corresponding options.
[50] Fix | Delete
if ( ! empty( $fieldset ) ) {
[51] Fix | Delete
$options = \array_filter(
[52] Fix | Delete
$options,
[53] Fix | Delete
function ( $option ) use ( $fieldset ) {
[54] Fix | Delete
return \array_key_exists( 'fieldset', $option ) && $option['fieldset'] === $fieldset;
[55] Fix | Delete
}
[56] Fix | Delete
);
[57] Fix | Delete
}
[58] Fix | Delete
[59] Fix | Delete
return $options;
[60] Fix | Delete
}
[61] Fix | Delete
[62] Fix | Delete
/**
[63] Fix | Delete
* Gets an option from the options array, based on its name.
[64] Fix | Delete
*
[65] Fix | Delete
* @param string $name The name of the option to retrieve.
[66] Fix | Delete
*
[67] Fix | Delete
* @return array The option. Empty array if it does not exist.
[68] Fix | Delete
*/
[69] Fix | Delete
public function get_option( $name ) {
[70] Fix | Delete
$options = $this->get_options();
[71] Fix | Delete
[72] Fix | Delete
return \array_key_exists( $name, $options ) ? [ $name => $options[ $name ] ] : [];
[73] Fix | Delete
}
[74] Fix | Delete
[75] Fix | Delete
/**
[76] Fix | Delete
* Gets the list of registered options.
[77] Fix | Delete
*
[78] Fix | Delete
* @return array The options.
[79] Fix | Delete
* @codeCoverageIgnore
[80] Fix | Delete
*/
[81] Fix | Delete
public function get_options() {
[82] Fix | Delete
return [
[83] Fix | Delete
'duplicate_post_copytitle' => [
[84] Fix | Delete
'tab' => 'what-to-copy',
[85] Fix | Delete
'fieldset' => 'elements-to-copy',
[86] Fix | Delete
'type' => 'checkbox',
[87] Fix | Delete
'label' => \__( 'Title', 'default' ),
[88] Fix | Delete
'value' => 1,
[89] Fix | Delete
],
[90] Fix | Delete
'duplicate_post_copydate' => [
[91] Fix | Delete
'tab' => 'what-to-copy',
[92] Fix | Delete
'fieldset' => 'elements-to-copy',
[93] Fix | Delete
'type' => 'checkbox',
[94] Fix | Delete
'label' => \__( 'Date', 'default' ),
[95] Fix | Delete
'value' => 1,
[96] Fix | Delete
],
[97] Fix | Delete
'duplicate_post_copystatus' => [
[98] Fix | Delete
'tab' => 'what-to-copy',
[99] Fix | Delete
'fieldset' => 'elements-to-copy',
[100] Fix | Delete
'type' => 'checkbox',
[101] Fix | Delete
'label' => \__( 'Status', 'default' ),
[102] Fix | Delete
'value' => 1,
[103] Fix | Delete
],
[104] Fix | Delete
'duplicate_post_copyslug' => [
[105] Fix | Delete
'tab' => 'what-to-copy',
[106] Fix | Delete
'fieldset' => 'elements-to-copy',
[107] Fix | Delete
'type' => 'checkbox',
[108] Fix | Delete
'label' => \__( 'Slug', 'default' ),
[109] Fix | Delete
'value' => 1,
[110] Fix | Delete
],
[111] Fix | Delete
'duplicate_post_copyexcerpt' => [
[112] Fix | Delete
'tab' => 'what-to-copy',
[113] Fix | Delete
'fieldset' => 'elements-to-copy',
[114] Fix | Delete
'type' => 'checkbox',
[115] Fix | Delete
'label' => \__( 'Excerpt', 'default' ),
[116] Fix | Delete
'value' => 1,
[117] Fix | Delete
],
[118] Fix | Delete
'duplicate_post_copycontent' => [
[119] Fix | Delete
'tab' => 'what-to-copy',
[120] Fix | Delete
'fieldset' => 'elements-to-copy',
[121] Fix | Delete
'type' => 'checkbox',
[122] Fix | Delete
'label' => \__( 'Content', 'default' ),
[123] Fix | Delete
'value' => 1,
[124] Fix | Delete
],
[125] Fix | Delete
'duplicate_post_copythumbnail' => [
[126] Fix | Delete
'tab' => 'what-to-copy',
[127] Fix | Delete
'fieldset' => 'elements-to-copy',
[128] Fix | Delete
'type' => 'checkbox',
[129] Fix | Delete
'label' => \__( 'Featured Image', 'default' ),
[130] Fix | Delete
'value' => 1,
[131] Fix | Delete
],
[132] Fix | Delete
'duplicate_post_copytemplate' => [
[133] Fix | Delete
'tab' => 'what-to-copy',
[134] Fix | Delete
'fieldset' => 'elements-to-copy',
[135] Fix | Delete
'type' => 'checkbox',
[136] Fix | Delete
'label' => \__( 'Template', 'default' ),
[137] Fix | Delete
'value' => 1,
[138] Fix | Delete
],
[139] Fix | Delete
'duplicate_post_copyformat' => [
[140] Fix | Delete
'tab' => 'what-to-copy',
[141] Fix | Delete
'fieldset' => 'elements-to-copy',
[142] Fix | Delete
'type' => 'checkbox',
[143] Fix | Delete
'label' => \__( 'Post format', 'default' ),
[144] Fix | Delete
'value' => 1,
[145] Fix | Delete
],
[146] Fix | Delete
'duplicate_post_copyauthor' => [
[147] Fix | Delete
'tab' => 'what-to-copy',
[148] Fix | Delete
'fieldset' => 'elements-to-copy',
[149] Fix | Delete
'type' => 'checkbox',
[150] Fix | Delete
'label' => \__( 'Author', 'default' ),
[151] Fix | Delete
'value' => 1,
[152] Fix | Delete
],
[153] Fix | Delete
'duplicate_post_copypassword' => [
[154] Fix | Delete
'tab' => 'what-to-copy',
[155] Fix | Delete
'fieldset' => 'elements-to-copy',
[156] Fix | Delete
'type' => 'checkbox',
[157] Fix | Delete
'label' => \__( 'Password', 'default' ),
[158] Fix | Delete
'value' => 1,
[159] Fix | Delete
],
[160] Fix | Delete
'duplicate_post_copyattachments' => [
[161] Fix | Delete
'tab' => 'what-to-copy',
[162] Fix | Delete
'fieldset' => 'elements-to-copy',
[163] Fix | Delete
'type' => 'checkbox',
[164] Fix | Delete
'label' => \__( 'Attachments', 'default' ),
[165] Fix | Delete
'value' => 1,
[166] Fix | Delete
'description' => \__( 'you probably want this unchecked, unless you have very special requirements', 'duplicate-post' ),
[167] Fix | Delete
],
[168] Fix | Delete
'duplicate_post_copychildren' => [
[169] Fix | Delete
'tab' => 'what-to-copy',
[170] Fix | Delete
'fieldset' => 'elements-to-copy',
[171] Fix | Delete
'type' => 'checkbox',
[172] Fix | Delete
'label' => \__( 'Children', 'default' ),
[173] Fix | Delete
'value' => 1,
[174] Fix | Delete
],
[175] Fix | Delete
'duplicate_post_copycomments' => [
[176] Fix | Delete
'tab' => 'what-to-copy',
[177] Fix | Delete
'fieldset' => 'elements-to-copy',
[178] Fix | Delete
'type' => 'checkbox',
[179] Fix | Delete
'label' => \__( 'Comments', 'default' ),
[180] Fix | Delete
'value' => 1,
[181] Fix | Delete
'description' => \__( 'except pingbacks and trackbacks', 'duplicate-post' ),
[182] Fix | Delete
],
[183] Fix | Delete
'duplicate_post_copymenuorder' => [
[184] Fix | Delete
'tab' => 'what-to-copy',
[185] Fix | Delete
'fieldset' => 'elements-to-copy',
[186] Fix | Delete
'type' => 'checkbox',
[187] Fix | Delete
'label' => \__( 'Menu order', 'default' ),
[188] Fix | Delete
'value' => 1,
[189] Fix | Delete
],
[190] Fix | Delete
'duplicate_post_title_prefix' => [
[191] Fix | Delete
'tab' => 'what-to-copy',
[192] Fix | Delete
'type' => 'text',
[193] Fix | Delete
'label' => \__( 'Title prefix', 'duplicate-post' ),
[194] Fix | Delete
'value' => \get_option( 'duplicate_post_title_prefix' ),
[195] Fix | Delete
'description' => [ \__( 'Prefix to be added before the title, e.g. "Copy of" (blank for no prefix)', 'duplicate-post' ) ],
[196] Fix | Delete
],
[197] Fix | Delete
'duplicate_post_title_suffix' => [
[198] Fix | Delete
'tab' => 'what-to-copy',
[199] Fix | Delete
'type' => 'text',
[200] Fix | Delete
'label' => \__( 'Title suffix', 'duplicate-post' ),
[201] Fix | Delete
'value' => \get_option( 'duplicate_post_title_suffix' ),
[202] Fix | Delete
'description' => [ \__( 'Suffix to be added after the title, e.g. "(dup)" (blank for no suffix)', 'duplicate-post' ) ],
[203] Fix | Delete
],
[204] Fix | Delete
'duplicate_post_increase_menu_order_by' => [
[205] Fix | Delete
'tab' => 'what-to-copy',
[206] Fix | Delete
'type' => 'number',
[207] Fix | Delete
'label' => \__( 'Increase menu order by', 'duplicate-post' ),
[208] Fix | Delete
'value' => \get_option( 'duplicate_post_increase_menu_order_by' ),
[209] Fix | Delete
'description' => [ \__( 'Add this number to the original menu order (blank or zero to retain the value)', 'duplicate-post' ) ],
[210] Fix | Delete
],
[211] Fix | Delete
'duplicate_post_blacklist' => [
[212] Fix | Delete
'tab' => 'what-to-copy',
[213] Fix | Delete
'type' => 'text',
[214] Fix | Delete
'label' => \__( 'Do not copy these fields', 'duplicate-post' ),
[215] Fix | Delete
'value' => \get_option( 'duplicate_post_blacklist' ),
[216] Fix | Delete
'description' => [
[217] Fix | Delete
__( 'Comma-separated list of meta fields that must not be copied.', 'duplicate-post' ),
[218] Fix | Delete
__( 'You can use * to match zero or more alphanumeric characters or underscores: e.g. field*', 'duplicate-post' ),
[219] Fix | Delete
],
[220] Fix | Delete
],
[221] Fix | Delete
'duplicate_post_taxonomies_blacklist' => [
[222] Fix | Delete
'tab' => 'what-to-copy',
[223] Fix | Delete
'callback' => 'generate_taxonomy_exclusion_list',
[224] Fix | Delete
],
[225] Fix | Delete
'duplicate_post_roles' => [
[226] Fix | Delete
'tab' => 'permissions',
[227] Fix | Delete
'callback' => 'generate_roles_permission_list',
[228] Fix | Delete
],
[229] Fix | Delete
'duplicate_post_types_enabled' => [
[230] Fix | Delete
'tab' => 'permissions',
[231] Fix | Delete
'callback' => 'generate_post_types_list',
[232] Fix | Delete
],
[233] Fix | Delete
'duplicate_post_show_original_meta_box' => [
[234] Fix | Delete
'tab' => 'display',
[235] Fix | Delete
'fieldset' => 'show-original',
[236] Fix | Delete
'type' => 'checkbox',
[237] Fix | Delete
'label' => \__( 'In a metabox in the Edit screen', 'duplicate-post' ),
[238] Fix | Delete
'value' => 1,
[239] Fix | Delete
'description' => [
[240] Fix | Delete
__( "You'll also be able to delete the reference to the original item with a checkbox", 'duplicate-post' ),
[241] Fix | Delete
],
[242] Fix | Delete
],
[243] Fix | Delete
'duplicate_post_show_original_column' => [
[244] Fix | Delete
'tab' => 'display',
[245] Fix | Delete
'fieldset' => 'show-original',
[246] Fix | Delete
'type' => 'checkbox',
[247] Fix | Delete
'label' => \__( 'In a column in the Post list', 'duplicate-post' ),
[248] Fix | Delete
'value' => 1,
[249] Fix | Delete
'description' => [
[250] Fix | Delete
__( "You'll also be able to delete the reference to the original item with a checkbox in Quick Edit", 'duplicate-post' ),
[251] Fix | Delete
],
[252] Fix | Delete
],
[253] Fix | Delete
'duplicate_post_show_original_in_post_states' => [
[254] Fix | Delete
'tab' => 'display',
[255] Fix | Delete
'fieldset' => 'show-original',
[256] Fix | Delete
'type' => 'checkbox',
[257] Fix | Delete
'label' => \__( 'After the title in the Post list', 'duplicate-post' ),
[258] Fix | Delete
'value' => 1,
[259] Fix | Delete
],
[260] Fix | Delete
'duplicate_post_show_notice' => [
[261] Fix | Delete
'tab' => 'display',
[262] Fix | Delete
'type' => 'checkbox',
[263] Fix | Delete
'label' => \__( 'Show update notice', 'duplicate-post' ),
[264] Fix | Delete
'value' => 1,
[265] Fix | Delete
],
[266] Fix | Delete
'duplicate_post_show_link' => [
[267] Fix | Delete
'tab' => 'display',
[268] Fix | Delete
'fieldset' => 'show-links',
[269] Fix | Delete
'sub_options' => [
[270] Fix | Delete
'new_draft' => [
[271] Fix | Delete
'type' => 'checkbox',
[272] Fix | Delete
'label' => \__( 'New Draft', 'duplicate-post' ),
[273] Fix | Delete
'value' => 1,
[274] Fix | Delete
],
[275] Fix | Delete
'clone' => [
[276] Fix | Delete
'type' => 'checkbox',
[277] Fix | Delete
'label' => \__( 'Clone', 'duplicate-post' ),
[278] Fix | Delete
'value' => 1,
[279] Fix | Delete
],
[280] Fix | Delete
'rewrite_republish' => [
[281] Fix | Delete
'type' => 'checkbox',
[282] Fix | Delete
'label' => \__( 'Rewrite & Republish', 'duplicate-post' ),
[283] Fix | Delete
'value' => 1,
[284] Fix | Delete
],
[285] Fix | Delete
],
[286] Fix | Delete
],
[287] Fix | Delete
'duplicate_post_show_link_in' => [
[288] Fix | Delete
'tab' => 'display',
[289] Fix | Delete
'fieldset' => 'show-links-in',
[290] Fix | Delete
'sub_options' => [
[291] Fix | Delete
'row' => [
[292] Fix | Delete
'type' => 'checkbox',
[293] Fix | Delete
'label' => \__( 'Post list', 'duplicate-post' ),
[294] Fix | Delete
'value' => 1,
[295] Fix | Delete
],
[296] Fix | Delete
'adminbar' => [
[297] Fix | Delete
'type' => 'checkbox',
[298] Fix | Delete
'label' => \__( 'Admin bar', 'duplicate-post' ),
[299] Fix | Delete
'value' => 1,
[300] Fix | Delete
],
[301] Fix | Delete
'submitbox' => [
[302] Fix | Delete
'type' => 'checkbox',
[303] Fix | Delete
'label' => \__( 'Edit screen', 'duplicate-post' ),
[304] Fix | Delete
'value' => 1,
[305] Fix | Delete
],
[306] Fix | Delete
'bulkactions' => [
[307] Fix | Delete
'type' => 'checkbox',
[308] Fix | Delete
'label' => \__( 'Bulk Actions', 'default' ),
[309] Fix | Delete
'value' => 1,
[310] Fix | Delete
],
[311] Fix | Delete
],
[312] Fix | Delete
],
[313] Fix | Delete
];
[314] Fix | Delete
}
[315] Fix | Delete
}
[316] Fix | Delete
[317] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function