Skip to content

Commit

Permalink
Notice Module Updated
Browse files Browse the repository at this point in the history
  • Loading branch information
priyomukul committed Jun 30, 2022
1 parent fb3dfe1 commit 7dbdd40
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 16 deletions.
8 changes: 4 additions & 4 deletions vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
"source": {
"type": "git",
"url": "[email protected]:priyomukul/wp-notice.git",
"reference": "2d3fc6fa4b7a04fd2bad06dac5faa589cd623f6a"
"reference": "d6300563a1b06f61639864b4e3a03c675a688ae6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/priyomukul/wp-notice/zipball/2d3fc6fa4b7a04fd2bad06dac5faa589cd623f6a",
"reference": "2d3fc6fa4b7a04fd2bad06dac5faa589cd623f6a",
"url": "https://api.github.com/repos/priyomukul/wp-notice/zipball/d6300563a1b06f61639864b4e3a03c675a688ae6",
"reference": "d6300563a1b06f61639864b4e3a03c675a688ae6",
"shasum": ""
},
"time": "2022-06-30T12:42:36+00:00",
"time": "2022-06-30T13:30:48+00:00",
"default-branch": true,
"type": "library",
"installation-source": "dist",
Expand Down
6 changes: 3 additions & 3 deletions vendor/composer/installed.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'reference' => '41db1310e958bc9f281527b30763488e87ba78e7',
'reference' => 'fb3dfe1b222fbcdf27c49c0b6f3c2ec594d987fb',
'name' => 'wpdeveloper/notificationx',
'dev' => true,
),
Expand All @@ -18,7 +18,7 @@
'aliases' => array(
0 => '9999999-dev',
),
'reference' => '2d3fc6fa4b7a04fd2bad06dac5faa589cd623f6a',
'reference' => 'd6300563a1b06f61639864b4e3a03c675a688ae6',
'dev_requirement' => false,
),
'udx/lib-settings' => array(
Expand Down Expand Up @@ -47,7 +47,7 @@
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'reference' => '41db1310e958bc9f281527b30763488e87ba78e7',
'reference' => 'fb3dfe1b222fbcdf27c49c0b6f3c2ec594d987fb',
'dev_requirement' => false,
),
),
Expand Down
4 changes: 2 additions & 2 deletions vendor/priyomukul/wp-notice/src/Notice.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ public function __construct( ...$args ){
}


public function display(){
if ( ! $this->show() ) {
public function display( $force = false ){
if ( ! $force && ! $this->show() ) {
return;
}

Expand Down
29 changes: 22 additions & 7 deletions vendor/priyomukul/wp-notice/src/Notices.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ public function __get( $name ){
}

public function __construct( $args ){
$this->system_id = ! empty( $args['app'] ) ? $args['app'] . '-notice-system' : $this->system_id;
$this->app = ! empty( $args['id'] ) ? $args['id'] : $this->app;
$this->version = ! empty( $args['version'] ) ? $args['version'] : '1.0.0';
$this->system_id = ! empty( $args['id'] ) ? $args['id'] . '-notice-system' : $this->system_id;
$this->app = ! empty( $args['id'] ) ? $args['id'] : $this->app;
$this->version = ! empty( $args['version'] ) ? $args['version'] : '1.0.0';
$this->dev_mode = ! empty( $args['dev_mode'] ) ? $args['dev_mode'] : false;

$this->args = $args;

Expand All @@ -54,11 +55,18 @@ public function init(){

public function notices(){
wp_enqueue_style( $this->system_id, $this->scripts );
$current_notice = current( $this->eligible_notices() );

if( isset( $this->notices[ $current_notice ] ) ) {
$this->notices[ $current_notice ]->display();
if( ! $this->dev_mode ) {
$current_notice = current( $this->eligible_notices() );
if( isset( $this->notices[ $current_notice ] ) ) {
$this->notices[ $current_notice ]->display();
}
} else {
foreach( $this->notices as $key => $notice ) {
$notice->display( true );
}
}

}

protected function eligible_notices(){
Expand All @@ -84,12 +92,19 @@ protected function eligible_notices(){
public function scripts(){
$current_notice = current( $this->eligible_notices() );

if( isset( $this->notices[ $current_notice ] ) ) {
if( isset( $this->notices[ $current_notice ] ) && ! $this->dev_mode ) {
$notice = $this->notices[ $current_notice ];
if( $notice->show() ) {
$notice->dismiss->print_script();
}
}

if( $this->dev_mode ) {
foreach( $this->notices as $key => $notice ) {
$notice->dismiss->print_script();
}
}

}

public function add( $id, $content, $options = [] ){
Expand Down

0 comments on commit 7dbdd40

Please sign in to comment.