-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtm-youtube-subcribe.php
149 lines (131 loc) · 3.77 KB
/
tm-youtube-subcribe.php
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?php
/**
* Plugin Name: TM YouTube Subscribe
* Plugin URI: https://wordpress.org/plugins/tm-youtube-subscribe/
* Description: This simple plugin allows to display YouTube subscribe widget on the website. Flexible customization options allow you to install it in no time flat.
* Version: 1.0.1
* Author: Jetimpex
* Author URI: https://jetimpex.com/wordpress/
* Text Domain: youtube-subscribe
* License: GPL-3.0+
* License URI: http://www.gnu.org/licenses/gpl-3.0.txt
* Domain Path: /languages
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
// If class 'TM_Youtube_Subscribe' not exists.
if ( ! class_exists( 'TM_Youtube_Subscribe' ) ) {
/**
* Class add all hooks.
*/
class TM_Youtube_Subscribe {
/**
* A reference to an instance of this class.
*
* @since 1.0.0
* @var object
*/
private static $instance = null;
/**
* A reference to an instance of cherry framework core class.
*
* @since 1.0.0
* @var object
*/
private $core = null;
/**
* Sets up needed actions/filters for the plugin to initialize.
*
* @since 1.0.0
*/
public function __construct() {
// Load the installer core.
add_action( 'after_setup_theme', require( trailingslashit( dirname( __FILE__ ) ) . 'cherry-framework/setup.php' ), 0 );
// Init the core.
add_action( 'after_setup_theme', array( $this, 'get_core' ), 1 );
add_action( 'after_setup_theme', array( 'Cherry_Core', 'load_all_modules' ), 2 );
// Internationalize the text strings used.
add_action( 'plugins_loaded', array( $this, 'lang' ), 5 );
// Load the functions files.
add_action( 'widgets_init', array( $this, 'subscribe_widget' ), 4 );
}
/**
* Add text domain to WP.
*
* @since 1.0.0
*/
function lang() {
load_plugin_textdomain( 'youtube-subscribe', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
}
/**
* Loads the core functions. These files are needed before loading anything else in the
* theme because they have required functions for use.
*
* @since 1.1.0
*/
public function get_core() {
global $chery_core_version;
if ( null !== $this->core ) {
return $this->core;
}
if ( 0 < sizeof( $chery_core_version ) ) {
$core_paths = array_values( $chery_core_version );
require_once( $core_paths[0] );
} else {
die( 'Class Cherry_Core not found' );
}
$this->core = new Cherry_Core( array(
'base_dir' => plugin_dir_path( __FILE__ ) . 'cherry-framework',
'base_url' => plugin_dir_url( __FILE__ ) . 'cherry-framework',
'modules' => array(
'cherry-js-core' => array(
'autoload' => true,
),
'cherry-ui-elements' => array(
'autoload' => true,
'args' => array(
'ui_elements' => array(
'text',
),
),
),
'cherry-widget-factory' => array(
'autoload' => true,
),
),
));
return $this->core;
}
/**
* Include and add all foles.
*
* @since 1.0.0
*
*/
function subscribe_widget() {
require_once 'class-youtube-subscribe-helper.php';
require_once 'class-youtube-subscribe-widget.php';
register_widget( 'Youtube_Subscribe_Widget' );
if ( apply_filters( 'youtube_subscribe_styles', true ) ) {
wp_enqueue_style( 'youtube-widget-style', plugin_dir_url( __FILE__ ) . 'assets/youtube-style.css' );
wp_enqueue_style( 'font-awesome', plugin_dir_url( __FILE__ ) . 'assets/font-awesome/css/font-awesome.min.css' );
}
}
/**
* Returns the instance.
*
* @since 1.0.0
* @return object
*/
public static function get_instance() {
// If the single instance hasn't been set, set it now.
if ( null == self::$instance ) {
self::$instance = new self;
}
return self::$instance;
}
}
TM_Youtube_Subscribe::get_instance();
}