forked from hoiyam/Captain-Slider
/
captain-slider.php
177 lines (145 loc) · 5.44 KB
/
captain-slider.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
<?php
/*
Plugin Name: Captain Slider
Plugin URI: http://captaintheme.com/plugins/captain-slider/
Description: Allows you to easily create multiple jQuery sliders.
Author: Captain Theme
Author URI: http://captaintheme.com
Version: 1.0.6
Text Domain: ctslider
License: GNU GPL v2
*/
/*
|--------------------------------------------------------------------------
| CONSTANTS
|--------------------------------------------------------------------------
*/
// Plugin Folder Path
if ( !defined( 'CTSLIDER_PLUGIN_DIR' ) ) {
define( 'CTSLIDER_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
}
// Plugin Folder URL
if ( !defined( 'CTSLIDER_PLUGIN_URL' ) ) {
define( 'CTSLIDER_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
}
// Plugin Version
if ( !defined( 'CTSLIDER_VERSION' ) ) {
define( 'CTSLIDER_VERSION', '1.0.6' );
}
/*
|--------------------------------------------------------------------------
| I18N - LOCALIZATION
|--------------------------------------------------------------------------
*/
load_plugin_textdomain( 'ctslider', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
/*
|--------------------------------------------------------------------------
| REGISTER & ENQUEUE SCRIPTS/STYLES
|--------------------------------------------------------------------------
*/
function ctslider_load_scripts() {
wp_register_style( 'flexslider-style', CTSLIDER_PLUGIN_URL . 'includes/css/flexslider.css', array( ), CTSLIDER_VERSION );
wp_register_script( 'flexslider', CTSLIDER_PLUGIN_URL . 'includes/js/jquery.flexslider-min.js', array( 'jquery' ), CTSLIDER_VERSION, false );
wp_register_script( 'fitvids', CTSLIDER_PLUGIN_URL . 'includes/js/jquery.fitvids.js', array( 'jquery' ), CTSLIDER_VERSION, false );
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'flexslider' );
wp_enqueue_script( 'fitvids' );
wp_enqueue_style( 'flexslider-style' );
}
add_action( 'wp_enqueue_scripts', 'ctslider_load_scripts' );
function ctslider_load_admin_scripts( $hook ) {
global $post;
wp_register_style( 'admin-styles', CTSLIDER_PLUGIN_URL . 'includes/css/admin-styles.css', false, CTSLIDER_VERSION );
if ( 'edit.php' === $hook && 'slides' === $post->post_type ) {
wp_enqueue_style( 'admin-styles' );
}
}
add_action( 'admin_enqueue_scripts', 'ctslider_load_admin_scripts' );
/**
* Load Slider
*
* Add the jQuery for the slider to wp_head
*
* @access private
* @uses add_filter()
* @uses ob_start()
* @uses ob_get_clean()
* @since 1.0.0
* @return void
*/
function ctslider_slider_load() {
$effect = ctslider_options_each( 'effect' );
$automatic = ctslider_options_each( 'automatic' );
$controlnav = ctslider_options_each( 'bullets' );
$arrownav = ctslider_options_each( 'arrows' );
$slidespeed = ctslider_options_each( 'slidelength' );
$anispeed = ctslider_options_each( 'animationlength' );
ob_start(); ?>
<script type="text/javascript">
/* Slider Parameters */
jQuery(window).load(function() {
jQuery(".flexslider")
.fitVids()
.flexslider({
animation: '<?php if ( $effect == 'fade' ) { echo 'fade'; } else { echo 'slide'; } ?>', // Specify sets like: 'fade' or 'slide'
direction: '<?php if ( $effect == 'slideh' ) { echo 'horizontal'; } else { echo 'vertical'; } ?>',
slideshow: <?php if ( 1 == $automatic ) { echo 'false'; } else { echo 'true'; } ?>,
controlNav: <?php if ( 1 == $controlnav ) { echo 'false'; } else { echo 'true'; } ?>,
directionNav: <?php if ( 1 == $arrownav ) { echo 'false'; } else { echo 'true'; } ?>,
slideshowSpeed: <?php echo $slidespeed; ?>,
animationSpeed: <?php echo $anispeed; ?>,
useCSS: false,
animationLoop: true,
smoothHeight: true,
//controlNav: "thumbnails"
});
});
</script>
<?php echo ob_get_clean();
}
add_action( 'wp_head', 'ctslider_slider_load' );
/*
|--------------------------------------------------------------------------
| MISC FUNCTIONS
|--------------------------------------------------------------------------
*/
/**
* Settings Link
*
* Add the jQuery for the slider to wp_head
*
* @access private
* @uses add_filter()
* @uses array_unshift()
* @since 1.0.0
* @return string $link
*/
function ctslider_settings_link( $link, $file ) {
static $this_plugin;
if ( !$this_plugin )
$this_plugin = plugin_basename( __FILE__ );
if ( $file == $this_plugin ) {
$settings_link = '<a href="' . admin_url( 'edit.php?post_type=slides&page=ctslider_all_options' ) . '">' . __( 'Settings', 'ctslider' ) . '</a>';
array_unshift( $link, $settings_link );
}
return $link;
}
add_filter( 'plugin_action_links', 'ctslider_settings_link', 10, 2 );
/*
|--------------------------------------------------------------------------
| INCLUDES
|--------------------------------------------------------------------------
*/
/* Admin Scripts */
if ( is_admin() ) {
include_once( CTSLIDER_PLUGIN_DIR . 'includes/admin/sorter.php' );
include_once( CTSLIDER_PLUGIN_DIR . 'includes/admin/ui.php' );
}
include_once( CTSLIDER_PLUGIN_DIR . 'includes/admin/settings.php' );
include_once( CTSLIDER_PLUGIN_DIR . 'includes/admin/post-types.php' );
include_once( CTSLIDER_PLUGIN_DIR . 'includes/admin/taxonomy.php' );
include_once( CTSLIDER_PLUGIN_DIR . 'includes/admin/meta-box.php' );
/* Front End Scripts */
include_once( CTSLIDER_PLUGIN_DIR . 'includes/front-end/template.php' );
include_once( CTSLIDER_PLUGIN_DIR . 'includes/front-end/shortcode.php' );
include_once( CTSLIDER_PLUGIN_DIR . 'includes/front-end/custom-size.php' );