Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/Yoast/wordpress-seo into PHPCS
Browse files Browse the repository at this point in the history
Conflicts:
	admin/class-config.php
	inc/class-wpseo-options.php
  • Loading branch information
jrfnl committed Jul 3, 2014
2 parents d4030c8 + 1f63659 commit b795c1f
Show file tree
Hide file tree
Showing 11 changed files with 519 additions and 145 deletions.
6 changes: 3 additions & 3 deletions admin/class-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ class WPSEO_Admin {
function __construct() {
$options = WPSEO_Options::get_all();

if ( is_multisite() && $options['ms_defaults_set'] === false ) {
WPSEO_Options::set_multisite_defaults();
if ( is_multisite() ) {
WPSEO_Options::maybe_set_multisite_defaults( false );
}

if ( $options['stripcategorybase'] === true ) {
Expand Down Expand Up @@ -723,4 +723,4 @@ function social_page() {

} /* End of class */

} /* End of class-exists wrapper */
} /* End of class-exists wrapper */
10 changes: 5 additions & 5 deletions admin/class-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,8 @@ function admin_header( $form = true, $option = 'yoast_wpseo_options', $optionsho
if ( $form === true ) {
echo '<form action="' . esc_url( admin_url( 'options.php' ) ) . '" method="post" id="wpseo-conf"' . ( $contains_files ? ' enctype="multipart/form-data"' : '' ) . ' accept-charset="' . esc_attr( get_bloginfo( 'charset' ) ) . '">';
settings_fields( $option );
$this->currentoption = $optionshort;
}

$this->currentoption = $optionshort;
}

/**
Expand Down Expand Up @@ -250,7 +249,7 @@ function admin_footer( $submit = true, $show_sidebar = true ) {
<div class="inside">
<h4>' . esc_html( __( 'Current option:', 'wordpress-seo' ) ) . ' <span class="wpseo-debug">' . esc_html( $this->currentoption ) . '</span></h4>
' . ( $xdebug ? '' : '<pre>' );
var_dump( get_option( $this->currentoption ) );
var_dump( $this->get_option( $this->currentoption ) );
echo '
' . ( $xdebug ? '' : '</pre>' ) . '
</div>
Expand Down Expand Up @@ -384,7 +383,7 @@ function config_page_scripts() {
* @return array
*/
function get_option( $option ) {
if ( function_exists( 'is_network_admin' ) && is_network_admin() ) {
if ( is_network_admin() ) {
return get_site_option( $option );
}
else {
Expand Down Expand Up @@ -518,13 +517,14 @@ function select( $var, $label, $values, $option = '' ) {
}

$options = $this->get_option( $option );
$val = ( isset( $options[$var] ) ) ? $options[$var] : '';

$output = '<label class="select" for="' . esc_attr( $var ) . '">' . $label . ':</label>';
$output .= '<select class="select" name="' . esc_attr( $option ) . '[' . esc_attr( $var ) . ']" id="' . esc_attr( $var ) . '">';

foreach ( $values as $value => $label ) {
if ( ! empty( $label ) ) {
$output .= '<option value="' . esc_attr( $value ) . '"' . selected( $options[ $var ], $value, false ) . '>' . $label . '</option>';
$output .= '<option value="' . esc_attr( $value ) . '"' . selected( $val, $value, false ) . '>' . $label . '</option>';
}
}
$output .= '</select>';
Expand Down
95 changes: 83 additions & 12 deletions admin/pages/network.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,70 @@
foreach ( array( 'access', 'defaultblog' ) as $opt ) {
$options[ $opt ] = $_POST['wpseo_ms'][ $opt ];
}
update_site_option( 'wpseo_ms', $options );
echo '<div id="message" class="updated"><p>' . __( 'Settings Updated.', 'wordpress-seo' ) . '</p></div>';
WPSEO_Options::update_site_option( 'wpseo_ms', $options );
add_settings_error( 'wpseo_ms', 'settings_updated', __( 'Settings Updated.', 'wordpress-seo' ), 'updated' );
}

if ( isset( $_POST[ 'wpseo_restore_blog' ] ) ) {
check_admin_referer( 'wpseo-network-restore' );
if ( isset( $_POST['wpseo_ms']['restoreblog'] ) && is_numeric( $_POST['wpseo_ms']['restoreblog'] ) ) {
$restoreblog = (int) WPSEO_Option::validate_int( $_POST['wpseo_ms']['restoreblog'] );
$blog = get_blog_details( $restoreblog );
$blog = get_blog_details( $restoreblog );

if ( $blog ) {
WPSEO_Options::reset_ms_blog( $restoreblog );

echo '<div id="message" class="updated"><p>' . sprintf( __( '%s restored to default SEO settings.', 'wordpress-seo' ), esc_html( $blog->blogname ) ) . '</p></div>';
add_settings_error( 'wpseo_ms', 'settings_updated', sprintf( __( '%s restored to default SEO settings.', 'wordpress-seo' ), esc_html( $blog->blogname ) ), 'updated' );
}
else {
echo '<div id="message" class="updated error"><p>' . sprintf( __( 'Blog %s not found.', 'wordpress-seo' ), esc_html( $restoreblog ) ) . '</p></div>';
add_settings_error( 'wpseo_ms', 'settings_updated', sprintf( __( 'Blog %s not found.', 'wordpress-seo' ), esc_html( $restoreblog ) ), 'error' );
}
unset( $restoreblog );
}
}

$wpseo_admin_pages->admin_header( false );
/* Set up selectbox dropdowns for smaller networks (usability) */
$use_dropdown = true;
if ( get_blog_count() > 100 ) {
$use_dropdown = false;
}
else {
$sites = wp_get_sites( array( 'deleted' => 0 ) );
if ( is_array( $sites ) && $sites !== array() ) {
$dropdown_input = array(
'-' => __( 'None', 'wordpress-seo' ),
);

foreach ( $sites as $site ) {
$dropdown_input[ $site['blog_id'] ] = $site['blog_id'] . ': ' . $site['domain'];

$blog_states = array();
if ( $site['public'] === '1' ) {
$blog_states[] = __( 'public', 'wordpress-seo' );
}
if ( $site['archived'] === '1' ) {
$blog_states[] = __( 'archived', 'wordpress-seo' );
}
if ( $site['mature'] === '1' ) {
$blog_states[] = __( 'mature', 'wordpress-seo' );
}
if ( $site['spam'] === '1' ) {
$blog_states[] = __( 'spam', 'wordpress-seo' );
}
if ( $blog_states !== array() ) {
$dropdown_input[ $site['blog_id'] ] .= ' [' . implode( ', ', $blog_states ) . ']';
}
}
unset( $site, $blog_states );
}
else {
$use_dropdown = false;
}
unset( $sites );
}



$wpseo_admin_pages->admin_header( false, 'wpseo-network-settings', 'wpseo_ms' );

$content = '<form method="post" accept-charset="' . esc_attr( get_bloginfo( 'charset' ) ) . '">';
$content .= wp_nonce_field( 'wpseo-network-settings', '_wpnonce', true, false );
Expand All @@ -55,20 +97,49 @@
),
'wpseo_ms'
);
$content .= $wpseo_admin_pages->textinput( 'defaultblog', __( 'New blogs get the SEO settings from this blog', 'wordpress-seo' ), 'wpseo_ms' );
$content .= '<p>' . __( 'Enter the Blog ID for the site whose settings you want to use as default for all sites that are added to your network. Leave empty for none (i.e. the normal plugin defaults will be used).', 'wordpress-seo' ) . '</p>';

if ( $use_dropdown === true ) {
$content .= $wpseo_admin_pages->select(
'defaultblog',
__( 'New sites in the network inherit their SEO settings from this site', 'wordpress-seo' ),
$dropdown_input,
'wpseo_ms'
);
$content .= '<p>' . __( 'Choose the site whose settings you want to use as default for all sites that are added to your network. If you choose \'None\', the normal plugin defaults will be used.', 'wordpress-seo' ) . '</p>';
}
else {
$content .= $wpseo_admin_pages->textinput( 'defaultblog', __( 'New sites in the network get the SEO settings from this site', 'wordpress-seo' ), 'wpseo_ms' );
$content .= '<p>' . sprintf( __( 'Enter the %sSite ID%s for the site whose settings you want to use as default for all sites that are added to your network. Leave empty for none (i.e. the normal plugin defaults will be used).', 'wordpress-seo' ), '<a href="' . esc_url( network_admin_url( 'sites.php' ) ) . '">', '</a>' ) . '</p>';
}
$content .= '<p><strong>' . __( 'Take note :', 'wordpress-seo' ) . '</strong> ' . __( 'Privacy sensitive (FB admins and such), theme specific (title rewrite) and a few very site specific settings will not be imported to new blogs.', 'wordpress-seo' ) . '</p>';


$content .= '<input type="submit" name="wpseo_submit" class="button-primary" value="' . __( 'Save MultiSite Settings', 'wordpress-seo' ) . '"/>';
$content .= '</form>';

$wpseo_admin_pages->postbox( 'wpseo_export', __( 'MultiSite Settings', 'wordpress-seo' ), $content );
$wpseo_admin_pages->postbox( 'wpseo_network_settings', __( 'MultiSite Settings', 'wordpress-seo' ), $content );


$content = '<form method="post" accept-charset="' . esc_attr( get_bloginfo( 'charset' ) ) . '">';
$content .= wp_nonce_field( 'wpseo-network-restore', '_wpnonce', true, false );
$content .= '<p>' . __( 'Using this form you can reset a site to the default SEO settings.', 'wordpress-seo' ) . '</p>';
$content .= $wpseo_admin_pages->textinput( 'restoreblog', __( 'Blog ID', 'wordpress-seo' ), 'wpseo_ms' );

if ( $use_dropdown === true ) {
unset( $dropdown_input['-'] );
$content .= $wpseo_admin_pages->select(
'restoreblog',
__( 'Site ID', 'wordpress-seo' ),
$dropdown_input,
'wpseo_ms'
);
}
else {
$content .= $wpseo_admin_pages->textinput( 'restoreblog', __( 'Blog ID', 'wordpress-seo' ), 'wpseo_ms' );
}

$content .= '<input type="submit" name="wpseo_restore_blog" value="' . __( 'Restore site to defaults', 'wordpress-seo' ) . '" class="button"/>';
$content .= '</form>';

$wpseo_admin_pages->postbox( 'wpseo_export', __( 'Restore site to default settings', 'wordpress-seo' ), $content );
$wpseo_admin_pages->postbox( 'wpseo-network-restore', __( 'Restore site to default settings', 'wordpress-seo' ), $content );

$wpseo_admin_pages->admin_footer( false );
4 changes: 4 additions & 0 deletions css/yst_plugin_tools.css
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ input.textinput, textarea.textinput, select.select, input.checkbox {
padding: 5px;
}

select.select {
padding: 3px;
}

input.checkbox.double {
margin-top: 2px;
}
Expand Down
2 changes: 1 addition & 1 deletion css/yst_plugin_tools.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b795c1f

Please sign in to comment.