forked from Boonstra/Slideshow
/
slideshow.php
179 lines (154 loc) · 4 KB
/
slideshow.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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<?php
/*
Plugin Name: Slideshow
Plugin URI: http://wordpress.org/extend/plugins/slideshow-jquery-image-gallery/
Description: The slideshow plugin is easily deployable on your website. Add any image that has already been uploaded to add to your slideshow, add text slides, or even add a video. Options and styles are customizable for every single slideshow on your website.
Version: 2.2.25
Requires at least: 3.5
Author: StefanBoonstra
Author URI: http://stefanboonstra.com/
License: GPLv2
Text Domain: slideshow-jquery-image-gallery
*/
/**
* Class SlideshowPluginMain fires up the application on plugin load and provides some
* methods for the other classes to use like the auto-includer and the
* base path/url returning method.
*
* @since 1.0.0
* @author Stefan Boonstra
*/
class SlideshowPluginMain
{
/** @var string $version */
static $version = '2.2.25';
/**
* Bootstraps the application by assigning the right functions to
* the right action hooks.
*
* @since 1.0.0
*/
static function bootStrap()
{
self::autoInclude();
// Initialize localization on init
add_action('init', array(__CLASS__, 'localize'));
// Include backend scripts and styles
add_action('admin_enqueue_scripts', array(__CLASS__, 'enqueueBackendScripts'));
// Ajax requests
SlideshowPluginAJAX::init();
// Register slideshow post type
SlideshowPluginPostType::init();
// Add general settings page
SlideshowPluginGeneralSettings::init();
// Initialize stylesheet builder
SlideshowPluginSlideshowStylesheet::init();
// Deploy slideshow on do_action('slideshow_deploy'); hook.
add_action('slideshow_deploy', array('SlideshowPlugin', 'deploy'));
// Initialize shortcode
SlideshowPluginShortcode::init();
// Register widget
add_action('widgets_init', array('SlideshowPluginWidget', 'registerWidget'));
// Initialize plugin updater
SlideshowPluginInstaller::init();
}
/**
* Includes backend script.
*
* Should always be called on the admin_enqueue_scrips hook.
*
* @since 2.2.12
*/
static function enqueueBackendScripts()
{
// Function get_current_screen() should be defined, as this method is expected to fire at 'admin_enqueue_scripts'
if (!function_exists('get_current_screen'))
{
return;
}
$currentScreen = get_current_screen();
// Enqueue 3.5 uploader
if ($currentScreen->post_type === 'slideshow' &&
function_exists('wp_enqueue_media'))
{
wp_enqueue_media();
}
wp_enqueue_script(
'slideshow-jquery-image-gallery-backend-script',
self::getPluginUrl() . '/js/min/all.backend.min.js',
array(
'jquery',
'jquery-ui-sortable',
'wp-color-picker'
),
SlideshowPluginMain::$version
);
wp_enqueue_style(
'slideshow-jquery-image-gallery-backend-style',
self::getPluginUrl() . '/css/all.backend.css',
array(
'wp-color-picker'
),
SlideshowPluginMain::$version
);
}
/**
* Translates the plugin
*
* @since 1.0.0
*/
static function localize()
{
load_plugin_textdomain(
'slideshow-jquery-image-gallery',
false,
dirname(plugin_basename(__FILE__)) . '/languages/'
);
}
/**
* Returns url to the base directory of this plugin.
*
* @since 1.0.0
* @return string pluginUrl
*/
static function getPluginUrl()
{
return plugins_url('', __FILE__);
}
/**
* Returns path to the base directory of this plugin
*
* @since 1.0.0
* @return string pluginPath
*/
static function getPluginPath()
{
return dirname(__FILE__);
}
/**
* This function will load classes automatically on-call.
*
* @since 1.0.0
*/
static function autoInclude()
{
if (!function_exists('spl_autoload_register'))
{
return;
}
function slideshowPluginAutoLoader($name)
{
$name = str_replace('\\', DIRECTORY_SEPARATOR, $name);
$file = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . $name . '.php';
if (is_file($file))
{
require_once $file;
}
}
spl_autoload_register('slideshowPluginAutoLoader');
}
}
/**
* Activate plugin
*/
SlideShowPluginMain::bootStrap();