Skip to content

Commit 05211a4

Browse files
author
Md. Alimuzzaman Alim
committed
Issue #279
1 parent 23696e1 commit 05211a4

File tree

4 files changed

+31
-3
lines changed

4 files changed

+31
-3
lines changed

lib/classes/class-bootstrap.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,7 @@ public function is_network_detected() {
724724
* Register scripts and styles
725725
*/
726726
public function admin_init() {
727+
$this->show_notice_stateless_cache_busting();
727728
wp_register_style( 'wp-stateless', $this->path( 'static/styles/wp-stateless.css', 'url' ), array(), self::$version );
728729

729730
/* Attachment or upload page */
@@ -1068,6 +1069,28 @@ public function flush_transients() {
10681069
*/
10691070
public function activate() {
10701071
add_action( 'activated_plugin', array($this, 'redirect_to_splash') );
1072+
add_action( 'activated_plugin', array($this, 'is_new_install'), 1 );
1073+
}
1074+
1075+
public function is_new_install($plugin =''){
1076+
if( $plugin == plugin_basename( $this->boot_file ) ) {
1077+
$sm_mode = get_option('sm_mode', null);
1078+
if(empty($sm_mode)){
1079+
update_option('dismissed_notice_stateless_cache_busting', true);
1080+
}
1081+
}
1082+
}
1083+
1084+
public function show_notice_stateless_cache_busting(){
1085+
$this->errors->add( array(
1086+
'key' => 'stateless_cache_busting',
1087+
'button' => 'View Settings',
1088+
'button_link' => admin_url('upload.php?page=stateless-settings'),
1089+
'title' => sprintf( __( "Stateless mode now requires the Cache-Busting option.", ud_get_stateless_media()->domain ) ),
1090+
'message' => sprintf( __("WordPress looks at local files to prevent files with the same filenames.
1091+
Since Stateless mode bypasses this check, there is a potential for files to be stored with the same file name. We enforce the Cache-Busting option to prevent this.
1092+
Override with the <a href='%s' target='_blank'>%s</a> constant.", ud_get_stateless_media()->domain),"https://github.com/wpCloud/wp-stateless/wiki/Constants#wp_stateless_media_cache_busting", "WP_STATELESS_MEDIA_CACHE_BUSTING" ),
1093+
), 'notice' );
10711094
}
10721095

10731096
public function redirect_to_splash($plugin =''){

lib/classes/class-errors.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ public function admin_notices() {
211211
'class' => 'notice',
212212
'message' => '',
213213
'button' => '',
214+
'button_link' => '#',
214215
'key' => '',
215216
'action_links' => $this->action_links[ 'notices' ],
216217
));

static/scripts/error-notice.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@
44
jQuery( document ).ready( function () {
55

66
jQuery( '.ud-admin-notice' ).on( 'click', '.button-action', function(e){
7+
if(_this.attr('href') != '#'){
8+
return;
9+
}
10+
711
e.preventDefault();
812

913
var _this = jQuery( this );
10-
14+
1115
var data = {
1216
action: 'button_action',
1317
key: _this.data('key'),
@@ -20,7 +24,7 @@ jQuery( document ).ready( function () {
2024
alert(result_data.error);
2125
}
2226
}, "json" );
23-
27+
return false;
2428
});
2529

2630
} );

static/views/error-notice.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
?>
1111
<div class="buttons-container">
1212
<?php if(!empty($data['button']) && !empty($data['key'])):?>
13-
<a class="button-action button button-primary" data-key="button_secondary_<?php echo $data['key'];?>" href="#"><?php echo $data['button'];?></a>
13+
<a class="button-action button button-primary" data-key="button_secondary_<?php echo $data['key'];?>" href="<?php echo $data['button_link'];?>"><?php echo $data['button'];?></a>
1414
<?php endif;?>
1515
<?php if(!empty($data['key'])):?>
1616
<a class="dismiss-warning dismiss notice-dismiss" data-key="dismissed_notice_<?php echo $data['key'];?>" href="#"></a>

0 commit comments

Comments
 (0)