generated from Pierre-Lannoy/wp-plugin-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 10
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
Pierre Lannoy
committed
Sep 13, 2019
1 parent
85c6c23
commit f08d7ed
Showing
2 changed files
with
72 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
/** | ||
* Jetpack listener for DecaLog. | ||
* | ||
* Defines class for Jetpack listener. | ||
* | ||
* @package Listeners | ||
* @author Pierre Lannoy <https://pierre.lannoy.fr/>. | ||
* @since 1.4.0 | ||
*/ | ||
|
||
namespace Decalog\Listener; | ||
|
||
/** | ||
* Jetpack listener for DecaLog. | ||
* | ||
* Defines methods and properties for User Switching listener class. | ||
* | ||
* @package Listeners | ||
* @author Pierre Lannoy <https://pierre.lannoy.fr/>. | ||
* @since 1.4.0 | ||
*/ | ||
class JetpackListener extends AbstractListener { | ||
|
||
/** | ||
* Sets the listener properties. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
protected function init() { | ||
$this->id = 'jetpack'; | ||
$this->class = 'plugin'; | ||
$this->product = 'Jetpack'; | ||
$this->name = 'Jetpack'; | ||
if ( defined( 'JETPACK__VERSION' ) ) { | ||
$this->version = JETPACK__VERSION; | ||
} else { | ||
$this->version = 'x'; | ||
} | ||
} | ||
|
||
/** | ||
* Verify if this listener is needed, mainly by verifying if the listen plugin/theme is loaded. | ||
* | ||
* @return boolean True if listener is needed, false otherwise. | ||
* @since 1.4.0 | ||
*/ | ||
protected function is_available() { | ||
return class_exists( 'Jetpack' ); | ||
} | ||
|
||
/** | ||
* "Launch" the listener. | ||
* | ||
* @return boolean True if listener was launched, false otherwise. | ||
* @since 1.4.0 | ||
*/ | ||
protected function launch() { | ||
add_action( 'jetpack_log_entry', [ $this, 'jetpack_log_entry' ], 10, 1 ); | ||
return true; | ||
} | ||
|
||
/** | ||
* "jetpack_log_entry" event. | ||
* | ||
* @since 1.4.0 | ||
*/ | ||
public function jetpack_log_entry( $log_entry) { | ||
$this->logger->emergency( print_r($log_entry, true) ); | ||
} | ||
} |
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