Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 48 additions & 46 deletions src/wp-admin/network/site-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,62 +132,64 @@
)
);

$ltr_fields = array(
'siteurl',
'home',
'admin_email',
'new_admin_email',
'mailserver_url',
'mailserver_login',
'mailserver_pass',
'ping_sites',
'permalink_structure',
'category_base',
'tag_base',
'upload_path',
'upload_url_path',
);

foreach ( $options as $option ) {
if ( 'default_role' === $option->option_name ) {
$editblog_default_role = $option->option_value;
}

$disabled = false;
$class = 'all-options';
$value = $option->option_value;
$disabled = false;
$is_serialized = false;

if ( is_serialized( $option->option_value ) ) {
if ( is_serialized_string( $option->option_value ) ) {
$option->option_value = esc_html( maybe_unserialize( $option->option_value ) );
if ( is_serialized( $value ) ) {
if ( is_serialized_string( $value ) ) {
$value = maybe_unserialize( $value );
} else {
$option->option_value = 'SERIALIZED DATA';
$disabled = true;
$class = 'all-options disabled';
// Other serialized values (arrays, objects) are shown raw, read-only, inside a collapsible <details>.
$disabled = true;
$is_serialized = true;
}
}

$ltr_fields = array(
'siteurl',
'home',
'admin_email',
'new_admin_email',
'mailserver_url',
'mailserver_login',
'mailserver_pass',
'ping_sites',
'permalink_structure',
'category_base',
'tag_base',
'upload_path',
'upload_url_path',
);
if ( in_array( $option->option_name, $ltr_fields, true ) ) {
$class .= ' ltr';
}

if ( str_contains( $option->option_value, "\n" ) ) {
?>
<tr class="form-field">
<th scope="row"><label for="<?php echo esc_attr( $option->option_name ); ?>" class="code"><?php echo esc_html( $option->option_name ); ?></label></th>
<td><textarea class="<?php echo $class; ?>" rows="5" cols="40" name="option[<?php echo esc_attr( $option->option_name ); ?>]" id="<?php echo esc_attr( $option->option_name ); ?>"<?php disabled( $disabled ); ?>><?php echo esc_textarea( $option->option_value ); ?></textarea></td>
</tr>
<?php
} else {
?>
<tr class="form-field">
<th scope="row"><label for="<?php echo esc_attr( $option->option_name ); ?>" class="code"><?php echo esc_html( $option->option_name ); ?></label></th>
<?php if ( $is_main_site && in_array( $option->option_name, array( 'siteurl', 'home' ), true ) ) { ?>
<td><code><?php echo esc_html( $option->option_value ); ?></code></td>
<?php } else { ?>
<td><input class="<?php echo $class; ?>" name="option[<?php echo esc_attr( $option->option_name ); ?>]" type="text" id="<?php echo esc_attr( $option->option_name ); ?>" value="<?php echo esc_attr( $option->option_value ); ?>" size="40" <?php disabled( $disabled ); ?> /></td>
<?php } ?>
</tr>
<?php
}
$class = 'all-options' . ( $disabled ? ' disabled' : '' );
$class .= in_array( $option->option_name, $ltr_fields, true ) ? ' ltr' : '';
$name = esc_attr( $option->option_name );
$label = esc_html( $option->option_name );
?>
<tr class="form-field">
<th scope="row"><label for="<?php echo $name; ?>" class="code"><?php echo $label; ?></label></th>
<?php if ( $is_serialized ) : ?>
<td>
<details class="<?php echo $class; ?>">
<summary><?php esc_html_e( 'Serialized data' ); ?></summary>
<textarea class="<?php echo $class; ?>" rows="5" cols="40" id="<?php echo $name; ?>" readonly="readonly"><?php echo esc_textarea( $value ); ?></textarea>
</details>
</td>
<?php elseif ( str_contains( $value, "\n" ) ) : ?>
<td><textarea class="<?php echo $class; ?>" rows="5" cols="40" name="option[<?php echo $name; ?>]" id="<?php echo $name; ?>"<?php disabled( $disabled ); ?>><?php echo esc_textarea( $value ); ?></textarea></td>
<?php elseif ( $is_main_site && in_array( $option->option_name, array( 'siteurl', 'home' ), true ) ) : ?>
<td><code><?php echo esc_html( $value ); ?></code></td>
<?php else : ?>
<td><input class="<?php echo $class; ?>" name="option[<?php echo $name; ?>]" type="text" id="<?php echo $name; ?>" value="<?php echo esc_attr( $value ); ?>" size="40" <?php disabled( $disabled ); ?> /></td>
<?php endif; ?>
</tr>
<?php
} // End foreach.

/**
Expand Down
51 changes: 26 additions & 25 deletions src/wp-admin/options.php
Original file line number Diff line number Diff line change
Expand Up @@ -400,56 +400,57 @@
$options = $wpdb->get_results( "SELECT * FROM $wpdb->options ORDER BY option_name" );

foreach ( (array) $options as $option ) :
$disabled = false;

if ( '' === $option->option_name ) {
continue;
}

if ( 'home' === $option->option_name && defined( 'WP_HOME' ) ) {
$disabled = true;
}
$value = $option->option_value;
$disabled = false;
$is_serialized = false;

if ( 'siteurl' === $option->option_name && defined( 'WP_SITEURL' ) ) {
if ( ( 'home' === $option->option_name && defined( 'WP_HOME' ) )
|| ( 'siteurl' === $option->option_name && defined( 'WP_SITEURL' ) )
) {
$disabled = true;
}

if ( is_serialized( $option->option_value ) ) {
if ( is_serialized_string( $option->option_value ) ) {
// This is a serialized string, so we should display it.
$value = maybe_unserialize( $option->option_value );
if ( is_serialized( $value ) ) {
if ( is_serialized_string( $value ) ) {
// Serialized strings can be safely displayed and edited as their unserialized form.
$value = maybe_unserialize( $value );
$options_to_update[] = $option->option_name;
} else {
$value = 'SERIALIZED DATA';
$disabled = true;
// Other serialized values (arrays, objects) are shown raw, read-only, inside a collapsible <details>.
$disabled = true;
$is_serialized = true;
}
} elseif ( str_starts_with( $option->option_name, 'connectors_' )
&& str_ends_with( $option->option_name, '_api_key' )
) {
// Mask connector API keys and prevent updates from this screen.
$value = _wp_connectors_mask_api_key( $option->option_value );
$value = _wp_connectors_mask_api_key( $value );
$disabled = true;
} else {
$value = $option->option_value;
$options_to_update[] = $option->option_name;
}

$class = 'all-options';

if ( $disabled ) {
$class .= ' disabled';
}

$name = esc_attr( $option->option_name );
$class = 'all-options' . ( $disabled ? ' disabled' : '' );
$name = esc_attr( $option->option_name );
?>
<tr>
<th scope="row"><label for="<?php echo $name; ?>"><?php echo esc_html( $option->option_name ); ?></label></th>
<td>
<?php if ( str_contains( $value, "\n" ) ) : ?>
<textarea class="<?php echo $class; ?>" name="<?php echo $name; ?>" id="<?php echo $name; ?>" cols="30" rows="5"><?php echo esc_textarea( $value ); ?></textarea>
<td>
<?php if ( $is_serialized ) : ?>
<details class="<?php echo $class; ?>">
<summary><?php esc_html_e( 'Serialized data' ); ?></summary>
<textarea class="<?php echo $class; ?>" id="<?php echo $name; ?>" cols="30" rows="5" readonly="readonly"><?php echo esc_textarea( $value ); ?></textarea>
</details>
<?php elseif ( str_contains( $value, "\n" ) ) : ?>
<textarea class="<?php echo $class; ?>" name="<?php echo $name; ?>" id="<?php echo $name; ?>" cols="30" rows="5"<?php disabled( $disabled, true ); ?>><?php echo esc_textarea( $value ); ?></textarea>
<?php else : ?>
<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 ); ?> />
<?php endif; ?></td>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</table>
Expand Down
Loading