-
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
0 parents
commit 104d21e
Showing
36 changed files
with
2,509 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Telelog | ||
|
||
Keep track of everything happening on your WordPress in Telegram. | ||
|
||
## Set up | ||
|
||
1. Create a new Telegram bot. ([Learn more](https://core.telegram.org/bots#3-how-do-i-create-a-bot)) | ||
2. Go to TeleLog admin page from your wordpress dashboard. | ||
3. Copy your bot token from botfather and paste it in the "API Key" field. | ||
4. If you want TeleLog to send the logs to your personal account, you can use your userid and put it in the "Chat ID" field ([Find your userid](https://t.me/userinfobot)), the other option is to create a channel and make your bot an admin with "Post Messages" access and enter the channel username as "Chat ID", with an atsign(@) before it, e.g: `@username`. |
Empty file.
Empty file.
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,29 @@ | ||
{ | ||
"name": "mahdyar/telelog", | ||
"description": "Keep track of everything happening on your WordPress in Telegram", | ||
"keywords": [ | ||
"telegram", | ||
"logging", | ||
"wordpress", | ||
"wp", | ||
"log", | ||
"wordpress log" | ||
], | ||
"type": "project", | ||
"license": "GPL", | ||
"autoload": { | ||
"psr-4": { | ||
"Telelog\\Inc\\": "inc/" | ||
} | ||
}, | ||
"homepage": "https://github.com/mahdyar/telelog", | ||
"authors": [ | ||
{ | ||
"name": "Mahdyar Hasanpour", | ||
"email": "hasanpour@mahdyar.me", | ||
"homepage": "https://mahdyar.me" | ||
} | ||
], | ||
"minimum-stability": "dev", | ||
"require": {} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
/** | ||
* @package Telelog | ||
*/ | ||
|
||
namespace Telelog\Inc\Base; | ||
|
||
class Activate | ||
{ | ||
public static function activate() | ||
{ | ||
flush_rewrite_rules(); | ||
|
||
if (get_option('telelog_on_post_publish') === false) | ||
update_option('telelog_on_post_publish', '1'); | ||
if (get_option('telelog_on_post_update') === false) | ||
update_option('telelog_on_post_update', '1'); | ||
} | ||
} |
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,20 @@ | ||
<?php | ||
|
||
/** | ||
* @package Telelog | ||
*/ | ||
|
||
namespace Telelog\Inc\Base; | ||
|
||
class BaseController | ||
{ | ||
public $plugin_path; | ||
public $plugin_url; | ||
public $plugin; | ||
public function __construct() | ||
{ | ||
$this->plugin_path = plugin_dir_path(dirname(__FILE__, 2)); | ||
$this->plugin_url = plugin_dir_url(dirname(__FILE__, 2)); | ||
$this->plugin = plugin_basename(dirname(__FILE__, 3)) . '/telelog.php'; | ||
} | ||
} |
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,20 @@ | ||
<?php | ||
|
||
/** | ||
* @package Telelog | ||
*/ | ||
|
||
namespace Telelog\Inc\Base; | ||
|
||
class Deactivate | ||
{ | ||
public static function deactivate() | ||
{ | ||
flush_rewrite_rules(); | ||
|
||
delete_option('telelog_api_key'); | ||
delete_option('telelog_chat_id'); | ||
delete_option('telelog_on_post_update'); | ||
delete_option('telelog_on_post_publish'); | ||
} | ||
} |
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,25 @@ | ||
<?php | ||
|
||
/** | ||
* @package Telelog | ||
*/ | ||
|
||
namespace Telelog\Inc\Base; | ||
|
||
use \Telelog\Inc\Base\BaseController; | ||
|
||
class Enqueue extends BaseController | ||
{ | ||
/** | ||
* Enqueue the scripts and stylesheets | ||
* @return void | ||
*/ | ||
public function register() | ||
{ | ||
// add_action('admin_enqueue_scripts', array($this, 'enqueue')); | ||
} | ||
function enqueue() | ||
{ | ||
// wp_enqueue_script('telelog_scripts', $this->plugin_url . 'assets/scripts.js', __FILE__); | ||
} | ||
} |
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,23 @@ | ||
<?php | ||
|
||
/** | ||
* @package Telelog | ||
*/ | ||
|
||
namespace Telelog\Inc\Base; | ||
|
||
use \Telelog\Inc\Base\BaseController; | ||
|
||
class SettingsLinks extends BaseController | ||
{ | ||
public function register() | ||
{ | ||
add_filter("plugin_action_links_$this->plugin", array($this, 'add_settings_link')); | ||
} | ||
public function add_settings_link($links) | ||
{ | ||
$settings_link = '<a href="admin.php?page=telelog">' . __('Settings', 'telelog') . '</a>'; | ||
array_unshift($links, $settings_link); | ||
return $links; | ||
} | ||
} |
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,17 @@ | ||
<?php | ||
|
||
/** | ||
* @package Telelog | ||
*/ | ||
|
||
namespace Telelog\Inc\Base; | ||
|
||
use Telelog\Inc\Base\BaseController; | ||
|
||
class Translation extends BaseController | ||
{ | ||
public function register() | ||
{ | ||
load_plugin_textdomain('telelog', false, str_replace('/telelog.php', '/languages/', $this->plugin)); | ||
} | ||
} |
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,51 @@ | ||
<?php | ||
|
||
/** | ||
* @package Telelog | ||
*/ | ||
|
||
namespace Telelog\Inc; | ||
|
||
|
||
final class Init | ||
{ | ||
/** | ||
* Store all the classes inside an array | ||
* @return array list of classes | ||
*/ | ||
public static function get_services() | ||
{ | ||
return [ | ||
Base\Translation::class, | ||
Pages\Admin::class, | ||
Base\Enqueue::class, | ||
Base\SettingsLinks::class, | ||
Telegram\PostTransition::class, | ||
]; | ||
} | ||
|
||
/** | ||
* Loop through the classes, initialize them, | ||
* and call the register() function if it exists | ||
* @return void | ||
*/ | ||
public static function register_services() | ||
{ | ||
foreach (self::get_services() as $class) { | ||
$service = self::instantiate($class); | ||
if (method_exists($service, 'register')) { | ||
$service->register(); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Initialize the class | ||
* @param class $class class from the services array | ||
* @return object new instance of the class | ||
*/ | ||
private static function instantiate($class) | ||
{ | ||
return new $class(); | ||
} | ||
} |
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,57 @@ | ||
<?php | ||
|
||
/** | ||
* @package Telelog | ||
*/ | ||
|
||
namespace Telelog\Inc\Pages; | ||
|
||
use Telelog\Inc\Pages\Callbacks\AdminCallbacks; | ||
|
||
class Admin | ||
{ | ||
public $callbacks; | ||
|
||
public $settings = array(); | ||
|
||
public $sections = array(); | ||
|
||
public $fields = array(); | ||
|
||
/** | ||
* Add TeleLog to the admin menu | ||
* @return void | ||
*/ | ||
public function register() | ||
{ | ||
$this->callbacks = new AdminCallbacks(); | ||
add_action('admin_menu', array($this, 'add_admin_pages')); | ||
add_action('admin_init', array($this, 'register_custom_fields')); | ||
} | ||
|
||
/** | ||
* Add the admin pages | ||
* @return void | ||
*/ | ||
public function add_admin_pages() | ||
{ | ||
add_menu_page(__('TeleLog', 'telelog'), __('TeleLog', 'telelog'), 'manage_options', 'telelog', array($this->callbacks, 'admin_index'), 'dashicons-megaphone', 110); | ||
} | ||
|
||
public function register_custom_fields() | ||
{ | ||
register_setting('telelog_options', 'telelog_api_key', array($this->callbacks, 'sanitize_api_key')); | ||
register_setting('telelog_options', 'telelog_chat_id', array($this->callbacks, 'sanitize_chat_id')); | ||
register_setting('telelog_options', 'telelog_on_post_publish', array($this->callbacks, 'sanitize_on_post_publish')); | ||
register_setting('telelog_options', 'telelog_on_post_update', array($this->callbacks, 'sanitize_on_post_update')); | ||
|
||
add_settings_section('api_settings', __('Settings', 'telelog'), array($this->callbacks, 'api_settings_text'), 'telelog'); | ||
add_settings_section('hooks_settings', __('Hooks', 'telelog'), array($this->callbacks, 'hooks_settings_text'), 'telelog'); | ||
|
||
add_settings_field('telelog_api_key', __('API Key', 'telelog'), array($this->callbacks, 'telelog_api_key'), 'telelog', 'api_settings'); | ||
add_settings_field('telelog_chat_id', __('Chat ID', 'telelog'), array($this->callbacks, 'telelog_chat_id'), 'telelog', 'api_settings'); | ||
|
||
add_settings_field('telelog_on_post_publish', __('Post Publish', 'telelog'), array($this->callbacks, 'telelog_on_post_publish'), 'telelog', 'hooks_settings'); | ||
add_settings_field('telelog_on_post_update', __('Post Update', 'telelog'), array($this->callbacks, 'telelog_on_post_update'), 'telelog', 'hooks_settings'); | ||
} | ||
} |
Oops, something went wrong.