-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgitfeed.php
More file actions
85 lines (69 loc) · 1.77 KB
/
gitfeed.php
File metadata and controls
85 lines (69 loc) · 1.77 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
<?php
/**
* @package Gitfeed
*/
/*
Plugin Name: Gitfeed
Plugin URI: https://github.com/apieschel/gitfeed
Description: Plugin for displaying a feed for your latest Git commits on a portfolio site.
Version: 1.0
Author: Alex Pieschel
Author URI: https://gtrsoftware.com
License: GPLv2 or later
Text Domain: gitfeed
*/
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
if ( ! defined( 'GF_DIR_PATH' ) ) {
define( 'GF_DIR_PATH', trailingslashit( dirname( __FILE__ ) ) );
}
if ( ! class_exists( 'Gitfeed' ) ) {
/**
* Class Gitfeed
*
* Main Plugin class. Intializes the plugin.
*/
class Gitfeed {
private static $instance = null;
public static function get_instance() {
if ( ! self::$instance ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Gitfeed constructor.
*/
public function __construct() {
$this->includes();
$this->init();
$this->load_textdomain();
$this->enqueue_globals();
}
/**
* Initialize the plugin.
*/
private function init() {
// Initialize the plugin core.
$this->api = new Github_API();
}
/**
* Load translations
*/
private function load_textdomain() {
load_plugin_textdomain('gitfeed', false, basename( dirname( __FILE__ ) ) . '/languages' );
}
/**
* Load needed files for the plugin
*/
private function includes() {
if ( file_exists( trailingslashit( plugin_dir_path( __FILE__ ) ) . 'class-api.php' ) ) {
include_once 'class-api.php';
}
}
private function enqueue_globals() {
wp_enqueue_style('gitfeed', plugin_dir_url( __FILE__ ) . 'assets/css/gitfeed-global.css');
}
}
}
// Init the plugin and load the plugin instance for the first time.
add_action( 'plugins_loaded', array( 'Gitfeed', 'get_instance' ) );