- Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmy-github.php
More file actions
Latest commit
134 lines (116 loc) · 3.15 KB
/
Copy pathmy-github.php
File metadata and controls
134 lines (116 loc) · 3.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php
/**
* Plugin Name: My Github
* Plugin URI: https://github.com/RatulHasan/my-github
* Description: A simple and nice WordPress plugin that can track your github's profile.
* Version: 1.2.4
* Requires at least: 5.2
* Tested up to: 6.4.2
* Author: Ratul Hasan
* Author URI: https://ratuljh.wordpress.com/
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
* Text Domain: my-github
* Domain Path: /languages
*
* @package MyGithub
*/
// To prevent direct access, if not define WordPress ABSOLUTE PATH then exit.
if ( ! defined( 'ABSPATH' ) ) {
exit();
}
/**
* Class MyGithub
*/
finalclass MyGithub {
// Plugin version.
constMY_GITHUB_VERSION = '1.2.4';
/**
* MyGithub constructor.
*/
publicfunction__construct() {
require_once__DIR__ . '/vendor/autoload.php';
$this->localization_setup();
$this->define_constant();
add_action( 'activate_plugin', array( $this, 'cb_activate_plugin' ) );
add_action( 'plugins_loaded', array( $this, 'initiate_plugin' ) );
}
/**
* Define main plugin constant here for future use.
*
* @return void
*/
publicfunctiondefine_constant() {
define( 'MY_GITHUB_VERSION', self::MY_GITHUB_VERSION );
define( 'MY_GITHUB_BASE_NAME', plugin_basename( __FILE__ ) );
define( 'MY_GITHUB_BASE_PATH', __DIR__ );
define( 'MY_GITHUB_INCLUDE_PATH', __DIR__ . '/includes' );
define( 'MY_GITHUB_URL', plugins_url( '', __FILE__ ) );
define( 'MY_GITHUB_ASSETS', MY_GITHUB_URL . '/assets' );
}
/**
* Activating the plugin
*
* @return void
*/
publicfunctioncb_activate_plugin() {
if ( ! get_option( '_my_github_installed' ) ) {
update_option( '_my_github_installed', time() );
}
update_option( '_my_github_version', MY_GITHUB_VERSION );
}
/**
* Initialize plugin for localization
*
* @return void
*/
publicfunctionlocalization_setup() {
load_plugin_textdomain( 'my-github', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
}
/**
* Initiate the plugin
*
* @return void
*/
publicfunctioninitiate_plugin() {
\My\GitHub\Init::register();
}
/**
* Init method for MyGithub
*
* @return false|\MyGithub
*/
publicstaticfunctioninit() {
$instance = false;
if ( ! $instance ) {
$instance = newself();
}
return$instance;
}
}
/**
* Initialize the Github
*
* @return void
*/
functionmy_github() {
MyGithub::init();
}
/**
* Hit start
*/
my_github();
/**
* Initialize the plugin tracker
*
* @return void
*/
functionappsero_init_tracker_my_github() {
if ( ! class_exists( 'Appsero\Client' ) ) {
require_once__DIR__ . '/appsero/src/Client.php';
}
$client = newAppsero\Client( '8161e2ef-b32c-4832-bf2a-5a746b2d617c', 'My Github', __FILE__ );
// Active insights
$client->insights()->init();
}
appsero_init_tracker_my_github();