Skip to content

Commit d881b36

Browse files
authored
now the unauthenticated messages are only shown on the settings page. T… (#254)
* now the unauthenicatd messages are only shown on the settings page. The notice of invalid API creds, doenst show is no keys entered, only if we have keys and they are wrong. * Fix simple liniting issues
1 parent 1ba3c93 commit d881b36

5 files changed

Lines changed: 11 additions & 12 deletions

File tree

functions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ function iawmlf_render_not_authenticated_notice(): void {
276276
// If the archive api is not configured.
277277
if ( ! Settings::is_archive_api_configured() ) {
278278
?>
279-
<div class="notice notice-error">
279+
<div class="notice notice-error is-dismissible">
280280
<p>
281281
<?php echo esc_html( $in_unauthenticated_mode ); ?>
282282
</p>

src/Dashboard/Report_Page.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,6 @@ private function render_list_page(): void {
267267

268268
// Render any notices.
269269
$table->render_notices();
270-
iawmlf_render_not_authenticated_notice();
271270

272271
// Get the current page.
273272
$current_page = isset( $_REQUEST['page'] ) ? \sanitize_text_field( wp_unslash( $_REQUEST['page'] ) ) : self::SLUG; // phpcs:ignore WordPress.Security.NonceVerification.Recommended, Can be linked, so no nonce possible.

src/Dashboard/Settings_Page.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -567,14 +567,16 @@ function () {
567567
array( 'class' => Settings::is_link_processing_enabled() ? 'iawmlf_toggle_setting__fixer' : 'iawmlf_toggle_setting__fixer hidden' )
568568
);
569569

570+
$empty_api_creds = '' === Settings::get_archive_access_key() && '' === Settings::get_archive_secret_key();
571+
570572
add_settings_field(
571573
Settings::ARCHIVE_ORG_ACCESS_KEY,
572574
__( 'Archive.org Access Key', 'internet-archive-wayback-machine-link-fixer' ),
573575
array( $this, 'render_archive_api_access_key' ),
574576
self::PAGE_SLUG,
575577
self::GROUP_IA_SETTINGS,
576578
array(
577-
'class' => Settings::has_valid_archive_api_credentials() ? '' : 'iawmlf_toggle_setting__invalid_api_keys',
579+
'class' => Settings::has_valid_archive_api_credentials() || $empty_api_creds ? '' : 'iawmlf_toggle_setting__invalid_api_keys',
578580
)
579581
);
580582

@@ -585,7 +587,7 @@ function () {
585587
self::PAGE_SLUG,
586588
self::GROUP_IA_SETTINGS,
587589
array(
588-
'class' => Settings::has_valid_archive_api_credentials() ? '' : 'iawmlf_toggle_setting__invalid_api_keys',
590+
'class' => Settings::has_valid_archive_api_credentials() || $empty_api_creds ? '' : 'iawmlf_toggle_setting__invalid_api_keys',
589591
)
590592
);
591593

@@ -633,6 +635,11 @@ function () {
633635
* @return string
634636
*/
635637
public function render_invalid_api_keys_message(): string {
638+
// If both keys are empty, do not show any message.
639+
if ( '' === Settings::get_archive_access_key() && '' === Settings::get_archive_secret_key() ) {
640+
return '';
641+
}
642+
636643
if ( ! Settings::has_valid_archive_api_credentials() ) {
637644
return '<div id="invalid_api_creds"><p class="description">' . esc_html__( 'The Archive.org API keys are invalid. Please check your settings.', 'internet-archive-wayback-machine-link-fixer' ) . '</p></div>' .
638645
'<div id="unchecked_api_creds" style="display: none;"><p class="description">' . esc_html__( 'API credentials will be verified when you save the settings.', 'internet-archive-wayback-machine-link-fixer' ) . '</p></div>';

templates/admin/dashboard/widget.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,6 @@
2222
?>
2323

2424
<div class="iawmlf_dashboard-wrapper">
25-
<?php if ( ! $iawmlf_api_configured ) : ?>
26-
<div class="iawmlf_dashboard-warning">
27-
<?php esc_html_e( 'You are using Link Fixer in unauthenticated mode, which restricts you to 4000 new snapshots per day. To unlock higher limits, please enter your API credentials to authenticate with Archive.org.', 'internet-archive-wayback-machine-link-fixer' ); ?>
28-
</div>
29-
<?php endif; ?>
30-
3125
<?php if ( $iawmlf_api_configured && ! \Internet_Archive\Wayback_Machine_Link_Fixer\Settings\Settings::has_valid_archive_api_credentials() ) : ?>
3226
<div class="iawmlf_dashboard-warning">
3327
<?php esc_html_e( 'Your Archive.org API credentials are invalid. Please check your settings.', 'internet-archive-wayback-machine-link-fixer' ); ?>

templates/admin/wizard/step-1.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
</div>
3636

3737
<div class="iawmlf-wizard__content__intro">
38-
<p><?php esc_html_e( 'To archive more than 4000 links from your site to the Wayback Machine per day, you\'ll need a free archive.org account. Once you have your account, enter the API Access Key and Secret Key below.', 'internet-archive-wayback-machine-link-fixer' ); ?>
38+
<p><?php esc_html_e( 'To archive more than 4000 links from your site to the Wayback Machine per day, you\'ll need a free archive.org account. Once you have your account, enter the API Access Key and Secret Key below. (Optional)', 'internet-archive-wayback-machine-link-fixer' ); ?>
3939
<br /><a href="https://archive.org/account/s3.php" target="_blank"><?php esc_html_e( 'Get your API keys here.', 'internet-archive-wayback-machine-link-fixer' ); ?></a></p>
4040
</div>
4141

@@ -52,5 +52,4 @@
5252
<input type="<?php echo esc_html( $iawmlf_secret_type ); ?>" name="iawmlf_wizard_archive_secret_key" value="<?php echo esc_attr( $iawmlf_existing_secret_key ); ?>"<?php echo $iawmlf_invalid_keys ? ' class="invalid"' : ''; ?>/>
5353
</div>
5454

55-
5655
<?php echo wp_kses( $footer, \Internet_Archive\Wayback_Machine_Link_Fixer\Util\Esc::wizard_allowed_tags() ); ?>

0 commit comments

Comments
 (0)