-
Notifications
You must be signed in to change notification settings - Fork 5
/
insert.php
174 lines (131 loc) · 5.48 KB
/
insert.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
<?php
//Adding "embed form" button
add_action('media_buttons_context', 'jtd_anythingslider_insert_button' );
function jtd_anythingslider_insert_button($context){
$image_btn = plugin_dir_url( __FILE__ ) . 'favicon.ico';
$out = '<a href="#TB_inline?width=660&height=900&inlineId=anythingSlider_insert_slideshow" class="thickbox" title="Add a Slideshow"><img src="'.$image_btn.'" alt="Add a Slideshow" /></a>';
return $context . $out;
}
if( !defined( "AS_CURRENT_PAGE" ) )
define( "AS_CURRENT_PAGE", basename( $_SERVER['PHP_SELF'] ) );
if( in_array( AS_CURRENT_PAGE, array( 'post.php', 'page.php', 'page-new.php', 'post-new.php' ) ) ){
add_action( 'admin_footer', 'jtd_anythingslider_insert_form_popup' );
}
function jtd_anythingslider_insert_form_popup() {
$options = get_option( 'jtd_anything_slides_options' );
?>
<script>
function InsertSlideshow(){
var cat_id = ( jQuery("#add_cat_id").val() ) ? 'cat=' + jQuery("#add_cat_id").val() : '';
var category = jQuery("#add_cat_id option[value='" + cat_id + "']").text().replace(" ", "");
var width = jQuery("#width").val();
var height = jQuery("#height").val();
var delay = jQuery("#delay").val();
var resume = jQuery("#resume").val();
var animation = jQuery("#animation").val();
var navFormat = ( jQuery("#nav_format").is(":checked") ) ? 'navFormat=true' : '';
var order = jQuery("#order").val();
var orderby = jQuery("#orderby").val();
var win = window.dialogArguments || opener || parent || top;
win.send_to_editor("[anything_slides " + cat_id + " width=" + width + " height=" + height + " " + navFormat + " delay=" + delay + " resume=" + resume + " animation=" + animation + " order=" + order + " orderby=" + orderby + "]");
}
</script>
<div id="anythingSlider_insert_slideshow" style="display:none;">
<div class="wrap">
<div>
<h3>Insert A SlideShow</h3>
</div>
<table class="form-table"><tbody>
<tr class="form-field">
<th scope="row"> <label for="add_cat_id">Select a Category</label> </th>
<td>
<select id="add_cat_id">
<option value="">Select a Category</option>
<?php
$cats = get_terms( 'slide_cat' );
foreach( $cats as $cat ){
?>
<option value="<?php echo $cat->slug; ?>"><?php echo esc_html( $cat->name ); ?></option>
<?php
//print_r($cat);
}
?>
</select>
</td>
<th scope="row"> <em>optional</em> </th>
</tr>
<tr class="form-field">
<th scope="row"><label for="width">Width</label></th>
<td><input type="number" id="width" name="width" value="<?php echo $options['width']; ?>" /></td>
<th scope="row"><em>Custom width for this slideshow?</em></th>
</tr>
<tr class="form-field">
<th scope="row"><label for="height">Height</label></th>
<td><input type="number" id="height" name="height" value="<?php echo $options['height']; ?>" /></td>
<th scope="row"><em>Custom height for this slideshow?</em></th>
</tr>
<tr class="form-field">
<th scope="row"><label for="delay">Slide Delay</label></th>
<td><input type="number" id="delay" name="delay" value="<?php echo $options['delay']; ?>" /></td>
<th scope="row"><em>How long between slideshow transitions in AutoPlay mode (in milliseconds)</em></th>
</tr>
<tr class="form-field">
<th scope="row"><label for="resume">Resume Delay</label></th>
<td><input type="number" id="resume" name="resume" value="<?php echo $options['resume']; ?>" /></td>
<th scope="row"><em>Resume slideshow after user interaction (in milliseconds).</em></th>
</tr>
<tr class="form-field">
<th scope="row"><label for="animation">Animation Time</label></th>
<td><input type="number" id="animation" name="animation" value="<?php echo $options['animation']; ?>" /></td>
<th scope="row"><em>How long the slideshow transition takes (in milliseconds)</em></th>
</tr>
<tr>
<td> </td>
</tr>
<tr class="form-field">
<th scope="row"><label for="order">Slide Order</label></th>
<td>
<select id="order" name="order">
<option value="ASC">Ascending</option>
<option value="DESC">Descending</option>
</select>
</td>
<th scope="row"><em>top to bottom or bottom to top</em></th>
</tr>
<tr class="form-field">
<th scope="row"><label for="orderby">Slide Sort</label></th>
<td>
<select id="orderby" name="orderby">
<option value="menu_order">Menu Order</option>
<option value="title">Title</option>
<option value="rand">Random</option>
<option value="date">Date</option>
<option value="modified">Modified</option>
<option value="title">Title</option>
<option value="ID">ID</option>
<option value="author">Author</option>
</select>
</td>
<th scope="row"><em><a href="http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters" target="_blank">Codex for details</a></em></th>
</tr>
<tr>
<td> </td>
</tr>
<tr class="form-field">
<th scope="row"><label for="nav_format">Navigation Formatting?</label></th>
<td><input type="checkbox" id="nav_format" /></td>
<th scope="row"><em>Not sure? leave it blank.</em></th>
</tr>
<tr>
<td> </td>
</tr>
<tr class="form-field">
<td><input type="button" class="button-primary" value="Insert Slideshow" onclick="InsertSlideshow();"/></td>
<td><a class="button" href="#" onclick="tb_remove(); return false;">Cancel</a></td>
</tr>
</tbody></table>
</div>
</div>
<?php
}
?>