learndash_course_grid.php
4.46 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<?php
namespace LearnDash;
/**
* Plugin Name: LearnDash LMS - Course Grid
* Plugin URI: https://www.learndash.com/
* Description: Build LearnDash course grid easily.
* Version: 2.0.7
* Author: LearnDash
* Author URI: https://www.learndash.com/
* Text Domain: learndash-course-grid
* Doman Path: languages
*/
if ( ! defined( 'ABSPATH' ) ) {
exit();
}
use LearnDash\Course_Grid\Admin\Meta_Boxes;
use LearnDash\Course_Grid\Security;
use LearnDash\Course_Grid\Skins;
use LearnDash\Course_Grid\AJAX;
use LearnDash\Course_Grid\Shortcodes;
use LearnDash\Course_Grid\Blocks;
use LearnDash\Course_Grid\Compatibility;
class Course_Grid {
private static $instance;
public $shortcodes;
public $blocks;
public $skins;
public $posts;
public static function instance()
{
if ( ! isset( self::$instance ) || ! self::$instance instanceof self ) {
self::$instance = new self;
}
return self::$instance;
}
public function __construct()
{
$this->define_constants();
spl_autoload_register( [ $this, 'autoload' ] );
add_action( 'plugins_loaded', [ $this, 'load_translations' ] );
$this->security = new Security();
$this->skins = new Skins();
$this->ajax = new AJAX();
$this->shortcodes = new Shortcodes();
$this->blocks = new Blocks();
$this->compatibility = new Compatibility();
// Include files manually
include_once LEARNDASH_COURSE_GRID_PLUGIN_PATH . 'includes/functions.php';
// Admin
if ( is_admin() ) {
$this->admin = new \stdClass();
$this->admin->meta_boxes = new Meta_Boxes();
}
}
public function define_constants()
{
if ( ! defined( 'LEARNDASH_COURSE_GRID_VERSION' ) ) {
define( 'LEARNDASH_COURSE_GRID_VERSION', '2.0.7' );
}
if ( ! defined( 'LEARNDASH_COURSE_GRID_FILE' ) ) {
define( 'LEARNDASH_COURSE_GRID_FILE', __FILE__ );
}
if ( ! defined( 'LEARNDASH_COURSE_GRID_PLUGIN_PATH' ) ) {
define( 'LEARNDASH_COURSE_GRID_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
}
if ( ! defined( 'LEARNDASH_COURSE_GRID_PLUGIN_URL' ) ) {
define( 'LEARNDASH_COURSE_GRID_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
}
if ( ! defined( 'LEARNDASH_COURSE_GRID_PLUGIN_TEMPLATE_PATH' ) ) {
define( 'LEARNDASH_COURSE_GRID_PLUGIN_TEMPLATE_PATH', LEARNDASH_COURSE_GRID_PLUGIN_PATH . 'templates/' );
}
if ( ! defined( 'LEARNDASH_COURSE_GRID_PLUGIN_TEMPLATE_URL' ) ) {
define( 'LEARNDASH_COURSE_GRID_PLUGIN_TEMPLATE_URL', LEARNDASH_COURSE_GRID_PLUGIN_URL . 'templates/' );
}
if ( ! defined( 'LEARNDASH_COURSE_GRID_PLUGIN_ASSET_PATH' ) ) {
define( 'LEARNDASH_COURSE_GRID_PLUGIN_ASSET_PATH', LEARNDASH_COURSE_GRID_PLUGIN_PATH . 'assets/' );
}
if ( ! defined( 'LEARNDASH_COURSE_GRID_PLUGIN_ASSET_URL' ) ) {
define( 'LEARNDASH_COURSE_GRID_PLUGIN_ASSET_URL', LEARNDASH_COURSE_GRID_PLUGIN_URL . 'assets/' );
}
// Added for backward compatibility.
if ( ! defined( 'LEARNDASH_COURSE_GRID_COLUMNS' ) ) {
define( 'LEARNDASH_COURSE_GRID_COLUMNS', 3 );
}
}
public function autoload( $class )
{
$class_components = explode( '\\', $class );
$class_file = str_replace( '_', '-', strtolower( $class_components[ count( $class_components ) - 1 ] ) );
$filename = $class_file . '.php';
$file = false;
if ( strpos( $class, 'LearnDash\\Course_Grid\\Shortcodes\\' ) !== false ) {
$file = 'includes/shortcodes/class-' . $filename;
} elseif ( strpos( $class, 'LearnDash\\Course_Grid\\Gutenberg\\Blocks\\' ) !== false ) {
$file = 'includes/gutenberg/blocks/' . $class_file . '/index.php';
} elseif ( strpos( $class, 'LearnDash\\Course_Grid\\Admin\\' ) !== false ) {
$file = 'includes/admin/class-' . $filename;
} elseif ( strpos( $class, 'LearnDash\\Course_Grid\\Lib' ) !== false ) {
$file = 'includes/lib/class-' . $filename;
} elseif ( strpos( $class, 'LearnDash\\Course_Grid\\' ) !== false ) {
$file = 'includes/class-' . $filename;
}
if ( $file && file_exists( LEARNDASH_COURSE_GRID_PLUGIN_PATH . $file ) ) {
include_once LEARNDASH_COURSE_GRID_PLUGIN_PATH . $file;
}
}
public function load_translations()
{
$locale = apply_filters( 'plugin_locale', get_locale(), 'learndash-course-grid' );
load_textdomain( 'learndash-course-grid', WP_LANG_DIR . '/plugins/learndash-course-grid-' . $locale . '.mo' );
load_plugin_textdomain( 'learndash-course-grid', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
include LEARNDASH_COURSE_GRID_PLUGIN_PATH . 'includes/class-translations.php';
}
}
function course_grid()
{
return Course_Grid::instance();
}
course_grid();