Edit File by line
/home/barbar84/public_h.../wp-admin
File: options.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Options Management Administration Screen.
[2] Fix | Delete
*
[3] Fix | Delete
* If accessed directly in a browser this page shows a list of all saved options
[4] Fix | Delete
* along with editable fields for their values. Serialized data is not supported
[5] Fix | Delete
* and there is no way to remove options via this page. It is not linked to from
[6] Fix | Delete
* anywhere else in the admin.
[7] Fix | Delete
*
[8] Fix | Delete
* This file is also the target of the forms in core and custom options pages
[9] Fix | Delete
* that use the Settings API. In this case it saves the new option values
[10] Fix | Delete
* and returns the user to their page of origin.
[11] Fix | Delete
*
[12] Fix | Delete
* @package WordPress
[13] Fix | Delete
* @subpackage Administration
[14] Fix | Delete
*/
[15] Fix | Delete
[16] Fix | Delete
/** WordPress Administration Bootstrap */
[17] Fix | Delete
require_once __DIR__ . '/admin.php';
[18] Fix | Delete
[19] Fix | Delete
$title = __( 'Settings' );
[20] Fix | Delete
$this_file = 'options.php';
[21] Fix | Delete
$parent_file = 'options-general.php';
[22] Fix | Delete
[23] Fix | Delete
wp_reset_vars( array( 'action', 'option_page' ) );
[24] Fix | Delete
[25] Fix | Delete
$capability = 'manage_options';
[26] Fix | Delete
[27] Fix | Delete
// This is for back compat and will eventually be removed.
[28] Fix | Delete
if ( empty( $option_page ) ) {
[29] Fix | Delete
$option_page = 'options';
[30] Fix | Delete
} else {
[31] Fix | Delete
[32] Fix | Delete
/**
[33] Fix | Delete
* Filters the capability required when using the Settings API.
[34] Fix | Delete
*
[35] Fix | Delete
* By default, the options groups for all registered settings require the manage_options capability.
[36] Fix | Delete
* This filter is required to change the capability required for a certain options page.
[37] Fix | Delete
*
[38] Fix | Delete
* @since 3.2.0
[39] Fix | Delete
*
[40] Fix | Delete
* @param string $capability The capability used for the page, which is manage_options by default.
[41] Fix | Delete
*/
[42] Fix | Delete
$capability = apply_filters( "option_page_capability_{$option_page}", $capability );
[43] Fix | Delete
}
[44] Fix | Delete
[45] Fix | Delete
if ( ! current_user_can( $capability ) ) {
[46] Fix | Delete
wp_die(
[47] Fix | Delete
'<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' .
[48] Fix | Delete
'<p>' . __( 'Sorry, you are not allowed to manage options for this site.' ) . '</p>',
[49] Fix | Delete
403
[50] Fix | Delete
);
[51] Fix | Delete
}
[52] Fix | Delete
[53] Fix | Delete
// Handle admin email change requests.
[54] Fix | Delete
if ( ! empty( $_GET['adminhash'] ) ) {
[55] Fix | Delete
$new_admin_details = get_option( 'adminhash' );
[56] Fix | Delete
$redirect = 'options-general.php?updated=false';
[57] Fix | Delete
if ( is_array( $new_admin_details ) && hash_equals( $new_admin_details['hash'], $_GET['adminhash'] ) && ! empty( $new_admin_details['newemail'] ) ) {
[58] Fix | Delete
update_option( 'admin_email', $new_admin_details['newemail'] );
[59] Fix | Delete
delete_option( 'adminhash' );
[60] Fix | Delete
delete_option( 'new_admin_email' );
[61] Fix | Delete
$redirect = 'options-general.php?updated=true';
[62] Fix | Delete
}
[63] Fix | Delete
wp_redirect( admin_url( $redirect ) );
[64] Fix | Delete
exit;
[65] Fix | Delete
} elseif ( ! empty( $_GET['dismiss'] ) && 'new_admin_email' === $_GET['dismiss'] ) {
[66] Fix | Delete
check_admin_referer( 'dismiss-' . get_current_blog_id() . '-new_admin_email' );
[67] Fix | Delete
delete_option( 'adminhash' );
[68] Fix | Delete
delete_option( 'new_admin_email' );
[69] Fix | Delete
wp_redirect( admin_url( 'options-general.php?updated=true' ) );
[70] Fix | Delete
exit;
[71] Fix | Delete
}
[72] Fix | Delete
[73] Fix | Delete
if ( is_multisite() && ! current_user_can( 'manage_network_options' ) && 'update' != $action ) {
[74] Fix | Delete
wp_die(
[75] Fix | Delete
'<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' .
[76] Fix | Delete
'<p>' . __( 'Sorry, you are not allowed to delete these items.' ) . '</p>',
[77] Fix | Delete
403
[78] Fix | Delete
);
[79] Fix | Delete
}
[80] Fix | Delete
[81] Fix | Delete
$allowed_options = array(
[82] Fix | Delete
'general' => array(
[83] Fix | Delete
'blogname',
[84] Fix | Delete
'blogdescription',
[85] Fix | Delete
'gmt_offset',
[86] Fix | Delete
'date_format',
[87] Fix | Delete
'time_format',
[88] Fix | Delete
'start_of_week',
[89] Fix | Delete
'timezone_string',
[90] Fix | Delete
'WPLANG',
[91] Fix | Delete
'new_admin_email',
[92] Fix | Delete
),
[93] Fix | Delete
'discussion' => array(
[94] Fix | Delete
'default_pingback_flag',
[95] Fix | Delete
'default_ping_status',
[96] Fix | Delete
'default_comment_status',
[97] Fix | Delete
'comments_notify',
[98] Fix | Delete
'moderation_notify',
[99] Fix | Delete
'comment_moderation',
[100] Fix | Delete
'require_name_email',
[101] Fix | Delete
'comment_previously_approved',
[102] Fix | Delete
'comment_max_links',
[103] Fix | Delete
'moderation_keys',
[104] Fix | Delete
'disallowed_keys',
[105] Fix | Delete
'show_avatars',
[106] Fix | Delete
'avatar_rating',
[107] Fix | Delete
'avatar_default',
[108] Fix | Delete
'close_comments_for_old_posts',
[109] Fix | Delete
'close_comments_days_old',
[110] Fix | Delete
'thread_comments',
[111] Fix | Delete
'thread_comments_depth',
[112] Fix | Delete
'page_comments',
[113] Fix | Delete
'comments_per_page',
[114] Fix | Delete
'default_comments_page',
[115] Fix | Delete
'comment_order',
[116] Fix | Delete
'comment_registration',
[117] Fix | Delete
'show_comments_cookies_opt_in',
[118] Fix | Delete
),
[119] Fix | Delete
'media' => array(
[120] Fix | Delete
'thumbnail_size_w',
[121] Fix | Delete
'thumbnail_size_h',
[122] Fix | Delete
'thumbnail_crop',
[123] Fix | Delete
'medium_size_w',
[124] Fix | Delete
'medium_size_h',
[125] Fix | Delete
'large_size_w',
[126] Fix | Delete
'large_size_h',
[127] Fix | Delete
'image_default_size',
[128] Fix | Delete
'image_default_align',
[129] Fix | Delete
'image_default_link_type',
[130] Fix | Delete
),
[131] Fix | Delete
'reading' => array(
[132] Fix | Delete
'posts_per_page',
[133] Fix | Delete
'posts_per_rss',
[134] Fix | Delete
'rss_use_excerpt',
[135] Fix | Delete
'show_on_front',
[136] Fix | Delete
'page_on_front',
[137] Fix | Delete
'page_for_posts',
[138] Fix | Delete
'blog_public',
[139] Fix | Delete
),
[140] Fix | Delete
'writing' => array(
[141] Fix | Delete
'default_category',
[142] Fix | Delete
'default_email_category',
[143] Fix | Delete
'default_link_category',
[144] Fix | Delete
'default_post_format',
[145] Fix | Delete
),
[146] Fix | Delete
);
[147] Fix | Delete
$allowed_options['misc'] = array();
[148] Fix | Delete
$allowed_options['options'] = array();
[149] Fix | Delete
$allowed_options['privacy'] = array();
[150] Fix | Delete
[151] Fix | Delete
$mail_options = array( 'mailserver_url', 'mailserver_port', 'mailserver_login', 'mailserver_pass' );
[152] Fix | Delete
[153] Fix | Delete
if ( ! in_array( get_option( 'blog_charset' ), array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ), true ) ) {
[154] Fix | Delete
$allowed_options['reading'][] = 'blog_charset';
[155] Fix | Delete
}
[156] Fix | Delete
[157] Fix | Delete
if ( get_site_option( 'initial_db_version' ) < 32453 ) {
[158] Fix | Delete
$allowed_options['writing'][] = 'use_smilies';
[159] Fix | Delete
$allowed_options['writing'][] = 'use_balanceTags';
[160] Fix | Delete
}
[161] Fix | Delete
[162] Fix | Delete
if ( ! is_multisite() ) {
[163] Fix | Delete
if ( ! defined( 'WP_SITEURL' ) ) {
[164] Fix | Delete
$allowed_options['general'][] = 'siteurl';
[165] Fix | Delete
}
[166] Fix | Delete
if ( ! defined( 'WP_HOME' ) ) {
[167] Fix | Delete
$allowed_options['general'][] = 'home';
[168] Fix | Delete
}
[169] Fix | Delete
[170] Fix | Delete
$allowed_options['general'][] = 'users_can_register';
[171] Fix | Delete
$allowed_options['general'][] = 'default_role';
[172] Fix | Delete
[173] Fix | Delete
$allowed_options['writing'] = array_merge( $allowed_options['writing'], $mail_options );
[174] Fix | Delete
$allowed_options['writing'][] = 'ping_sites';
[175] Fix | Delete
[176] Fix | Delete
$allowed_options['media'][] = 'uploads_use_yearmonth_folders';
[177] Fix | Delete
[178] Fix | Delete
/*
[179] Fix | Delete
* If upload_url_path is not the default (empty),
[180] Fix | Delete
* or upload_path is not the default ('wp-content/uploads' or empty),
[181] Fix | Delete
* they can be edited, otherwise they're locked.
[182] Fix | Delete
*/
[183] Fix | Delete
if ( get_option( 'upload_url_path' ) || ( get_option( 'upload_path' ) != 'wp-content/uploads' && get_option( 'upload_path' ) ) ) {
[184] Fix | Delete
$allowed_options['media'][] = 'upload_path';
[185] Fix | Delete
$allowed_options['media'][] = 'upload_url_path';
[186] Fix | Delete
}
[187] Fix | Delete
} else {
[188] Fix | Delete
/**
[189] Fix | Delete
* Filters whether the post-by-email functionality is enabled.
[190] Fix | Delete
*
[191] Fix | Delete
* @since 3.0.0
[192] Fix | Delete
*
[193] Fix | Delete
* @param bool $enabled Whether post-by-email configuration is enabled. Default true.
[194] Fix | Delete
*/
[195] Fix | Delete
if ( apply_filters( 'enable_post_by_email_configuration', true ) ) {
[196] Fix | Delete
$allowed_options['writing'] = array_merge( $allowed_options['writing'], $mail_options );
[197] Fix | Delete
}
[198] Fix | Delete
}
[199] Fix | Delete
[200] Fix | Delete
/**
[201] Fix | Delete
* Filters the allowed options list.
[202] Fix | Delete
*
[203] Fix | Delete
* @since 2.7.0
[204] Fix | Delete
* @deprecated 5.5.0 Use {@see 'allowed_options'} instead.
[205] Fix | Delete
*
[206] Fix | Delete
* @param array $allowed_options The allowed options list.
[207] Fix | Delete
*/
[208] Fix | Delete
$allowed_options = apply_filters_deprecated(
[209] Fix | Delete
'whitelist_options',
[210] Fix | Delete
array( $allowed_options ),
[211] Fix | Delete
'5.5.0',
[212] Fix | Delete
'allowed_options',
[213] Fix | Delete
__( 'Please consider writing more inclusive code.' )
[214] Fix | Delete
);
[215] Fix | Delete
[216] Fix | Delete
/**
[217] Fix | Delete
* Filters the allowed options list.
[218] Fix | Delete
*
[219] Fix | Delete
* @since 5.5.0
[220] Fix | Delete
*
[221] Fix | Delete
* @param array $allowed_options The allowed options list.
[222] Fix | Delete
*/
[223] Fix | Delete
$allowed_options = apply_filters( 'allowed_options', $allowed_options );
[224] Fix | Delete
[225] Fix | Delete
if ( 'update' === $action ) { // We are saving settings sent from a settings page.
[226] Fix | Delete
if ( 'options' === $option_page && ! isset( $_POST['option_page'] ) ) { // This is for back compat and will eventually be removed.
[227] Fix | Delete
$unregistered = true;
[228] Fix | Delete
check_admin_referer( 'update-options' );
[229] Fix | Delete
} else {
[230] Fix | Delete
$unregistered = false;
[231] Fix | Delete
check_admin_referer( $option_page . '-options' );
[232] Fix | Delete
}
[233] Fix | Delete
[234] Fix | Delete
if ( ! isset( $allowed_options[ $option_page ] ) ) {
[235] Fix | Delete
wp_die(
[236] Fix | Delete
sprintf(
[237] Fix | Delete
/* translators: %s: The options page name. */
[238] Fix | Delete
__( '<strong>Error</strong>: Options page %s not found in the allowed options list.' ),
[239] Fix | Delete
'<code>' . esc_html( $option_page ) . '</code>'
[240] Fix | Delete
)
[241] Fix | Delete
);
[242] Fix | Delete
}
[243] Fix | Delete
[244] Fix | Delete
if ( 'options' === $option_page ) {
[245] Fix | Delete
if ( is_multisite() && ! current_user_can( 'manage_network_options' ) ) {
[246] Fix | Delete
wp_die( __( 'Sorry, you are not allowed to modify unregistered settings for this site.' ) );
[247] Fix | Delete
}
[248] Fix | Delete
$options = explode( ',', wp_unslash( $_POST['page_options'] ) );
[249] Fix | Delete
} else {
[250] Fix | Delete
$options = $allowed_options[ $option_page ];
[251] Fix | Delete
}
[252] Fix | Delete
[253] Fix | Delete
if ( 'general' === $option_page ) {
[254] Fix | Delete
// Handle custom date/time formats.
[255] Fix | Delete
if ( ! empty( $_POST['date_format'] ) && isset( $_POST['date_format_custom'] )
[256] Fix | Delete
&& '\c\u\s\t\o\m' === wp_unslash( $_POST['date_format'] )
[257] Fix | Delete
) {
[258] Fix | Delete
$_POST['date_format'] = $_POST['date_format_custom'];
[259] Fix | Delete
}
[260] Fix | Delete
[261] Fix | Delete
if ( ! empty( $_POST['time_format'] ) && isset( $_POST['time_format_custom'] )
[262] Fix | Delete
&& '\c\u\s\t\o\m' === wp_unslash( $_POST['time_format'] )
[263] Fix | Delete
) {
[264] Fix | Delete
$_POST['time_format'] = $_POST['time_format_custom'];
[265] Fix | Delete
}
[266] Fix | Delete
[267] Fix | Delete
// Map UTC+- timezones to gmt_offsets and set timezone_string to empty.
[268] Fix | Delete
if ( ! empty( $_POST['timezone_string'] ) && preg_match( '/^UTC[+-]/', $_POST['timezone_string'] ) ) {
[269] Fix | Delete
$_POST['gmt_offset'] = $_POST['timezone_string'];
[270] Fix | Delete
$_POST['gmt_offset'] = preg_replace( '/UTC\+?/', '', $_POST['gmt_offset'] );
[271] Fix | Delete
$_POST['timezone_string'] = '';
[272] Fix | Delete
}
[273] Fix | Delete
[274] Fix | Delete
// Handle translation installation.
[275] Fix | Delete
if ( ! empty( $_POST['WPLANG'] ) && current_user_can( 'install_languages' ) ) {
[276] Fix | Delete
require_once ABSPATH . 'wp-admin/includes/translation-install.php';
[277] Fix | Delete
[278] Fix | Delete
if ( wp_can_install_language_pack() ) {
[279] Fix | Delete
$language = wp_download_language_pack( $_POST['WPLANG'] );
[280] Fix | Delete
if ( $language ) {
[281] Fix | Delete
$_POST['WPLANG'] = $language;
[282] Fix | Delete
}
[283] Fix | Delete
}
[284] Fix | Delete
}
[285] Fix | Delete
}
[286] Fix | Delete
[287] Fix | Delete
if ( $options ) {
[288] Fix | Delete
$user_language_old = get_user_locale();
[289] Fix | Delete
[290] Fix | Delete
foreach ( $options as $option ) {
[291] Fix | Delete
if ( $unregistered ) {
[292] Fix | Delete
_deprecated_argument(
[293] Fix | Delete
'options.php',
[294] Fix | Delete
'2.7.0',
[295] Fix | Delete
sprintf(
[296] Fix | Delete
/* translators: %s: The option/setting. */
[297] Fix | Delete
__( 'The %s setting is unregistered. Unregistered settings are deprecated. See https://developer.wordpress.org/plugins/settings/settings-api/' ),
[298] Fix | Delete
'<code>' . esc_html( $option ) . '</code>'
[299] Fix | Delete
)
[300] Fix | Delete
);
[301] Fix | Delete
}
[302] Fix | Delete
[303] Fix | Delete
$option = trim( $option );
[304] Fix | Delete
$value = null;
[305] Fix | Delete
if ( isset( $_POST[ $option ] ) ) {
[306] Fix | Delete
$value = $_POST[ $option ];
[307] Fix | Delete
if ( ! is_array( $value ) ) {
[308] Fix | Delete
$value = trim( $value );
[309] Fix | Delete
}
[310] Fix | Delete
$value = wp_unslash( $value );
[311] Fix | Delete
}
[312] Fix | Delete
update_option( $option, $value );
[313] Fix | Delete
}
[314] Fix | Delete
[315] Fix | Delete
/*
[316] Fix | Delete
* Switch translation in case WPLANG was changed.
[317] Fix | Delete
* The global $locale is used in get_locale() which is
[318] Fix | Delete
* used as a fallback in get_user_locale().
[319] Fix | Delete
*/
[320] Fix | Delete
unset( $GLOBALS['locale'] );
[321] Fix | Delete
$user_language_new = get_user_locale();
[322] Fix | Delete
if ( $user_language_old !== $user_language_new ) {
[323] Fix | Delete
load_default_textdomain( $user_language_new );
[324] Fix | Delete
}
[325] Fix | Delete
}
[326] Fix | Delete
[327] Fix | Delete
/*
[328] Fix | Delete
* Handle settings errors and return to options page.
[329] Fix | Delete
*/
[330] Fix | Delete
[331] Fix | Delete
// If no settings errors were registered add a general 'updated' message.
[332] Fix | Delete
if ( ! count( get_settings_errors() ) ) {
[333] Fix | Delete
add_settings_error( 'general', 'settings_updated', __( 'Settings saved.' ), 'success' );
[334] Fix | Delete
}
[335] Fix | Delete
set_transient( 'settings_errors', get_settings_errors(), 30 );
[336] Fix | Delete
[337] Fix | Delete
// Redirect back to the settings page that was submitted.
[338] Fix | Delete
$goback = add_query_arg( 'settings-updated', 'true', wp_get_referer() );
[339] Fix | Delete
wp_redirect( $goback );
[340] Fix | Delete
exit;
[341] Fix | Delete
}
[342] Fix | Delete
[343] Fix | Delete
require_once ABSPATH . 'wp-admin/admin-header.php'; ?>
[344] Fix | Delete
[345] Fix | Delete
<div class="wrap">
[346] Fix | Delete
<h1><?php esc_html_e( 'All Settings' ); ?></h1>
[347] Fix | Delete
[348] Fix | Delete
<div class="notice notice-warning">
[349] Fix | Delete
<p><strong><?php _e( 'Warning:' ); ?></strong> <?php _e( 'This page allows direct access to your site settings. You can break things here. Please be cautious!' ); ?></p>
[350] Fix | Delete
</div>
[351] Fix | Delete
[352] Fix | Delete
<form name="form" action="options.php" method="post" id="all-options">
[353] Fix | Delete
<?php wp_nonce_field( 'options-options' ); ?>
[354] Fix | Delete
<input type="hidden" name="action" value="update" />
[355] Fix | Delete
<input type="hidden" name="option_page" value="options" />
[356] Fix | Delete
<table class="form-table" role="presentation">
[357] Fix | Delete
<?php
[358] Fix | Delete
$options = $wpdb->get_results( "SELECT * FROM $wpdb->options ORDER BY option_name" );
[359] Fix | Delete
[360] Fix | Delete
foreach ( (array) $options as $option ) :
[361] Fix | Delete
$disabled = false;
[362] Fix | Delete
[363] Fix | Delete
if ( '' === $option->option_name ) {
[364] Fix | Delete
continue;
[365] Fix | Delete
}
[366] Fix | Delete
[367] Fix | Delete
if ( is_serialized( $option->option_value ) ) {
[368] Fix | Delete
if ( is_serialized_string( $option->option_value ) ) {
[369] Fix | Delete
// This is a serialized string, so we should display it.
[370] Fix | Delete
$value = maybe_unserialize( $option->option_value );
[371] Fix | Delete
$options_to_update[] = $option->option_name;
[372] Fix | Delete
$class = 'all-options';
[373] Fix | Delete
} else {
[374] Fix | Delete
$value = 'SERIALIZED DATA';
[375] Fix | Delete
$disabled = true;
[376] Fix | Delete
$class = 'all-options disabled';
[377] Fix | Delete
}
[378] Fix | Delete
} else {
[379] Fix | Delete
$value = $option->option_value;
[380] Fix | Delete
$options_to_update[] = $option->option_name;
[381] Fix | Delete
$class = 'all-options';
[382] Fix | Delete
}
[383] Fix | Delete
[384] Fix | Delete
$name = esc_attr( $option->option_name );
[385] Fix | Delete
?>
[386] Fix | Delete
<tr>
[387] Fix | Delete
<th scope="row"><label for="<?php echo $name; ?>"><?php echo esc_html( $option->option_name ); ?></label></th>
[388] Fix | Delete
<td>
[389] Fix | Delete
<?php if ( strpos( $value, "\n" ) !== false ) : ?>
[390] Fix | Delete
<textarea class="<?php echo $class; ?>" name="<?php echo $name; ?>" id="<?php echo $name; ?>" cols="30" rows="5"><?php echo esc_textarea( $value ); ?></textarea>
[391] Fix | Delete
<?php else : ?>
[392] Fix | Delete
<input class="regular-text <?php echo $class; ?>" type="text" name="<?php echo $name; ?>" id="<?php echo $name; ?>" value="<?php echo esc_attr( $value ); ?>"<?php disabled( $disabled, true ); ?> />
[393] Fix | Delete
<?php endif ?></td>
[394] Fix | Delete
</tr>
[395] Fix | Delete
<?php endforeach; ?>
[396] Fix | Delete
</table>
[397] Fix | Delete
[398] Fix | Delete
<input type="hidden" name="page_options" value="<?php echo esc_attr( implode( ',', $options_to_update ) ); ?>" />
[399] Fix | Delete
[400] Fix | Delete
<?php submit_button( __( 'Save Changes' ), 'primary', 'Update' ); ?>
[401] Fix | Delete
[402] Fix | Delete
</form>
[403] Fix | Delete
</div>
[404] Fix | Delete
[405] Fix | Delete
<?php
[406] Fix | Delete
require_once ABSPATH . 'wp-admin/admin-footer.php';
[407] Fix | Delete
[408] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function