-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmcSlider.php
More file actions
executable file
·128 lines (113 loc) · 5.77 KB
/
mcSlider.php
File metadata and controls
executable file
·128 lines (113 loc) · 5.77 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
<?php
/*
Plugin Name: Message Creative Slider
Plugin URI: http://messagecreative.com
Description: A slider manager and displayer using slides plugin at http://www.woothemes.com/flexslider/
Author: Matthew Laver
Version: 1.4
*/
// Make sure we don't expose any info if called directly
if ( ! function_exists( 'add_action' ) ) {
_e( "Hi there! I'm just a plugin, not much I can do when called directly." );
exit;
}
//load Admin scripts and styles
function mcSlider_scripts() {
wp_enqueue_script('media-upload');
wp_enqueue_script('thickbox');
wp_enqueue_script('jquery');
wp_enqueue_script('jquery-ui-core');
wp_enqueue_script('jquery-ui-widget');
wp_enqueue_script('jquery-ui-mouse');
wp_enqueue_script('jquery-ui-draggable');
wp_enqueue_script('jquery-ui-droppable');
wp_enqueue_script('jquery-ui-sortable');
wp_enqueue_script('mcslider', plugins_url('mcSlider.js', __FILE__), array('jquery'), '', true);
}
function mcSlider_styles(){
wp_enqueue_style('thickbox');
}
if (isset($_GET['page']) && $_GET['page'] == 'mc_slider_manager'){
add_action('admin_print_scripts', 'mcSlider_scripts');
add_action('admin_print_styles', 'mcSlider_styles');
}
//add plugin to menu
function mcSlider_admin_actions(){
add_submenu_page('upload.php', 'MessageCreative Slider Manager', 'Slider Manager', 'manage_options', 'mc_slider_manager', 'mcSlider_admin');
}
add_action('admin_menu','mcSlider_admin_actions');
/* ----------------------------------------------------------------------------------------------------- */
/* ---------------------------------------- Display Menu Page ------------------------------------------ */
/* ----------------------------------------------------------------------------------------------------- */
function mcSlider_admin(){
global $wpdb;
//check if page is loading after form submit or just normally
if($_POST['mcSlider_hidden'] == 'Y'){
$image = $_POST["mcSlider_image"]; $json = json_encode($image); update_option('mcSlider_image',$json);
$count = count($image);
$imageW = $_POST["mcSlider_imageWidth"]; update_option('mcSlider_imageWidth', $imageW);
$imageH = $_POST["mcSlider_imageHeight"]; update_option('mcSlider_imageHeight', $imageH);
$captions = $_POST["captions"]; update_option('mcSlider_captions', $captions);
$effect = $_POST["effect"]; update_option('mcSlider_effect', $effect);
} else {
$imageW = get_option('mcSlider_imageWidth');
$imageW = (empty($imageW)) ? '960' : $imageW;
$imageH = get_option('mcSlider_imageHeight');
$imageH = (empty($imageH) ? '380' : $imageH);
$json = get_option("mcSlider_image"); $image = json_decode($json, true);
$count = (count($image) == 0) ? 1 : count($image);
$captions = get_option('mcSlider_captions');
$effect = get_option('mcSlider_effect');
}
if ($captions == 'true'){ $checked = "checked";}
include_once dirname(__FILE__) . '/sliderAdminTemplate.php';
}
/* ----------------------------------------------------------------------------------------------------- */
/* ---------------------------------------- In-Page Function ------------------------------------------- */
/* ----------------------------------------------------------------------------------------------------- */
function mcSlider(){
wp_enqueue_script('slides', plugins_url('slider/jquery.flexslider-min.js', __FILE__), array('jquery'));
wp_enqueue_style('mcSlider-sliderstyle', plugins_url('slider/flexslider.css', __FILE__));
$json = get_option('mcSlider_image');
$slidesArray = json_decode($json, true);
$width = get_option('mcSlider_imageWidth');
$height = get_option('mcSlider_imageHeight');
$captions = get_option('mcSlider_captions');
$effect = get_option('mcSlider_effect');
$slideCount = 0;
foreach($slidesArray as $slide){
if($slide['image']){ $slideCount++; }
}
?>
<style>
ul.slides li {list-style: none;margin: 0;}
</style>
<div class="flexslider" data-effect="<?= $effect; ?>" style="margin-bottom:18px;">
<ul class="slides">
<?php foreach($slidesArray as $slide): ?>
<?php if ($slide['image']): $slideCount++; ?>
<li>
<?php if($slide['link']) echo("<a href='". $slide['link']. "'>"); ?>
<img src="<?= plugins_url('timthumb.php', __FILE__); ?>?src=<?= $slide['image']; ?>&w=<?= $width; ?>&h=<?= $height; ?>">
<?php if($captions && !empty($slide['text'])){ ?><p class="flex-caption"><?= $slide['text']; ?></p><?php } ?>
<?php if($slide['link']) echo("</a>"); ?>
</li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
</div>
<script>
jQuery(document).ready(function($) {
var effect = $('.flexslider').attr('data-effect'),
args = {
directionNav: false,
animation: effect,
slideshowSpeed: 3000,
animationDuration: 600,
pauseOnHover: true
};
$('.flexslider').flexslider(args);
});
</script>
<?php
}