Skip to content

Commit

Permalink
Remove unused notice
Browse files Browse the repository at this point in the history
  • Loading branch information
av3nger committed Nov 10, 2023
1 parent 6dd09f4 commit a9bb8b1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 62 deletions.
38 changes: 0 additions & 38 deletions app/class-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ public function __construct() {
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );

add_action( 'admin_menu', array( $this, 'register_menu' ) );
add_action( 'admin_notices', array( $this, 'show_notice' ) );
add_filter( 'plugin_action_links_cf-images/cf-images.php', array( $this, 'settings_link' ) );

if ( wp_doing_ajax() ) {
Expand Down Expand Up @@ -173,43 +172,6 @@ public function register_menu() {
);
}

/**
* Show notice.
*
* @since 1.0.0
*/
public function show_notice() {
if ( false !== $this->get_error() ) {
$message = sprintf( /* translators: %1$s - error message, %2$d - error code */
esc_html__( '%1$s (code: %2$d)', 'cf-images' ),
esc_html( $this->get_error()->get_error_message() ),
(int) $this->get_error()->get_error_code()
);

$this->render_notice( $message, 'error' );
}
}

/**
* Render notice.
*
* @since 1.0.0
*
* @param string $message Notice message.
* @param string $type Notice type.
*/
public function render_notice( string $message, string $type = 'success' ) {
?>
<div class="cf-images-notifications">
<div class="notice notice-<?php echo esc_attr( $type ); ?>" id="cf-images-notice">
<p>
<?php echo esc_html( $message ); ?>
</p>
</div>
</div>
<?php
}

/**
* Render page.
*
Expand Down
41 changes: 17 additions & 24 deletions assets/_src/js/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import { post } from './helpers/post';

( function( $ ) {
(function ($) {
'use strict';

/**
Expand All @@ -28,38 +28,31 @@ import { post } from './helpers/post';
cf_images_compress: '.cf-images-compress', // Compress image.
};

/**
* Auto hide any pending notices.
*
* @since 1.0.0
*/
$( document ).ready( function() {
setTimeout( () => $( '#cf-images-notice' ).slideUp( 'slow' ), 5000 );
} );

/**
* Register Ajax actions.
*/
Object.keys( ajaxActions ).forEach( ( action ) => {
$( document ).on( 'click', ajaxActions[ action ], function( e ) {
Object.keys(ajaxActions).forEach((action) => {
$(document).on('click', ajaxActions[action], function (e) {
e.preventDefault();

const { inProgress, offloadError } = CFImages.strings;

const divStatus = $( this ).closest( '.cf-images-status' );
divStatus.html( inProgress + '<span class="spinner is-active"></span>' );
const divStatus = $(this).closest('.cf-images-status');
divStatus.html(
inProgress + '<span class="spinner is-active"></span>'
);

post( action, $( this ).data( 'id' ) )
.then( ( response ) => {
if ( ! response.success ) {
post(action, $(this).data('id'))
.then((response) => {
if (!response.success) {
const message = response.data || offloadError;
divStatus.html( message );
divStatus.html(message);
return;
}

divStatus.html( response.data );
} )
.catch( window.console.log );
} );
} );
}( jQuery ) );
divStatus.html(response.data);
})
.catch(window.console.log);
});
});
})(jQuery);

0 comments on commit a9bb8b1

Please sign in to comment.