MetaSlider - Version 1.3

Version Description

  • Renamed to Meta Slider (previously ML Slider)
  • Improvement: Admin styling cleaned up
  • Improvement: Code refactored
  • Improvement: Plugin localised
  • Improvement: Template include PHP code now displayed on slider edit page
  • Improvement: jQuery tablednd replaced with jQuery sortable for reordering slides
  • Improvement: Open URL in new window option added
  • Improvement: max-width css rule added to slider wrapper
  • Fix: UTF-8 support in captions (reported by and thanks to: petergluk)
  • Fix: JS && encoding error (reported by and thanks to: neefje)
  • Fix: Editors now have permission to use MetaSlider (reported by and thanks to: rritsud)
Download this release

Release Info

Developer matchalabs
Plugin Icon 128x128 MetaSlider
Version 1.3
Comparing to
See all releases

Code changes from version 1.2.1 to 1.3

assets/jquery.tablednd.js DELETED
@@ -1,314 +0,0 @@
1
- /**
2
- * TableDnD plug-in for JQuery, allows you to drag and drop table rows
3
- * You can set up various options to control how the system will work
4
- * Copyright © Denis Howlett <denish@isocra.com>
5
- * Licensed like jQuery, see http://docs.jquery.com/License.
6
- *
7
- * Configuration options:
8
- *
9
- * onDragStyle
10
- * This is the style that is assigned to the row during drag. There are limitations to the styles that can be
11
- * associated with a row (such as you can't assign a border—well you can, but it won't be
12
- * displayed). (So instead consider using onDragClass.) The CSS style to apply is specified as
13
- * a map (as used in the jQuery css(...) function).
14
- * onDropStyle
15
- * This is the style that is assigned to the row when it is dropped. As for onDragStyle, there are limitations
16
- * to what you can do. Also this replaces the original style, so again consider using onDragClass which
17
- * is simply added and then removed on drop.
18
- * onDragClass
19
- * This class is added for the duration of the drag and then removed when the row is dropped. It is more
20
- * flexible than using onDragStyle since it can be inherited by the row cells and other content. The default
21
- * is class is tDnD_whileDrag. So to use the default, simply customise this CSS class in your
22
- * stylesheet.
23
- * onDrop
24
- * Pass a function that will be called when the row is dropped. The function takes 2 parameters: the table
25
- * and the row that was dropped. You can work out the new order of the rows by using
26
- * table.rows.
27
- * onDragStart
28
- * Pass a function that will be called when the user starts dragging. The function takes 2 parameters: the
29
- * table and the row which the user has started to drag.
30
- * onAllowDrop
31
- * Pass a function that will be called as a row is over another row. If the function returns true, allow
32
- * dropping on that row, otherwise not. The function takes 2 parameters: the dragged row and the row under
33
- * the cursor. It returns a boolean: true allows the drop, false doesn't allow it.
34
- * scrollAmount
35
- * This is the number of pixels to scroll if the user moves the mouse cursor to the top or bottom of the
36
- * window. The page should automatically scroll up or down as appropriate (tested in IE6, IE7, Safari, FF2,
37
- * FF3 beta)
38
- *
39
- * Other ways to control behaviour:
40
- *
41
- * Add class="nodrop" to any rows for which you don't want to allow dropping, and class="nodrag" to any rows
42
- * that you don't want to be draggable.
43
- *
44
- * Inside the onDrop method you can also call $.tableDnD.serialize() this returns a string of the form
45
- * <tableID>[]=<rowID1>&<tableID>[]=<rowID2> so that you can send this back to the server. The table must have
46
- * an ID as must all the rows.
47
- *
48
- * Known problems:
49
- * - Auto-scoll has some problems with IE7 (it scrolls even when it shouldn't), work-around: set scrollAmount to 0
50
- *
51
- * Version 0.2: 2008-02-20 First public version
52
- * Version 0.3: 2008-02-07 Added onDragStart option
53
- * Made the scroll amount configurable (default is 5 as before)
54
- * Version 0.4: 2008-03-15 Changed the noDrag/noDrop attributes to nodrag/nodrop classes
55
- * Added onAllowDrop to control dropping
56
- * Fixed a bug which meant that you couldn't set the scroll amount in both directions
57
- * Added serialise method
58
- */
59
- jQuery.tableDnD = {
60
- /** Keep hold of the current table being dragged */
61
- currentTable : null,
62
- /** Keep hold of the current drag object if any */
63
- dragObject: null,
64
- /** The current mouse offset */
65
- mouseOffset: null,
66
- /** Remember the old value of Y so that we don't do too much processing */
67
- oldY: 0,
68
-
69
- /** Actually build the structure */
70
- build: function(options) {
71
- // Make sure options exists
72
- options = options || {};
73
- // Set up the defaults if any
74
-
75
- this.each(function() {
76
- // Remember the options
77
- this.tableDnDConfig = {
78
- onDragStyle: options.onDragStyle,
79
- onDropStyle: options.onDropStyle,
80
- // Add in the default class for whileDragging
81
- onDragClass: options.onDragClass ? options.onDragClass : "tDnD_whileDrag",
82
- onDrop: options.onDrop,
83
- onDragStart: options.onDragStart,
84
- scrollAmount: options.scrollAmount ? options.scrollAmount : 5
85
- };
86
- // Now make the rows draggable
87
- jQuery.tableDnD.makeDraggable(this);
88
- });
89
-
90
- // Now we need to capture the mouse up and mouse move event
91
- // We can use bind so that we don't interfere with other event handlers
92
- jQuery(document)
93
- .bind('mousemove', jQuery.tableDnD.mousemove)
94
- .bind('mouseup', jQuery.tableDnD.mouseup);
95
-
96
- // Don't break the chain
97
- return this;
98
- },
99
-
100
- /** This function makes all the rows on the table draggable apart from those marked as "NoDrag" */
101
- makeDraggable: function(table) {
102
- // Now initialise the rows
103
- var rows = table.rows; //getElementsByTagName("tr")
104
- var config = table.tableDnDConfig;
105
- for (var i=0; i<rows.length; i++) {
106
- // To make non-draggable rows, add the nodrag class (eg for Category and Header rows)
107
- // inspired by John Tarr and Famic
108
- var nodrag = jQuery(rows[i]).hasClass("nodrag");
109
- if (! nodrag) { //There is no NoDnD attribute on rows I want to drag
110
- jQuery(rows[i]).mousedown(function(ev) {
111
- if (ev.target.tagName == "TD") {
112
- jQuery.tableDnD.dragObject = this;
113
- jQuery.tableDnD.currentTable = table;
114
- jQuery.tableDnD.mouseOffset = jQuery.tableDnD.getMouseOffset(this, ev);
115
- if (config.onDragStart) {
116
- // Call the onDrop method if there is one
117
- config.onDragStart(table, this);
118
- }
119
- return false;
120
- }
121
- }).css("cursor", "move"); // Store the tableDnD object
122
- }
123
- }
124
- },
125
-
126
- /** Get the mouse coordinates from the event (allowing for browser differences) */
127
- mouseCoords: function(ev){
128
- if(ev.pageX || ev.pageY){
129
- return {x:ev.pageX, y:ev.pageY};
130
- }
131
- return {
132
- x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
133
- y:ev.clientY + document.body.scrollTop - document.body.clientTop
134
- };
135
- },
136
-
137
- /** Given a target element and a mouse event, get the mouse offset from that element.
138
- To do this we need the element's position and the mouse position */
139
- getMouseOffset: function(target, ev) {
140
- ev = ev || window.event;
141
-
142
- var docPos = this.getPosition(target);
143
- var mousePos = this.mouseCoords(ev);
144
- return {x:mousePos.x - docPos.x, y:mousePos.y - docPos.y};
145
- },
146
-
147
- /** Get the position of an element by going up the DOM tree and adding up all the offsets */
148
- getPosition: function(e){
149
- var left = 0;
150
- var top = 0;
151
- /** Safari fix -- thanks to Luis Chato for this! */
152
- if (e.offsetHeight == 0) {
153
- /** Safari 2 doesn't correctly grab the offsetTop of a table row
154
- this is detailed here:
155
- http://jacob.peargrove.com/blog/2006/technical/table-row-offsettop-bug-in-safari/
156
- the solution is likewise noted there, grab the offset of a table cell in the row - the firstChild.
157
- note that firefox will return a text node as a first child, so designing a more thorough
158
- solution may need to take that into account, for now this seems to work in firefox, safari, ie */
159
- e = e.firstChild; // a table cell
160
- }
161
-
162
- while (e.offsetParent){
163
- left += e.offsetLeft;
164
- top += e.offsetTop;
165
- e = e.offsetParent;
166
- }
167
-
168
- left += e.offsetLeft;
169
- top += e.offsetTop;
170
-
171
- return {x:left, y:top};
172
- },
173
-
174
- mousemove: function(ev) {
175
- if (jQuery.tableDnD.dragObject == null) {
176
- return;
177
- }
178
-
179
- var dragObj = jQuery(jQuery.tableDnD.dragObject);
180
- var config = jQuery.tableDnD.currentTable.tableDnDConfig;
181
- var mousePos = jQuery.tableDnD.mouseCoords(ev);
182
- var y = mousePos.y - jQuery.tableDnD.mouseOffset.y;
183
- //auto scroll the window
184
- var yOffset = window.pageYOffset;
185
- if (document.all) {
186
- // Windows version
187
- //yOffset=document.body.scrollTop;
188
- if (typeof document.compatMode != 'undefined' &&
189
- document.compatMode != 'BackCompat') {
190
- yOffset = document.documentElement.scrollTop;
191
- }
192
- else if (typeof document.body != 'undefined') {
193
- yOffset=document.body.scrollTop;
194
- }
195
-
196
- }
197
-
198
- if (mousePos.y-yOffset < config.scrollAmount) {
199
- window.scrollBy(0, -config.scrollAmount);
200
- } else {
201
- var windowHeight = window.innerHeight ? window.innerHeight
202
- : document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight;
203
- if (windowHeight-(mousePos.y-yOffset) < config.scrollAmount) {
204
- window.scrollBy(0, config.scrollAmount);
205
- }
206
- }
207
-
208
-
209
- if (y != jQuery.tableDnD.oldY) {
210
- // work out if we're going up or down...
211
- var movingDown = y > jQuery.tableDnD.oldY;
212
- // update the old value
213
- jQuery.tableDnD.oldY = y;
214
- // update the style to show we're dragging
215
- if (config.onDragClass) {
216
- dragObj.addClass(config.onDragClass);
217
- } else {
218
- dragObj.css(config.onDragStyle);
219
- }
220
- // If we're over a row then move the dragged row to there so that the user sees the
221
- // effect dynamically
222
- var currentRow = jQuery.tableDnD.findDropTargetRow(dragObj, y);
223
- if (currentRow) {
224
- // TODO worry about what happens when there are multiple TBODIES
225
- if (movingDown && jQuery.tableDnD.dragObject != currentRow) {
226
- jQuery.tableDnD.dragObject.parentNode.insertBefore(jQuery.tableDnD.dragObject, currentRow.nextSibling);
227
- } else if (! movingDown && jQuery.tableDnD.dragObject != currentRow) {
228
- jQuery.tableDnD.dragObject.parentNode.insertBefore(jQuery.tableDnD.dragObject, currentRow);
229
- }
230
- }
231
- }
232
-
233
- return false;
234
- },
235
-
236
- /** We're only worried about the y position really, because we can only move rows up and down */
237
- findDropTargetRow: function(draggedRow, y) {
238
- var rows = jQuery.tableDnD.currentTable.rows;
239
- for (var i=0; i<rows.length; i++) {
240
- var row = rows[i];
241
- var rowY = this.getPosition(row).y;
242
- var rowHeight = parseInt(row.offsetHeight)/2;
243
- if (row.offsetHeight == 0) {
244
- rowY = this.getPosition(row.firstChild).y;
245
- rowHeight = parseInt(row.firstChild.offsetHeight)/2;
246
- }
247
- // Because we always have to insert before, we need to offset the height a bit
248
- if ((y > rowY - rowHeight) && (y < (rowY + rowHeight))) {
249
- // that's the row we're over
250
- // If it's the same as the current row, ignore it
251
- if (row == draggedRow) {return null;}
252
- var config = jQuery.tableDnD.currentTable.tableDnDConfig;
253
- if (config.onAllowDrop) {
254
- if (config.onAllowDrop(draggedRow, row)) {
255
- return row;
256
- } else {
257
- return null;
258
- }
259
- } else {
260
- // If a row has nodrop class, then don't allow dropping (inspired by John Tarr and Famic)
261
- var nodrop = jQuery(row).hasClass("nodrop");
262
- if (! nodrop) {
263
- return row;
264
- } else {
265
- return null;
266
- }
267
- }
268
- return row;
269
- }
270
- }
271
- return null;
272
- },
273
-
274
- mouseup: function(e) {
275
- if (jQuery.tableDnD.currentTable && jQuery.tableDnD.dragObject) {
276
- var droppedRow = jQuery.tableDnD.dragObject;
277
- var config = jQuery.tableDnD.currentTable.tableDnDConfig;
278
- // If we have a dragObject, then we need to release it,
279
- // The row will already have been moved to the right place so we just reset stuff
280
- if (config.onDragClass) {
281
- jQuery(droppedRow).removeClass(config.onDragClass);
282
- } else {
283
- jQuery(droppedRow).css(config.onDropStyle);
284
- }
285
- jQuery.tableDnD.dragObject = null;
286
- if (config.onDrop) {
287
- // Call the onDrop method if there is one
288
- config.onDrop(jQuery.tableDnD.currentTable, droppedRow);
289
- }
290
- jQuery.tableDnD.currentTable = null; // let go of the table too
291
- }
292
- },
293
-
294
- serialize: function() {
295
- if (jQuery.tableDnD.currentTable) {
296
- var result = "";
297
- var tableId = jQuery.tableDnD.currentTable.id;
298
- var rows = jQuery.tableDnD.currentTable.rows;
299
- for (var i=0; i<rows.length; i++) {
300
- if (result.length > 0) result += "&";
301
- result += tableId + '[]=' + rows[i].id;
302
- }
303
- return result;
304
- } else {
305
- return "Error: No Table id set, you need to set an id on your table and every row";
306
- }
307
- }
308
- }
309
-
310
- jQuery.fn.extend(
311
- {
312
- tableDnD : jQuery.tableDnD.build
313
- }
314
- );
assets/{ml-slider-admin.css → metaslider-admin.css} RENAMED
@@ -1,4 +1,93 @@
1
- .ml-slider .unsaved {
2
float: right;
3
background: #ff3019; /* Old browsers */
4
background: -moz-linear-gradient(top, #ff3019 0%, #cf0404 100%); /* FF3.6+ */
@@ -17,15 +106,22 @@
17
text-rendering: optimizeLegibility;
18
margin: 2px 10px;
19
}
20
- .ml-slider tr.slide textarea {
21
width: 100%;
22
height: 75px;
23
}
24
-
25
- .ml-slider tr.slide input {
26
width: 100%;
27
}
28
- .ml-slider .delete-slide {
29
position: relative;
30
top: 0px;
31
left: 0px;
@@ -35,9 +131,13 @@
35
height: 16px;
36
float: left;
37
text-align: center;
38
}
39
40
- .ml-slider .slider-wrap {
41
border-left: 1px solid #ccc;
42
border-right: 1px solid #ccc;
43
border-bottom: 1px solid #ccc;
@@ -45,7 +145,7 @@
45
float: left;
46
}
47
48
- .ml-slider .slider-lib {
49
float: left;
50
width: 23%;
51
margin: 1%;
@@ -53,25 +153,27 @@
53
text-align: center;
54
}
55
56
- .ml-slider .tooltip {
57
- font-size: 0.8em;
58
}
59
60
- .ml-slider .settings td {
61
font-size: 0.9em;
62
}
63
64
- .ml-slider .slider-lib label {
65
color: white;
66
border-radius: 10%;
67
- font-size: 0.8em;
68
float: left;
69
width: 100%;
70
padding: 10px 0px;
71
vertical-align: bottom;
72
}
73
74
- .ml-slider .slider-lib.nivo label {
75
background: #b6e026; /* Old browsers */
76
background: -moz-linear-gradient(top, #b6e026 0%, #abdc28 100%); /* FF3.6+ */
77
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#b6e026), color-stop(100%,#abdc28)); /* Chrome,Safari4+ */
@@ -81,7 +183,7 @@
81
background: linear-gradient(to bottom, #b6e026 0%,#abdc28 100%); /* W3C */
82
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#b6e026', endColorstr='#abdc28',GradientType=0 ); /* IE6-9 */
83
}
84
- .ml-slider .slider-lib.flex label {
85
background: #00b7ea; /* Old browsers */
86
background: -moz-linear-gradient(top, #00b7ea 0%, #009ec3 100%); /* FF3.6+ */
87
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#00b7ea), color-stop(100%,#009ec3)); /* Chrome,Safari4+ */
@@ -92,7 +194,7 @@
92
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00b7ea', endColorstr='#009ec3',GradientType=0 ); /* IE6-9 */
93
}
94
95
- .ml-slider .slider-lib.coin label {
96
background: #ffd65e; /* Old browsers */
97
background: -moz-linear-gradient(top, #ffd65e 0%, #febf04 100%); /* FF3.6+ */
98
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffd65e), color-stop(100%,#febf04)); /* Chrome,Safari4+ */
@@ -103,7 +205,7 @@
103
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffd65e', endColorstr='#febf04',GradientType=0 ); /* IE6-9 */
104
}
105
106
- .ml-slider .slider-lib.responsive label {
107
background: #959595; /* Old browsers */
108
background: -moz-linear-gradient(top, #959595 0%, #0d0d0d 46%, #010101 50%, #0a0a0a 53%, #4e4e4e 76%, #383838 87%, #1b1b1b 100%); /* FF3.6+ */
109
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#959595), color-stop(46%,#0d0d0d), color-stop(50%,#010101), color-stop(53%,#0a0a0a), color-stop(76%,#4e4e4e), color-stop(87%,#383838), color-stop(100%,#1b1b1b)); /* Chrome,Safari4+ */
1
+ .msTipsy .tipsy-inner { color: white; background-color: #555; }
2
+ .msTipsy .tipsy-arrow-n { border-bottom-color: #555; }
3
+ .msTipsy .tipsy-arrow-s { border-top-color: #555; }
4
+ .msTipsy .tipsy-arrow-e { border-left-color: #555; }
5
+ .msTipsy .tipsy-arrow-w { border-right-color: #555; }
6
+
7
+ .metaslider .highlight {
8
+ background: #f1f1f1;
9
+ background-image: -webkit-gradient(linear, left bottom, left top, from(#ececec), to(#f9f9f9));
10
+ background-image: -webkit-linear-gradient(bottom, #ececec, #f9f9f9);
11
+ background-image: -moz-linear-gradient(bottom, #ececec, #f9f9f9);
12
+ background-image: -o-linear-gradient(bottom, #ececec, #f9f9f9);
13
+ background-image: linear-gradient(to top, #ececec, #f9f9f9);
14
+ }
15
+ .metaslider .ui-sortable-helper {
16
+ box-shadow: 3px 3px 5px #cccccc;
17
+ }
18
+ .metaslider tr.slide .new_window {
19
+ position: relative;
20
+ float: right;
21
+ font-size: 10px;
22
+ padding: 0px 3px;
23
+ color: #a9a9a9;
24
+ }
25
+ .metaslider tr.slide .new_window label {
26
+ position: absolute;
27
+ width: 78px;
28
+ right: 0;
29
+ top: -30px;
30
+ }
31
+ .metaslider tr.slide .new_window label input {
32
+ margin: 1px 0 0 4px;
33
+ margin-bottom: 0;
34
+ }
35
+ .metaslider .shortcode {
36
+ width: 100%;
37
+ margin-top: 20px;
38
+
39
+ }
40
+ .metaslider .shortcode input {
41
+ width: 100%;
42
+ font-size: 0.9em;
43
+ background: transparent;
44
+ border: 0;
45
+ }
46
+ .metaslider .shortcode td {
47
+ border-bottom: 0;
48
+ border-top: 0;
49
+ font-size: 0.9em;
50
+ }
51
+ .metaslider .nav-tab,
52
+ .metaslider h2.nav-tab-wrapper {
53
+ font-size: 13px;
54
+ }
55
+ .metaslider .nav-tab-active input {
56
+ padding: 0;
57
+ margin: 0;
58
+ border: 0;
59
+ width: 100px;
60
+ font-size: 13px;
61
+ }
62
+ .metaslider .left {
63
+ width: 68%;
64
+ margin-top: 20px;
65
+ float: left;
66
+ clear: none;
67
+ }
68
+ .metaslider .right {
69
+ width: 30%;
70
+ float: right;
71
+ margin-top: 20px;
72
+ clear: none;
73
+ }
74
+ .metaslider table.slides td {
75
+ border-bottom: 0;
76
+ border-top: 0;
77
+ background: #f9f9f9;
78
+ cursor: move;
79
+ padding: 5px 10px 5px 10px;
80
+ }
81
+ .metaslider table.slides td.col-1 {
82
+ padding: 10px 10px 0 10px;
83
+ }
84
+ .metaslider table.slides td.col-2 {
85
+ padding: 10px 10px 0 0;
86
+ }
87
+ .metaslider table.slides tr:last-child td {
88
+ padding-bottom: 10px;
89
+ }
90
+ .metaslider .unsaved {
91
float: right;
92
background: #ff3019; /* Old browsers */
93
background: -moz-linear-gradient(top, #ff3019 0%, #cf0404 100%); /* FF3.6+ */
106
text-rendering: optimizeLegibility;
107
margin: 2px 10px;
108
}
109
+ .metaslider tr.slide {
110
+ background-color: #f9f9f9;
111
+ }
112
+ .metaslider tr.slide textarea {
113
width: 100%;
114
height: 75px;
115
+ margin-bottom: 5px;
116
}
117
+ .metaslider tr.slide input {
118
+ margin-bottom: 10px;
119
+ }
120
+ .metaslider tr.slide input.alt,
121
+ .metaslider tr.slide input.url {
122
width: 100%;
123
}
124
+ .metaslider .delete-slide {
125
position: relative;
126
top: 0px;
127
left: 0px;
131
height: 16px;
132
float: left;
133
text-align: center;
134
+ display: none;
135
+ }
136
+ .metaslider tr.slide td.col-1:hover .delete-slide {
137
+ display: block;
138
}
139
140
+ .metaslider .slider-wrap {
141
border-left: 1px solid #ccc;
142
border-right: 1px solid #ccc;
143
border-bottom: 1px solid #ccc;
145
float: left;
146
}
147
148
+ .metaslider .slider-lib {
149
float: left;
150
width: 23%;
151
margin: 1%;
153
text-align: center;
154
}
155
156
+ .metaslider .tooltip {
157
+ font-size: 0.9em;
158
}
159
160
+ .metaslider .settings td {
161
font-size: 0.9em;
162
+ vertical-align: middle;
163
+ padding: 3px 0px 3px 6px;
164
+ border-bottom: 0;
165
}
166
167
+ .metaslider .slider-lib label {
168
color: white;
169
border-radius: 10%;
170
float: left;
171
width: 100%;
172
padding: 10px 0px;
173
vertical-align: bottom;
174
}
175
176
+ .metaslider .slider-lib.nivo label {
177
background: #b6e026; /* Old browsers */
178
background: -moz-linear-gradient(top, #b6e026 0%, #abdc28 100%); /* FF3.6+ */
179
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#b6e026), color-stop(100%,#abdc28)); /* Chrome,Safari4+ */
183
background: linear-gradient(to bottom, #b6e026 0%,#abdc28 100%); /* W3C */
184
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#b6e026', endColorstr='#abdc28',GradientType=0 ); /* IE6-9 */
185
}
186
+ .metaslider .slider-lib.flex label {
187
background: #00b7ea; /* Old browsers */
188
background: -moz-linear-gradient(top, #00b7ea 0%, #009ec3 100%); /* FF3.6+ */
189
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#00b7ea), color-stop(100%,#009ec3)); /* Chrome,Safari4+ */
194
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00b7ea', endColorstr='#009ec3',GradientType=0 ); /* IE6-9 */
195
}
196
197
+ .metaslider .slider-lib.coin label {
198
background: #ffd65e; /* Old browsers */
199
background: -moz-linear-gradient(top, #ffd65e 0%, #febf04 100%); /* FF3.6+ */
200
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffd65e), color-stop(100%,#febf04)); /* Chrome,Safari4+ */
205
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffd65e', endColorstr='#febf04',GradientType=0 ); /* IE6-9 */
206
}
207
208
+ .metaslider .slider-lib.responsive label {
209
background: #959595; /* Old browsers */
210
background: -moz-linear-gradient(top, #959595 0%, #0d0d0d 46%, #010101 50%, #0a0a0a 53%, #4e4e4e 76%, #383838 87%, #1b1b1b 100%); /* FF3.6+ */
211
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#959595), color-stop(46%,#0d0d0d), color-stop(50%,#010101), color-stop(53%,#0a0a0a), color-stop(76%,#4e4e4e), color-stop(87%,#383838), color-stop(100%,#1b1b1b)); /* Chrome,Safari4+ */
assets/{ml-slider-display.css → metaslider-display.css} RENAMED
@@ -1,23 +1,23 @@
1
- .ml-slider .flexslider,
2
- .ml-slider .flexslider ul,
3
- .ml-slider .flexslider .slides li,
4
- .ml-slider .flexslider .slides ul,
5
- .ml-slider .flexslider .slides ol,
6
- .ml-slider .flexslider .flex-direction-nav,
7
- .ml-slider .rslides li,
8
- .ml-slider .rslides .rslides_tabs {
9
border: 0;
10
margin: 0;
11
list-style-type: none;
12
}
13
- .ml-slider .flexslider .slides p {
14
margin: 0;
15
}
16
- .ml-slider .flexslider .flex-control-nav {
17
position: inherit;
18
bottom: auto;
19
}
20
- .ml-slider .rslides_tabs {
21
margin: 0;
22
padding: 7px 0 !important;
23
background: #333;
@@ -31,7 +31,7 @@
31
text-align: center;
32
width: 100%;
33
}
34
- .ml-slider .rslides_tabs li {
35
margin: 0;
36
padding: 0;
37
display: inline;
@@ -39,7 +39,7 @@
39
margin-right: 1px;
40
list-style-type: none;
41
}
42
- .ml-slider .rslides_tabs a {
43
text-decoration: none;
44
width: auto;
45
line-height: 20px;
@@ -48,23 +48,23 @@
48
background: transparent;
49
display: inline;
50
}
51
- .ml-slider .rslides_tabs a:hover {
52
border: 0;
53
color: white;
54
}
55
56
- .ml-slider .rslides_tabs li:first-child {
57
margin-left: 0;
58
}
59
- .ml-slider .rslides_tabs .rslides_here a {
60
background: rgba(255,255,255,.1);
61
color: #fff;
62
font-weight: bold;
63
}
64
- .ml-slider-responsive {
65
position: relative;
66
}
67
- .ml-slider .rslides_nav {
68
background-color: #000000;
69
color: #FFFFFF;
70
padding: 0px 10px;
@@ -73,9 +73,9 @@
73
z-index:9;
74
cursor:pointer;
75
}
76
- .ml-slider .rslides_nav.prev {
77
left:0px;
78
}
79
- .ml-slider .rslides_nav.next {
80
right:0px;
81
}
1
+ .metaslider .flexslider,
2
+ .metaslider .flexslider ul,
3
+ .metaslider .flexslider .slides li,
4
+ .metaslider .flexslider .slides ul,
5
+ .metaslider .flexslider .slides ol,
6
+ .metaslider .flexslider .flex-direction-nav,
7
+ .metaslider .rslides li,
8
+ .metaslider .rslides .rslides_tabs {
9
border: 0;
10
margin: 0;
11
list-style-type: none;
12
}
13
+ .metaslider .flexslider .slides p {
14
margin: 0;
15
}
16
+ .metaslider .flexslider .flex-control-nav {
17
position: inherit;
18
bottom: auto;
19
}
20
+ .metaslider .rslides_tabs {
21
margin: 0;
22
padding: 7px 0 !important;
23
background: #333;
31
text-align: center;
32
width: 100%;
33
}
34
+ .metaslider .rslides_tabs li {
35
margin: 0;
36
padding: 0;
37
display: inline;
39
margin-right: 1px;
40
list-style-type: none;
41
}
42
+ .metaslider .rslides_tabs a {
43
text-decoration: none;
44
width: auto;
45
line-height: 20px;
48
background: transparent;
49
display: inline;
50
}
51
+ .metaslider .rslides_tabs a:hover {
52
border: 0;
53
color: white;
54
}
55
56
+ .metaslider .rslides_tabs li:first-child {
57
margin-left: 0;
58
}
59
+ .metaslider .rslides_tabs .rslides_here a {
60
background: rgba(255,255,255,.1);
61
color: #fff;
62
font-weight: bold;
63
}
64
+ .metaslider-responsive {
65
position: relative;
66
}
67
+ .metaslider .rslides_nav {
68
background-color: #000000;
69
color: #FFFFFF;
70
padding: 0px 10px;
73
z-index:9;
74
cursor:pointer;
75
}
76
+ .metaslider .rslides_nav.prev {
77
left:0px;
78
}
79
+ .metaslider .rslides_nav.next {
80
right:0px;
81
}
assets/{ml-slider.js → metaslider.js} RENAMED
@@ -3,11 +3,12 @@
3
*/
4
(function ($) {
5
$(function () {
6
/**
7
* Reindex the slides after they have been dragged/dropped
8
*/
9
var updateSlideOrder = function() {
10
- $('.ml-slider table.sortable tr').each(function() {
11
$('input.menu_order', $(this)).val($(this).index());
12
});
13
}
@@ -16,8 +17,8 @@
16
* Enable the correct options for this slider type
17
*/
18
var enableOptions = function(slider) {
19
- $('.ml-slider .option:not(.' + slider + ')').attr('disabled', 'disabled').css('color','#ccc').parents('tr').hide();
20
- $('.ml-slider .option.' + slider).removeAttr('disabled').css('color','').parents('tr').show();
21
22
if ($('.effect option:selected').attr('disabled') == 'disabled') {
23
$('.effect option:enabled:first').attr('selected', 'selected');
@@ -27,34 +28,40 @@
27
/**
28
* Enable the correct options on page load
29
*/
30
- enableOptions($('.ml-slider .select-slider:checked').attr('rel'));
31
32
/**
33
* Handle slide libary switching
34
*/
35
- $('.ml-slider .select-slider').click(function() {
36
enableOptions($(this).attr('rel'));
37
});
38
39
- /**
40
- * Enable drag and drop table rows for slides
41
- */
42
- $(".ml-slider table.sortable").tableDnD({
43
- onDrop: function() {
44
- updateSlideOrder();
45
- $('.ml-slider .unsaved').fadeIn();
46
}
47
});
48
49
$(".confirm").click(function() {
50
- return confirm("Are you sure?");
51
});
52
53
/**
54
* Helptext tooltips
55
*/
56
- $(".ml-slider .tooltip").tipsy({html: true, fade: true, gravity: 'e'});
57
- $(".ml-slider .tooltiptop").tipsy({html: true, fade: true, gravity: 'se'});
58
59
/**
60
* Image uploader
@@ -98,21 +105,22 @@
98
url = attachment.sizes.thumbnail.url;
99
}
100
101
- var tableRow = "<tr class='slide'><td>" +
102
- "<div style='position: absolute'>" +
103
- "<a class='delete-slide remove-slide' href='#'>x</a> " +
104
"</div>" +
105
- "<img src='" + url + "' width='150px'></td><td> " +
106
- "<textarea name='attachment[" + attachment.id + "][post_excerpt]' placeholder='Caption'>" + attachment.caption + "</textarea>" +
107
- "<input type='text' name='attachment[" + attachment.id + "][url]' placeholder='URL'>" +
108
- "<input type='hidden' class='menu_order' name='attachment[" + attachment.id + "][menu_order]' value='100'>" +
109
"</td></tr>";
110
111
// add slide to existing slides table
112
- jQuery(".ml-slider .slides tbody").append(tableRow);
113
114
// display the unsaved changes warning
115
- $('.ml-slider .unsaved').show();
116
});
117
118
// the slides haven't been assigned to the slider yet, so just remove the row if the delete
@@ -125,20 +133,19 @@
125
// reindex the slides
126
updateSlideOrder();
127
128
- // ensure the rows are sortable
129
- $(".ml-slider table.sortable").tableDnD({
130
- onDrop: function() {
131
- updateSlideOrder()
132
- }
133
- });
134
});
135
136
file_frame.open();
137
});
138
139
// show the unsaved changes when the form is changed
140
- $('.ml-slider form').live('change', function() {
141
- $('.ml-slider .unsaved').fadeIn();
142
});
143
});
144
}(jQuery));
3
*/
4
(function ($) {
5
$(function () {
6
+
7
/**
8
* Reindex the slides after they have been dragged/dropped
9
*/
10
var updateSlideOrder = function() {
11
+ $('.metaslider table.sortable tr').each(function() {
12
$('input.menu_order', $(this)).val($(this).index());
13
});
14
}
17
* Enable the correct options for this slider type
18
*/
19
var enableOptions = function(slider) {
20
+ $('.metaslider .option:not(.' + slider + ')').attr('disabled', 'disabled').css('color','#ccc').parents('tr').hide();
21
+ $('.metaslider .option.' + slider).removeAttr('disabled').css('color','').parents('tr').show();
22
23
if ($('.effect option:selected').attr('disabled') == 'disabled') {
24
$('.effect option:enabled:first').attr('selected', 'selected');
28
/**
29
* Enable the correct options on page load
30
*/
31
+ enableOptions($('.metaslider .select-slider:checked').attr('rel'));
32
33
/**
34
* Handle slide libary switching
35
*/
36
+ $('.metaslider .select-slider').click(function() {
37
enableOptions($(this).attr('rel'));
38
});
39
40
+ // Return a helper with preserved width of cells
41
+ var helper = function(e, ui) {
42
+ ui.children().each(function() {
43
+ $(this).width($(this).width());
44
+ });
45
+ return ui;
46
+ };
47
+
48
+ $(".metaslider table.sortable tbody").sortable({
49
+ helper: helper,
50
+ stop: function() {
51
+ updateSlideOrder()
52
}
53
});
54
55
+
56
$(".confirm").click(function() {
57
+ return confirm(metaslider.confirm);
58
});
59
60
/**
61
* Helptext tooltips
62
*/
63
+ $(".metaslider .tooltip").tipsy({className: 'msTipsy', live: true, delayIn: 200, html: true, fade: true, gravity: 'e'});
64
+ $(".metaslider .tooltiptop").tipsy({live: true, delayIn: 500, html: true, fade: true, gravity: 'se'});
65
66
/**
67
* Image uploader
105
url = attachment.sizes.thumbnail.url;
106
}
107
108
+ var tableRow = "<tr class='slide'><td class='col-1'>" +
109
+ "<div style='position: absolute'><a class='delete-slide remove-slide' href='#'>x</a></div>" +
110
+ "<img src='" + url + "' width='150px'></td>" +
111
+ "<td class='col-2'><textarea name='attachment[" + attachment.id + "][post_excerpt]' placeholder='" + metaslider.caption + "'>" + attachment.caption + "</textarea>" +
112
+ "<input class='url' type='text' name='attachment[" + attachment.id + "][url]' placeholder='" + metaslider.url + "' value=''>" +
113
+ "<div class='new_window'>" +
114
+ "<label>" + metaslider.new_window + "<input type='checkbox' name='attachment[" + attachment.id + "][new_window]'></label>" +
115
"</div>" +
116
+ "<input type='hidden' class='menu_order' name='attachment[" + attachment.id + "][menu_order]'>" +
117
"</td></tr>";
118
119
// add slide to existing slides table
120
+ jQuery(".metaslider .slides tbody").append(tableRow);
121
122
// display the unsaved changes warning
123
+ $('.metaslider .unsaved').show();
124
});
125
126
// the slides haven't been assigned to the slider yet, so just remove the row if the delete
133
// reindex the slides
134
updateSlideOrder();
135
136
});
137
138
file_frame.open();
139
});
140
141
// show the unsaved changes when the form is changed
142
+ $('.metaslider form').live('change', function() {
143
+ $('.metaslider .unsaved').fadeIn();
144
+ });
145
+
146
+ $(".metaslider .shortcode input").click(function(){
147
+ // Select input field contents
148
+ this.select();
149
});
150
});
151
}(jQuery));
inc/metaslider.class.php ADDED
@@ -0,0 +1,210 @@
1
+ <?php
2
+ /**
3
+ *
4
+ */
5
+ class MetaSlider {
6
+
7
+ public $id = 0; // slider ID
8
+ public $identifier = 0; // unique identifier
9
+ public $slides = array(); //slides belonging to this slider
10
+ public $settings = array(); // slider settings
11
+
12
+ /**
13
+ * Constructor
14
+ */
15
+ public function __construct($id) {
16
+ $this->id = $id;
17
+ $this->slides = $this->get_slides();
18
+ $this->settings = $this->get_settings();
19
+ $this->identifier = 'metaslider_' . rand();
20
+ }
21
+
22
+ /**
23
+ * Return the unique identifier for the slider (used to avoid javascript conflicts)
24
+ */
25
+ protected function get_identifier() {
26
+ return $this->identifier;
27
+ }
28
+
29
+ /**
30
+ * Return slides for the current slider
31
+ *
32
+ * @return array collection of slides belonging to the current slider
33
+ */
34
+ protected function get_slides() {
35
+ $slides = array();
36
+
37
+ $args = array(
38
+ 'orderby' => $this->get_setting('random') == 'true' && !is_admin() ? 'rand' : 'menu_order',
39
+ 'order' => 'ASC',
40
+ 'post_type' => 'attachment',
41
+ 'post_status' => 'inherit',
42
+ 'posts_per_page' => -1,
43
+ 'tax_query' => array(
44
+ array(
45
+ 'taxonomy' => 'ml-slider',
46
+ 'field' => 'slug',
47
+ 'terms' => $this->id
48
+ )
49
+ )
50
+ );
51
+
52
+ $query = new WP_Query($args);
53
+
54
+ while ($query->have_posts()) {
55
+ $query->next_post();
56
+
57
+ $slide_src = wp_get_attachment_image_src($query->post->ID, 'ml-slider-slide'); // returns an array
58
+ $slide_thumb = wp_get_attachment_image_src($query->post->ID); // returns an array
59
+
60
+ $slides[] = array(
61
+ 'id' => $query->post->ID,
62
+ 'type' => 'image',
63
+ 'url' => get_post_meta($query->post->ID, 'ml-slider_url', true),
64
+ 'caption' => htmlentities($query->post->post_excerpt, ENT_QUOTES, 'UTF-8'),
65
+ 'src' => $slide_src[0],
66
+ 'thumb' => $slide_thumb[0],
67
+ 'menu_order' => $query->post->menu_order,
68
+ 'target' => get_post_meta($query->post->ID, 'ml-slider_new_window', true) ? '_blank' : '_self',
69
+ 'alt' => get_post_meta($query->post->ID, '_wp_attachment_image_alt', true)
70
+ );
71
+ }
72
+
73
+ return $slides;
74
+ }
75
+
76
+ /**
77
+ * Get settings for the current slider
78
+ *
79
+ * @return array slider settings
80
+ */
81
+ private function get_settings() {
82
+ return get_post_meta($this->id, 'ml-slider_settings', true);
83
+ }
84
+
85
+ /**
86
+ * Return an individual setting
87
+ *
88
+ * @param string $name Name of the setting
89
+ * @return string | bool setting value or fase
90
+ */
91
+ public function get_setting($name) {
92
+ return isset($this->settings[$name]) && strlen($this->settings[$name]) > 0 ? $this->settings[$name] : "false";
93
+ }
94
+
95
+ /**
96
+ * Get the slider libary parameters. This function is overridden by sub classes.
97
+ *
98
+ * @return string javascript options
99
+ */
100
+ public function get_default_parameters() {
101
+ $params = array(
102
+ 'type' => 'nivo',
103
+ 'random' => false,
104
+ 'cssClass' => '',
105
+ 'printCss' => true,
106
+ 'printJs' => true,
107
+ 'width' => 565,
108
+ 'height' => 290,
109
+ 'spw' => 7,
110
+ 'sph' => 5,
111
+ 'delay' => 3000,
112
+ 'sDelay' => 30,
113
+ 'opacity' => 0.7,
114
+ 'titleSpeed' => 500,
115
+ 'effect' => 'random',
116
+ 'navigation' => true,
117
+ 'links' => true,
118
+ 'hoverPause' => true,
119
+ 'theme' => 'default',
120
+ 'direction' => 'horizontal',
121
+ 'reverse' => false,
122
+ 'animationSpeed' => 600,
123
+ 'prevText' => 'Previous',
124
+ 'nextText' => 'Next',
125
+ 'slices' => 15
126
+ );
127
+
128
+ return $params;
129
+ }
130
+
131
+ /**
132
+ *
133
+ */
134
+ private function get_javascript_parameters() {
135
+ $options = array();
136
+
137
+ foreach ($this->get_default_parameters() as $name => $default) {
138
+ if ($param = $this->get_param($name)) {
139
+ $val = $this->get_setting($name);
140
+
141
+ if (gettype($default) == 'string') {
142
+ $options[] = $param . ": '" . $val . "'";
143
+ } else {
144
+ $options[] = $param . ": " . $val;
145
+ }
146
+ }
147
+ }
148
+
149
+ return implode(",\n ", $options);
150
+ }
151
+
152
+ /**
153
+ * Return the Javascript to kick off the slider. Code is wrapped in a timer
154
+ * to allow for themes that load jQuery at the bottom of the page.
155
+ *
156
+ * @return string javascript
157
+ */
158
+ public function get_javascript() {
159
+ $identifier = $this->identifier;
160
+
161
+ $return_value = "\n<script type='text/javascript'>";
162
+ $return_value .= "\n var " . $identifier . " = function($) {";
163
+ $return_value .= "\n $('#" . $identifier . "')." . $this->js_function . "({ ";
164
+ $return_value .= "\n " . $this->get_javascript_parameters();
165
+ $return_value .= "\n });";
166
+ $return_value .= "\n };";
167
+ $return_value .= "\n var timer_" . $identifier . " = function() {";
168
+ $return_value .= "\n if (window.jQuery && jQuery.isReady) {";
169
+ $return_value .= "\n " . $identifier . "(window.jQuery);";
170
+ $return_value .= "\n } else {";
171
+ $return_value .= "\n window.setTimeout(timer_" . $identifier . ", 100);";
172
+ $return_value .= "\n }";
173
+ $return_value .= "\n };";
174
+ $return_value .= "\n timer_" . $identifier . "();";
175
+ $return_value .= "\n</script>";
176
+
177
+ return $return_value;
178
+ }
179
+
180
+ /**
181
+ * Output the HTML and Javascript for this slider
182
+ */
183
+ public function output() {
184
+ $class = "metaslider metaslider-{$this->get_setting('type')} metaslider-{$this->id} ml-slider";
185
+
186
+ if ($this->get_setting('cssClass') != 'false') {
187
+ $class .= " " . $this->get_setting('cssClass');
188
+ }
189
+
190
+ return "<div style='max-width: {$this->get_setting('width')}px;' class='{$class}'>" .
191
+ $this->get_html() .
192
+ "</div>" .
193
+ $this->get_javascript();
194
+ }
195
+
196
+ /**
197
+ * Include slider assets
198
+ */
199
+ public function enqueue_scripts() {
200
+ if ($this->get_setting('printJs') == 'true') {
201
+ wp_enqueue_script('metaslider_' . $this->get_setting('type') . '_slider', METASLIDER_ASSETS_URL . $this->get_js_path(), array('jquery'), METASLIDER_VERSION);
202
+ }
203
+
204
+ if ($this->get_setting('printCss') == 'true') {
205
+ wp_enqueue_style('metaslider_display_css', METASLIDER_ASSETS_URL . 'metaslider-display.css');
206
+ wp_enqueue_style('metaslider_' . $this->get_setting('type') . '_slider_css', METASLIDER_ASSETS_URL . $this->get_css_path());
207
+ }
208
+ }
209
+ }
210
+ ?>
inc/metaslider.coin.class.php ADDED
@@ -0,0 +1,78 @@
1
+ <?php
2
+ /*
3
+ *
4
+ */
5
+ class MetaCoinSlider extends MetaSlider {
6
+
7
+ protected $js_function = 'coinslider';
8
+
9
+ /**
10
+ * Constructor
11
+ */
12
+ public function __construct($id) {
13
+ parent::__construct($id);
14
+ }
15
+
16
+ /**
17
+ * Return the file path to the Javascript for this slider
18
+ */
19
+ public function get_js_path() {
20
+ return 'coinslider/coin-slider.min.js';
21
+ }
22
+
23
+ /**
24
+ * Return the file path to the CSS for this slider
25
+ */
26
+ public function get_css_path() {
27
+ return 'coinslider/coin-slider-styles.css';
28
+ }
29
+
30
+ /**
31
+ * Enable the parameters that are accepted by the slider
32
+ *
33
+ * @return array enabled parameters
34
+ */
35
+ protected function get_param($param) {
36
+ $params = array(
37
+ 'effect' => 'animation',
38
+ 'width' => 'width',
39
+ 'height' => 'height',
40
+ 'sph' => 'sph',
41
+ 'spw' => 'spw',
42
+ 'delay' => 'delay',
43
+ 'sDelay' => 'sDelay',
44
+ 'opacity' => 'opacity',
45
+ 'titleSpeed' => 'titleSpeed',
46
+ 'hoverPause' => 'hoverPause',
47
+ 'navigation' => 'navigation'
48
+ );
49
+
50
+ if (isset($params[$param])) {
51
+ return $params[$param];
52
+ }
53
+
54
+ return false;
55
+ }
56
+
57
+ /**
58
+ * Build the HTML for a slider.
59
+ *
60
+ * @return string slider markup.
61
+ */
62
+ protected function get_html() {
63
+ $retVal = "<div id='" . $this->get_identifier() . "' class='coin-slider'>";
64
+
65
+ foreach ($this->get_slides() as $slide) {
66
+ $url = strlen($slide['url']) ? $slide['url'] : "javascript:void(0)"; // coinslider always wants a URL
67
+ $retVal .= "<a href='{$url}'>";
68
+ $retVal .= "<img src='{$slide['src']}' alt='{$slide['alt']}' target='{$slide['target']}'>";
69
+ $retVal .= "<span>{$slide['caption']}</span>";
70
+ $retVal .= "</a>";
71
+ }
72
+
73
+ $retVal .= "</div>";
74
+
75
+ return $retVal;
76
+ }
77
+ }
78
+ ?>
inc/metaslider.flex.class.php ADDED
@@ -0,0 +1,78 @@
1
+ <?php
2
+ /*
3
+ *
4
+ */
5
+ class MetaFlexSlider extends MetaSlider {
6
+
7
+ protected $js_function = 'flexslider';
8
+
9
+ /**
10
+ * Constructor
11
+ */
12
+ public function __construct($id) {
13
+ parent::__construct($id);
14
+ }
15
+
16
+ /**
17
+ * Return the file path to the Javascript for this slider
18
+ */
19
+ public function get_js_path() {
20
+ return 'flexslider/jquery.flexslider-min.js';
21
+ }
22
+
23
+ /**
24
+ * Return the css path to the Javascript for this slider
25
+ */
26
+ public function get_css_path() {
27
+ return 'flexslider/flexslider.css';
28
+ }
29
+
30
+ /**
31
+ * Enable the parameters that are accepted by the slider
32
+ *
33
+ * @return array enabled parameters
34
+ */
35
+ protected function get_param($param) {
36
+ $params = array(
37
+ 'effect' => 'animation',
38
+ 'direction' => 'direction',
39
+ 'prevText' => 'prevText',
40
+ 'nextText' => 'nextText',
41
+ 'delay' => 'slideshowSpeed',
42
+ 'animationSpeed' => 'animationSpeed',
43
+ 'hoverPause' => 'pauseOnHover',
44
+ 'reverse' => 'reverse',
45
+ 'navigation' => 'controlNav',
46
+ 'links' =>'directionNav'
47
+ );
48
+
49
+ if (isset($params[$param])) {
50
+ return $params[$param];
51
+ }
52
+
53
+ return false;
54
+ }
55
+
56
+ /**
57
+ * Build the HTML for a slider.
58
+ *
59
+ * @return string slider markup.
60
+ */
61
+ protected function get_html() {
62
+ $return_value = "<div id='" . $this->get_identifier() . "' class='flexslider'><ul class='slides'>";
63
+
64
+ foreach ($this->get_slides() as $slide) {
65
+ $return_value .= "<li>";
66
+ if (strlen($slide['url'])) $return_value .= "<a href='{$slide['url']}' target='{$slide['target']}'>";
67
+ $return_value .= "<img src='{$slide['src']}' alt='{$slide['alt']}'>";
68
+ if (strlen($slide['caption'])) $return_value .= "<p class='flex-caption'>{$slide['caption']}</p>";
69
+ if (strlen($slide['url'])) $return_value .= "</a>";
70
+ $return_value .= "</li>";
71
+ }
72
+
73
+ $return_value .= "</ul></div>";
74
+
75
+ return $return_value;
76
+ }
77
+ }
78
+ ?>
inc/metaslider.nivo.class.php ADDED
@@ -0,0 +1,92 @@
1
+ <?php
2
+ /*
3
+ *
4
+ */
5
+ class MetaNivoSlider extends MetaSlider {
6
+
7
+ protected $js_function = 'nivoSlider';
8
+
9
+ /**
10
+ * Constructor
11
+ */
12
+ public function __construct($id) {
13
+ parent::__construct($id);
14
+ }
15
+
16
+ /**
17
+ * Return the file path to the Javascript for this slider
18
+ */
19
+ public function get_js_path() {
20
+ return 'nivoslider/jquery.nivo.slider.pack.js';
21
+ }
22
+
23
+ /**
24
+ * Return the file path to the CSS for this slider
25
+ */
26
+ public function get_css_path() {
27
+ return 'nivoslider/nivo-slider.css';
28
+ }
29
+
30
+ /**
31
+ * Detect whether thie slide supports the requested setting,
32
+ * and if so, the name to use for the setting in the Javascript parameters
33
+ *
34
+ * @return false (parameter not supported) or parameter name (parameter supported)
35
+ */
36
+ protected function get_param($param) {
37
+ $params = array(
38
+ 'effect' => 'effect',
39
+ 'slices' => 'slices',
40
+ 'prevText' => 'prevText',
41
+ 'nextText' => 'nextText',
42
+ 'delay' => 'pauseTime',
43
+ 'animationSpeed' => 'animSpeed',
44
+ 'hoverPause' => 'pauseOnHover',
45
+ 'spw' => 'boxCols',
46
+ 'sph' => 'boxRows',
47
+ 'navigation' => 'controlNav',
48
+ 'links' =>'directionNav'
49
+ );
50
+
51
+ if (isset($params[$param])) {
52
+ return $params[$param];
53
+ }
54
+
55
+ return false;
56
+ }
57
+
58
+ /**
59
+ * Include slider assets
60
+ */
61
+ public function enqueue_scripts() {
62
+ parent::enqueue_scripts();
63
+
64
+ // include the theme
65
+ if ($this->get_setting('printCss') == 'true') {
66
+ $theme = $this->get_setting('theme');
67
+ wp_enqueue_style('ml-slider_nivo_slider_theme_' . $theme, METASLIDER_ASSETS_URL . "nivoslider/themes/{$theme}/{$theme}.css");
68
+ }
69
+ }
70
+
71
+ /**
72
+ * Build the HTML for a slider.
73
+ *
74
+ * @return string slider markup.
75
+ */
76
+ protected function get_html() {
77
+ $retVal = "<div class='slider-wrapper theme-{$this->get_setting('theme')}'>";
78
+ $retVal .= "<div class='ribbon'></div>";
79
+ $retVal .= "<div id='" . $this->get_identifier() . "' class='nivoSlider'>";
80
+
81
+ foreach ($this->get_slides() as $slide) {
82
+ if (strlen($slide['url'])) $retVal .= "<a href='{$slide['url']}' target='{$slide['target']}'>";
83
+ $retVal .= "<img src='{$slide['src']}' title='{$slide['caption']}' alt='{$slide['alt']}'>";
84
+ if (strlen($slide['url'])) $retVal .= "</a>";
85
+ }
86
+
87
+ $retVal .= "</div></div>";
88
+
89
+ return $retVal;
90
+ }
91
+ }
92
+ ?>
inc/metaslider.responsive.class.php ADDED
@@ -0,0 +1,75 @@
1
+ <?php
2
+ /*
3
+ *
4
+ */
5
+ class MetaResponsiveSlider extends MetaSlider {
6
+
7
+ public $js_function = 'responsiveSlides';
8
+
9
+ /**
10
+ * Constructor
11
+ */
12
+ public function __construct($id) {
13
+ parent::__construct($id);
14
+ }
15
+
16
+ /**
17
+ * Return the file path to the Javascript for this slider
18
+ */
19
+ public function get_js_path() {
20
+ return 'responsiveslides/responsiveslides.min.js';
21
+ }
22
+
23
+ /**
24
+ * Return the file path to the CSS for this slider
25
+ */
26
+ public function get_css_path() {
27
+ return 'responsiveslides/responsiveslides.css';
28
+ }
29
+
30
+ /**
31
+ * Detect whether thie slide supports the requested setting,
32
+ * and if so, the name to use for the setting in the Javascript parameters
33
+ *
34
+ * @return false (parameter not supported) or parameter name (parameter supported)
35
+ */
36
+ protected function get_param($param) {
37
+ $params = array(
38
+ 'prevText' => 'prevText',
39
+ 'nextText' => 'nextText',
40
+ 'delay' => 'timeout',
41
+ 'animationSpeed' => 'speed',
42
+ 'hoverPause' => 'pause',
43
+ 'navigation' => 'pager',
44
+ 'links' =>'nav'
45
+ );
46
+
47
+ if (isset($params[$param])) {
48
+ return $params[$param];
49
+ }
50
+
51
+ return false;
52
+ }
53
+
54
+ /**
55
+ * Build the HTML for a slider.
56
+ *
57
+ * @return string slider markup.
58
+ */
59
+ protected function get_html() {
60
+ $return_value = "<ul id='" . $this->get_identifier() . "' class='rslides'>";
61
+
62
+ foreach ($this->get_slides() as $slide) {
63
+ $return_value .= "<li>";
64
+ if (strlen($slide['url'])) $return_value .= "<a href='{$slide['url']}' target='{$slide['target']}'>";
65
+ $return_value .= "<img src='{$slide['src']}' alt='{$slide['alt']}'>";
66
+ if (strlen($slide['url'])) $return_value .= "</a>";
67
+ $return_value .= "</li>";
68
+ }
69
+
70
+ $return_value .= "</ul>";
71
+
72
+ return $return_value;
73
+ }
74
+ }
75
+ ?>
languages/default.mo ADDED
Binary file
languages/default.po ADDED
@@ -0,0 +1,272 @@
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: metaslider\n"
4
+ "POT-Creation-Date: 2013-02-28 14:38-0000\n"
5
+ "PO-Revision-Date: 2013-02-28 14:39-0000\n"
6
+ "Last-Translator: \n"
7
+ "Language-Team: Matcha Labs <hello@matchalabs.com>\n"
8
+ "MIME-Version: 1.0\n"
9
+ "Content-Type: text/plain; charset=UTF-8\n"
10
+ "Content-Transfer-Encoding: 8bit\n"
11
+ "X-Generator: Poedit 1.5.5\n"
12
+ "X-Poedit-KeywordsList: _e;__\n"
13
+ "X-Poedit-Basepath: ../\n"
14
+ "X-Poedit-SearchPath-0: .\n"
15
+ "X-Poedit-SearchPath-1: ..\n"
16
+
17
+ #: metaslider.php:65 metaslider.php:494 ../ml-slider/metaslider.php:65
18
+ #: ../ml-slider/metaslider.php:494
19
+ msgid "URL"
20
+ msgstr ""
21
+
22
+ #: metaslider.php:66 metaslider.php:492 ../ml-slider/metaslider.php:66
23
+ #: ../ml-slider/metaslider.php:492
24
+ msgid "Caption"
25
+ msgstr ""
26
+
27
+ #: metaslider.php:67 metaslider.php:493 ../ml-slider/metaslider.php:67
28
+ #: ../ml-slider/metaslider.php:493
29
+ msgid "New Window"
30
+ msgstr ""
31
+
32
+ #: metaslider.php:68 ../ml-slider/metaslider.php:68
33
+ msgid "Are you sure?"
34
+ msgstr ""
35
+
36
+ #: metaslider.php:95 metaslider.php:115 ../ml-slider/metaslider.php:95
37
+ #: ../ml-slider/metaslider.php:115
38
+ msgid "Slider"
39
+ msgstr ""
40
+
41
+ #: metaslider.php:483 ../ml-slider/metaslider.php:483
42
+ msgid "Slides"
43
+ msgstr ""
44
+
45
+ #: metaslider.php:484 ../ml-slider/metaslider.php:484
46
+ msgid "Add Slide"
47
+ msgstr ""
48
+
49
+ #: metaslider.php:484 ../ml-slider/metaslider.php:484
50
+ msgid "Select Slide"
51
+ msgstr ""
52
+
53
+ #: metaslider.php:484 ../ml-slider/metaslider.php:484
54
+ msgid "Add to slider"
55
+ msgstr ""
56
+
57
+ #: metaslider.php:519 ../ml-slider/metaslider.php:519
58
+ msgid "Configuration"
59
+ msgstr ""
60
+
61
+ #: metaslider.php:521 ../ml-slider/metaslider.php:521
62
+ msgid "Save"
63
+ msgstr ""
64
+
65
+ #: metaslider.php:522 ../ml-slider/metaslider.php:522
66
+ msgid "Unsaved Changes"
67
+ msgstr ""
68
+
69
+ #: metaslider.php:548 ../ml-slider/metaslider.php:548
70
+ msgid "Set the initial size for the slides (width x height)"
71
+ msgstr ""
72
+
73
+ #: metaslider.php:549 ../ml-slider/metaslider.php:549
74
+ msgid "Size"
75
+ msgstr ""
76
+
77
+ #: metaslider.php:557 ../ml-slider/metaslider.php:557
78
+ msgid "Slide transition effect"
79
+ msgstr ""
80
+
81
+ #: metaslider.php:558 ../ml-slider/metaslider.php:558
82
+ msgid "Effect"
83
+ msgstr ""
84
+
85
+ #: metaslider.php:584 ../ml-slider/metaslider.php:584
86
+ msgid "Change the slider style"
87
+ msgstr ""
88
+
89
+ #: metaslider.php:585 ../ml-slider/metaslider.php:585
90
+ msgid "Theme"
91
+ msgstr ""
92
+
93
+ #: metaslider.php:597 ../ml-slider/metaslider.php:597
94
+ msgid "Show slide navigation row"
95
+ msgstr ""
96
+
97
+ #: metaslider.php:598 ../ml-slider/metaslider.php:598
98
+ msgid "Show Navigation"
99
+ msgstr ""
100
+
101
+ #: metaslider.php:605 ../ml-slider/metaslider.php:605
102
+ msgid "Show previous and next links"
103
+ msgstr ""
104
+
105
+ #: metaslider.php:606 ../ml-slider/metaslider.php:606
106
+ msgid "Show Links"
107
+ msgstr ""
108
+
109
+ #: metaslider.php:613 ../ml-slider/metaslider.php:613
110
+ msgid ""
111
+ "Pause the slideshow when hovering over slider, then resume when no longer "
112
+ "hovering"
113
+ msgstr ""
114
+
115
+ #: metaslider.php:614 ../ml-slider/metaslider.php:614
116
+ msgid "Hover pause"
117
+ msgstr ""
118
+
119
+ #: metaslider.php:621 ../ml-slider/metaslider.php:621
120
+ msgid "How long to display each slide, in milliseconds"
121
+ msgstr ""
122
+
123
+ #: metaslider.php:622 ../ml-slider/metaslider.php:622
124
+ msgid "Slide delay"
125
+ msgstr ""
126
+
127
+ #: metaslider.php:629 ../ml-slider/metaslider.php:629
128
+ msgid "Randomise the order of the slides"
129
+ msgstr ""
130
+
131
+ #: metaslider.php:630 ../ml-slider/metaslider.php:630
132
+ msgid "Random"
133
+ msgstr ""
134
+
135
+ #: metaslider.php:637 ../ml-slider/metaslider.php:637
136
+ msgid "Select the sliding direction"
137
+ msgstr ""
138
+
139
+ #: metaslider.php:637 ../ml-slider/metaslider.php:637
140
+ msgid "Direction"
141
+ msgstr ""
142
+
143
+ #: metaslider.php:646 ../ml-slider/metaslider.php:646
144
+ msgid "Set the text for the 'previous' direction item"
145
+ msgstr ""
146
+
147
+ #: metaslider.php:647 ../ml-slider/metaslider.php:647
148
+ msgid "Previous text"
149
+ msgstr ""
150
+
151
+ #: metaslider.php:654 ../ml-slider/metaslider.php:654
152
+ msgid "Set the text for the 'next' direction item"
153
+ msgstr ""
154
+
155
+ #: metaslider.php:655 ../ml-slider/metaslider.php:655
156
+ msgid "Next text"
157
+ msgstr ""
158
+
159
+ #: metaslider.php:662 ../ml-slider/metaslider.php:662
160
+ msgid "Advanced Settings"
161
+ msgstr ""
162
+
163
+ #: metaslider.php:665 ../ml-slider/metaslider.php:665
164
+ msgid "Reverse the animation direction"
165
+ msgstr ""
166
+
167
+ #: metaslider.php:666 ../ml-slider/metaslider.php:666
168
+ msgid "Reverse"
169
+ msgstr ""
170
+
171
+ #: metaslider.php:673 ../ml-slider/metaslider.php:673
172
+ msgid "Number of squares (width x height)"
173
+ msgstr ""
174
+
175
+ #: metaslider.php:674 ../ml-slider/metaslider.php:674
176
+ msgid "Number of squares"
177
+ msgstr ""
178
+
179
+ #: metaslider.php:682 metaslider.php:683 ../ml-slider/metaslider.php:682
180
+ #: ../ml-slider/metaslider.php:683
181
+ msgid "Number of slices"
182
+ msgstr ""
183
+
184
+ #: metaslider.php:690 ../ml-slider/metaslider.php:690
185
+ msgid "Delay beetwen squares in ms"
186
+ msgstr ""
187
+
188
+ #: metaslider.php:691 ../ml-slider/metaslider.php:691
189
+ msgid "Square delay"
190
+ msgstr ""
191
+
192
+ #: metaslider.php:698 ../ml-slider/metaslider.php:698
193
+ msgid "Opacity of title and navigation"
194
+ msgstr ""
195
+
196
+ #: metaslider.php:699 ../ml-slider/metaslider.php:699
197
+ msgid "Opacity"
198
+ msgstr ""
199
+
200
+ #: metaslider.php:706 ../ml-slider/metaslider.php:706
201
+ msgid "Set the fade in speef of the caption"
202
+ msgstr ""
203
+
204
+ #: metaslider.php:707 ../ml-slider/metaslider.php:707
205
+ msgid "Caption speed"
206
+ msgstr ""
207
+
208
+ #: metaslider.php:714 ../ml-slider/metaslider.php:714
209
+ msgid "Set the speed of animations, in milliseconds"
210
+ msgstr ""
211
+
212
+ #: metaslider.php:715 ../ml-slider/metaslider.php:715
213
+ msgid "Animation speed"
214
+ msgstr ""
215
+
216
+ #: metaslider.php:722 ../ml-slider/metaslider.php:722
217
+ msgid "Developer Options"
218
+ msgstr ""
219
+
220
+ #: metaslider.php:725 ../ml-slider/metaslider.php:725
221
+ msgid ""
222
+ "Specify any custom CSS Classes you would like to be added to the slider "
223
+ "wrapper"
224
+ msgstr ""
225
+
226
+ #: metaslider.php:726 ../ml-slider/metaslider.php:726
227
+ msgid "CSS classes"
228
+ msgstr ""
229
+
230
+ #: metaslider.php:733 ../ml-slider/metaslider.php:733
231
+ msgid "Uncheck this is you would like to include your own CSS"
232
+ msgstr ""
233
+
234
+ #: metaslider.php:734 ../ml-slider/metaslider.php:734
235
+ msgid "Print CSS"
236
+ msgstr ""
237
+
238
+ #: metaslider.php:741 ../ml-slider/metaslider.php:741
239
+ msgid "Uncheck this is you would like to include your own Javascript"
240
+ msgstr ""
241
+
242
+ #: metaslider.php:742 ../ml-slider/metaslider.php:742
243
+ msgid "Print JS"
244
+ msgstr ""
245
+
246
+ #: metaslider.php:754 ../ml-slider/metaslider.php:754
247
+ msgid "Usage"
248
+ msgstr ""
249
+
250
+ #: metaslider.php:760 ../ml-slider/metaslider.php:760
251
+ msgid "Shortcode"
252
+ msgstr ""
253
+
254
+ #: metaslider.php:766 ../ml-slider/metaslider.php:766
255
+ msgid "Template Include"
256
+ msgstr ""
257
+
258
+ #: metaslider.php:776 ../ml-slider/metaslider.php:776
259
+ msgid "Delete Slider"
260
+ msgstr ""
261
+
262
+ #: ../ml-post-slider/ml-post-slider.php:71
263
+ msgid "Title"
264
+ msgstr ""
265
+
266
+ #: ../ml-post-slider/ml-post-slider.php:72
267
+ msgid "Slider category"
268
+ msgstr ""
269
+
270
+ #: ../ml-post-slider/ml-post-slider.php:73
271
+ msgid "Date"
272
+ msgstr ""
ml-slider.php CHANGED
@@ -1,34 +1,34 @@
1
<?php
2
/*
3
- * Plugin Name: ML Slider
4
- * Plugin URI: http://www.ml-slider.com
5
* Description: 4 sliders in 1! Choose from Nivo Slider, Flex Slider, Coin Slider or Responsive Slides.
6
- * Version: 1.2.1
7
* Author: Matcha Labs
8
* Author URI: http://www.matchalabs.com
9
- * License: GPL
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
- */
16
17
- define( 'MLSLIDER_VERSION', '1.2.1' );
18
- define( 'MLSLIDER_BASE_URL', plugin_dir_url( __FILE__ ) );
19
- define( 'MLSLIDER_ASSETS_URL', MLSLIDER_BASE_URL . 'assets/' );
20
21
- class MLSlider {
22
23
- var $slider = 0;
24
- var $slides = array();
25
- var $settings = array();
26
27
- /**
28
- * /////////////////////////////////////////////////////////////////
29
- * Plugin Registration
30
- * /////////////////////////////////////////////////////////////////
31
- */
32
33
/**
34
* Constructor
@@ -36,19 +36,20 @@ class MLSlider {
36
public function __construct() {
37
add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'));
38
add_action('admin_menu', array($this, 'register_admin_menu'), 10001);
39
- add_action('admin_menu', array($this, 'admin_process'), 10002);
40
add_action('init', array($this, 'register_post_type' ));
41
add_action('init', array($this, 'register_taxonomy' ));
42
add_action('admin_print_styles', array( $this, 'register_admin_styles'));
43
- add_shortcode('ml-slider', array($this, 'register_shortcode'));
44
}
45
46
/**
47
* Registers and enqueues admin-specific styles.
48
*/
49
public function register_admin_styles() {
50
- wp_enqueue_style('ml-slider-tipsy-styles', plugins_url('ml-slider/assets/tipsy/tipsy.css'));
51
- wp_enqueue_style('ml-slider-admin-styles', plugins_url('ml-slider/assets/ml-slider-admin.css'));
52
}
53
54
/**
@@ -56,26 +57,32 @@ class MLSlider {
56
*/
57
public function register_admin_scripts() {
58
wp_enqueue_media();
59
- wp_enqueue_script('ml-slider-tipsy', plugins_url('ml-slider/assets/tipsy/jquery.tipsy.js'), array('jquery'));
60
- wp_enqueue_script('jquery-tablednd', plugins_url('ml-slider/assets/jquery.tablednd.js'), array('jquery'));
61
- wp_enqueue_script('ml-slider-admin-script', plugins_url('ml-slider/assets/ml-slider.js'), array('jquery', 'ml-slider-tipsy', 'jquery-tablednd', 'media-upload'));
62
}
63
64
/**
65
* Include the default CSS
66
*/
67
public function enqueue_scripts() {
68
- wp_enqueue_style('ml-slider_display_css', plugins_url('ml-slider/assets/ml-slider-display.css'));
69
}
70
71
/**
72
* Add the menu page
73
*/
74
public function register_admin_menu() {
75
- $page = add_menu_page('ML Slider', 'ML Slider', 'add_users', 'ml-slider', array(
76
- $this,
77
- 'render_admin_page'
78
- ), MLSLIDER_ASSETS_URL . 'matchalabs.png', 99999);
79
80
add_action('admin_print_scripts-' . $page, array( $this, 'register_admin_scripts' ) );
81
}
@@ -102,65 +109,29 @@ class MLSlider {
102
* Create taxonomy to store slider => slides relationship
103
*/
104
public function register_taxonomy() {
105
- $labels = array(
106
'name' => _x( 'Slider', 'taxonomy general name' ),
107
'singular_name' => _x( 'Slider', 'taxonomy singular name' ),
108
'menu_name' => __( 'Slider' )
109
- );
110
111
- $args = array(
112
'hierarchical' => true,
113
'labels' => $labels,
114
'show_ui' => false,
115
'show_admin_column' => true,
116
'query_var' => false,
117
- 'rewrite' => array( 'slug' => 'ml-slider' )
118
- );
119
120
- register_taxonomy( 'ml-slider', 'attachment', $args );
121
}
122
123
- /**
124
- * /////////////////////////////////////////////////////////////////
125
- * ML Slider
126
- * /////////////////////////////////////////////////////////////////
127
- */
128
-
129
/**
130
* Current slide ID
131
*/
132
private function set_slider($id) {
133
- $this->slider = $id;
134
- $this->settings = $this->get_settings();
135
- $this->slides = $this->get_slides();
136
- }
137
-
138
- /**
139
- * Get slide ID
140
- *
141
- * @return int the current slider ID
142
- */
143
- private function get_slider() {
144
- return $this->slider;
145
- }
146
-
147
- /**
148
- * Get settings for the current slider
149
- *
150
- * @return array slider settings
151
- */
152
- private function get_settings() {
153
- return get_post_meta($this->get_slider(), 'ml-slider_settings', true);
154
- }
155
-
156
- /**
157
- * Return an individual setting
158
- *
159
- * @param string $name Name of the setting
160
- * @return string | bool setting value or fase
161
- */
162
- private function get_setting($name) {
163
- return isset($this->settings[$name]) && strlen($this->settings[$name]) > 0 ? $this->settings[$name] : "false";
164
}
165
166
/**
@@ -168,12 +139,12 @@ class MLSlider {
168
*/
169
public function admin_process() {
170
if (isset($_REQUEST['id'])) {
171
- $slider = $_REQUEST['id'];
172
} else {
173
- $slider = $this->find_slider('date', 'DESC');
174
}
175
176
- $this->set_slider($slider);
177
178
$this->handle_slide_updates();
179
$this->handle_delete_slider();
@@ -181,6 +152,8 @@ class MLSlider {
181
$this->handle_update_slider_title();
182
$this->handle_update_slider_settings();
183
$this->handle_create_slider();
184
}
185
186
/**
@@ -204,12 +177,12 @@ class MLSlider {
204
$the_query = new WP_Query($args);
205
206
while ($the_query->have_posts()) {
207
- if (!$this->get_slider()) {
208
$this->set_slider($the_query->post->ID);
209
}
210
211
$the_query->the_post();
212
- $active = $this->get_slider() == $the_query->post->ID ? true : false;
213
214
$sliders[] = array(
215
'active' => $active,
@@ -221,87 +194,17 @@ class MLSlider {
221
return $sliders;
222
}
223
224
- /**
225
- * Return slides for the current slider
226
- *
227
- * @return array collection of slides belonging to the current slider
228
- */
229
- public function get_slides() {
230
- $retVal = array();
231
-
232
- $args = array(
233
- 'orderby' => $this->get_setting('random') == 'true' && !is_admin() ? 'rand' : 'menu_order',
234
- 'order' => 'ASC',
235
- 'post_type' => 'attachment',
236
- 'post_status' => 'inherit',
237
- 'posts_per_page' => -1,
238
- 'tax_query' => array(
239
- array(
240
- 'taxonomy' => 'ml-slider',
241
- 'field' => 'slug',
242
- 'terms' => $this->get_slider()
243
- )
244
- )
245
- );
246
-
247
- $query = new WP_Query($args);
248
-
249
- while ($query->have_posts()) {
250
- $query->next_post();
251
-
252
- $image_attributes = wp_get_attachment_image_src($query->post->ID, 'ml-slider-slide'); // returns an array
253
-
254
- $retVal[] = array(
255
- 'id' => $query->post->ID,
256
- 'type' => 'image',
257
- 'url' => get_post_meta($query->post->ID, 'ml-slider_url', true),
258
- 'caption' => htmlentities($query->post->post_excerpt, ENT_QUOTES),
259
- 'src' => $image_attributes[0],
260
- 'alt' => htmlentities(get_post_meta($query->post->ID, '_wp_attachment_image_alt', true),ENT_QUOTES),
261
- 'menu_order' => $query->post->menu_order
262
- );
263
- }
264
-
265
- return $retVal;
266
- }
267
-
268
/**
269
* Create a new slider
270
*/
271
private function handle_create_slider() {
272
// create a new slider
273
if (isset($_GET['add'])) {
274
// if possible, take a copy of the last edited slider settings in place of default settings
275
if ($last_modified = $this->find_slider('modified', 'DESC')) {
276
$defaults = get_post_meta($last_modified, 'ml-slider_settings', true);
277
- } else {
278
- // default settings
279
- $defaults = array(
280
- 'type' => 'nivo',
281
- 'height' => 290,
282
- 'width' => 565,
283
- 'spw' => 7, // squares per width
284
- 'sph' => 5, // squares per height
285
- 'delay' => 3000,
286
- 'sDelay' => 30, // delay between squares
287
- 'opacity' => 0.7, // opacity of title and navigation
288
- 'titleSpeed' => 500, // speed of title appereance in ms
289
- 'effect' => 'random', // random, swirl, rain, straight
290
- 'navigation' => 'true', // prev next and buttons
291
- 'links' => 'true', // show images as links
292
- 'hoverPause' => 'true', // pause on hover
293
- 'theme' => 'dark',
294
- 'direction' => 'horizontal',
295
- 'reverse' => 'false',
296
- 'animationSpeed' => 600,
297
- 'prevText' => 'Previous',
298
- 'nextText' => 'Next',
299
- 'slices' => 15,
300
- 'random' => 'false',
301
- 'cssClass' => '',
302
- 'printCss' => 'true',
303
- 'printJs' => 'true'
304
- );
305
}
306
307
// insert the post
@@ -311,6 +214,12 @@ class MLSlider {
311
'post_type' => 'ml-slider'
312
));
313
314
// insert the post meta
315
add_post_meta($id, 'ml-slider_settings', $defaults, true);
316
@@ -327,7 +236,8 @@ class MLSlider {
327
*/
328
private function handle_update_slider_settings() {
329
if (isset($_POST['settings'])) {
330
- $old_settings = get_post_meta($this->get_slider(), 'ml-slider_settings', true);
331
$new_settings = $_POST['settings'];
332
333
// convert submitted checkbox values from 'on' or 'off' to boolean values
@@ -335,17 +245,14 @@ class MLSlider {
335
336
foreach ($checkboxes as $checkbox) {
337
if (isset($new_settings[$checkbox]) && $new_settings[$checkbox] == 'on') {
338
- $new_settings[$checkbox] = true;
339
} else {
340
- $new_settings[$checkbox] = false;
341
}
342
}
343
-
344
- // update the slider settings
345
- update_post_meta($this->get_slider(), 'ml-slider_settings', array_merge($old_settings, $new_settings));
346
347
- // update settings
348
- $this->settings = get_post_meta($this->get_slider(), 'ml-slider_settings', true);
349
}
350
}
351
@@ -355,7 +262,7 @@ class MLSlider {
355
private function handle_update_slider_title() {
356
if (isset($_POST['title'])) {
357
$slide = array(
358
- 'ID' => $this->get_slider(),
359
'post_title' => $_POST['title']
360
);
361
@@ -376,7 +283,7 @@ class MLSlider {
376
// Get the existing terms and only keep the ones we don't want removed
377
$new_terms = array();
378
$current_terms = wp_get_object_terms($slideToUntagFromCurrentSlider, 'ml-slider', array('fields' => 'ids'));
379
- $term = get_term_by('name', $this->get_slider(), 'ml-slider');
380
381
foreach ($current_terms as $current_term) {
382
if ($current_term != $term->term_id) {
@@ -397,7 +304,7 @@ class MLSlider {
397
if (isset($_POST['attachment'])) {
398
foreach ($_POST['attachment'] as $id => $fields) {
399
// get the term thats name is the same as the ID of the slider
400
- $term = get_term_by('name', $this->get_slider(), 'ml-slider');
401
402
// tag this slide to the taxonomy term
403
wp_set_post_terms($id, $term->term_id, 'ml-slider', true);
@@ -420,8 +327,21 @@ class MLSlider {
420
add_post_meta($id, 'ml-slider_url', $fields['url'], true);
421
}
422
423
// add a new image size for the current slider
424
- add_image_size('ml-slider-slide', $this->get_setting('width'), $this->get_setting('height'), true);
425
$file = get_attached_file($id);
426
// ask WordPress to resize our slides for us
427
wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $file));
@@ -471,278 +391,7 @@ class MLSlider {
471
472
return false;
473
}
474
-
475
476
-
477
- /**
478
- * Get the slider libary parameters
479
- *
480
- * @return string javascript options
481
- */
482
- private function get_params() {
483
- $params = array(
484
- 'width' => array(
485
- 'map' => array(
486
- 'coin' => 'width'
487
- ),
488
- 'default' => 565
489
- ),
490
- 'height' => array(
491
- 'map' => array(
492
- 'coin' => 'height'
493
- ),
494
- 'default' => 290
495
- ),
496
- 'spw' => array(
497
- 'map' => array(
498
- 'coin' => 'spw',
499
- 'nivo' => 'boxCols'
500
- ),
501
- 'default' => 7
502
- ),
503
- 'sph' => array(
504
- 'map' => array(
505
- 'coin' => 'sph',
506
- 'nivo' => 'boxRows'
507
- ),
508
- 'default' => 5
509
- ),
510
- 'delay' => array(
511
- 'map' => array(
512
- 'coin' => 'delay',
513
- 'nivo' => 'pauseTime',
514
- 'flex' => 'slideshowSpeed',
515
- 'responsive' => 'timeout'
516
- ),
517
- 'default' => 3000
518
- ),
519
- 'sDelay' => array(
520
- 'map' => array(
521
- 'coin' => 'sDelay'
522
- ),
523
- 'default' => 30
524
- ),
525
- 'opacity' => array(
526
- 'map' => array(
527
- 'coin' => 'opacity'
528
- ),
529
- 'default' => 0.7
530
- ),
531
- 'effect' => array(
532
- 'map' => array(
533
- 'coin' => 'effect',
534
- 'nivo' => 'effect',
535
- 'flex' => 'animation'
536
- ),
537
- 'default' => 'random'
538
- ),
539
- 'navigation' => array(
540
- 'map' => array(
541
- 'coin' => 'navigation',
542
- 'nivo' => 'controlNav',
543
- 'flex' => 'controlNav',
544
- 'responsive' => 'pager'
545
- ),
546
- 'default' => true
547
- ),
548
- 'links' => array(
549
- 'map' => array(
550
- 'nivo' => 'directionNav',
551
- 'flex' => 'directionNav',
552
- 'responsive' => 'nav'
553
- ),
554
- 'default' => true
555
- ),
556
- 'hoverPause' => array(
557
- 'map' => array(
558
- 'coin' => 'hoverPause',
559
- 'nivo' => 'pauseOnHover',
560
- 'flex' => 'pauseOnHover',
561
- 'responsive' => 'pause'
562
- ),
563
- 'default' => true
564
- ),
565
- 'theme' => array(
566
- 'map' => array(
567
- 'nivo' => 'theme'
568
- ),
569
- 'default' => 'dark'
570
- ),
571
- 'direction' => array(
572
- 'map' => array(
573
- 'flex' => 'direction'
574
- ),
575
- 'default' => 'horizontal'
576
- ),
577
- 'reverse' => array(
578
- 'map' => array(
579
- 'flex' => 'reverse'
580
- ),
581
- 'default' => false,
582
- ),
583
- 'animationSpeed' => array(
584
- 'map' => array(
585
- 'nivo' => 'animSpeed',
586
- 'flex' => 'animationSpeed',
587
- 'responsive' => 'speed'
588
- ),
589
- 'default' => 600
590
- ),
591
- 'prevText' => array(
592
- 'map' => array(
593
- 'nivo' => 'prevText',
594
- 'flex' => 'prevText',
595
- 'responsive' => 'prevText'
596
- ),
597
- 'default' => 'Previous'
598
- ),
599
- 'nextText' => array(
600
- 'map' => array(
601
- 'nivo' => 'nextText',
602
- 'flex' => 'nextText',
603
- 'responsive' => 'nextText'
604
- ),
605
- 'default' => 'Next'
606
- ),
607
- 'slices' => array(
608
- 'map' => array(
609
- 'nivo' => 'slices'
610
- ),
611
- 'default' => 15
612
- )
613
- );
614
-
615
- $options = array();
616
-
617
- foreach ($params as $setting => $map) {
618
- if (isset($map['map'][$this->get_setting('type')])) {
619
- $optionName = $map['map'][$this->get_setting('type')];
620
-
621
- if (!$optionVal = $this->get_setting($setting)) {
622
- $optionVal = $map['default'];
623
- }
624
-
625
- if (gettype($map['default']) == 'string') {
626
- $options[] = $optionName . ": '" . $optionVal . "'";
627
- } else {
628
- $options[] = $optionName . ": " . $optionVal;
629
- }
630
- }
631
- }
632
-
633
- return implode(",\n ", $options);;
634
- }
635
-
636
- /**
637
- * Return the Javascript to kick off the slider. Code is wrapped in a timer
638
- * to allow for themes that load jQuery at the bottom of the page.
639
- *
640
- * @return string javascript
641
- */
642
- private function get_inline_javascript($type, $identifier) {
643
- $retVal = "\n<script type='text/javascript'>";
644
- $retVal .= "\n var " . $identifier . " = function($) {";
645
- $retVal .= "\n $('#" . $identifier . "')." . $type . "({ ";
646
- $retVal .= "\n " . $this->get_params();
647
- $retVal .= "\n });";
648
- $retVal .= "\n };";
649
- $retVal .= "\n var timer_" . $identifier . " = function() {";
650
- $retVal .= "\n if (window.jQuery && jQuery.isReady) {";
651
- $retVal .= "\n " . $identifier . "(window.jQuery);";
652
- $retVal .= "\n } else {";
653
- $retVal .= "\n window.setTimeout(timer_" . $identifier . ", 100);";
654
- $retVal .= "\n }";
655
- $retVal .= "\n };";
656
- $retVal .= "\n timer_" . $identifier . "();";
657
- $retVal .= "\n</script>";
658
-
659
- return $retVal;
660
- }
661
-
662
- /**
663
- * Return coin slider markup
664
- *
665
- * @return string coin slider markup.
666
- */
667
- private function get_coin_slider($identifier) {
668
- $retVal = "<div id='" . $identifier . "' class='coin-slider'>";
669
-
670
- foreach ($this->get_slides() as $slide) {
671
- $url = strlen($slide['url']) ? $slide['url'] : "javascript:void(0)"; // coinslider always wants a URL
672
- $retVal .= "<a href='{$url}'>";
673
- $retVal .= "<img src='{$slide['src']}' alt='{$slide['alt']}'>";
674
- $retVal .= "<span>{$slide['caption']}</span>";
675
- $retVal .= "</a>";
676
- }
677
-
678
- $retVal .= "</div>";
679
-
680
- return $retVal;
681
- }
682
-
683
- /**
684
- * Return flexslider markup
685
- *
686
- * @return string flex slider markup.
687
- */
688
- private function get_flex_slider($identifier) {
689
- $retVal = "<div id='" . $identifier . "' class='flexslider'><ul class='slides'>";
690
-
691
- foreach ($this->get_slides() as $slide) {
692
- $retVal .= "<li>";
693
- if (strlen($slide['url'])) $retVal .= "<a href='{$slide['url']}'>";
694
- $retVal .= "<img src='{$slide['src']}' alt='{$slide['alt']}'>";
695
- if (strlen($slide['caption'])) $retVal .= "<p class='flex-caption'>{$slide['caption']}</p>";
696
- if (strlen($slide['url'])) $retVal .= "</a>";
697
- $retVal .= "</li>";
698
- }
699
-
700
- $retVal .= "</ul></div>";
701
-
702
- return $retVal;
703
- }
704
-
705
- /**
706
- * Return responsive slides markup
707
- *
708
- * @return string responsive slider markup.
709
- */
710
- private function get_responsive_slider($identifier) {
711
- $retVal = "<ul id='" . $identifier . "' class='rslides'>";
712
-
713
- foreach ($this->get_slides() as $slide) {
714
- $retVal .= "<li>";
715
- if (strlen($slide['url'])) $retVal .= "<a href='{$slide['url']}'>";
716
- $retVal .= "<img src='{$slide['src']}' alt='{$slide['alt']}'>";
717
- if (strlen($slide['url'])) $retVal .= "</a>";
718
- $retVal .= "</li>";
719
- }
720
-
721
- $retVal .= "</ul>";
722
-
723
- return $retVal;
724
- }
725
-
726
- /**
727
- * Return nivoslider markup
728
- *
729
- * @return string nivo slider markup.
730
- */
731
- private function get_nivo_slider($identifier) {
732
- $retVal = "<div class='slider-wrapper theme-{$this->get_setting('theme')}'>";
733
- $retVal .= "<div class='ribbon'></div>";
734
- $retVal .= "<div id='" . $identifier . "' class='nivoSlider'>";
735
-
736
- foreach ($this->get_slides() as $slide) {
737
- if (strlen($slide['url'])) $retVal .= "<a href='{$slide['url']}'>";
738
- $retVal .= "<img src='{$slide['src']}' title='{$slide['caption']}' alt='{$slide['alt']}'>";
739
- if (strlen($slide['url'])) $retVal .= "</a>";
740
- }
741
-
742
- $retVal .= "</div></div>";
743
-
744
- return $retVal;
745
- }
746
747
/**
748
* Shortcode used to display slideshow
@@ -753,7 +402,6 @@ class MLSlider {
753
extract(shortcode_atts(array(
754
'id' => null
755
), $atts));
756
-
757
758
if ($id == null) {
759
return;