diff --git a/js/zoninator.js b/js/zoninator.js index ba6ce87..5611ef6 100644 --- a/js/zoninator.js +++ b/js/zoninator.js @@ -280,7 +280,7 @@ var zoninator = {}; setTimeout(zoninator.updateLock, zoninator.heartbeatInterval); } else { alert(zoninatorOptions.errorZoneLockMax); - location.href = zoninatorOptions.adminUrl; + location.href = zoninatorOptions.baseUrl + '&zone_lock=' + zoninator.getZoneId(); } }, function(returnData, originalData) { // Show alert and reload page to update lock diff --git a/zoninator.php b/zoninator.php index 368d705..c8cd76e 100644 --- a/zoninator.php +++ b/zoninator.php @@ -101,7 +101,9 @@ function init() { 'delete-success' => __( 'The zone was successfully deleted.', 'zoninator' ), 'error-general' => __( 'Sorry, something went wrong! Please try again?', 'zoninator' ), 'error-zone-lock' => __( 'Sorry, this zone is in use by %s and is currently locked. Please try again later.', 'zoninator' ), - 'error-zone-lock-max' => __( 'Sorry, you have reached the maximum idle limit and will now be redirected to the Dashboard.', 'zoninator' ), + 'error-zone-lock-max' => __( 'Sorry, you have reached the maximum idle limit and will now be redirected to the Zones page.', 'zoninator' ), + // Translators: %s below refers to the zone title + 'error-zone-lock-redirect' => __( 'Sorry, you had reached the maximum idle limit while editing zone "%s" and were redirected to the Zones page.', 'zoninator' ), ); $this->zone_lock_period = apply_filters( 'zoninator_zone_lock_period', $this->zone_lock_period ); @@ -131,6 +133,8 @@ function init() { add_action( 'admin_menu', array( $this, 'admin_page_init' ) ); + add_action( 'admin_notices', array( $this, 'admin_notices' ) ); + # Add default advanced search fields add_action( 'zoninator_advanced_search_fields', array( $this, 'zone_advanced_search_cat_filter' ) ); add_action( 'zoninator_advanced_search_fields', array( $this, 'zone_advanced_search_date_filter' ), 20 ); @@ -171,6 +175,31 @@ function admin_page_init() { add_menu_page( __( 'Zoninator', 'zoninator' ), __( 'Zones', 'zoninator' ), $this->_get_manage_zones_cap(), $this->key, array( $this, 'admin_page' ), '', 11 ); } + /** + * Loads any admin notices on the top level zones screen. + */ + public function admin_notices() { + + $screen = get_current_screen(); + + if ( 'toplevel_page_zoninator' === $screen->base ) { + + if ( isset( $_GET['zone_lock'] ) ) { + $zone = $this->get_zone( intval( $_GET['zone_lock'] ) ); + + // Make sure we actually have a good $zone before showing a notice + if ( false !== $zone ) { + ?> +
_get_message( 'error-zone-lock-redirect' ), esc_html( $zone->name ) ); ?>
+