Version Description
Download this release
Release Info
Developer | nathanrice |
Plugin | WP-Cycle |
Version | 0.1 |
Comparing to | |
See all releases |
Version 0.1
- jquery.cycle.all.min.js +27 -0
- readme.txt +86 -0
- wp-cycle.php +441 -0
jquery.cycle.all.min.js
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*
|
2 |
+
* jQuery Cycle Plugin (with Transition Definitions)
|
3 |
+
* Examples and documentation at: http://jquery.malsup.com/cycle/
|
4 |
+
* Copyright (c) 2007-2009 M. Alsup
|
5 |
+
* Version: 2.63 (17-MAR-2009)
|
6 |
+
* Dual licensed under the MIT and GPL licenses:
|
7 |
+
* http://www.opensource.org/licenses/mit-license.php
|
8 |
+
* http://www.gnu.org/licenses/gpl.html
|
9 |
+
* Requires: jQuery v1.2.6 or later
|
10 |
+
*
|
11 |
+
* Originally based on the work of:
|
12 |
+
* 1) Matt Oakes
|
13 |
+
* 2) Torsten Baldes (http://medienfreunde.com/lab/innerfade/)
|
14 |
+
* 3) Benjamin Sterling (http://www.benjaminsterling.com/experiments/jqShuffle/)
|
15 |
+
*/
|
16 |
+
;(function($){var ver="2.63";if($.support==undefined){$.support={opacity:!($.browser.msie)};}function log(){if(window.console&&window.console.log){window.console.log("[cycle] "+Array.prototype.join.call(arguments," "));}}$.fn.cycle=function(options,arg2){var o={s:this.selector,c:this.context};if(this.length==0&&options!="stop"){if(!$.isReady&&o.s){log("DOM not ready, queuing slideshow");$(function(){$(o.s,o.c).cycle(options,arg2);});return this;}log("terminating; zero elements found by selector"+($.isReady?"":" (DOM not ready)"));return this;}return this.each(function(){options=handleArguments(this,options,arg2);if(options===false){return;}if(this.cycleTimeout){clearTimeout(this.cycleTimeout);}this.cycleTimeout=this.cyclePause=0;var $cont=$(this);var $slides=options.slideExpr?$(options.slideExpr,this):$cont.children();var els=$slides.get();if(els.length<2){log("terminating; too few slides: "+els.length);return;}var opts=buildOptions($cont,$slides,els,options,o);if(opts===false){return;}if(opts.timeout||opts.continuous){this.cycleTimeout=setTimeout(function(){go(els,opts,0,!opts.rev);},opts.continuous?10:opts.timeout+(opts.delay||0));}});};function handleArguments(cont,options,arg2){if(cont.cycleStop==undefined){cont.cycleStop=0;}if(options===undefined||options===null){options={};}if(options.constructor==String){switch(options){case"stop":cont.cycleStop++;if(cont.cycleTimeout){clearTimeout(cont.cycleTimeout);}cont.cycleTimeout=0;$(cont).removeData("cycle.opts");return false;case"pause":cont.cyclePause=1;return false;case"resume":cont.cyclePause=0;if(arg2===true){options=$(cont).data("cycle.opts");if(!options){log("options not found, can not resume");return false;}if(cont.cycleTimeout){clearTimeout(cont.cycleTimeout);cont.cycleTimeout=0;}go(options.elements,options,1,1);}return false;default:options={fx:options};}}else{if(options.constructor==Number){var num=options;options=$(cont).data("cycle.opts");if(!options){log("options not found, can not advance slide");return false;}if(num<0||num>=options.elements.length){log("invalid slide index: "+num);return false;}options.nextSlide=num;if(cont.cycleTimeout){clearTimeout(this.cycleTimeout);cont.cycleTimeout=0;}if(typeof arg2=="string"){options.oneTimeFx=arg2;}go(options.elements,options,1,num>=options.currSlide);return false;}}return options;}function removeFilter(el,opts){if(!$.support.opacity&&opts.cleartype&&el.style.filter){try{el.style.removeAttribute("filter");}catch(smother){}}}function buildOptions($cont,$slides,els,options,o){var opts=$.extend({},$.fn.cycle.defaults,options||{},$.metadata?$cont.metadata():$.meta?$cont.data():{});if(opts.autostop){opts.countdown=opts.autostopCount||els.length;}var cont=$cont[0];$cont.data("cycle.opts",opts);opts.$cont=$cont;opts.stopCount=cont.cycleStop;opts.elements=els;opts.before=opts.before?[opts.before]:[];opts.after=opts.after?[opts.after]:[];opts.after.unshift(function(){opts.busy=0;});if(!$.support.opacity&&opts.cleartype){opts.after.push(function(){removeFilter(this,opts);});}if(opts.continuous){opts.after.push(function(){go(els,opts,0,!opts.rev);});}saveOriginalOpts(opts);if(!$.support.opacity&&opts.cleartype&&!opts.cleartypeNoBg){clearTypeFix($slides);}if($cont.css("position")=="static"){$cont.css("position","relative");}if(opts.width){$cont.width(opts.width);}if(opts.height&&opts.height!="auto"){$cont.height(opts.height);}if(opts.startingSlide){opts.startingSlide=parseInt(opts.startingSlide);}if(opts.random){opts.randomMap=[];for(var i=0;i<els.length;i++){opts.randomMap.push(i);}opts.randomMap.sort(function(a,b){return Math.random()-0.5;});opts.randomIndex=0;opts.startingSlide=opts.randomMap[0];}else{if(opts.startingSlide>=els.length){opts.startingSlide=0;}}opts.currSlide=opts.startingSlide=opts.startingSlide||0;var first=opts.startingSlide;$slides.css({position:"absolute",top:0,left:0}).hide().each(function(i){var z=first?i>=first?els.length-(i-first):first-i:els.length-i;$(this).css("z-index",z);});$(els[first]).css("opacity",1).show();removeFilter(els[first],opts);if(opts.fit&&opts.width){$slides.width(opts.width);}if(opts.fit&&opts.height&&opts.height!="auto"){$slides.height(opts.height);}var reshape=opts.containerResize&&!$cont.innerHeight();if(reshape){var maxw=0,maxh=0;for(var i=0;i<els.length;i++){var $e=$(els[i]),e=$e[0],w=$e.outerWidth(),h=$e.outerHeight();if(!w){w=e.offsetWidth;}if(!h){h=e.offsetHeight;}maxw=w>maxw?w:maxw;maxh=h>maxh?h:maxh;}if(maxw>0&&maxh>0){$cont.css({width:maxw+"px",height:maxh+"px"});}}if(opts.pause){$cont.hover(function(){this.cyclePause++;},function(){this.cyclePause--;});}if(supportMultiTransitions(opts)===false){return false;}if(!opts.multiFx){var init=$.fn.cycle.transitions[opts.fx];if($.isFunction(init)){init($cont,$slides,opts);}else{if(opts.fx!="custom"&&!opts.multiFx){log("unknown transition: "+opts.fx,"; slideshow terminating");return false;}}}var requeue=false;options.requeueAttempts=options.requeueAttempts||0;$slides.each(function(){var $el=$(this);this.cycleH=(opts.fit&&opts.height)?opts.height:$el.height();this.cycleW=(opts.fit&&opts.width)?opts.width:$el.width();if($el.is("img")){var loadingIE=($.browser.msie&&this.cycleW==28&&this.cycleH==30&&!this.complete);var loadingOp=($.browser.opera&&this.cycleW==42&&this.cycleH==19&&!this.complete);var loadingOther=(this.cycleH==0&&this.cycleW==0&&!this.complete);if(loadingIE||loadingOp||loadingOther){if(o.s&&opts.requeueOnImageNotLoaded&&++options.requeueAttempts<100){log(options.requeueAttempts," - img slide not loaded, requeuing slideshow: ",this.src,this.cycleW,this.cycleH);setTimeout(function(){$(o.s,o.c).cycle(options);},opts.requeueTimeout);requeue=true;return false;}else{log("could not determine size of image: "+this.src,this.cycleW,this.cycleH);}}}return true;});if(requeue){return false;}opts.cssBefore=opts.cssBefore||{};opts.animIn=opts.animIn||{};opts.animOut=opts.animOut||{};$slides.not(":eq("+first+")").css(opts.cssBefore);if(opts.cssFirst){$($slides[first]).css(opts.cssFirst);}if(opts.timeout){opts.timeout=parseInt(opts.timeout);if(opts.speed.constructor==String){opts.speed=$.fx.speeds[opts.speed]||parseInt(opts.speed);}if(!opts.sync){opts.speed=opts.speed/2;}while((opts.timeout-opts.speed)<250){opts.timeout+=opts.speed;}}if(opts.easing){opts.easeIn=opts.easeOut=opts.easing;}if(!opts.speedIn){opts.speedIn=opts.speed;}if(!opts.speedOut){opts.speedOut=opts.speed;}opts.slideCount=els.length;opts.currSlide=opts.lastSlide=first;if(opts.random){opts.nextSlide=opts.currSlide;if(++opts.randomIndex==els.length){opts.randomIndex=0;}opts.nextSlide=opts.randomMap[opts.randomIndex];}else{opts.nextSlide=opts.startingSlide>=(els.length-1)?0:opts.startingSlide+1;}var e0=$slides[first];if(opts.before.length){opts.before[0].apply(e0,[e0,e0,opts,true]);}if(opts.after.length>1){opts.after[1].apply(e0,[e0,e0,opts,true]);}if(opts.next){$(opts.next).click(function(){return advance(opts,opts.rev?-1:1);});}if(opts.prev){$(opts.prev).click(function(){return advance(opts,opts.rev?1:-1);});}if(opts.pager){buildPager(els,opts);}exposeAddSlide(opts,els);return opts;}function saveOriginalOpts(opts){opts.original={before:[],after:[]};opts.original.cssBefore=$.extend({},opts.cssBefore);opts.original.cssAfter=$.extend({},opts.cssAfter);opts.original.animIn=$.extend({},opts.animIn);opts.original.animOut=$.extend({},opts.animOut);$.each(opts.before,function(){opts.original.before.push(this);});$.each(opts.after,function(){opts.original.after.push(this);});}function supportMultiTransitions(opts){var txs=$.fn.cycle.transitions;if(opts.fx.indexOf(",")>0){opts.multiFx=true;opts.fxs=opts.fx.replace(/\s*/g,"").split(",");for(var i=0;i<opts.fxs.length;i++){var fx=opts.fxs[i];var tx=txs[fx];if(!tx||!txs.hasOwnProperty(fx)||!$.isFunction(tx)){log("discarding unknown transition: ",fx);opts.fxs.splice(i,1);i--;}}if(!opts.fxs.length){log("No valid transitions named; slideshow terminating.");return false;}}else{if(opts.fx=="all"){opts.multiFx=true;opts.fxs=[];for(p in txs){var tx=txs[p];if(txs.hasOwnProperty(p)&&$.isFunction(tx)){opts.fxs.push(p);}}}}if(opts.multiFx&&opts.randomizeEffects){var r1=Math.floor(Math.random()*20)+30;for(var i=0;i<r1;i++){var r2=Math.floor(Math.random()*opts.fxs.length);opts.fxs.push(opts.fxs.splice(r2,1)[0]);}log("randomized fx sequence: ",opts.fxs);}return true;}function exposeAddSlide(opts,els){opts.addSlide=function(newSlide,prepend){var $s=$(newSlide),s=$s[0];if(!opts.autostopCount){opts.countdown++;}els[prepend?"unshift":"push"](s);if(opts.els){opts.els[prepend?"unshift":"push"](s);}opts.slideCount=els.length;$s.css("position","absolute");$s[prepend?"prependTo":"appendTo"](opts.$cont);if(prepend){opts.currSlide++;opts.nextSlide++;}if(!$.support.opacity&&opts.cleartype&&!opts.cleartypeNoBg){clearTypeFix($s);}if(opts.fit&&opts.width){$s.width(opts.width);}if(opts.fit&&opts.height&&opts.height!="auto"){$slides.height(opts.height);}s.cycleH=(opts.fit&&opts.height)?opts.height:$s.height();s.cycleW=(opts.fit&&opts.width)?opts.width:$s.width();$s.css(opts.cssBefore);if(opts.pager){$.fn.cycle.createPagerAnchor(els.length-1,s,$(opts.pager),els,opts);}if($.isFunction(opts.onAddSlide)){opts.onAddSlide($s);}else{$s.hide();}};}$.fn.cycle.resetState=function(opts,fx){fx=fx||opts.fx;opts.before=[];opts.after=[];opts.cssBefore=$.extend({},opts.original.cssBefore);opts.cssAfter=$.extend({},opts.original.cssAfter);opts.animIn=$.extend({},opts.original.animIn);opts.animOut=$.extend({},opts.original.animOut);opts.fxFn=null;$.each(opts.original.before,function(){opts.before.push(this);});$.each(opts.original.after,function(){opts.after.push(this);});var init=$.fn.cycle.transitions[fx];if($.isFunction(init)){init(opts.$cont,$(opts.elements),opts);}};function go(els,opts,manual,fwd){if(manual&&opts.busy&&opts.manualTrump){$(els).stop(true,true);opts.busy=false;}if(opts.busy){return;}var p=opts.$cont[0],curr=els[opts.currSlide],next=els[opts.nextSlide];if(p.cycleStop!=opts.stopCount||p.cycleTimeout===0&&!manual){return;}if(!manual&&!p.cyclePause&&((opts.autostop&&(--opts.countdown<=0))||(opts.nowrap&&!opts.random&&opts.nextSlide<opts.currSlide))){if(opts.end){opts.end(opts);}return;}if(manual||!p.cyclePause){var fx=opts.fx;curr.cycleH=curr.cycleH||$(curr).height();curr.cycleW=curr.cycleW||$(curr).width();next.cycleH=next.cycleH||$(next).height();next.cycleW=next.cycleW||$(next).width();if(opts.multiFx){if(opts.lastFx==undefined||++opts.lastFx>=opts.fxs.length){opts.lastFx=0;}fx=opts.fxs[opts.lastFx];opts.currFx=fx;}if(opts.oneTimeFx){fx=opts.oneTimeFx;opts.oneTimeFx=null;}$.fn.cycle.resetState(opts,fx);if(opts.before.length){$.each(opts.before,function(i,o){if(p.cycleStop!=opts.stopCount){return;}o.apply(next,[curr,next,opts,fwd]);});}var after=function(){$.each(opts.after,function(i,o){if(p.cycleStop!=opts.stopCount){return;}o.apply(next,[curr,next,opts,fwd]);});};if(opts.nextSlide!=opts.currSlide){opts.busy=1;if(opts.fxFn){opts.fxFn(curr,next,opts,after,fwd);}else{if($.isFunction($.fn.cycle[opts.fx])){$.fn.cycle[opts.fx](curr,next,opts,after);}else{$.fn.cycle.custom(curr,next,opts,after,manual&&opts.fastOnEvent);}}}opts.lastSlide=opts.currSlide;if(opts.random){opts.currSlide=opts.nextSlide;if(++opts.randomIndex==els.length){opts.randomIndex=0;}opts.nextSlide=opts.randomMap[opts.randomIndex];}else{var roll=(opts.nextSlide+1)==els.length;opts.nextSlide=roll?0:opts.nextSlide+1;opts.currSlide=roll?els.length-1:opts.nextSlide-1;}if(opts.pager){$.fn.cycle.updateActivePagerLink(opts.pager,opts.currSlide);}}var ms=0;if(opts.timeout&&!opts.continuous){ms=getTimeout(curr,next,opts,fwd);}else{if(opts.continuous&&p.cyclePause){ms=10;}}if(ms>0){p.cycleTimeout=setTimeout(function(){go(els,opts,0,!opts.rev);},ms);}}$.fn.cycle.updateActivePagerLink=function(pager,currSlide){$(pager).find("a").removeClass("activeSlide").filter("a:eq("+currSlide+")").addClass("activeSlide");};function getTimeout(curr,next,opts,fwd){if(opts.timeoutFn){var t=opts.timeoutFn(curr,next,opts,fwd);if(t!==false){return t;}}return opts.timeout;}$.fn.cycle.next=function(opts){advance(opts,opts.rev?-1:1);};$.fn.cycle.prev=function(opts){advance(opts,opts.rev?1:-1);};function advance(opts,val){var els=opts.elements;var p=opts.$cont[0],timeout=p.cycleTimeout;if(timeout){clearTimeout(timeout);p.cycleTimeout=0;}if(opts.random&&val<0){opts.randomIndex--;if(--opts.randomIndex==-2){opts.randomIndex=els.length-2;}else{if(opts.randomIndex==-1){opts.randomIndex=els.length-1;}}opts.nextSlide=opts.randomMap[opts.randomIndex];}else{if(opts.random){if(++opts.randomIndex==els.length){opts.randomIndex=0;}opts.nextSlide=opts.randomMap[opts.randomIndex];}else{opts.nextSlide=opts.currSlide+val;if(opts.nextSlide<0){if(opts.nowrap){return false;}opts.nextSlide=els.length-1;}else{if(opts.nextSlide>=els.length){if(opts.nowrap){return false;}opts.nextSlide=0;}}}}if($.isFunction(opts.prevNextClick)){opts.prevNextClick(val>0,opts.nextSlide,els[opts.nextSlide]);}go(els,opts,1,val>=0);return false;}function buildPager(els,opts){var $p=$(opts.pager);$.each(els,function(i,o){$.fn.cycle.createPagerAnchor(i,o,$p,els,opts);});$.fn.cycle.updateActivePagerLink(opts.pager,opts.startingSlide);}$.fn.cycle.createPagerAnchor=function(i,el,$p,els,opts){var a=($.isFunction(opts.pagerAnchorBuilder))?opts.pagerAnchorBuilder(i,el):'<a href="#">'+(i+1)+"</a>";if(!a){return;}var $a=$(a);if($a.parents("body").length==0){$a.appendTo($p);}$a.bind(opts.pagerEvent,function(){opts.nextSlide=i;var p=opts.$cont[0],timeout=p.cycleTimeout;if(timeout){clearTimeout(timeout);p.cycleTimeout=0;}if($.isFunction(opts.pagerClick)){opts.pagerClick(opts.nextSlide,els[opts.nextSlide]);}go(els,opts,1,opts.currSlide<i);return false;});if(opts.pauseOnPagerHover){$a.hover(function(){opts.$cont[0].cyclePause++;},function(){opts.$cont[0].cyclePause--;});}};$.fn.cycle.hopsFromLast=function(opts,fwd){var hops,l=opts.lastSlide,c=opts.currSlide;if(fwd){hops=c>l?c-l:opts.slideCount-l;}else{hops=c<l?l-c:l+opts.slideCount-c;}return hops;};function clearTypeFix($slides){function hex(s){s=parseInt(s).toString(16);return s.length<2?"0"+s:s;}function getBg(e){for(;e&&e.nodeName.toLowerCase()!="html";e=e.parentNode){var v=$.css(e,"background-color");if(v.indexOf("rgb")>=0){var rgb=v.match(/\d+/g);return"#"+hex(rgb[0])+hex(rgb[1])+hex(rgb[2]);}if(v&&v!="transparent"){return v;}}return"#ffffff";}$slides.each(function(){$(this).css("background-color",getBg(this));});}$.fn.cycle.commonReset=function(curr,next,opts,w,h,rev){$(opts.elements).not(curr).hide();opts.cssBefore.opacity=1;opts.cssBefore.display="block";if(w!==false&&next.cycleW>0){opts.cssBefore.width=next.cycleW;}if(h!==false&&next.cycleH>0){opts.cssBefore.height=next.cycleH;}opts.cssAfter=opts.cssAfter||{};opts.cssAfter.display="none";$(curr).css("zIndex",opts.slideCount+(rev===true?1:0));$(next).css("zIndex",opts.slideCount+(rev===true?0:1));};$.fn.cycle.custom=function(curr,next,opts,cb,speedOverride){var $l=$(curr),$n=$(next);var speedIn=opts.speedIn,speedOut=opts.speedOut,easeIn=opts.easeIn,easeOut=opts.easeOut;$n.css(opts.cssBefore);if(speedOverride){if(typeof speedOverride=="number"){speedIn=speedOut=speedOverride;}else{speedIn=speedOut=1;}easeIn=easeOut=null;}var fn=function(){$n.animate(opts.animIn,speedIn,easeIn,cb);};$l.animate(opts.animOut,speedOut,easeOut,function(){if(opts.cssAfter){$l.css(opts.cssAfter);}if(!opts.sync){fn();}});if(opts.sync){fn();}};$.fn.cycle.transitions={fade:function($cont,$slides,opts){$slides.not(":eq("+opts.currSlide+")").css("opacity",0);opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts);opts.cssBefore.opacity=0;});opts.animIn={opacity:1};opts.animOut={opacity:0};opts.cssBefore={top:0,left:0};}};$.fn.cycle.ver=function(){return ver;};$.fn.cycle.defaults={fx:"fade",timeout:4000,timeoutFn:null,continuous:0,speed:1000,speedIn:null,speedOut:null,next:null,prev:null,prevNextClick:null,pager:null,pagerClick:null,pagerEvent:"click",pagerAnchorBuilder:null,before:null,after:null,end:null,easing:null,easeIn:null,easeOut:null,shuffle:null,animIn:null,animOut:null,cssBefore:null,cssAfter:null,fxFn:null,height:"auto",startingSlide:0,sync:1,random:0,fit:0,containerResize:1,pause:0,pauseOnPagerHover:0,autostop:0,autostopCount:0,delay:0,slideExpr:null,cleartype:!$.support.opacity,nowrap:0,fastOnEvent:0,randomizeEffects:1,rev:0,manualTrump:true,requeueOnImageNotLoaded:true,requeueTimeout:250};})(jQuery);
|
17 |
+
/*
|
18 |
+
* jQuery Cycle Plugin Transition Definitions
|
19 |
+
* This script is a plugin for the jQuery Cycle Plugin
|
20 |
+
* Examples and documentation at: http://malsup.com/jquery/cycle/
|
21 |
+
* Copyright (c) 2007-2008 M. Alsup
|
22 |
+
* Version: 2.52
|
23 |
+
* Dual licensed under the MIT and GPL licenses:
|
24 |
+
* http://www.opensource.org/licenses/mit-license.php
|
25 |
+
* http://www.gnu.org/licenses/gpl.html
|
26 |
+
*/
|
27 |
+
;(function($){$.fn.cycle.transitions.scrollUp=function($cont,$slides,opts){$cont.css("overflow","hidden");opts.before.push($.fn.cycle.commonReset);var h=$cont.height();opts.cssBefore={top:h,left:0};opts.cssFirst={top:0};opts.animIn={top:0};opts.animOut={top:-h};};$.fn.cycle.transitions.scrollDown=function($cont,$slides,opts){$cont.css("overflow","hidden");opts.before.push($.fn.cycle.commonReset);var h=$cont.height();opts.cssFirst={top:0};opts.cssBefore={top:-h,left:0};opts.animIn={top:0};opts.animOut={top:h};};$.fn.cycle.transitions.scrollLeft=function($cont,$slides,opts){$cont.css("overflow","hidden");opts.before.push($.fn.cycle.commonReset);var w=$cont.width();opts.cssFirst={left:0};opts.cssBefore={left:w,top:0};opts.animIn={left:0};opts.animOut={left:0-w};};$.fn.cycle.transitions.scrollRight=function($cont,$slides,opts){$cont.css("overflow","hidden");opts.before.push($.fn.cycle.commonReset);var w=$cont.width();opts.cssFirst={left:0};opts.cssBefore={left:-w,top:0};opts.animIn={left:0};opts.animOut={left:w};};$.fn.cycle.transitions.scrollHorz=function($cont,$slides,opts){$cont.css("overflow","hidden").width();opts.before.push(function(curr,next,opts,fwd){$.fn.cycle.commonReset(curr,next,opts);opts.cssBefore.left=fwd?(next.cycleW-1):(1-next.cycleW);opts.animOut.left=fwd?-curr.cycleW:curr.cycleW;});opts.cssFirst={left:0};opts.cssBefore={top:0};opts.animIn={left:0};opts.animOut={top:0};};$.fn.cycle.transitions.scrollVert=function($cont,$slides,opts){$cont.css("overflow","hidden");opts.before.push(function(curr,next,opts,fwd){$.fn.cycle.commonReset(curr,next,opts);opts.cssBefore.top=fwd?(1-next.cycleH):(next.cycleH-1);opts.animOut.top=fwd?curr.cycleH:-curr.cycleH;});opts.cssFirst={top:0};opts.cssBefore={left:0};opts.animIn={top:0};opts.animOut={left:0};};$.fn.cycle.transitions.slideX=function($cont,$slides,opts){opts.before.push(function(curr,next,opts){$(opts.elements).not(curr).hide();$.fn.cycle.commonReset(curr,next,opts,false,true);opts.animIn.width=next.cycleW;});opts.cssBefore={left:0,top:0,width:0};opts.animIn={width:"show"};opts.animOut={width:0};};$.fn.cycle.transitions.slideY=function($cont,$slides,opts){opts.before.push(function(curr,next,opts){$(opts.elements).not(curr).hide();$.fn.cycle.commonReset(curr,next,opts,true,false);opts.animIn.height=next.cycleH;});opts.cssBefore={left:0,top:0,height:0};opts.animIn={height:"show"};opts.animOut={height:0};};$.fn.cycle.transitions.shuffle=function($cont,$slides,opts){var w=$cont.css("overflow","visible").width();$slides.css({left:0,top:0});opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts,true,true,true);});opts.speed=opts.speed/2;opts.random=0;opts.shuffle=opts.shuffle||{left:-w,top:15};opts.els=[];for(var i=0;i<$slides.length;i++){opts.els.push($slides[i]);}for(var i=0;i<opts.currSlide;i++){opts.els.push(opts.els.shift());}opts.fxFn=function(curr,next,opts,cb,fwd){var $el=fwd?$(curr):$(next);$(next).css(opts.cssBefore);var count=opts.slideCount;$el.animate(opts.shuffle,opts.speedIn,opts.easeIn,function(){var hops=$.fn.cycle.hopsFromLast(opts,fwd);for(var k=0;k<hops;k++){fwd?opts.els.push(opts.els.shift()):opts.els.unshift(opts.els.pop());}if(fwd){for(var i=0,len=opts.els.length;i<len;i++){$(opts.els[i]).css("z-index",len-i+count);}}else{var z=$(curr).css("z-index");$el.css("z-index",parseInt(z)+1+count);}$el.animate({left:0,top:0},opts.speedOut,opts.easeOut,function(){$(fwd?this:curr).hide();if(cb){cb();}});});};opts.cssBefore={display:"block",opacity:1,top:0,left:0};};$.fn.cycle.transitions.turnUp=function($cont,$slides,opts){opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts,true,false);opts.cssBefore.top=next.cycleH;opts.animIn.height=next.cycleH;});opts.cssFirst={top:0};opts.cssBefore={left:0,height:0};opts.animIn={top:0};opts.animOut={height:0};};$.fn.cycle.transitions.turnDown=function($cont,$slides,opts){opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts,true,false);opts.animIn.height=next.cycleH;opts.animOut.top=curr.cycleH;});opts.cssFirst={top:0};opts.cssBefore={left:0,top:0,height:0};opts.animOut={height:0};};$.fn.cycle.transitions.turnLeft=function($cont,$slides,opts){opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts,false,true);opts.cssBefore.left=next.cycleW;opts.animIn.width=next.cycleW;});opts.cssBefore={top:0,width:0};opts.animIn={left:0};opts.animOut={width:0};};$.fn.cycle.transitions.turnRight=function($cont,$slides,opts){opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts,false,true);opts.animIn.width=next.cycleW;opts.animOut.left=curr.cycleW;});opts.cssBefore={top:0,left:0,width:0};opts.animIn={left:0};opts.animOut={width:0};};$.fn.cycle.transitions.zoom=function($cont,$slides,opts){opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts,false,false,true);opts.cssBefore.top=next.cycleH/2;opts.cssBefore.left=next.cycleW/2;opts.animIn={top:0,left:0,width:next.cycleW,height:next.cycleH};opts.animOut={width:0,height:0,top:curr.cycleH/2,left:curr.cycleW/2};});opts.cssFirst={top:0,left:0};opts.cssBefore={width:0,height:0};};$.fn.cycle.transitions.fadeZoom=function($cont,$slides,opts){opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts,false,false);opts.cssBefore.left=next.cycleW/2;opts.cssBefore.top=next.cycleH/2;opts.animIn={top:0,left:0,width:next.cycleW,height:next.cycleH};});opts.cssBefore={width:0,height:0};opts.animOut={opacity:0};};$.fn.cycle.transitions.blindX=function($cont,$slides,opts){var w=$cont.css("overflow","hidden").width();opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts);opts.animIn.width=next.cycleW;opts.animOut.left=curr.cycleW;});opts.cssBefore={left:w,top:0};opts.animIn={left:0};opts.animOut={left:w};};$.fn.cycle.transitions.blindY=function($cont,$slides,opts){var h=$cont.css("overflow","hidden").height();opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts);opts.animIn.height=next.cycleH;opts.animOut.top=curr.cycleH;});opts.cssBefore={top:h,left:0};opts.animIn={top:0};opts.animOut={top:h};};$.fn.cycle.transitions.blindZ=function($cont,$slides,opts){var h=$cont.css("overflow","hidden").height();var w=$cont.width();opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts);opts.animIn.height=next.cycleH;opts.animOut.top=curr.cycleH;});opts.cssBefore={top:h,left:w};opts.animIn={top:0,left:0};opts.animOut={top:h,left:w};};$.fn.cycle.transitions.growX=function($cont,$slides,opts){opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts,false,true);opts.cssBefore.left=this.cycleW/2;opts.animIn={left:0,width:this.cycleW};opts.animOut={left:0};});opts.cssBefore={width:0,top:0};};$.fn.cycle.transitions.growY=function($cont,$slides,opts){opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts,true,false);opts.cssBefore.top=this.cycleH/2;opts.animIn={top:0,height:this.cycleH};opts.animOut={top:0};});opts.cssBefore={height:0,left:0};};$.fn.cycle.transitions.curtainX=function($cont,$slides,opts){opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts,false,true,true);opts.cssBefore.left=next.cycleW/2;opts.animIn={left:0,width:this.cycleW};opts.animOut={left:curr.cycleW/2,width:0};});opts.cssBefore={top:0,width:0};};$.fn.cycle.transitions.curtainY=function($cont,$slides,opts){opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts,true,false,true);opts.cssBefore.top=next.cycleH/2;opts.animIn={top:0,height:next.cycleH};opts.animOut={top:curr.cycleH/2,height:0};});opts.cssBefore={left:0,height:0};};$.fn.cycle.transitions.cover=function($cont,$slides,opts){var d=opts.direction||"left";var w=$cont.css("overflow","hidden").width();var h=$cont.height();opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts);if(d=="right"){opts.cssBefore.left=-w;}else{if(d=="up"){opts.cssBefore.top=h;}else{if(d=="down"){opts.cssBefore.top=-h;}else{opts.cssBefore.left=w;}}}});opts.animIn={left:0,top:0};opts.animOut={opacity:1};opts.cssBefore={top:0,left:0};};$.fn.cycle.transitions.uncover=function($cont,$slides,opts){var d=opts.direction||"left";var w=$cont.css("overflow","hidden").width();var h=$cont.height();opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts,true,true,true);if(d=="right"){opts.animOut.left=w;}else{if(d=="up"){opts.animOut.top=-h;}else{if(d=="down"){opts.animOut.top=h;}else{opts.animOut.left=-w;}}}});opts.animIn={left:0,top:0};opts.animOut={opacity:1};opts.cssBefore={top:0,left:0};};$.fn.cycle.transitions.toss=function($cont,$slides,opts){var w=$cont.css("overflow","visible").width();var h=$cont.height();opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts,true,true,true);if(!opts.animOut.left&&!opts.animOut.top){opts.animOut={left:w*2,top:-h/2,opacity:0};}else{opts.animOut.opacity=0;}});opts.cssBefore={left:0,top:0};opts.animIn={left:0};};$.fn.cycle.transitions.wipe=function($cont,$slides,opts){var w=$cont.css("overflow","hidden").width();var h=$cont.height();opts.cssBefore=opts.cssBefore||{};var clip;if(opts.clip){if(/l2r/.test(opts.clip)){clip="rect(0px 0px "+h+"px 0px)";}else{if(/r2l/.test(opts.clip)){clip="rect(0px "+w+"px "+h+"px "+w+"px)";}else{if(/t2b/.test(opts.clip)){clip="rect(0px "+w+"px 0px 0px)";}else{if(/b2t/.test(opts.clip)){clip="rect("+h+"px "+w+"px "+h+"px 0px)";}else{if(/zoom/.test(opts.clip)){var t=parseInt(h/2);var l=parseInt(w/2);clip="rect("+t+"px "+l+"px "+t+"px "+l+"px)";}}}}}}opts.cssBefore.clip=opts.cssBefore.clip||clip||"rect(0px 0px 0px 0px)";var d=opts.cssBefore.clip.match(/(\d+)/g);var t=parseInt(d[0]),r=parseInt(d[1]),b=parseInt(d[2]),l=parseInt(d[3]);opts.before.push(function(curr,next,opts){if(curr==next){return;}var $curr=$(curr),$next=$(next);$.fn.cycle.commonReset(curr,next,opts,true,true,false);opts.cssAfter.display="block";var step=1,count=parseInt((opts.speedIn/13))-1;(function f(){var tt=t?t-parseInt(step*(t/count)):0;var ll=l?l-parseInt(step*(l/count)):0;var bb=b<h?b+parseInt(step*((h-b)/count||1)):h;var rr=r<w?r+parseInt(step*((w-r)/count||1)):w;$next.css({clip:"rect("+tt+"px "+rr+"px "+bb+"px "+ll+"px)"});(step++<=count)?setTimeout(f,13):$curr.css("display","none");})();});opts.cssBefore={display:"block",opacity:1,top:0,left:0};opts.animIn={left:0};opts.animOut={left:0};};})(jQuery);
|
readme.txt
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Plugin Name ===
|
2 |
+
Contributors: nathanrice
|
3 |
+
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5553118
|
4 |
+
Tags: slideshow, images, jquery cycle
|
5 |
+
Requires at least: 2.7
|
6 |
+
Tested up to: 2.8
|
7 |
+
Stable tag: 0.1
|
8 |
+
|
9 |
+
This plugin creates an image slideshow in your theme, using the jQuery Cycle plugin. You can upload/delete images via the administration panel, and display the images in your theme by using the <code>wp_cycle();</code> template tag, which will generate all the necessary HTML for outputting the rotating images.
|
10 |
+
|
11 |
+
== Description ==
|
12 |
+
|
13 |
+
The WP-Cycle plugin allows you to upload images from your computer, which will then be used to generate a jQuery Cycle Plugin slideshow of the images.
|
14 |
+
|
15 |
+
Each image can also be given a URL which, when the image is active in the slideshow, will be used as an anchor wrapper around the image, turning the image into a link to the URL you specified. The slideshow is set to pause when the user hovers over the slideshow images, giving them ample time to click the link.
|
16 |
+
|
17 |
+
Images can also be deleted via the plugins Administration page.
|
18 |
+
|
19 |
+
== Installation ==
|
20 |
+
|
21 |
+
1. Upload the entire `wp-cycle` folder to the `/wp-content/plugins/` directory
|
22 |
+
1. Activate the plugin through the 'Plugins' menu in WordPress
|
23 |
+
1. Configure the plugin, and upload/edit/delete images via the WP-Cycle menu within the Plugins tab
|
24 |
+
1. Place `<?php wp_cycle(); ?>` in your theme where you want the slideshow to appear
|
25 |
+
|
26 |
+
== Frequently Asked Questions ==
|
27 |
+
|
28 |
+
= My images won't upload. What should I do? =
|
29 |
+
|
30 |
+
The plugin uses built in WordPress functions to handle image uploading. Therefore, you need to have [correct permissions](http://codex.wordpress.org/Changing_File_Permissions "Changing File Permissions") set for your uploads directory.
|
31 |
+
|
32 |
+
Also, a file that is not an image, or an image that does not meet the minimum height/width requirements, will not upload. Images larger than the dimensions set in the Settings of this plugin will be scaled down to fit, but images smaller than the dimensions set in the Settings will NOT be scaled up. The upload will fail and you will be asked to try again with another image.
|
33 |
+
|
34 |
+
= I'm getting an error message that I don't understand. What should I do? =
|
35 |
+
|
36 |
+
Please [email me](http://www.nathanrice.net/contact/ "email Nathan Rice") or [@nathanrice](http://twitter.com/nathanrice) me on Twitter. This plugin is still in early alpha stages, and I'm looking for good error reporting. I'll try to fix errors as soon as I possibly can.
|
37 |
+
|
38 |
+
= How can I style the slideshow further? =
|
39 |
+
In the settings of the plugin, you're able to set a custom DIV ID for the slideshow. Use that DIV ID to style the slideshow however you want using CSS.
|
40 |
+
|
41 |
+
= In what order are the images shown during the slideshow? =
|
42 |
+
|
43 |
+
Chronologically, from the time of upload. For instance, the first image you upload will be the first image in the slideshow. The last image will be the last, etc.
|
44 |
+
|
45 |
+
= Can I reorder the images? =
|
46 |
+
|
47 |
+
Not at the moment, but this is a feature I do want to include in the plugin soon.
|
48 |
+
|
49 |
+
= Can I rotate anything other than images with this plugin? =
|
50 |
+
|
51 |
+
No. This is an image slideshow. Enjoy it for what it is.
|
52 |
+
|
53 |
+
= Do you have future plans for this plugin? =
|
54 |
+
Yes. Here are some things that I want to eventually include:
|
55 |
+
|
56 |
+
* Add ability to reorder the images
|
57 |
+
* Add new effects to the slideshow
|
58 |
+
* Add options for the user to define the duration of the effect, and the time between effects via the Settings
|
59 |
+
* Add the ability to override settings by using function arguments: `<?php wp_cycle('rotate=1&effect=fade&img_width=300&img_height=200&div=slideshow'); ?>`
|
60 |
+
* Add shortcode ability so that you can rotate images attached to a post
|
61 |
+
* Possibly add widget support so that you can put a slideshow in a widget area
|
62 |
+
|
63 |
+
== Using this plugin with themes ==
|
64 |
+
|
65 |
+
If you are a theme author and what to make your theme compatible with this plugin, you have a couple of options.
|
66 |
+
|
67 |
+
First of all, the theme settings defaults are filterable. Therefore, you have the ability, from within your theme's functions.php file, to set the defaults for this plugin. The filter you want to use is `wp_cycle_defaults` and you need to set your return function to return an array. For example:
|
68 |
+
|
69 |
+
`
|
70 |
+
<?php
|
71 |
+
add_filter('wp_cycle_defaults', 'my_theme_wp_cycle_defaults');
|
72 |
+
function my_theme_wp_cycle_defaults() {
|
73 |
+
$defaults = array(
|
74 |
+
'rotate' => 1,
|
75 |
+
'effect' => 'fade',
|
76 |
+
'img_width' => 300,
|
77 |
+
'img_height' => 200,
|
78 |
+
'div' => 'rotator'
|
79 |
+
);
|
80 |
+
return $defaults;
|
81 |
+
}
|
82 |
+
?>
|
83 |
+
`
|
84 |
+
|
85 |
+
|
86 |
+
Change the array values to what you need for your theme. The user will be able to change them, if they so desire, but you'll be able to at least start them off right.
|
wp-cycle.php
ADDED
@@ -0,0 +1,441 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: WP-Cycle
|
4 |
+
Plugin URI: http://www.nathanrice.net/plugins/wp-cycle/
|
5 |
+
Description: This plugin creates an image slideshow from the images you upload using the jQuery Cycle plugin. You can upload/delete images via the administration panel, and display the images in your theme by using the <code>wp_cycle();</code> template tag, which will generate all the necessary HTML for outputting the rotating images.
|
6 |
+
Version: 0.1
|
7 |
+
Author: Nathan Rice
|
8 |
+
Author URI: http://www.nathanrice.net/
|
9 |
+
|
10 |
+
This plugin inherits the GPL license from it's parent system, WordPress.
|
11 |
+
*/
|
12 |
+
|
13 |
+
|
14 |
+
/*
|
15 |
+
///////////////////////////////////////////////
|
16 |
+
This section defines the variables that
|
17 |
+
will be used throughout the plugin
|
18 |
+
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
|
19 |
+
*/
|
20 |
+
// define our defaults (filterable)
|
21 |
+
$wp_cycle_defaults = apply_filters('wp_cycle_defaults', array(
|
22 |
+
'rotate' => 1,
|
23 |
+
'effect' => 'fade',
|
24 |
+
'img_width' => 300,
|
25 |
+
'img_height' => 200,
|
26 |
+
'div' => 'rotator'
|
27 |
+
));
|
28 |
+
|
29 |
+
// pull the settings from the db
|
30 |
+
$wp_cycle_settings = get_option('wp_cycle_settings');
|
31 |
+
$wp_cycle_images = get_option('wp_cycle_images');
|
32 |
+
|
33 |
+
// use defaults if options aren't set yet
|
34 |
+
$wp_cycle_settings = wp_parse_args($wp_cycle_settings, $wp_cycle_defaults);
|
35 |
+
|
36 |
+
|
37 |
+
/*
|
38 |
+
///////////////////////////////////////////////
|
39 |
+
This section hooks the proper functions
|
40 |
+
to the proper actions in WordPress
|
41 |
+
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
|
42 |
+
*/
|
43 |
+
|
44 |
+
// this function registers our settings in the db
|
45 |
+
add_action('admin_init', 'wp_cycle_register_settings');
|
46 |
+
function wp_cycle_register_settings() {
|
47 |
+
register_setting('wp_cycle_images', 'wp_cycle_images', 'wp_cycle_images_validate');
|
48 |
+
register_setting('wp_cycle_settings', 'wp_cycle_settings', 'wp_cycle_settings_validate');
|
49 |
+
}
|
50 |
+
// this function adds the settings page to the Appearance tab
|
51 |
+
add_action('admin_menu', 'add_wp_cycle_menu');
|
52 |
+
function add_wp_cycle_menu() {
|
53 |
+
add_submenu_page('plugins.php', 'WP-Cycle Settings', 'WP-Cycle', 8, 'wp-cycle', 'wp_cycle_admin_page');
|
54 |
+
}
|
55 |
+
|
56 |
+
|
57 |
+
/*
|
58 |
+
///////////////////////////////////////////////
|
59 |
+
this function is the code that gets loaded when the
|
60 |
+
settings page gets loaded by the browser. It calls
|
61 |
+
functions that handle image uploads and image settings
|
62 |
+
changes, as well as producing the visible page output.
|
63 |
+
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
|
64 |
+
*/
|
65 |
+
function wp_cycle_admin_page() {
|
66 |
+
echo '<div class="wrap">';
|
67 |
+
|
68 |
+
// handle image upload, if necessary
|
69 |
+
if($_REQUEST['action'] == 'wp_handle_upload')
|
70 |
+
wp_cycle_handle_upload();
|
71 |
+
|
72 |
+
// delete an image, if necessary
|
73 |
+
if(isset($_REQUEST['delete']))
|
74 |
+
wp_cycle_delete_upload($_REQUEST['delete']);
|
75 |
+
|
76 |
+
// the image management form
|
77 |
+
wp_cycle_images_admin();
|
78 |
+
|
79 |
+
// the settings management form
|
80 |
+
wp_cycle_settings_admin();
|
81 |
+
|
82 |
+
echo '</div>';
|
83 |
+
}
|
84 |
+
|
85 |
+
|
86 |
+
/*
|
87 |
+
///////////////////////////////////////////////
|
88 |
+
this section handles uploading images, adding
|
89 |
+
the image data to the database, deleting images,
|
90 |
+
and deleting image data from the database.
|
91 |
+
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
|
92 |
+
*/
|
93 |
+
// this function handles the file upload,
|
94 |
+
// resize/crop, and adds the image data to the db
|
95 |
+
function wp_cycle_handle_upload() {
|
96 |
+
global $wp_cycle_settings, $wp_cycle_images;
|
97 |
+
|
98 |
+
// upload the image
|
99 |
+
$upload = wp_handle_upload($_FILES['wp_cycle'], 0);
|
100 |
+
|
101 |
+
// extract the $upload array
|
102 |
+
extract($upload);
|
103 |
+
|
104 |
+
// the URL of the directory the file was loaded in
|
105 |
+
$upload_dir_url = str_replace(basename($file), '', $url);
|
106 |
+
|
107 |
+
// get the image dimensions
|
108 |
+
list($width, $height) = getimagesize($file);
|
109 |
+
|
110 |
+
// if the uploaded file is NOT an image
|
111 |
+
if(strpos($type, 'image') === FALSE) {
|
112 |
+
unlink($file); // delete the file
|
113 |
+
echo '<div class="error" id="message"><p>Sorry, but the file you uploaded does not seem to be a valid image. Please try again.</p></div>';
|
114 |
+
return;
|
115 |
+
}
|
116 |
+
|
117 |
+
// if the image doesn't meet the minimum width/height requirements ...
|
118 |
+
if($width < $wp_cycle_settings['img_width'] || $height < $wp_cycle_settings['img_height']) {
|
119 |
+
unlink($file); // delete the image
|
120 |
+
echo '<div class="error" id="message"><p>Sorry, but this image does not meet the minimum height/width requirements. Please upload another image</p></div>';
|
121 |
+
return;
|
122 |
+
}
|
123 |
+
|
124 |
+
// if the image is larger than the width/height requirements, then scale it down.
|
125 |
+
if($width > $wp_cycle_settings['img_width'] || $height > $wp_cycle_settings['img_height']) {
|
126 |
+
// resize the image
|
127 |
+
$resized = image_resize($file, $wp_cycle_settings['img_width'], $wp_cycle_settings['img_height'], true, 'resized');
|
128 |
+
$resized_url = $upload_dir_url . basename($resized);
|
129 |
+
// delete the original
|
130 |
+
unlink($file);
|
131 |
+
$file = $resized;
|
132 |
+
$url = $resized_url;
|
133 |
+
}
|
134 |
+
|
135 |
+
// make the thumbnail
|
136 |
+
$thumb_height = round((100 * $wp_cycle_settings['img_height']) / $wp_cycle_settings['img_width']);
|
137 |
+
if(isset($upload['file'])) {
|
138 |
+
$thumbnail = image_resize($file, 100, $thumb_height, true, 'thumb');
|
139 |
+
$thumbnail_url = $upload_dir_url . basename($thumbnail);
|
140 |
+
}
|
141 |
+
|
142 |
+
// use the timestamp as the array key and id
|
143 |
+
$time = date('YmdHis');
|
144 |
+
|
145 |
+
// add the image data to the array
|
146 |
+
$wp_cycle_images[$time] = array(
|
147 |
+
'id' => $time,
|
148 |
+
'file' => $file,
|
149 |
+
'file_url' => $url,
|
150 |
+
'thumbnail' => $thumbnail,
|
151 |
+
'thumbnail_url' => $thumbnail_url,
|
152 |
+
'image_links_to' => ''
|
153 |
+
);
|
154 |
+
|
155 |
+
// add the image information to the database
|
156 |
+
$wp_cycle_images['update'] = 'Added';
|
157 |
+
update_option('wp_cycle_images', $wp_cycle_images);
|
158 |
+
}
|
159 |
+
|
160 |
+
// this function deletes the image,
|
161 |
+
// and removes the image data from the db
|
162 |
+
function wp_cycle_delete_upload($id) {
|
163 |
+
global $wp_cycle_images;
|
164 |
+
|
165 |
+
// if the ID passed to this function is invalid,
|
166 |
+
// halt the process, and don't try to delete.
|
167 |
+
if(!isset($wp_cycle_images[$id])) return;
|
168 |
+
|
169 |
+
// delete the image and thumbnail
|
170 |
+
unlink($wp_cycle_images[$id]['file']);
|
171 |
+
unlink($wp_cycle_images[$id]['thumbnail']);
|
172 |
+
|
173 |
+
// indicate that the image was deleted
|
174 |
+
$wp_cycle_images['update'] = 'Deleted';
|
175 |
+
|
176 |
+
// remove the image data from the db
|
177 |
+
unset($wp_cycle_images[$id]);
|
178 |
+
update_option('wp_cycle_images', $wp_cycle_images);
|
179 |
+
}
|
180 |
+
|
181 |
+
|
182 |
+
/*
|
183 |
+
///////////////////////////////////////////////
|
184 |
+
these two functions check to see if an update
|
185 |
+
to the data just occurred. if it did, then they
|
186 |
+
will display a notice, and reset the update option.
|
187 |
+
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
|
188 |
+
*/
|
189 |
+
// this function checks to see if we just updated the settings
|
190 |
+
// if so, it displays the "updated" message.
|
191 |
+
function wp_cycle_settings_update_check() {
|
192 |
+
global $wp_cycle_settings;
|
193 |
+
if(isset($wp_cycle_settings['update'])) {
|
194 |
+
echo '<div class="updated fade" id="message"><p>WP-Cycle Settings <strong>'.$wp_cycle_settings['update'].'</strong></p></div>';
|
195 |
+
unset($wp_cycle_settings['update']);
|
196 |
+
update_option('wp_cycle_settings', $wp_cycle_settings);
|
197 |
+
}
|
198 |
+
}
|
199 |
+
// this function checks to see if we just added a new image
|
200 |
+
// if so, it displays the "updated" message.
|
201 |
+
function wp_cycle_images_update_check() {
|
202 |
+
global $wp_cycle_images;
|
203 |
+
if($wp_cycle_images['update'] == 'Added' || $wp_cycle_images['update'] == 'Deleted' || $wp_cycle_images['update'] == 'Updated') {
|
204 |
+
echo '<div class="updated fade" id="message"><p>Image(s) '.$wp_cycle_images['update'].' Successfully</p></div>';
|
205 |
+
unset($wp_cycle_images['update']);
|
206 |
+
update_option('wp_cycle_images', $wp_cycle_images);
|
207 |
+
}
|
208 |
+
}
|
209 |
+
|
210 |
+
|
211 |
+
/*
|
212 |
+
///////////////////////////////////////////////
|
213 |
+
these two functions display the front-end code
|
214 |
+
on the admin page. it's mostly form markup.
|
215 |
+
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
|
216 |
+
*/
|
217 |
+
// display the images administration code
|
218 |
+
function wp_cycle_images_admin() { ?>
|
219 |
+
<?php global $wp_cycle_images; ?>
|
220 |
+
<?php wp_cycle_images_update_check(); ?>
|
221 |
+
<h2><?php _e('WP-Cycle Images', 'wp_cycle'); ?></h2>
|
222 |
+
|
223 |
+
<table class="form-table">
|
224 |
+
<tr valign="top"><th scope="row">Upload New Image</th>
|
225 |
+
<td>
|
226 |
+
<form enctype="multipart/form-data" method="post" action="?page=wp-cycle">
|
227 |
+
<input type="hidden" name="post_id" id="post_id" value="0" />
|
228 |
+
<input type="hidden" name="action" id="action" value="wp_handle_upload" />
|
229 |
+
|
230 |
+
<label for="wp_cycle">Select a File: </label>
|
231 |
+
<input type="file" name="wp_cycle" id="wp_cycle" />
|
232 |
+
<input type="submit" class="button-primary" name="html-upload" value="Upload" />
|
233 |
+
</form>
|
234 |
+
</td>
|
235 |
+
</tr>
|
236 |
+
</table><br />
|
237 |
+
|
238 |
+
<?php if(!empty($wp_cycle_images)) : ?>
|
239 |
+
<table class="widefat fixed" cellspacing="0">
|
240 |
+
<thead>
|
241 |
+
<tr>
|
242 |
+
<th scope="col" class="column-slug">Image</th>
|
243 |
+
<th scope="col">Image Links To</th>
|
244 |
+
<th scope="col" class="column-slug">Actions</th>
|
245 |
+
</tr>
|
246 |
+
</thead>
|
247 |
+
|
248 |
+
<tfoot>
|
249 |
+
<tr>
|
250 |
+
<th scope="col" class="column-slug">Image</th>
|
251 |
+
<th scope="col">Image Links To</th>
|
252 |
+
<th scope="col" class="column-slug">Actions</th>
|
253 |
+
</tr>
|
254 |
+
</tfoot>
|
255 |
+
|
256 |
+
<tbody>
|
257 |
+
|
258 |
+
<form method="post" action="options.php">
|
259 |
+
<?php settings_fields('wp_cycle_images'); ?>
|
260 |
+
<?php foreach((array)$wp_cycle_images as $image => $data) : ?>
|
261 |
+
<tr>
|
262 |
+
<input type="hidden" name="wp_cycle_images[<?php echo $image; ?>][id]" value="<?php echo $data['id']; ?>" />
|
263 |
+
<input type="hidden" name="wp_cycle_images[<?php echo $image; ?>][file]" value="<?php echo $data['file']; ?>" />
|
264 |
+
<input type="hidden" name="wp_cycle_images[<?php echo $image; ?>][file_url]" value="<?php echo $data['file_url']; ?>" />
|
265 |
+
<input type="hidden" name="wp_cycle_images[<?php echo $image; ?>][thumbnail]" value="<?php echo $data['thumbnail']; ?>" />
|
266 |
+
<input type="hidden" name="wp_cycle_images[<?php echo $image; ?>][thumbnail_url]" value="<?php echo $data['thumbnail_url']; ?>" />
|
267 |
+
<th scope="row" class="column-slug"><img src="<?php echo $data['thumbnail_url']; ?>" /></th>
|
268 |
+
<td><input type="text" name="wp_cycle_images[<?php echo $image; ?>][image_links_to]" value="<?php echo $data['image_links_to']; ?>" size="35" /></td>
|
269 |
+
<td class="column-slug"><input type="submit" class="button-primary" value="Update" /> <a href="?page=wp-cycle&delete=<?php echo $image; ?>" class="button">Delete</a></td>
|
270 |
+
</tr>
|
271 |
+
<?php endforeach; ?>
|
272 |
+
<input type="hidden" name="wp_cycle_images[update]" value="Updated" />
|
273 |
+
</form>
|
274 |
+
|
275 |
+
</tbody>
|
276 |
+
</table>
|
277 |
+
<?php endif; ?>
|
278 |
+
|
279 |
+
<?php
|
280 |
+
}
|
281 |
+
|
282 |
+
// display the settings administration code
|
283 |
+
function wp_cycle_settings_admin() { ?>
|
284 |
+
|
285 |
+
<?php wp_cycle_settings_update_check(); ?>
|
286 |
+
<h2><?php _e('WP-Cycle Settings', 'wp-cycle'); ?></h2>
|
287 |
+
<form method="post" action="options.php">
|
288 |
+
<?php settings_fields('wp_cycle_settings'); ?>
|
289 |
+
<?php global $wp_cycle_settings; $options = $wp_cycle_settings; ?>
|
290 |
+
<table class="form-table">
|
291 |
+
|
292 |
+
<tr valign="top"><th scope="row">Effects Enabled</th>
|
293 |
+
<td><input name="wp_cycle_settings[rotate]" type="checkbox" value="1" <?php checked('1', $options['rotate']); ?> /> <label for="wp_cycle_settings[rotate]">Check this box if you want to enable the rotating effects</td>
|
294 |
+
</tr>
|
295 |
+
|
296 |
+
<tr><th scope="row">Animation Effect</th>
|
297 |
+
<td>Please select the effect you would like to use when your images rotate (if applicable):<br />
|
298 |
+
<select name="wp_cycle_settings[effect]">
|
299 |
+
<option value="fade" <?php selected('fade', $options['effect']); ?>>fade</option>
|
300 |
+
<option value="wipe" <?php selected('wipe', $options['effect']); ?>>wipe</option>
|
301 |
+
<option value="scrollUp" <?php selected('scrollUp', $options['effect']); ?>>scrollUp</option>
|
302 |
+
<option value="scrollDown" <?php selected('scrollDown', $options['effect']); ?>>scrollDown</option>
|
303 |
+
<option value="scrollLeft" <?php selected('scrollLeft', $options['effect']); ?>>scrollLeft</option>
|
304 |
+
<option value="scrollRight" <?php selected('scrollRight', $options['effect']); ?>>scrollRight</option>
|
305 |
+
<option value="cover" <?php selected('cover', $options['effect']); ?>>cover</option>
|
306 |
+
<option value="shuffle" <?php selected('shuffle', $options['effect']); ?>>shuffle</option>
|
307 |
+
</select>
|
308 |
+
</td></tr>
|
309 |
+
|
310 |
+
<tr><th scope="row">Image Dimensions</th>
|
311 |
+
<td>Please input the width of the image rotator:<br />
|
312 |
+
<input type="text" name="wp_cycle_settings[img_width]" value="<?php echo $options['img_width'] ?>" size="4" />
|
313 |
+
<label for="wp_cycle_settings[img_width]">px</label>
|
314 |
+
<br /><br />
|
315 |
+
Please input the height of the image rotator:<br />
|
316 |
+
<input type="text" name="wp_cycle_settings[img_height]" value="<?php echo $options['img_height'] ?>" size="4" />
|
317 |
+
<label for="wp_cycle_settings[img_height]">px</label>
|
318 |
+
</td></tr>
|
319 |
+
|
320 |
+
<tr><th scope="row">Rotator DIV ID</th>
|
321 |
+
<td>Please indicate what you would like the rotator DIV ID to be:<br />
|
322 |
+
<input type="text" name="wp_cycle_settings[div]" value="<?php echo $options['div'] ?>" />
|
323 |
+
</td></tr>
|
324 |
+
|
325 |
+
<input type="hidden" name="wp_cycle_settings[update]" value="UPDATED" />
|
326 |
+
|
327 |
+
</table>
|
328 |
+
<p class="submit">
|
329 |
+
<input type="submit" class="button-primary" value="<?php _e('Save Settings') ?>" />
|
330 |
+
</form>
|
331 |
+
|
332 |
+
<!-- The Reset Optiom -->
|
333 |
+
<form method="post" action="options.php">
|
334 |
+
<?php settings_fields('wp_cycle_settings'); ?>
|
335 |
+
<?php global $wp_cycle_defaults; // use the defaults ?>
|
336 |
+
<?php foreach($wp_cycle_defaults as $key => $value) : ?>
|
337 |
+
<input type="hidden" name="wp_cycle_settings[<?php echo $key; ?>]" value="<?php echo $value; ?>" />
|
338 |
+
<?php endforeach; ?>
|
339 |
+
<input type="hidden" name="wp_cycle_settings[update]" value="RESET" />
|
340 |
+
<input type="submit" class="button" value="<?php _e('Reset Settings') ?>" />
|
341 |
+
</form>
|
342 |
+
<!-- End Reset Option -->
|
343 |
+
</p>
|
344 |
+
|
345 |
+
<?php
|
346 |
+
}
|
347 |
+
|
348 |
+
|
349 |
+
/*
|
350 |
+
///////////////////////////////////////////////
|
351 |
+
these two functions sanitize the data before it
|
352 |
+
gets stored in the database via options.php
|
353 |
+
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
|
354 |
+
*/
|
355 |
+
// this function sanitizes our settings data for storage
|
356 |
+
function wp_cycle_settings_validate($input) {
|
357 |
+
$input['rotate'] = ($input['rotate'] == 1 ? 1 : 0);
|
358 |
+
$input['effect'] = wp_filter_nohtml_kses($input['effect']);
|
359 |
+
$input['img_width'] = intval($input['img_width']);
|
360 |
+
$input['img_height'] = intval($input['img_height']);
|
361 |
+
$input['div'] = wp_filter_nohtml_kses($input['div']);
|
362 |
+
|
363 |
+
return $input;
|
364 |
+
}
|
365 |
+
// this function sanitizes our image data for storage
|
366 |
+
function wp_cycle_images_validate($input) {
|
367 |
+
foreach($input as $key => $value) {
|
368 |
+
if($key != 'update') {
|
369 |
+
$input[$key]['file_url'] = clean_url($value['file_url']);
|
370 |
+
$input[$key]['thumbnail_url'] = clean_url($value['thumbnail_url']);
|
371 |
+
|
372 |
+
if($value['image_links_to'])
|
373 |
+
$input[$key]['image_links_to'] = clean_url($value['image_links_to']);
|
374 |
+
}
|
375 |
+
}
|
376 |
+
return $input;
|
377 |
+
}
|
378 |
+
|
379 |
+
/*
|
380 |
+
///////////////////////////////////////////////
|
381 |
+
this final section generates all the code that
|
382 |
+
is displayed on the front-end of the WP Theme
|
383 |
+
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
|
384 |
+
*/
|
385 |
+
function wp_cycle($args = array()) {
|
386 |
+
global $wp_cycle_settings, $wp_cycle_images;
|
387 |
+
$args = wp_parse_args($args, $wp_cycle_settings);
|
388 |
+
|
389 |
+
$newline = "\n"; // line break
|
390 |
+
|
391 |
+
echo '<div id="'.$wp_cycle_settings['div'].'">'.$newline;
|
392 |
+
|
393 |
+
foreach($wp_cycle_images as $image => $data) {
|
394 |
+
if($data['image_links_to'])
|
395 |
+
echo '<a href="'.$data['image_links_to'].'">';
|
396 |
+
|
397 |
+
echo '<img src="'.$data['file_url'].'" width="'.$wp_cycle_settings['img_width'].'" height="'.$wp_cycle_settings['img_height'].'" class="'.$data['id'].'" />';
|
398 |
+
|
399 |
+
if($data['image_links_to'])
|
400 |
+
echo '</a>';
|
401 |
+
|
402 |
+
echo $newline;
|
403 |
+
}
|
404 |
+
|
405 |
+
echo '</div>'.$newline;
|
406 |
+
}
|
407 |
+
|
408 |
+
add_action('wp_print_scripts', 'wp_cycle_scripts');
|
409 |
+
function wp_cycle_scripts() {
|
410 |
+
if(!is_admin())
|
411 |
+
wp_enqueue_script('cycle', $src = WP_CONTENT_URL.'/plugins/wp-cycle/jquery.cycle.all.min.js', $deps = array('jquery'));
|
412 |
+
}
|
413 |
+
|
414 |
+
add_action('wp_head', 'wp_cycle_head');
|
415 |
+
function wp_cycle_head() {
|
416 |
+
global $wp_cycle_settings; ?>
|
417 |
+
|
418 |
+
<?php if($wp_cycle_settings['rotate']) : ?>
|
419 |
+
<script type="text/javascript">
|
420 |
+
jQuery(document).ready(function($) {
|
421 |
+
$("#<?php echo $wp_cycle_settings['div']; ?>").cycle({
|
422 |
+
fx: '<?php echo $wp_cycle_settings['effect']; ?>',
|
423 |
+
timeout: 3000,
|
424 |
+
speed: 1000,
|
425 |
+
pause: 1,
|
426 |
+
fit: 1
|
427 |
+
});
|
428 |
+
});
|
429 |
+
</script>
|
430 |
+
<?php endif; ?>
|
431 |
+
|
432 |
+
<style type="text/css" media="screen">
|
433 |
+
#<?php echo $wp_cycle_settings['div']; ?> {
|
434 |
+
width: <?php echo $wp_cycle_settings['img_width']; ?>px;
|
435 |
+
height: <?php echo $wp_cycle_settings['img_height']?>px;
|
436 |
+
margin: 0; padding: 0;
|
437 |
+
overflow: hidden;
|
438 |
+
}
|
439 |
+
</style>
|
440 |
+
<?php }
|
441 |
+
?>
|