Skip to content

Commit

Permalink
Fix CSS admin notices (#664)
Browse files Browse the repository at this point in the history
  • Loading branch information
herrvigg committed Apr 6, 2019
1 parent 9cc1928 commit b9e7550
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 35 deletions.
22 changes: 11 additions & 11 deletions admin/qtx_activation_hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,7 @@ function qtranxf_admin_notice_config_files_changed() {
}
qtranxf_admin_notice_dismiss_script();
$url = admin_url( 'options-general.php?page=qtranslate-xt#integration' );
echo '<div class="update-nag qtranxs-notice-ajax notice is-dismissible" id="qtranxs-config-files-changed" action="unset"><p>';
echo '<div class="notice notice-success qtranxs-notice-ajax is-dismissible" id="qtranxs-config-files-changed" action="unset"><p>';
printf( __( 'Option "%s" for plugin %s has been auto-adjusted after recent changes in the site configuration. It might be a good idea to %sreview the changes%s in the list of configuration files.', 'qtranslate' ), '<a href="' . $url . '">' . __( 'Configuration Files', 'qtranslate' ) . '</a>', qtranxf_get_plugin_link(), '<a href="' . $url . '">', '</a>' );
echo '<br/></p><p>';
echo '<a class="button" href="' . $url . '">';
Expand All @@ -852,7 +852,7 @@ function qtranxf_admin_notice_first_install() {
return;
}
qtranxf_admin_notice_dismiss_script();
echo '<div class="updated qtranxs-notice-ajax notice is-dismissible" id="qtranxs-initial-install"><p style="font-size: larger;">';// text-align: center;
echo '<div class="notice notice-info qtranxs-notice-ajax notice is-dismissible" id="qtranxs-initial-install"><p>';
printf( __( 'Are you new to plugin %s?', 'qtranslate' ), qtranxf_get_plugin_link() );
echo '<br/>';
echo '</p><p><a class="button" href="https://qtranslatexteam.wordpress.com/startup-guide/" target="_blank">';
Expand Down Expand Up @@ -899,7 +899,7 @@ function qtranxf_admin_notices_new_options( $nms, $ver, $url, $conf_url = null )
}
$me = qtranxf_get_plugin_link();
qtranxf_admin_notice_dismiss_script();
echo '<div class="update-nag qtranxs-notice-ajax notice is-dismissible" id="qtranxs-' . $id . '">';// style="font-size: larger"
echo '<div class="notice notice-info qtranxs-notice-ajax is-dismissible" id="qtranxs-' . $id . '">';
if ( ! empty( $nms ) ) {
$opns = '';
foreach ( $nms as $nm ) {
Expand Down Expand Up @@ -958,16 +958,16 @@ function qtranxf_admin_notice_plugin_conflict( $title, $plugin ) {
return;
}
$me = qtranxf_get_plugin_link();
$link = '<a href="https://wordpress.org/plugins/' . dirname( $plugin ) . '/" style="color:magenta" target="_blank">' . $title . '</a>';
echo '<div class="error notice is-dismissible"><p style="font-size: larger">';
printf( __( '%sError:%s plugin %s cannot run concurrently with plugin %s. You may import and export compatible settings between %s and %s on Settings/<a href="%s">Languages</a> configuration page. Then you have to deactivate one of the plugins to continue.', 'qtranslate' ), '<span style="color:red"><strong>', '</strong></span>', $me, $link, 'qTranslate&#8209;XT', $title, admin_url( 'options-general.php?page=qtranslate-xt' ), 'qtranslate' );
$link = '<a href="https://wordpress.org/plugins/' . dirname( $plugin ) . '/" target="_blank">' . $title . '</a>';
echo '<div class="notice notice-error is-dismissible"><p>';
printf( __( '%sError:%s plugin %s cannot run concurrently with plugin %s. You may import and export compatible settings between %s and %s on Settings/<a href="%s">Languages</a> configuration page. Then you have to deactivate one of the plugins to continue.', 'qtranslate' ), '<strong>', '</strong>', $me, $link, 'qTranslate&#8209;XT', $title, admin_url( 'options-general.php?page=qtranslate-xt' ), 'qtranslate' );
echo ' ';
printf( __( 'It might be a good idea to review %smigration instructions%s, if you have not yet done so.', 'qtranslate' ), '<a href="https://qtranslatexteam.wordpress.com/migration/" target="_blank">', '</a>' );

$nonce = wp_create_nonce( 'deactivate-plugin_' . $plugin );
echo '</p><p> &nbsp; &nbsp; &nbsp; &nbsp;<a class="button" href="' . admin_url( 'plugins.php?action=deactivate&plugin=' . urlencode( $plugin ) . '&plugin_status=all&paged=1&s&_wpnonce=' . $nonce ) . '"><strong>' . sprintf( __( 'Deactivate %s', 'qtranslate' ), '<span style="color:magenta">' . $title . '</span>' ) . '</strong></a>';
echo '</p><p> &nbsp; &nbsp; &nbsp; &nbsp;<a class="button" href="' . admin_url( 'plugins.php?action=deactivate&plugin=' . urlencode( $plugin ) . '&plugin_status=all&paged=1&s&_wpnonce=' . $nonce ) . '"><strong>' . sprintf( __( 'Deactivate %s', 'qtranslate' ), $title ) . '</strong></a>';
$nonce = wp_create_nonce( 'deactivate-plugin_qtranslate-xt/qtranslate.php' );
echo ' &nbsp; &nbsp; &nbsp; &nbsp;<a class="button" href="' . admin_url( 'plugins.php?action=deactivate&plugin=' . urlencode( 'qtranslate-xt/qtranslate.php' ) . '&plugin_status=all&paged=1&s&_wpnonce=' . $nonce ) . '"><strong>' . sprintf( __( 'Deactivate %s', 'qtranslate' ), '<span style="color:blue">qTranslate&#8209;XT</span>' ) . '</strong></a>';
echo ' &nbsp; &nbsp; &nbsp; &nbsp;<a class="button" href="' . admin_url( 'plugins.php?action=deactivate&plugin=' . urlencode( 'qtranslate-xt/qtranslate.php' ) . '&plugin_status=all&paged=1&s&_wpnonce=' . $nonce ) . '"><strong>' . sprintf( __( 'Deactivate %s', 'qtranslate' ), 'qTranslate&#8209;XT' ) . '</strong></a>';
echo '</p></div>';
}

Expand All @@ -982,7 +982,7 @@ function qtranxf_admin_notices_plugin_conflicts() {
add_action( 'admin_notices', 'qtranxf_admin_notices_plugin_conflicts' );

function qtranxf_get_plugin_link() {
return '<a href="https://github.com/qTranslate/qtranslate-xt/" style="color:blue" target="_blank">qTranslate&#8209;XT</a>';
return '<a href="https://github.com/qTranslate/qtranslate-xt/" target="_blank">qTranslate&#8209;XT</a>';
}

function qtranxf_admin_notices_block_editor() {
Expand Down Expand Up @@ -1037,9 +1037,9 @@ function qtranxf_admin_notices_errors() {
return;
}
foreach ( $msgs as $key => $msg ) {
echo '<div class="error notice is-dismissible" id="qtranxs_config_error_' . $key . '"><p><a href="' . admin_url( 'options-general.php?page=qtranslate-xt' ) . '" style="color:magenta">qTranslate&#8209;XT</a>:&nbsp;';
echo '<div class="notice notice-error is-dismissible" id="qtranxs_config_error_' . $key . '"><p><a href="' . admin_url( 'options-general.php?page=qtranslate-xt' ) . '">qTranslate&#8209;XT</a>:&nbsp;';
//translators: Colon after a title. Template reused from language menu item.
echo sprintf( __( '%s:', 'qtranslate' ), '<strong><span style="color: red;">' . __( 'Error', 'qtranslate' ) . '</span></strong>' );
echo sprintf( __( '%s:', 'qtranslate' ), '<strong>' . __( 'Error', 'qtranslate' ) . '</strong>' );
echo '&nbsp;' . $msg . '</p></div>';
}
}
Expand Down
18 changes: 9 additions & 9 deletions admin/qtx_admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -824,18 +824,18 @@ function qtranxf_admin_notices_config() {
}

$screen = get_current_screen();
if ( isset( $screen->id ) && $screen->id == 'settings_page_qtranslate-x' ) {
if ( isset( $screen->id ) && $screen->id == 'settings_page_qtranslate-xt' ) {
$qtitle = '';
} else {
$qlink = admin_url( 'options-general.php?page=qtranslate-xt' );
$qtitle = '<a href="' . $qlink . '" style="color:magenta">qTranslate&#8209;XT</a>:&nbsp;';
$qtitle = '<a href="' . $qlink . '">qTranslate&#8209;XT</a>:&nbsp;';
}
$fmt = '<div class="%1$s notice is-dismissible" id="qtranxs-%2$s-%1$s"><p>' . $qtitle . '%3$s</p></div>' . PHP_EOL;
$fmt = '<div class="notice notice-%1$s is-dismissible" id="qtranxs-%2$s-%1$s"><p>' . $qtitle . '%3$s</p></div>' . PHP_EOL;

if ( isset( $q_config['url_info']['errors'] ) ) {
if ( is_array( $q_config['url_info']['errors'] ) ) {
//translators: Colon after a title. Template reused from language menu item.
$hdr = sprintf( __( '%s:', 'qtranslate' ), '<strong><span style="color: red;">' . __( 'Error', 'qtranslate' ) . '</span></strong>' ) . '&nbsp;';
// translators: Colon after a title. Template reused from language menu item.
$hdr = sprintf( __( '%s:', 'qtranslate' ), '<strong>' . __( 'Error', 'qtranslate' ) . '</strong>' ) . '&nbsp;';
foreach ( $q_config['url_info']['errors'] as $key => $msg ) {
printf( $fmt, 'error', $key, $hdr . $msg );
}
Expand All @@ -844,18 +844,18 @@ function qtranxf_admin_notices_config() {
}
if ( isset( $q_config['url_info']['warnings'] ) ) {
if ( is_array( $q_config['url_info']['warnings'] ) ) {
//translators: Colon after a title. Template reused from language menu item.
$hdr = sprintf( __( '%s:', 'qtranslate' ), '<strong><span style="color: blue;">' . __( 'Warning', 'qtranslate' ) . '</span></strong>' ) . '&nbsp;';
// translators: Colon after a title. Template reused from language menu item.
$hdr = sprintf( __( '%s:', 'qtranslate' ), '<strong>' . __( 'Warning', 'qtranslate' ) . '</strong>' ) . '&nbsp;';
foreach ( $q_config['url_info']['warnings'] as $key => $msg ) {
printf( $fmt, 'update-nag', $key, $hdr . $msg );
printf( $fmt, 'warning', $key, $hdr . $msg );
}
}
unset( $q_config['url_info']['warnings'] );
}
if ( isset( $q_config['url_info']['messages'] ) ) {
if ( is_array( $q_config['url_info']['messages'] ) ) {
foreach ( $q_config['url_info']['messages'] as $key => $msg ) {
printf( $fmt, 'updated', $key, $msg );
printf( $fmt, 'info', $key, $msg );
}
}
unset( $q_config['url_info']['messages'] );
Expand Down
6 changes: 3 additions & 3 deletions admin/qtx_admin_modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ protected static function check_module( $module_def ) {
$incompatible_plugin = $module_def['incompatible'];
if ( isset( $incompatible_plugin ) && is_plugin_active( $incompatible_plugin ) ) {
$module_status = false;
add_action( 'admin_notices', function () use ( $incompatible_plugin ) {
add_action( 'admin_notices', function () use ( $incompatible_plugin, $module_def ) {
$plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $incompatible_plugin, false, true );
$plugin_name = $plugin_data['Name'];
if ( is_plugin_active( $incompatible_plugin ) ) :
?>
<div class="notice notice-error is-dismissible">
<p><?php printf( __( '[%s] Incompatible plugin detected: "%s". Please disable it.', 'qtranslate' ), 'qTranslate&#8209;XT', $plugin_name ); ?></p>
<div class="notice notice-warning is-dismissible">
<p><?php printf( __( 'The plugin "%s" is incompatible with the module "%s" of %s. Please disable it.', 'qtranslate' ), $plugin_name, $module_def['name'], 'qTranslate&#8209;XT' ); ?></p>
<p><a class="button"
href="<?php echo esc_url( wp_nonce_url( admin_url( 'plugins.php?action=deactivate&plugin=' . urlencode( $incompatible_plugin ) ), 'deactivate-plugin_' . $incompatible_plugin ) ) ?>"><strong><?php printf( __( 'Deactivate plugin %s', 'qtranslate' ), $plugin_name ) ?></strong></a>
</div>
Expand Down
19 changes: 7 additions & 12 deletions admin/qtx_import_export.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ function qtranxf_migrate_options_copy( $nm_to, $nm_from ) {
function qtranxf_migrate_import_mqtranslate() {
qtranxf_migrate_import( 'mqTranslate', 'mqtranslate' );
update_option( 'qtranslate_qtrans_compatibility', '1' );//since 3.1
$nm = '<span style="color:blue"><strong>mqTranslate</strong></span>';
qtranxf_add_message( sprintf( __( 'Option "%s" has also been turned on, as the most common case for importing configuration from %s. You may turn it off manually if your setup does not require it. Refer to %sFAQ%s for more information.', 'qtranslate' ), '<span style="color:magenta">' . __( 'Compatibility Functions', 'qtranslate' ) . '</span>', $nm, '<a href="https://qtranslatexteam.wordpress.com/faq/#CompatibilityFunctions" target="_blank">', '</a>' ) );
$nm = '<strong>mqTranslate</strong>';
qtranxf_add_warning( sprintf( __( 'Option "%s" has also been turned on, as the most common case for importing configuration from %s. You may turn it off manually if your setup does not require it. Refer to %sFAQ%s for more information.', 'qtranslate' ), __( 'Compatibility Functions', 'qtranslate' ), $nm, '<a href="https://qtranslatexteam.wordpress.com/faq/#CompatibilityFunctions" target="_blank">', '</a>' ) );
}

function qtranxf_migrate_export_mqtranslate() {
Expand All @@ -82,20 +82,15 @@ function qtranxf_migrate_export_qtranslate_xp() {

function qtranxf_migrate_import( $plugin_name, $nm_from ) {
qtranxf_migrate_options_update( 'qtranslate', $nm_from );

$nm = '<span style="color:blue"><strong>' . $plugin_name . '</strong></span>';

qtranxf_add_message( sprintf( __( 'Applicable options and taxonomy names from plugin %s have been imported. Note that the multilingual content of posts, pages and other objects has not been altered during this operation. There is no additional operation needed to import content, since its format is compatible with %s.', 'qtranslate' ), $nm, 'qTranslate&#8209;XT' ) . ' ' . sprintf( __( 'It might be a good idea to review %smigration instructions%s, if you have not yet done so.', 'qtranslate' ), '<a href="https://qtranslatexteam.wordpress.com/migration/" target="_blank">', '</a>' ) );

qtranxf_add_message( sprintf( __( '%sImportant%s: Before you start making edits to post and pages, please, make sure that both, your front site and admin back-end, work under this configuration. It may help to review "%s" and see if any of conflicting plugins mentioned there are used here. While the current content, coming from %s, is compatible with this plugin, the newly modified posts and pages will be saved with a new square-bracket-only encoding, which has a number of advantages comparing to former %s encoding. However, the new encoding is not straightforwardly compatible with %s and you will need an additional step available under "%s" option if you ever decide to go back to %s. Even with this additional conversion step, the 3rd-party plugins custom-stored data will not be auto-converted, but manual editing will still work. That is why it is advisable to create a test-copy of your site before making any further changes. In case you encounter a problem, please give us a chance to improve %s, send the login information to the test-copy of your site to %s along with a detailed step-by-step description of what is not working, and continue using your main site with %s meanwhile. It would also help, if you share a success story as well, either on %sthe forum%s, or via the same e-mail as mentioned above. Thank you very much for trying %s.', 'qtranslate' ), '<span style="color:red">', '</span>', '<a href="https://qtranslatexteam.wordpress.com/known-issues/" target="_blank">' . 'Known Issues' . '</a>', $nm, 'qTranslate', $nm, '<a href="https://qtranslatexteam.wordpress.com/option-convert-database/" target="_blank"><span style="color:magenta">' . __( 'Convert Database', 'qtranslate' ) . '</span></a>', $nm, 'qTranslate&#8209;X', '[no mail support]', $nm, '<a href="https://github.com/qTranslate/qtranslate-xt/issues">', '</a>', 'qTranslate&#8209;X' ) . '<br/><span style="font-size: smaller">' . __( 'This is a one-time message, which you will not see again, unless the same import is repeated.', 'qtranslate' ) . '</span>' );
$nm = '<strong>' . $plugin_name . '</strong>';
qtranxf_add_warning( sprintf( __( 'Applicable options and taxonomy names from plugin %s have been imported. Note that the multilingual content of posts, pages and other objects has not been altered during this operation. There is no additional operation needed to import content, since its format is compatible with %s.', 'qtranslate' ), $nm, 'qTranslate&#8209;XT' ) . ' ' . sprintf( __( 'It might be a good idea to review %smigration instructions%s, if you have not yet done so.', 'qtranslate' ), '<a href="https://qtranslatexteam.wordpress.com/migration/" target="_blank">', '</a>' ) );
qtranxf_add_warning( sprintf( __( '%sImportant%s: Before you start making edits to post and pages, please, make sure that both, your front site and admin back-end, work under this configuration. It may help to review "%s" and see if any of conflicting plugins mentioned there are used here. While the current content, coming from %s, is compatible with this plugin, the newly modified posts and pages will be saved with a new square-bracket-only encoding, which has a number of advantages comparing to former %s encoding. However, the new encoding is not straightforwardly compatible with %s and you will need an additional step available under "%s" option if you ever decide to go back to %s. Even with this additional conversion step, the 3rd-party plugins custom-stored data will not be auto-converted, but manual editing will still work. That is why it is advisable to create a test-copy of your site before making any further changes. In case you encounter a problem, please give us a chance to improve %s, send the login information to the test-copy of your site to %s along with a detailed step-by-step description of what is not working, and continue using your main site with %s meanwhile. It would also help, if you share a success story as well, either on %sthe forum%s, or via the same e-mail as mentioned above. Thank you very much for trying %s.', 'qtranslate' ), '<strong>', '</strong>', '<a href="https://qtranslatexteam.wordpress.com/known-issues/" target="_blank">' . 'Known Issues' . '</a>', $nm, 'qTranslate', $nm, '<a href="https://qtranslatexteam.wordpress.com/option-convert-database/" target="_blank"><strong>' . __( 'Convert Database', 'qtranslate' ) . '</strong></a>', $nm, 'qTranslate&#8209;XT', '[no mail support]', $nm, '<a href="https://github.com/qTranslate/qtranslate-xt/issues">', '</a>', 'qTranslate&#8209;XT' ) . '<br/>' . __( 'This is a one-time message, which you will not see again, unless the same import is repeated.', 'qtranslate' ) );
}

function qtranxf_migrate_export( $plugin_name, $nm_to ) {
qtranxf_migrate_options_copy( $nm_to, 'qtranslate' );

$nm = '<span style="color:blue"><strong>' . $plugin_name . '</strong></span>';

qtranxf_add_message( sprintf( __( 'Applicable options have been exported to plugin %s. If you have done some post or page updates after migrating from %s, then "%s" operation is also required to convert the content to "dual language tag" style in order for plugin %s to function.', 'qtranslate' ), $nm, $nm, '<a href="https://qtranslatexteam.wordpress.com/option-convert-database/" target="_blank"><span style="color:magenta">' . __( 'Convert Database', 'qtranslate' ) . '</span></a>', $nm ) );
$nm = '<strong>' . $plugin_name . '</strong>';
qtranxf_add_message( sprintf( __( 'Applicable options have been exported to plugin %s. If you have done some post or page updates after migrating from %s, then "%s" operation is also required to convert the content to "dual language tag" style in order for plugin %s to function.', 'qtranslate' ), $nm, $nm, '<a href="https://qtranslatexteam.wordpress.com/option-convert-database/" target="_blank"><strong>' . __( 'Convert Database', 'qtranslate' ) . '</strong></a>', $nm ) );
}

function qtranxf_migrate_plugins() {
Expand Down

0 comments on commit b9e7550

Please sign in to comment.