-
Notifications
You must be signed in to change notification settings - Fork 6
/
tutorial.php
110 lines (101 loc) · 2.58 KB
/
tutorial.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
<?php
/**
* Plugin Name: Turotial
* Plugin URI: https://github.com/tutorial
* Description: Getting started with Gutenberg block development.
* Author: weDevs
* Version: 1.0.0
* Text Domain: tutorial
* Domain Path: /languages
* License: GPL2
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
*/
if ( ! class_exists( 'Tutorial' ) ) :
/**
* Main Tutorial Class.
*
* @since 1.0.0
*/
final class Tutorial {
/**
* This plugin's instance.
*
* @var Tutorial
* @since 1.0.0
*/
private static $instance;
/**
* Main Tutorial Instance.
*
* Insures that only one instance of Tutorial exists in memory at any one
* time. Also prevents needing to define globals all over the place.
*
* @since 1.0.0
* @static
* @return object|Tutorial The one true Tutorial
*/
public static function instance() {
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Tutorial ) ) {
self::$instance = new Tutorial();
self::$instance->define_constants();
self::$instance->includes();
self::$instance->dependency_class_instance();
}
return self::$instance;
}
/**
* Define woogool Constants
*
* @return type
*/
private function define_constants() {
$this->define( 'TUTORIAL_PATH', dirname( __FILE__ ) );
$this->define( 'TUTORIAL_INCLUDES_PATH', dirname( __FILE__ ) . '/includes' );
$this->define( 'TUTORIAL_DIST_PATH', dirname( __FILE__ ) . '/dist' );
$this->define( 'TUTORIAL_DIST_URL',plugin_dir_url( __FILE__ ) . 'dist' );
//$this->define( 'TUTORIAL_ASSET', plugin_dir_url( __FILE__ ) . 'assets' );
}
/**
* Define constant if not already set
*
* @param string $name
* @param string|bool $value
* @return type
*/
private function define( $name, $value ) {
if ( ! defined( $name ) ) {
define( $name, $value );
}
}
/**
* Load actions
*
* @return void
*/
private function includes() {
include( TUTORIAL_PATH . '/vendor/autoload.php' );
}
/**
* Load actions
*
* @return void
*/
private function dependency_class_instance() {
\Tutorial\Includes\Actions::instance();
\Tutorial\Includes\Scripts::instance();
}
}
endif;
/**
* The main function for that returns Tutorial
*
*/
function tutorial() {
return Tutorial::instance();
}
// Get the plugin running. Load on plugins_loaded action to avoid issue on multisite.
if ( function_exists( 'is_multisite' ) && is_multisite() ) {
add_action( 'plugins_loaded', 'tutorial', 90 );
} else {
tutorial();
}