-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
2,632 additions
and
676 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
|
||
namespace yaim; | ||
|
||
// If this file is called directly, abort. | ||
if ( ! defined( 'WPINC' ) ) { | ||
die; | ||
} | ||
|
||
use croox\wde\utils; | ||
|
||
class Admin_Message_Log { | ||
|
||
protected $msgs = array(); | ||
|
||
protected static $option_key = 'yaim_log'; | ||
|
||
protected $start; | ||
|
||
public function __construct(){ | ||
$this->start = date('d-M-Y H:i:s T'); | ||
update_option( self::$option_key . '_start', $this->start ); | ||
|
||
$this->add_entries( array( $this->start, '' ) ); | ||
|
||
} | ||
|
||
public function add_entries( $msgs = array(), $key = null ){ | ||
foreach( $msgs as $msg ) { | ||
$this->add_entry( $msg ); | ||
} | ||
} | ||
|
||
public function add_entry( $msg = '', $key = null ){ | ||
if ( null === $key ) { | ||
$this->msgs[] = $msg; | ||
} else { | ||
if ( array_key_exists( $key, $this->msgs ) ) { | ||
$this->msgs[$key] .= $msg; | ||
|
||
} else { | ||
$this->msgs[$key] = $msg; | ||
} | ||
} | ||
} | ||
|
||
public function get(){ | ||
return $this->msgs; | ||
} | ||
|
||
public static function get_from_db(){ | ||
$msgs = get_option( self::$option_key ); | ||
$last = get_option( self::$option_key . '_start' ); | ||
return array( | ||
'msgs' => $msgs, | ||
'last_start' => get_option( self::$option_key . '_start' ), | ||
'last_log_saved' => count( $msgs ) > 0 && $msgs[0] === $last, | ||
); | ||
} | ||
|
||
public function save(){ | ||
update_option( self::$option_key, $this->msgs ); | ||
} | ||
|
||
} | ||
|
Oops, something went wrong.