Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion js/zoninator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 30 additions & 1 deletion zoninator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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 ) {
?>
<div class="notice notice-warning is-dismissible">
<p><?php echo sprintf( $this->_get_message( 'error-zone-lock-redirect' ), esc_html( $zone->name ) ); ?></p>
</div>

<?php
}
}
}
}

function admin_enqueue_scripts() {
if( $this->is_zoninator_page() ) {
wp_enqueue_script( 'zoninator-js', ZONINATOR_URL . 'js/zoninator.js', array( 'jquery', 'jquery-ui-core', 'jquery-ui-widget', 'jquery-ui-mouse', 'jquery-ui-position', 'jquery-ui-sortable', 'jquery-ui-autocomplete' ), ZONINATOR_VERSION, true );
Expand Down