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 da294be commit 0f1ac92
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 21 deletions.
8 changes: 4 additions & 4 deletions vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -538,15 +538,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' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'reference' => '80c4440b05e916bda48ceec2e11d65fe477dbee0',
'reference' => 'da294be529bcf0ebb69b90e9fc5f30a128803524',
'name' => 'schedulepress/wp-schedule-posts',
'dev' => true,
),
Expand Down Expand Up @@ -99,7 +99,7 @@
'aliases' => array(
0 => '9999999-dev',
),
'reference' => '2d3fc6fa4b7a04fd2bad06dac5faa589cd623f6a',
'reference' => 'd6300563a1b06f61639864b4e3a03c675a688ae6',
'dev_requirement' => false,
),
'psr/http-message' => array(
Expand Down Expand Up @@ -132,7 +132,7 @@
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'reference' => '80c4440b05e916bda48ceec2e11d65fe477dbee0',
'reference' => 'da294be529bcf0ebb69b90e9fc5f30a128803524',
'dev_requirement' => false,
),
'symfony/polyfill-intl-idn' => array(
Expand Down
34 changes: 20 additions & 14 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['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->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,16 +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 );
}
}


// foreach( $this->notices as $key => $notice ) {
// $notice->display( true );
// }
}

protected function eligible_notices(){
Expand All @@ -89,16 +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();
}
}

// foreach( $this->notices as $key => $notice ) {
// $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 0f1ac92

Please sign in to comment.