Slider by Nivo – Responsive WordPress Image Slider - Version 1.0.0

Version Description

  • Initial release
Download this release

Release Info

Developer dev7studios
Plugin Icon 128x128 Slider by Nivo – Responsive WordPress Image Slider
Version 1.0.0
Comparing to
See all releases

Version 1.0.0

Files changed (43) hide show
  1. assets/css/admin.css +14 -0
  2. assets/css/nivo-slider.css +115 -0
  3. assets/images/favicon.png +0 -0
  4. assets/js/admin.js +33 -0
  5. assets/js/jquery.nivo.slider.pack.js +10 -0
  6. assets/js/tinymce.js +63 -0
  7. assets/themes/bar/arrows.png +0 -0
  8. assets/themes/bar/bar.css +133 -0
  9. assets/themes/bar/bullets.png +0 -0
  10. assets/themes/bar/loading.gif +0 -0
  11. assets/themes/dark/arrows.png +0 -0
  12. assets/themes/dark/bullets.png +0 -0
  13. assets/themes/dark/dark.css +103 -0
  14. assets/themes/dark/loading.gif +0 -0
  15. assets/themes/default/arrows.png +0 -0
  16. assets/themes/default/bullets.png +0 -0
  17. assets/themes/default/default.css +94 -0
  18. assets/themes/default/loading.gif +0 -0
  19. assets/themes/light/arrows.png +0 -0
  20. assets/themes/light/bullets.png +0 -0
  21. assets/themes/light/light.css +103 -0
  22. assets/themes/light/loading.gif +0 -0
  23. changelog.txt +4 -0
  24. includes/core/README.md +11 -0
  25. includes/core/assets/css/admin.css +55 -0
  26. includes/core/assets/js/admin.js +303 -0
  27. includes/core/assets/js/image-admin.js +359 -0
  28. includes/core/includes/admin-ajax.php +305 -0
  29. includes/core/includes/admin-edit.php +512 -0
  30. includes/core/includes/admin-images.php +254 -0
  31. includes/core/includes/admin-settings.php +397 -0
  32. includes/core/includes/admin-view.php +152 -0
  33. includes/core/includes/assets.php +162 -0
  34. includes/core/includes/edd_sl_plugin_updater.php +339 -0
  35. includes/core/includes/functions.php +201 -0
  36. includes/core/includes/images.php +534 -0
  37. includes/core/includes/post-type.php +184 -0
  38. includes/core/includes/shortcode.php +317 -0
  39. includes/core/plugin.php +173 -0
  40. includes/plugin.php +829 -0
  41. license.txt +674 -0
  42. nivo-slider-lite.php +83 -0
  43. readme.txt +54 -0
assets/css/admin.css ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #nivoslider_settings_box .dev7-pro-feature {
2
+ display: block;
3
+ font-size: 13px;
4
+ font-style: normal;
5
+ margin-top: 5px;
6
+ }
7
+ #nivoslider_settings_box .dev7-pro-feature a {
8
+ font-weight: bold;
9
+ }
10
+
11
+ #nivoslider_upgrade_box ul {
12
+ list-style: disc;
13
+ margin: 0 0 20px 20px;
14
+ }
assets/css/nivo-slider.css ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * jQuery Nivo Slider v3.2
3
+ * http://nivo.dev7studios.com
4
+ *
5
+ * Copyright 2012, Dev7studios
6
+ * Free to use and abuse under the MIT license.
7
+ * http://www.opensource.org/licenses/mit-license.php
8
+ */
9
+
10
+ /* The Nivo Slider styles */
11
+ .nivoSlider {
12
+ position:relative;
13
+ width:100%;
14
+ height:auto;
15
+ overflow: hidden;
16
+ }
17
+ .nivoSlider img {
18
+ position:absolute;
19
+ top:0px;
20
+ left:0px;
21
+ max-width: none !important;
22
+ display: none;
23
+ }
24
+ .nivo-main-image {
25
+ display: block !important;
26
+ position: relative !important;
27
+ width: 100% !important;
28
+ }
29
+
30
+ /* If an image is wrapped in a link */
31
+ .nivoSlider a.nivo-imageLink {
32
+ position:absolute;
33
+ top:0px;
34
+ left:0px;
35
+ width:100%;
36
+ height:100%;
37
+ border:0;
38
+ padding:0;
39
+ margin:0;
40
+ z-index:6;
41
+ display:none;
42
+ background:white;
43
+ filter:alpha(opacity=0);
44
+ opacity:0;
45
+ }
46
+ /* The slices and boxes in the Slider */
47
+ .nivo-slice {
48
+ display:block;
49
+ position:absolute;
50
+ z-index:5;
51
+ height:100%;
52
+ top:0;
53
+ }
54
+ .nivo-box {
55
+ display:block;
56
+ position:absolute;
57
+ z-index:5;
58
+ overflow:hidden;
59
+ }
60
+ .nivo-box img { display:block; }
61
+
62
+ /* Caption styles */
63
+ .nivo-caption {
64
+ position:absolute;
65
+ left:0px;
66
+ bottom:0px;
67
+ background:#000;
68
+ color:#fff;
69
+ width:100%;
70
+ z-index:8;
71
+ padding: 5px 10px;
72
+ opacity: 0.8;
73
+ overflow: hidden;
74
+ display: none;
75
+ -moz-opacity: 0.8;
76
+ filter:alpha(opacity=8);
77
+ -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=80)";
78
+ -webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
79
+ -moz-box-sizing: border-box; /* Firefox, other Gecko */
80
+ box-sizing: border-box; /* Opera/IE 8+ */
81
+ }
82
+ .nivo-caption p {
83
+ padding:5px;
84
+ margin:0;
85
+ }
86
+ .nivo-caption a {
87
+ display:inline !important;
88
+ }
89
+ .nivo-html-caption {
90
+ display:none;
91
+ }
92
+ /* Direction nav styles (e.g. Next & Prev) */
93
+ .nivo-directionNav a {
94
+ position:absolute;
95
+ top:45%;
96
+ z-index:9;
97
+ cursor:pointer;
98
+ }
99
+ .nivo-prevNav {
100
+ left:0px;
101
+ }
102
+ .nivo-nextNav {
103
+ right:0px;
104
+ }
105
+ /* Control nav styles (e.g. 1,2,3...) */
106
+ .nivo-controlNav {
107
+ text-align:center;
108
+ padding: 15px 0;
109
+ }
110
+ .nivo-controlNav a {
111
+ cursor:pointer;
112
+ }
113
+ .nivo-controlNav a.active {
114
+ font-weight:bold;
115
+ }
assets/images/favicon.png ADDED
Binary file
assets/js/admin.js ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready(function($){
2
+
3
+ var proFeatureDesc = $('.manual.description' ).find('.dev7-pro-feature');
4
+ $('.manual.description' ).html('').append(proFeatureDesc);
5
+
6
+ /**
7
+ * Nivo Themes
8
+ *
9
+ *
10
+ **/
11
+
12
+ $('select[name="nivo_settings[theme]"]').change(function(){
13
+ nivo_theme_thumbs_enabled();
14
+ });
15
+
16
+ nivo_theme_thumbs_enabled();
17
+
18
+ function nivo_theme_thumbs_enabled(){
19
+ var current_theme = $('select[name="nivo_settings[theme]"] option:selected').val();
20
+ var controlNavThumbs = $('input[name="nivo_settings[controlNavThumbs]"]');
21
+
22
+ $('.dev7_thumb_nav,.dev7_thumb_size').show();
23
+ if(dev7plugin.themes[current_theme] != undefined){
24
+ if(dev7plugin.themes[current_theme].theme_details.SupportsThumbs == 'false'){
25
+ controlNavThumbs.attr('checked', false);
26
+ $('.dev7_thumb_nav,.dev7_thumb_size').hide();
27
+ }
28
+ }
29
+
30
+ }
31
+
32
+
33
+ });
assets/js/jquery.nivo.slider.pack.js ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * jQuery Nivo Slider v3.2
3
+ * http://nivo.dev7studios.com
4
+ *
5
+ * Copyright 2012, Dev7studios
6
+ * Free to use and abuse under the MIT license.
7
+ * http://www.opensource.org/licenses/mit-license.php
8
+ */
9
+
10
+ (function(e){var t=function(t,n){var r=e.extend({},e.fn.nivoSlider.defaults,n);var i={currentSlide:0,currentImage:"",totalSlides:0,running:false,paused:false,stop:false,controlNavEl:false};var s=e(t);s.data("nivo:vars",i).addClass("nivoSlider");var o=s.children();o.each(function(){var t=e(this);var n="";if(!t.is("img")){if(t.is("a")){t.addClass("nivo-imageLink");n=t}t=t.find("img:first")}var r=r===0?t.attr("width"):t.width(),s=s===0?t.attr("height"):t.height();if(n!==""){n.css("display","none")}t.css("display","none");i.totalSlides++});if(r.randomStart){r.startSlide=Math.floor(Math.random()*i.totalSlides)}if(r.startSlide>0){if(r.startSlide>=i.totalSlides){r.startSlide=i.totalSlides-1}i.currentSlide=r.startSlide}if(e(o[i.currentSlide]).is("img")){i.currentImage=e(o[i.currentSlide])}else{i.currentImage=e(o[i.currentSlide]).find("img:first")}if(e(o[i.currentSlide]).is("a")){e(o[i.currentSlide]).css("display","block")}var u=e("<img/>").addClass("nivo-main-image");u.attr("src",i.currentImage.attr("src")).show();s.append(u);e(window).resize(function(){s.children("img").width(s.width());u.attr("src",i.currentImage.attr("src"));u.stop().height("auto");e(".nivo-slice").remove();e(".nivo-box").remove()});s.append(e('<div class="nivo-caption"></div>'));var a=function(t){var n=e(".nivo-caption",s);if(i.currentImage.attr("title")!=""&&i.currentImage.attr("title")!=undefined){var r=i.currentImage.attr("title");if(r.substr(0,1)=="#")r=e(r).html();if(n.css("display")=="block"){setTimeout(function(){n.html(r)},t.animSpeed)}else{n.html(r);n.stop().fadeIn(t.animSpeed)}}else{n.stop().fadeOut(t.animSpeed)}};a(r);var f=0;if(!r.manualAdvance&&o.length>1){f=setInterval(function(){d(s,o,r,false)},r.pauseTime)}if(r.directionNav){s.append('<div class="nivo-directionNav"><a class="nivo-prevNav">'+r.prevText+'</a><a class="nivo-nextNav">'+r.nextText+"</a></div>");e(s).on("click","a.nivo-prevNav",function(){if(i.running){return false}clearInterval(f);f="";i.currentSlide-=2;d(s,o,r,"prev")});e(s).on("click","a.nivo-nextNav",function(){if(i.running){return false}clearInterval(f);f="";d(s,o,r,"next")})}if(r.controlNav){i.controlNavEl=e('<div class="nivo-controlNav"></div>');s.after(i.controlNavEl);for(var l=0;l<o.length;l++){if(r.controlNavThumbs){i.controlNavEl.addClass("nivo-thumbs-enabled");var c=o.eq(l);if(!c.is("img")){c=c.find("img:first")}if(c.attr("data-thumb"))i.controlNavEl.append('<a class="nivo-control" rel="'+l+'"><img src="'+c.attr("data-thumb")+'" alt="" /></a>')}else{i.controlNavEl.append('<a class="nivo-control" rel="'+l+'">'+(l+1)+"</a>")}}e("a:eq("+i.currentSlide+")",i.controlNavEl).addClass("active");e("a",i.controlNavEl).bind("click",function(){if(i.running)return false;if(e(this).hasClass("active"))return false;clearInterval(f);f="";u.attr("src",i.currentImage.attr("src"));i.currentSlide=e(this).attr("rel")-1;d(s,o,r,"control")})}if(r.pauseOnHover){s.hover(function(){i.paused=true;clearInterval(f);f=""},function(){i.paused=false;if(f===""&&!r.manualAdvance){f=setInterval(function(){d(s,o,r,false)},r.pauseTime)}})}s.bind("nivo:animFinished",function(){u.attr("src",i.currentImage.attr("src"));i.running=false;e(o).each(function(){if(e(this).is("a")){e(this).css("display","none")}});if(e(o[i.currentSlide]).is("a")){e(o[i.currentSlide]).css("display","block")}if(f===""&&!i.paused&&!r.manualAdvance){f=setInterval(function(){d(s,o,r,false)},r.pauseTime)}r.afterChange.call(this)});var h=function(t,n,r){if(e(r.currentImage).parent().is("a"))e(r.currentImage).parent().css("display","block");e('img[src="'+r.currentImage.attr("src")+'"]',t).not(".nivo-main-image,.nivo-control img").width(t.width()).css("visibility","hidden").show();var i=e('img[src="'+r.currentImage.attr("src")+'"]',t).not(".nivo-main-image,.nivo-control img").parent().is("a")?e('img[src="'+r.currentImage.attr("src")+'"]',t).not(".nivo-main-image,.nivo-control img").parent().height():e('img[src="'+r.currentImage.attr("src")+'"]',t).not(".nivo-main-image,.nivo-control img").height();for(var s=0;s<n.slices;s++){var o=Math.round(t.width()/n.slices);if(s===n.slices-1){t.append(e('<div class="nivo-slice" name="'+s+'"><img src="'+r.currentImage.attr("src")+'" style="position:absolute; width:'+t.width()+"px; height:auto; display:block !important; top:0; left:-"+(o+s*o-o)+'px;" /></div>').css({left:o*s+"px",width:t.width()-o*s+"px",height:i+"px",opacity:"0",overflow:"hidden"}))}else{t.append(e('<div class="nivo-slice" name="'+s+'"><img src="'+r.currentImage.attr("src")+'" style="position:absolute; width:'+t.width()+"px; height:auto; display:block !important; top:0; left:-"+(o+s*o-o)+'px;" /></div>').css({left:o*s+"px",width:o+"px",height:i+"px",opacity:"0",overflow:"hidden"}))}}e(".nivo-slice",t).height(i);u.stop().animate({height:e(r.currentImage).height()},n.animSpeed)};var p=function(t,n,r){if(e(r.currentImage).parent().is("a"))e(r.currentImage).parent().css("display","block");e('img[src="'+r.currentImage.attr("src")+'"]',t).not(".nivo-main-image,.nivo-control img").width(t.width()).css("visibility","hidden").show();var i=Math.round(t.width()/n.boxCols),s=Math.round(e('img[src="'+r.currentImage.attr("src")+'"]',t).not(".nivo-main-image,.nivo-control img").height()/n.boxRows);for(var o=0;o<n.boxRows;o++){for(var a=0;a<n.boxCols;a++){if(a===n.boxCols-1){t.append(e('<div class="nivo-box" name="'+a+'" rel="'+o+'"><img src="'+r.currentImage.attr("src")+'" style="position:absolute; width:'+t.width()+"px; height:auto; display:block; top:-"+s*o+"px; left:-"+i*a+'px;" /></div>').css({opacity:0,left:i*a+"px",top:s*o+"px",width:t.width()-i*a+"px"}));e('.nivo-box[name="'+a+'"]',t).height(e('.nivo-box[name="'+a+'"] img',t).height()+"px")}else{t.append(e('<div class="nivo-box" name="'+a+'" rel="'+o+'"><img src="'+r.currentImage.attr("src")+'" style="position:absolute; width:'+t.width()+"px; height:auto; display:block; top:-"+s*o+"px; left:-"+i*a+'px;" /></div>').css({opacity:0,left:i*a+"px",top:s*o+"px",width:i+"px"}));e('.nivo-box[name="'+a+'"]',t).height(e('.nivo-box[name="'+a+'"] img',t).height()+"px")}}}u.stop().animate({height:e(r.currentImage).height()},n.animSpeed)};var d=function(t,n,r,i){var s=t.data("nivo:vars");if(s&&s.currentSlide===s.totalSlides-1){r.lastSlide.call(this)}if((!s||s.stop)&&!i){return false}r.beforeChange.call(this);if(!i){u.attr("src",s.currentImage.attr("src"))}else{if(i==="prev"){u.attr("src",s.currentImage.attr("src"))}if(i==="next"){u.attr("src",s.currentImage.attr("src"))}}s.currentSlide++;if(s.currentSlide===s.totalSlides){s.currentSlide=0;r.slideshowEnd.call(this)}if(s.currentSlide<0){s.currentSlide=s.totalSlides-1}if(e(n[s.currentSlide]).is("img")){s.currentImage=e(n[s.currentSlide])}else{s.currentImage=e(n[s.currentSlide]).find("img:first")}if(r.controlNav){e("a",s.controlNavEl).removeClass("active");e("a:eq("+s.currentSlide+")",s.controlNavEl).addClass("active")}a(r);e(".nivo-slice",t).remove();e(".nivo-box",t).remove();var o=r.effect,f="";if(r.effect==="random"){f=new Array("sliceDownRight","sliceDownLeft","sliceUpRight","sliceUpLeft","sliceUpDown","sliceUpDownLeft","fold","fade","boxRandom","boxRain","boxRainReverse","boxRainGrow","boxRainGrowReverse");o=f[Math.floor(Math.random()*(f.length+1))];if(o===undefined){o="fade"}}if(r.effect.indexOf(",")!==-1){f=r.effect.split(",");o=f[Math.floor(Math.random()*f.length)];if(o===undefined){o="fade"}}if(s.currentImage.attr("data-transition")){o=s.currentImage.attr("data-transition")}s.running=true;var l=0,c=0,d="",m="",g="",y="";if(o==="sliceDown"||o==="sliceDownRight"||o==="sliceDownLeft"){h(t,r,s);l=0;c=0;d=e(".nivo-slice",t);if(o==="sliceDownLeft"){d=e(".nivo-slice",t)._reverse()}d.each(function(){var n=e(this);n.css({top:"0px"});if(c===r.slices-1){setTimeout(function(){n.animate({opacity:"1.0"},r.animSpeed,"",function(){t.trigger("nivo:animFinished")})},100+l)}else{setTimeout(function(){n.animate({opacity:"1.0"},r.animSpeed)},100+l)}l+=50;c++})}else if(o==="sliceUp"||o==="sliceUpRight"||o==="sliceUpLeft"){h(t,r,s);l=0;c=0;d=e(".nivo-slice",t);if(o==="sliceUpLeft"){d=e(".nivo-slice",t)._reverse()}d.each(function(){var n=e(this);n.css({bottom:"0px"});if(c===r.slices-1){setTimeout(function(){n.animate({opacity:"1.0"},r.animSpeed,"",function(){t.trigger("nivo:animFinished")})},100+l)}else{setTimeout(function(){n.animate({opacity:"1.0"},r.animSpeed)},100+l)}l+=50;c++})}else if(o==="sliceUpDown"||o==="sliceUpDownRight"||o==="sliceUpDownLeft"){h(t,r,s);l=0;c=0;var b=0;d=e(".nivo-slice",t);if(o==="sliceUpDownLeft"){d=e(".nivo-slice",t)._reverse()}d.each(function(){var n=e(this);if(c===0){n.css("top","0px");c++}else{n.css("bottom","0px");c=0}if(b===r.slices-1){setTimeout(function(){n.animate({opacity:"1.0"},r.animSpeed,"",function(){t.trigger("nivo:animFinished")})},100+l)}else{setTimeout(function(){n.animate({opacity:"1.0"},r.animSpeed)},100+l)}l+=50;b++})}else if(o==="fold"){h(t,r,s);l=0;c=0;e(".nivo-slice",t).each(function(){var n=e(this);var i=n.width();n.css({top:"0px",width:"0px"});if(c===r.slices-1){setTimeout(function(){n.animate({width:i,opacity:"1.0"},r.animSpeed,"",function(){t.trigger("nivo:animFinished")})},100+l)}else{setTimeout(function(){n.animate({width:i,opacity:"1.0"},r.animSpeed)},100+l)}l+=50;c++})}else if(o==="fade"){h(t,r,s);m=e(".nivo-slice:first",t);m.css({width:t.width()+"px"});m.animate({opacity:"1.0"},r.animSpeed*2,"",function(){t.trigger("nivo:animFinished")})}else if(o==="slideInRight"){h(t,r,s);m=e(".nivo-slice:first",t);m.css({width:"0px",opacity:"1"});m.animate({width:t.width()+"px"},r.animSpeed*2,"",function(){t.trigger("nivo:animFinished")})}else if(o==="slideInLeft"){h(t,r,s);m=e(".nivo-slice:first",t);m.css({width:"0px",opacity:"1",left:"",right:"0px"});m.animate({width:t.width()+"px"},r.animSpeed*2,"",function(){m.css({left:"0px",right:""});t.trigger("nivo:animFinished")})}else if(o==="boxRandom"){p(t,r,s);g=r.boxCols*r.boxRows;c=0;l=0;y=v(e(".nivo-box",t));y.each(function(){var n=e(this);if(c===g-1){setTimeout(function(){n.animate({opacity:"1"},r.animSpeed,"",function(){t.trigger("nivo:animFinished")})},100+l)}else{setTimeout(function(){n.animate({opacity:"1"},r.animSpeed)},100+l)}l+=20;c++})}else if(o==="boxRain"||o==="boxRainReverse"||o==="boxRainGrow"||o==="boxRainGrowReverse"){p(t,r,s);g=r.boxCols*r.boxRows;c=0;l=0;var w=0;var E=0;var S=[];S[w]=[];y=e(".nivo-box",t);if(o==="boxRainReverse"||o==="boxRainGrowReverse"){y=e(".nivo-box",t)._reverse()}y.each(function(){S[w][E]=e(this);E++;if(E===r.boxCols){w++;E=0;S[w]=[]}});for(var x=0;x<r.boxCols*2;x++){var T=x;for(var N=0;N<r.boxRows;N++){if(T>=0&&T<r.boxCols){(function(n,i,s,u,a){var f=e(S[n][i]);var l=f.width();var c=f.height();if(o==="boxRainGrow"||o==="boxRainGrowReverse"){f.width(0).height(0)}if(u===a-1){setTimeout(function(){f.animate({opacity:"1",width:l,height:c},r.animSpeed/1.3,"",function(){t.trigger("nivo:animFinished")})},100+s)}else{setTimeout(function(){f.animate({opacity:"1",width:l,height:c},r.animSpeed/1.3)},100+s)}})(N,T,l,c,g);c++}T--}l+=100}}};var v=function(e){for(var t,n,r=e.length;r;t=parseInt(Math.random()*r,10),n=e[--r],e[r]=e[t],e[t]=n);return e};var m=function(e){if(this.console&&typeof console.log!=="undefined"){console.log(e)}};this.stop=function(){if(!e(t).data("nivo:vars").stop){e(t).data("nivo:vars").stop=true;m("Stop Slider")}};this.start=function(){if(e(t).data("nivo:vars").stop){e(t).data("nivo:vars").stop=false;m("Start Slider")}};r.afterLoad.call(this);return this};e.fn.nivoSlider=function(n){return this.each(function(r,i){var s=e(this);if(s.data("nivoslider")){return s.data("nivoslider")}var o=new t(this,n);s.data("nivoslider",o)})};e.fn.nivoSlider.defaults={effect:"random",slices:15,boxCols:8,boxRows:4,animSpeed:500,pauseTime:3e3,startSlide:0,directionNav:true,controlNav:true,controlNavThumbs:false,pauseOnHover:true,manualAdvance:false,prevText:"Prev",nextText:"Next",randomStart:false,beforeChange:function(){},afterChange:function(){},slideshowEnd:function(){},lastSlide:function(){},afterLoad:function(){}};e.fn._reverse=[].reverse})(jQuery)
assets/js/tinymce.js ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function() {
2
+ tinymce.create('tinymce.plugins.nivoslider', {
3
+ init : function( editor ) {
4
+ editor.addButton('nivoslider', function() {
5
+ var galleries = nivoslider.galleries;
6
+ galleries = jQuery.parseJSON(galleries);
7
+
8
+ var items = []
9
+ for(var i in galleries){
10
+ items.push({
11
+ text: galleries[i].name,
12
+ value: galleries[i].id
13
+ });
14
+ }
15
+
16
+ return {
17
+ type: 'listbox',
18
+ text: 'Nivo Sliders',
19
+ values: items,
20
+ fixedWidth: true,
21
+ onselect: function(v) {
22
+ if(v != ''){
23
+ editor.insertContent( '[nivoslider id="' + this.value() + '"]' );
24
+ }
25
+ return false;
26
+ }
27
+ };
28
+ });
29
+ },
30
+ createControl : function(n, cm) {
31
+ switch (n) {
32
+ case 'nivoslider':
33
+ var mlb = cm.createListBox( 'nivoslider' , {
34
+ title : 'Nivo Sliders',
35
+ onselect : function(v) {
36
+ if(v != ''){
37
+ tinyMCE.execCommand('mceInsertContent', false, '[nivoslider id="' + v + '"]');
38
+ }
39
+ return false;
40
+ }
41
+ });
42
+ var galleries = nivoslider.galleries;
43
+ galleries = jQuery.parseJSON(galleries);
44
+ for(var i in galleries){
45
+ mlb.add(galleries[i].name, galleries[i].id);
46
+ }
47
+ return mlb;
48
+ }
49
+ return null;
50
+ },
51
+ getInfo : function() {
52
+ return {
53
+ longname : 'Nivo Slider Shortcode',
54
+ author : 'Dev7studios',
55
+ authorurl : 'http://www.dev7studios.me',
56
+ infourl : 'http://www.dev7studios.com/plugins/nivo-slider',
57
+ version : '1.0'
58
+ };
59
+ }
60
+ });
61
+ tinymce.PluginManager.add( 'nivoslider', tinymce.plugins.nivoslider);
62
+ })();
63
+
assets/themes/bar/arrows.png ADDED
Binary file
assets/themes/bar/bar.css ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Skin Name: Nivo Slider Bar Theme
3
+ Skin URI: http://nivo.dev7studios.com
4
+ Description: The bottom bar skin for the Nivo Slider.
5
+ Version: 1.0
6
+ Author: Gilbert Pellegrom
7
+ Author URI: http://dev7studios.com
8
+ Supports Thumbs: false
9
+ */
10
+
11
+ .theme-bar.slider-wrapper {
12
+ position: relative;
13
+ border: 1px solid #333;
14
+ overflow: hidden;
15
+ }
16
+ .theme-bar .nivoSlider {
17
+ position:relative;
18
+ background:#fff url(loading.gif) no-repeat 50% 50%;
19
+ }
20
+ .theme-bar .nivoSlider img {
21
+ position:absolute;
22
+ top:0px;
23
+ left:0px;
24
+ display:none;
25
+ max-width: none !important;
26
+ }
27
+ .theme-bar .nivoSlider a {
28
+ border:0;
29
+ display:block;
30
+ }
31
+
32
+ .theme-bar .nivo-controlNav {
33
+ position: absolute;
34
+ left: 0;
35
+ bottom: -41px;
36
+ z-index: 10;
37
+ width: 100%;
38
+ height: 30px;
39
+ text-align: center;
40
+ padding: 5px 0;
41
+ border-top: 1px solid #333;
42
+ background: #333;
43
+ background: -moz-linear-gradient(top, #565656 0%, #333333 100%); /* FF3.6+ */
44
+ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#565656), color-stop(100%,#333333)); /* Chrome,Safari4+ */
45
+ background: -webkit-linear-gradient(top, #565656 0%,#333333 100%); /* Chrome10+,Safari5.1+ */
46
+ background: -o-linear-gradient(top, #565656 0%,#333333 100%); /* Opera 11.10+ */
47
+ background: -ms-linear-gradient(top, #565656 0%,#333333 100%); /* IE10+ */
48
+ background: linear-gradient(to bottom, #565656 0%,#333333 100%); /* W3C */
49
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#565656', endColorstr='#333333',GradientType=0 ); /* IE6-9 */
50
+ opacity: 0.5;
51
+ -webkit-transition: all 200ms ease-in-out;
52
+ -moz-transition: all 200ms ease-in-out;
53
+ -o-transition: all 200ms ease-in-out;
54
+ transition: all 200ms ease-in-out;
55
+ }
56
+ .theme-bar:hover .nivo-controlNav {
57
+ bottom: 0;
58
+ opacity: 1;
59
+ }
60
+ .theme-bar .nivo-controlNav a {
61
+ display:inline-block;
62
+ width:22px;
63
+ height:22px;
64
+ background:url(bullets.png) no-repeat;
65
+ text-indent:-9999px;
66
+ border:0;
67
+ margin: 5px 2px 0 2px;
68
+ }
69
+ .theme-bar .nivo-controlNav a.active {
70
+ background-position:0 -22px;
71
+ }
72
+
73
+ .theme-bar .nivo-directionNav a {
74
+ display:block;
75
+ border:0;
76
+ color: #fff;
77
+ text-transform: uppercase;
78
+ top: auto;
79
+ bottom: 10px;
80
+ z-index: 11;
81
+ font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
82
+ font-size: 13px;
83
+ line-height: 20px;
84
+ opacity: 0.5;
85
+ -webkit-transition: all 200ms ease-in-out;
86
+ -moz-transition: all 200ms ease-in-out;
87
+ -o-transition: all 200ms ease-in-out;
88
+ transition: all 200ms ease-in-out;
89
+ }
90
+ .theme-bar a.nivo-nextNav { right: -50px; }
91
+ .theme-bar a.nivo-prevNav { left: -50px; }
92
+ .theme-bar:hover a.nivo-nextNav {
93
+ right: 15px;
94
+ opacity: 1;
95
+ }
96
+ .theme-bar:hover a.nivo-prevNav {
97
+ left: 15px;
98
+ opacity: 1;
99
+ }
100
+ .theme-bar .nivo-directionNav a:hover { color: #ddd; }
101
+
102
+ .theme-bar .nivo-caption {
103
+ font-family: Helvetica, Arial, sans-serif;
104
+ -webkit-transition: all 200ms ease-in-out;
105
+ -moz-transition: all 200ms ease-in-out;
106
+ -o-transition: all 200ms ease-in-out;
107
+ transition: all 200ms ease-in-out;
108
+ }
109
+ .theme-bar:hover .nivo-caption {
110
+ bottom: 41px;
111
+ }
112
+ .theme-bar .nivo-caption a {
113
+ color:#fff;
114
+ border-bottom:1px dotted #fff;
115
+ }
116
+ .theme-bar .nivo-caption a:hover {
117
+ color:#fff;
118
+ }
119
+
120
+ .theme-bar .nivo-controlNav.nivo-thumbs-enabled {
121
+ width: 100%;
122
+ }
123
+ .theme-bar .nivo-controlNav.nivo-thumbs-enabled a {
124
+ width: auto;
125
+ height: auto;
126
+ background: none;
127
+ margin-bottom: 5px;
128
+ }
129
+ .theme-bar .nivo-controlNav.nivo-thumbs-enabled img {
130
+ display: block;
131
+ width: 120px;
132
+ height: auto;
133
+ }
assets/themes/bar/bullets.png ADDED
Binary file
assets/themes/bar/loading.gif ADDED
Binary file
assets/themes/dark/arrows.png ADDED
Binary file
assets/themes/dark/bullets.png ADDED
Binary file
assets/themes/dark/dark.css ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Skin Name: Nivo Slider Dark Theme
3
+ Skin URI: http://nivo.dev7studios.com
4
+ Description: A dark skin for the Nivo Slider.
5
+ Version: 1.0
6
+ Author: Gilbert Pellegrom
7
+ Author URI: http://dev7studios.com
8
+ Supports Thumbs: true
9
+ */
10
+
11
+ .theme-dark.slider-wrapper {
12
+ background: #222;
13
+ padding: 10px;
14
+ }
15
+ .theme-dark .nivoSlider {
16
+ position:relative;
17
+ background:#fff url(loading.gif) no-repeat 50% 50%;
18
+ margin-bottom:10px;
19
+ overflow: visible;
20
+ }
21
+ .theme-dark .nivoSlider img {
22
+ position:absolute;
23
+ top:0px;
24
+ left:0px;
25
+ display:none;
26
+ max-width: none !important;
27
+ }
28
+ .theme-dark .nivoSlider a {
29
+ border:0;
30
+ display:block;
31
+ }
32
+
33
+ .theme-dark .nivo-controlNav {
34
+ text-align: left;
35
+ padding: 0;
36
+ position: relative;
37
+ z-index: 10;
38
+ }
39
+ .theme-dark .nivo-controlNav a {
40
+ display:inline-block;
41
+ width:10px;
42
+ height:10px;
43
+ background:url(bullets.png) no-repeat 0 2px;
44
+ text-indent:-9999px;
45
+ border:0;
46
+ margin: 0 2px;
47
+ }
48
+ .theme-dark .nivo-controlNav a.active {
49
+ background-position:0 100%;
50
+ }
51
+
52
+ .theme-dark .nivo-directionNav a {
53
+ display:block;
54
+ width:30px;
55
+ height:30px;
56
+ background: url(arrows.png) no-repeat;
57
+ text-indent:-9999px;
58
+ border:0;
59
+ top: auto;
60
+ bottom: -36px;
61
+ z-index: 11;
62
+ }
63
+ .theme-dark .nivo-directionNav a:hover {
64
+ background-color: #333;
65
+ -webkit-border-radius: 2px;
66
+ -moz-border-radius: 2px;
67
+ border-radius: 2px;
68
+ }
69
+ .theme-dark a.nivo-nextNav {
70
+ background-position:-16px 50%;
71
+ right:0px;
72
+ }
73
+ .theme-dark a.nivo-prevNav {
74
+ background-position:11px 50%;
75
+ left: auto;
76
+ right: 35px;
77
+ }
78
+
79
+ .theme-dark .nivo-caption {
80
+ font-family: Helvetica, Arial, sans-serif;
81
+ }
82
+ .theme-dark .nivo-caption a {
83
+ color:#fff;
84
+ border-bottom:1px dotted #fff;
85
+ }
86
+ .theme-dark .nivo-caption a:hover {
87
+ color:#fff;
88
+ }
89
+
90
+ .theme-dark .nivo-controlNav.nivo-thumbs-enabled {
91
+ width: 80%;
92
+ }
93
+ .theme-dark .nivo-controlNav.nivo-thumbs-enabled a {
94
+ width: auto;
95
+ height: auto;
96
+ background: none;
97
+ margin-bottom: 5px;
98
+ }
99
+ .theme-dark .nivo-controlNav.nivo-thumbs-enabled img {
100
+ display: block;
101
+ width: 120px;
102
+ height: auto;
103
+ }
assets/themes/dark/loading.gif ADDED
Binary file
assets/themes/default/arrows.png ADDED
Binary file
assets/themes/default/bullets.png ADDED
Binary file
assets/themes/default/default.css ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Skin Name: Nivo Slider Default Theme
3
+ Skin URI: http://nivo.dev7studios.com
4
+ Description: The default skin for the Nivo Slider.
5
+ Version: 1.3
6
+ Author: Gilbert Pellegrom
7
+ Author URI: http://dev7studios.com
8
+ Supports Thumbs: true
9
+ */
10
+
11
+ .theme-default .nivoSlider {
12
+ position:relative;
13
+ background:#fff url(loading.gif) no-repeat 50% 50%;
14
+ margin-bottom:10px;
15
+ -webkit-box-shadow: 0px 1px 5px 0px #4a4a4a;
16
+ -moz-box-shadow: 0px 1px 5px 0px #4a4a4a;
17
+ box-shadow: 0px 1px 5px 0px #4a4a4a;
18
+ }
19
+ .theme-default .nivoSlider img {
20
+ position:absolute;
21
+ top:0px;
22
+ left:0px;
23
+ display:none;
24
+ max-width: none !important;
25
+ }
26
+ .theme-default .nivoSlider a {
27
+ border:0;
28
+ display:block;
29
+ }
30
+
31
+ .theme-default .nivo-controlNav {
32
+ text-align: center;
33
+ padding: 20px 0;
34
+ }
35
+ .theme-default .nivo-controlNav a {
36
+ display:inline-block;
37
+ width:22px;
38
+ height:22px;
39
+ background:url(bullets.png) no-repeat;
40
+ text-indent:-9999px;
41
+ border:0;
42
+ margin: 0 2px;
43
+ }
44
+ .theme-default .nivo-controlNav a.active {
45
+ background-position:0 -22px;
46
+ }
47
+
48
+ .theme-default .nivo-directionNav a {
49
+ display:block;
50
+ width:30px;
51
+ height:30px;
52
+ background:url(arrows.png) no-repeat;
53
+ text-indent:-9999px;
54
+ border:0;
55
+ opacity: 0;
56
+ -webkit-transition: all 200ms ease-in-out;
57
+ -moz-transition: all 200ms ease-in-out;
58
+ -o-transition: all 200ms ease-in-out;
59
+ transition: all 200ms ease-in-out;
60
+ }
61
+ .theme-default:hover .nivo-directionNav a { opacity: 1; }
62
+ .theme-default a.nivo-nextNav {
63
+ background-position:-30px 0;
64
+ right:15px;
65
+ }
66
+ .theme-default a.nivo-prevNav {
67
+ left:15px;
68
+ }
69
+
70
+ .theme-default .nivo-caption {
71
+ font-family: Helvetica, Arial, sans-serif;
72
+ }
73
+ .theme-default .nivo-caption a {
74
+ color:#fff;
75
+ border-bottom:1px dotted #fff;
76
+ }
77
+ .theme-default .nivo-caption a:hover {
78
+ color:#fff;
79
+ }
80
+
81
+ .theme-default .nivo-controlNav.nivo-thumbs-enabled {
82
+ width: 100%;
83
+ }
84
+ .theme-default .nivo-controlNav.nivo-thumbs-enabled a {
85
+ width: auto;
86
+ height: auto;
87
+ background: none;
88
+ margin-bottom: 5px;
89
+ }
90
+ .theme-default .nivo-controlNav.nivo-thumbs-enabled img {
91
+ display: block;
92
+ width: 120px;
93
+ height: auto;
94
+ }
assets/themes/default/loading.gif ADDED
Binary file
assets/themes/light/arrows.png ADDED
Binary file
assets/themes/light/bullets.png ADDED
Binary file
assets/themes/light/light.css ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Skin Name: Nivo Slider Light Theme
3
+ Skin URI: http://nivo.dev7studios.com
4
+ Description: A light skin for the Nivo Slider.
5
+ Version: 1.0
6
+ Author: Gilbert Pellegrom
7
+ Author URI: http://dev7studios.com
8
+ Supports Thumbs: true
9
+ */
10
+
11
+ .theme-light.slider-wrapper {
12
+ background: #fff;
13
+ padding: 10px;
14
+ }
15
+ .theme-light .nivoSlider {
16
+ position:relative;
17
+ background:#fff url(loading.gif) no-repeat 50% 50%;
18
+ margin-bottom:10px;
19
+ overflow: visible;
20
+ }
21
+ .theme-light .nivoSlider img {
22
+ position:absolute;
23
+ top:0px;
24
+ left:0px;
25
+ display:none;
26
+ max-width: none !important;
27
+ }
28
+ .theme-light .nivoSlider a {
29
+ border:0;
30
+ display:block;
31
+ }
32
+
33
+ .theme-light .nivo-controlNav {
34
+ text-align: left;
35
+ padding: 0;
36
+ position: relative;
37
+ z-index: 10;
38
+ }
39
+ .theme-light .nivo-controlNav a {
40
+ display:inline-block;
41
+ width:10px;
42
+ height:10px;
43
+ background:url(bullets.png) no-repeat;
44
+ text-indent:-9999px;
45
+ border:0;
46
+ margin: 0 2px;
47
+ }
48
+ .theme-light .nivo-controlNav a.active {
49
+ background-position:0 100%;
50
+ }
51
+
52
+ .theme-light .nivo-directionNav a {
53
+ display:block;
54
+ width:30px;
55
+ height:30px;
56
+ background: url(arrows.png) no-repeat;
57
+ text-indent:-9999px;
58
+ border:0;
59
+ top: auto;
60
+ bottom: -36px;
61
+ z-index: 11;
62
+ }
63
+ .theme-light .nivo-directionNav a:hover {
64
+ background-color: #eee;
65
+ -webkit-border-radius: 2px;
66
+ -moz-border-radius: 2px;
67
+ border-radius: 2px;
68
+ }
69
+ .theme-light a.nivo-nextNav {
70
+ background-position:160% 50%;
71
+ right:0px;
72
+ }
73
+ .theme-light a.nivo-prevNav {
74
+ background-position:-60% 50%;
75
+ left: auto;
76
+ right: 35px;
77
+ }
78
+
79
+ .theme-light .nivo-caption {
80
+ font-family: Helvetica, Arial, sans-serif;
81
+ }
82
+ .theme-light .nivo-caption a {
83
+ color:#fff;
84
+ border-bottom:1px dotted #fff;
85
+ }
86
+ .theme-light .nivo-caption a:hover {
87
+ color:#fff;
88
+ }
89
+
90
+ .theme-light .nivo-controlNav.nivo-thumbs-enabled {
91
+ width: 80%;
92
+ }
93
+ .theme-light .nivo-controlNav.nivo-thumbs-enabled a {
94
+ width: auto;
95
+ height: auto;
96
+ background: none;
97
+ margin-bottom: 5px;
98
+ }
99
+ .theme-light .nivo-controlNav.nivo-thumbs-enabled img {
100
+ display: block;
101
+ width: 120px;
102
+ height: auto;
103
+ }
assets/themes/light/loading.gif ADDED
Binary file
changelog.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ *** Nivo Slider Lite WordPress Plugin Changelog ***
2
+
3
+ 2015.09.15 - version 1.0.0
4
+ * Initial release
includes/core/README.md ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ ### Add plugin-core to Dev7studios Plugin
2
+
3
+ ```
4
+ git subtree add --prefix includes/core https://github.com/Dev7studios/plugin-core.git master --squash
5
+ ```
6
+
7
+ ### Update plugin-core from within Dev7studios Plugin
8
+
9
+ ```
10
+ git subtree pull --prefix includes/core https://github.com/Dev7studios/plugin-core.git master --squash -m "Update plugin-core"
11
+ ```
includes/core/assets/css/admin.css ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #edit-slug-box,
2
+ #postimagediv,
3
+ #minor-publishing,
4
+ .dev7_type,
5
+ .manual.description{
6
+ display:none;
7
+ }
8
+
9
+ .useful-links a {
10
+ float: right;
11
+ }
12
+
13
+ .dev7plugin-images li {
14
+ display: inline-block;
15
+ margin: 0;
16
+ position: relative;
17
+ }
18
+
19
+ .dev7plugin-images li .spinner {
20
+ float: left;
21
+ display: block;
22
+ }
23
+
24
+ .dev7plugin-images li img {
25
+ background: none repeat scroll 0 0 #FFFFFF;
26
+ border: 1px solid #DFDFDF;
27
+ margin: 0 10px 10px 0;
28
+ padding: 3px;
29
+ }
30
+
31
+ .dev7plugin-thumbs {
32
+ list-style: none outside none;
33
+ margin: 0;
34
+ padding: 3px 0 0;
35
+ }
36
+
37
+ .dev7plugin-thumbs li {
38
+ display: inline-block;
39
+ margin: 0;
40
+ position: relative;
41
+ }
42
+
43
+ .dev7plugin-thumbs li img {
44
+ background: none repeat scroll 0 0 #FFFFFF;
45
+ border: 1px solid #DFDFDF;
46
+ margin: 0 10px 5px 0;
47
+ padding: 2px;
48
+ }
49
+
50
+ #dev7license .spinner,
51
+ #dev7license #deactivate-license,
52
+ #dev7license #activate-license,
53
+ .reattach-spinner {
54
+ float: left;
55
+ }
includes/core/assets/js/admin.js ADDED
@@ -0,0 +1,303 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready(function($){
2
+
3
+ function get_image_source_setting() {
4
+ return $('select[name="' + dev7plugin.labels.post_meta_key + '[' + dev7plugin.labels.source_name + ']"] option:selected').val();
5
+ }
6
+
7
+ // Edit screen Images
8
+ if (dev7plugin.post_id != '') {
9
+ load_image_source(); // Initial load
10
+ }
11
+
12
+ $('select[name="' + dev7plugin.labels.post_meta_key + '[' + dev7plugin.labels.source_name + ']"]').change(function(){
13
+ load_image_source();
14
+ display_params();
15
+ });
16
+
17
+ $('select[name="' + dev7plugin.labels.post_meta_key + '[' + dev7plugin.labels.type_name + '_gallery]"]').change(function(){
18
+ load_image_source();
19
+ });
20
+
21
+ $('select[name="' + dev7plugin.labels.post_meta_key + '[' + dev7plugin.labels.type_name + '_category]"]').change(function(){
22
+ load_image_source();
23
+ });
24
+
25
+ function escapeHTML (unsafe_str) {
26
+ return unsafe_str
27
+ .replace(/&/g, '&amp;')
28
+ .replace(/</g, '&lt;')
29
+ .replace(/>/g, '&gt;')
30
+ .replace(/\"/g, '&quot;')
31
+ .replace(/\'/g, '&#39;'); // '&apos;' is not valid HTML 4
32
+ }
33
+
34
+ function load_images( ){
35
+ var image_source = $('select[name="' + dev7plugin.labels.post_meta_key + '[' + dev7plugin.labels.source_name + ']"] option:selected').val();
36
+ var image_method = $('select[name="' + dev7plugin.labels.post_meta_key + '[' + image_source + '_type]"] option:selected').val();
37
+ var image_param = $('#' + image_source + '_' + image_method).val();
38
+
39
+ var number_images = $('input[name="' + dev7plugin.labels.post_meta_key + '[number_images]"]').val();
40
+
41
+ if (image_param != '') {
42
+ $('#' + dev7plugin.labels.post_type + '-images').html('<li class="loading"><div class="spinner"></div></li>');
43
+ $.ajax({
44
+ url: ajaxurl,
45
+ type: 'POST',
46
+ dataType: 'json',
47
+ data: { action: dev7plugin.labels.post_type + '_load_images',
48
+ id: dev7plugin.post_id,
49
+ nonce: dev7plugin.nonce,
50
+ source: image_source,
51
+ gallery:$('select[name="' + dev7plugin.labels.post_meta_key + '[' + dev7plugin.labels.type_name + '_gallery]"] option:selected').val(),
52
+ category:$('select[name="' + dev7plugin.labels.post_meta_key + '[' + dev7plugin.labels.type_name + '_category]"] option:selected').val(),
53
+ method:image_method,
54
+ param:image_param,
55
+ number_images:number_images
56
+ },
57
+ success: function(response){
58
+ if(response.error){
59
+ $('#' + dev7plugin.labels.post_type +'-images').html('');
60
+ alert(response.message);
61
+ } else {
62
+ $('#' + dev7plugin.labels.post_type +'-images').html('');
63
+ for(var i in response.images){
64
+ var image = response.images[i];
65
+ var output = '<li id="attachment-' + image.id + '">' +
66
+ '<img src="' + image.image_src + '" alt="' + escapeHTML( image.post_title ) + '" title="' + escapeHTML( image.post_title ) + '" class="attachment-thumbnail" />' +
67
+ '</li>';
68
+ $('#' + dev7plugin.labels.post_type +'-images').append(output);
69
+ }
70
+ }
71
+ },
72
+ error: function(response, status, error){
73
+ $('#' + dev7plugin.labels.post_type +'-images').html('<li class="loading">Error '+ error.replace(/(<([^>]+)>)/ig,"") +'</li>');
74
+ //alert('Error: ' + error.replace(/(<([^>]+)>)/ig,""));
75
+ }
76
+ });
77
+ }
78
+ }
79
+
80
+ function load_image_source() {
81
+ var selected_source = get_image_source_setting();
82
+ $('.dev7_type').hide();
83
+ if( selected_source != dev7plugin.labels.manual_name){
84
+ $( '#dev7_type_' + selected_source ).show();
85
+ $('.manual.description').hide();
86
+ $('.dev7_non_manual').show();
87
+ $('#manual_images_upload').hide();
88
+ } else {
89
+ $('.manual.description').show();
90
+ $('.dev7_non_manual').hide();
91
+ $('#manual_images_upload').show();
92
+ }
93
+
94
+ if( selected_source == 'category' || selected_source == 'sticky' || selected_source == 'custom'){
95
+ $('tr.dev7_captions').show();
96
+ } else {
97
+ $('tr.dev7_captions').hide();
98
+ }
99
+
100
+ if( selected_source == 'category' ||
101
+ selected_source == 'gallery' ||
102
+ selected_source == 'sticky' ||
103
+ selected_source == 'custom' ||
104
+ selected_source == dev7plugin.labels.manual_name
105
+ ){
106
+ $('tr.wp-image-size').show();
107
+ } else {
108
+ $('tr.wp-image-size').hide();
109
+ }
110
+
111
+ load_images();
112
+ }
113
+
114
+ // Dependant Select visibilty
115
+ $( '#' + dev7plugin.labels.post_type + '-settings select' ).each( function( index, element ){
116
+ dependant_visible( this );
117
+ });
118
+
119
+ $('#' + dev7plugin.labels.post_type + '-settings').on('change', 'select', function(){
120
+ dependant_visible( this );
121
+ });
122
+
123
+ $( '#' + dev7plugin.labels.post_type + '-settings input:checkbox' ).each( function( index, element ){
124
+ dependant_visible( this );
125
+ });
126
+
127
+ $('#' + dev7plugin.labels.post_type + '-settings').on('change', 'input:checkbox', function(){
128
+ dependant_visible( this );
129
+ });
130
+
131
+ function dependant_visible( element ) {
132
+ var id = $(element).attr( 'id' );
133
+ if ($('tr.parent-' + id).length > 0) {
134
+
135
+ if ( $(element).is(':checkbox') ) {
136
+ var value = ( $(element).is(':checked') ) ? 'on' : 'off';
137
+ } else if ( $(element).is('select') ) {
138
+ var value = $('option:selected', element).val();
139
+ }
140
+ $('tr.parent-' + id).hide();
141
+ $('tr.parent-' + id + '.' + value).show();
142
+ }
143
+ }
144
+
145
+ // Reload images
146
+ $('#' + dev7plugin.labels.post_type + '-settings').on('change', 'input.reload', function(){
147
+ load_images();
148
+ });
149
+
150
+ $('#' + dev7plugin.labels.post_type + '-settings').on('change', 'select.reload', function(){
151
+ load_images();
152
+ });
153
+
154
+
155
+ /**
156
+ * MMP integration
157
+ *
158
+ */
159
+
160
+ function display_params() {
161
+ var source = $('select[name="' + dev7plugin.labels.post_meta_key + '[' + dev7plugin.labels.source_name + ']"] option:selected').val();
162
+ var method = $('select[name="' + dev7plugin.labels.post_meta_key + '[' + source + '_type]"] option:selected').val();
163
+ $('.image_source_param').hide();
164
+ if(typeof method != 'undefined') {
165
+ $('#' + source + '_param_' + method).show();
166
+ }
167
+ }
168
+
169
+ display_params();
170
+
171
+ $('#' + dev7plugin.labels.post_type + '-settings').on('change', 'select.image_source_type', function(){
172
+ display_params();
173
+ load_images();
174
+ });
175
+
176
+ $('#' + dev7plugin.labels.post_type + '-settings').on('change', '.image_source_param', function(){
177
+ load_images();
178
+ });
179
+
180
+ $('.image_source_param').keydown(function(e){
181
+ if (e.which == 13) {
182
+ e.preventDefault();
183
+ load_images();
184
+ }
185
+ });
186
+
187
+ $('input.reload').keydown(function(e){
188
+ if (e.which == 13) {
189
+ e.preventDefault();
190
+ load_images();
191
+ }
192
+ });
193
+
194
+ $('.reattach-images').on('click', function(e){
195
+ e.preventDefault();
196
+ var post_id = $(this).attr('data-post');
197
+ $spinner = $(this).next('.spinner');
198
+ if (post_id != '') {
199
+ $spinner.show();
200
+ $(this).hide();
201
+ $.ajax({
202
+ url: ajaxurl,
203
+ type: 'POST',
204
+ dataType: 'json',
205
+ data: { action: dev7plugin.labels.post_type + '_reattach_images',
206
+ nonce: dev7plugin.nonce,
207
+ post_id: post_id
208
+ },
209
+ success: function(response){
210
+ if(response.error){
211
+ alert(response.message);
212
+ $spinner.hide();
213
+ } else {
214
+ // images attached
215
+ window.location = response.redirect;
216
+ }
217
+ },
218
+ error: function(response, status, error){
219
+ alert('Error: ' + error.replace(/(<([^>]+)>)/ig,""));
220
+ $spinner.hide();
221
+ }
222
+ });
223
+ }
224
+ });
225
+
226
+
227
+ /**
228
+ * License Calls
229
+ *
230
+ *
231
+ **/
232
+
233
+ var license_input = dev7plugin.labels.options_key + '[license_key]';
234
+ var license_status = dev7plugin.labels.options_key + '[license_status]';
235
+ $('#activate-license').on('click', function(){
236
+ var license_key = $('input[name="' + license_input + '"]').val();
237
+ if (license_key != '') {
238
+ $('#dev7license .spinner').show();
239
+ document.getElementById("activate-license").disabled = true;
240
+ $.ajax({
241
+ url: ajaxurl,
242
+ type: 'POST',
243
+ dataType: 'json',
244
+ data: { action: dev7plugin.labels.post_type + '_activate_license',
245
+ nonce: dev7plugin.nonce,
246
+ license_key: license_key
247
+ },
248
+ success: function(response){
249
+ if(response.error){
250
+ alert(response.message);
251
+ $('#dev7license .spinner').hide();
252
+ document.getElementById("activate-license").disabled = false;
253
+ } else {
254
+ $('input[name="' + license_status + '"]').val(response.license_status);
255
+ if (response.license_status == 'valid') window.location = response.redirect;
256
+ else {
257
+ alert('License ' + response.license_status);
258
+ $('#dev7license .spinner').hide();
259
+ document.getElementById("activate-license").disabled = false;
260
+ }
261
+ }
262
+ },
263
+ error: function(response, status, error){
264
+ alert('Error: ' + error.replace(/(<([^>]+)>)/ig,""));
265
+ $('#dev7license .spinner').hide();
266
+ document.getElementById("activate-license").disabled = false;
267
+ }
268
+ });
269
+ }
270
+ });
271
+
272
+ $('#deactivate-license').on('click', function(){
273
+ $('#dev7license .spinner').show();
274
+ document.getElementById("deactivate-license").disabled = true;
275
+ $.ajax({
276
+ url: ajaxurl,
277
+ type: 'POST',
278
+ dataType: 'json',
279
+ data: { action: dev7plugin.labels.post_type + '_deactivate_license',
280
+ nonce: dev7plugin.nonce
281
+ },
282
+ success: function(response){
283
+ if(response.error){
284
+ alert(response.message);
285
+ $('#dev7license .spinner').hide();
286
+ document.getElementById("deactivate-license").disabled = false;
287
+ } else {
288
+ if (response.license_status == 'deactivated') {
289
+ $('input[name="' + license_status + '"]').val('');
290
+ }
291
+ window.location = response.redirect;
292
+ }
293
+ },
294
+ error: function(response, status, error){
295
+ alert('Error: ' + error.replace(/(<([^>]+)>)/ig,""));
296
+ $('#dev7license .spinner').hide();
297
+ document.getElementById("deactivate-license").disabled = false;
298
+ }
299
+ });
300
+
301
+ });
302
+
303
+ });
includes/core/assets/js/image-admin.js ADDED
@@ -0,0 +1,359 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready(function($){
2
+
3
+
4
+ if(typeof wp === 'undefined') return;
5
+
6
+ if(typeof wp.media === 'undefined') return;
7
+
8
+ var frame,
9
+ images = wp.media.view.l10n[dev7plugin.labels.post_type + 'Images'],
10
+ selection = getImages(images);
11
+
12
+ if(typeof wp.media.view.Toolbar.UberMedia !== 'undefined') {
13
+
14
+ var UberImage = Backbone.Model.extend({
15
+ });
16
+
17
+ var UberImages = Backbone.Collection.extend({
18
+ model: UberImage
19
+ });
20
+
21
+ var SelectedImages = Backbone.Collection.extend({
22
+ model: UberImage
23
+ });
24
+
25
+ wp.media.view.Toolbar.UberMedia = wp.media.view.Toolbar.UberMedia.extend({
26
+ className: 'media-toolbar mmp-toolbar',
27
+ initialize: function() {
28
+ _.defaults( this.options, {
29
+ event: 'mmp_event_insert',
30
+ close: false,
31
+ items: {
32
+ mmp_event_insert: {
33
+ text: wp.media.view.l10n.ubermediaButton,
34
+ style: 'primary',
35
+ id: 'uber-button',
36
+ priority: 80,
37
+ requires: false,
38
+ click: this.insertAction
39
+ }
40
+ }
41
+ });
42
+
43
+ wp.media.view.Toolbar.prototype.initialize.apply( this, arguments );
44
+ },
45
+
46
+
47
+ insertAction: function(){
48
+ if($('#uber-button').is('[disabled=disabled]')) return;
49
+
50
+ $('div.ubermedia').addClass('uber-media-overlay');
51
+ $('#method').attr("disabled", 'disabled');
52
+ $('#param').attr("disabled", 'disabled');
53
+ $('#pagination').attr("disabled", 'disabled');
54
+
55
+ $('#uber-button').attr("disabled", 'disabled');
56
+ $("#uber-button").text('Adding...');
57
+
58
+ var selectedimages = this.controller.state().props.get('custom_data');
59
+ var selection = new SelectedImages(selectedimages.models);
60
+
61
+ var that = this,
62
+ count = 0,
63
+ jqHXRs = [],
64
+ new_ids = '';
65
+
66
+ selection.each(function(model){
67
+ count++;
68
+
69
+ var modelAttr = model.attributes;
70
+ var fields = $.param(modelAttr);
71
+ data = 'action=uber_pre_insert&nonce=' + uber_media.nonce + '&imgsrc=' + encodeURI(model.get('data-full')) + '&postid=' + $('#post_ID').val() + '&dev7plugin=' + dev7plugin.labels.post_type +'&' + fields;
72
+
73
+ var full = model.get('data-full');
74
+ var imgstr;
75
+
76
+ jqHXRs.push(
77
+ $.post(ajaxurl, data,
78
+ function(data){
79
+ if(data.message == 'success')
80
+ new_ids += data.attachment_id + ',';
81
+ }
82
+ , 'json')
83
+ );
84
+ });
85
+
86
+ $.when.apply(this, jqHXRs).done(function(){
87
+
88
+ that.controller.state().props.set( 'custom_data', '');
89
+ that.controller.state().props.set( 'selected_id', '' );
90
+ that.controller.state().props.set( 'selected_image', '' );
91
+
92
+ new_ids = new_ids.substring(0, new_ids.length - 1);
93
+ var new_selection = getImages(new_ids);
94
+
95
+ var checkExist = setInterval(function() {
96
+ if (new_selection.length) {
97
+ var controller = that.controller,
98
+ state = controller.state(),
99
+ edit = controller.state('gallery-edit');
100
+ edit.get('library').add( new_selection.models );
101
+ state.trigger('reset');
102
+ controller.setState('gallery-edit');
103
+ clearInterval(checkExist);
104
+ }
105
+ }, 100);
106
+
107
+ });
108
+ }
109
+
110
+ });
111
+ }
112
+
113
+
114
+
115
+ $('#manual_images_upload').on('click', function(e) {
116
+ e.preventDefault();
117
+
118
+ var media = wp.media;
119
+ selection = getImages($('#_manual_image_ids').val());
120
+ // Set options for 1st frame render
121
+ var options = {
122
+ state: 'gallery-edit',
123
+ frame: 'post',
124
+ selection: selection
125
+ };
126
+
127
+ // Set Links for image meta
128
+ $.ajax({
129
+ url: ajaxurl,
130
+ type: 'POST',
131
+ dataType: 'json',
132
+ data: { action: dev7plugin.labels.post_type + '_get_meta_link', ids: images,
133
+ nonce: dev7plugin.nonce },
134
+ success: function(response){
135
+ $.each(response.metalink, function(index, value) {
136
+ selection.get(index).set('metalink', value);
137
+ });
138
+ },
139
+ error: function(response, status, error){
140
+ alert('Error: ' + error.replace(/(<([^>]+)>)/ig,""));
141
+ }
142
+ });
143
+
144
+ overrideAttachmentDetails();
145
+
146
+ frame = wp.media(options).open();
147
+
148
+ // Tweak views
149
+ frame.menu.get('view').unset('cancel');
150
+ frame.menu.get('view').unset('separateCancel');
151
+
152
+ frame.content.get('view').sidebar.unset('gallery'); // Hide Gallery Settings in sidebar
153
+
154
+ // When we are editing a gallery
155
+ overrideGalleryInsert();
156
+ frame.on( 'toolbar:render:gallery-edit', function() {
157
+ overrideGalleryInsert();
158
+ });
159
+
160
+ frame.on( 'content:render:browse', function( browser ) {
161
+ if ( !browser ) return;
162
+ // Hide Gallery Settings in sidebar
163
+ browser.sidebar.on('ready', function(){
164
+ browser.sidebar.unset('gallery');
165
+ });
166
+ // Hide filter/search as they don't work
167
+ browser.toolbar.on('ready', function(){
168
+ if(browser.toolbar.controller._state == 'gallery-library'){
169
+ browser.toolbar.$el.hide();
170
+ }
171
+ });
172
+ });
173
+
174
+
175
+ // Override Attachment Details
176
+ function overrideAttachmentDetails() {
177
+
178
+ media.view.Attachment.Details = media.view.Attachment.Details.extend({
179
+ tagName: 'div',
180
+ className: 'attachment-details',
181
+ template: media.template('attachment-details'),
182
+
183
+ events: {
184
+ 'change [data-setting]': 'updateSetting',
185
+ 'change [data-setting] input': 'updateSetting',
186
+ 'change [data-setting] select': 'updateSetting',
187
+ 'change [data-setting] textarea': 'updateSetting',
188
+ 'change [data-customsetting] input': 'updateCustomSetting',
189
+ 'click .delete-attachment': 'deleteAttachment',
190
+ 'click .edit-attachment': 'editAttachment',
191
+ 'click .refresh-attachment': 'refreshAttachment'
192
+ },
193
+
194
+ initialize: function() {
195
+ this.focusManager = new media.view.FocusManager({
196
+ el: this.el
197
+ });
198
+
199
+ media.view.Attachment.prototype.initialize.apply( this, arguments );
200
+ },
201
+
202
+ render: function() {
203
+ media.view.Attachment.prototype.render.apply( this, arguments );
204
+ this.focusManager.focus();
205
+ return this;
206
+ },
207
+
208
+ deleteAttachment: function( event ) {
209
+ event.preventDefault();
210
+
211
+ if ( confirm( l10n.warnDelete ) )
212
+ this.model.destroy();
213
+ },
214
+
215
+ editAttachment: function( event ) {
216
+ this.$el.addClass('needs-refresh');
217
+ },
218
+
219
+ refreshAttachment: function( event ) {
220
+ this.$el.removeClass('needs-refresh');
221
+ event.preventDefault();
222
+ this.model.fetch();
223
+ },
224
+
225
+ updateCustomSetting: function( event ) {
226
+
227
+ var $setting = $( event.target ).closest('[data-customsetting]'),
228
+ setting, value;
229
+
230
+ if ( ! $setting.length )
231
+ return;
232
+
233
+ setting = $setting.data('customsetting');
234
+ value = event.target.value;
235
+
236
+ if ( this.model.get( setting ) !== value ) {
237
+ this.model.set( setting, value );
238
+ $.ajax({
239
+ url: ajaxurl,
240
+ type: 'POST',
241
+ dataType: 'json',
242
+ data: { action: dev7plugin.labels.post_type + '_set_meta_link',
243
+ id:this.model.id,
244
+ metalink: value,
245
+ nonce: dev7plugin.nonce },
246
+ success: function(response){
247
+ },
248
+ error: function(response, status, error){
249
+ alert('Error: ' + error.replace(/(<([^>]+)>)/ig,""));
250
+ }
251
+ });
252
+
253
+ }
254
+
255
+ }
256
+
257
+ });
258
+
259
+ }
260
+
261
+ // Override insert button
262
+ function overrideGalleryInsert() {
263
+ var editing = frame.state().get('editing');
264
+
265
+ frame.toolbar.get('view').set({
266
+ insert: {
267
+ style: 'primary',
268
+ text: editing ? wp.media.view.l10n.updateGallery : wp.media.view.l10n.insertGallery,
269
+
270
+ click: function() {
271
+ var models = frame.state().get('library'),
272
+ ids = '';
273
+
274
+ models.each( function( attachment ) {
275
+ ids += attachment.id + ','
276
+ });
277
+ ids = ids.substring(0, ids.length - 1);
278
+
279
+ this.el.innerHTML = 'Saving'; //'<?php _e("Saving...", "zilla"); ?>';
280
+
281
+ $('#_manual_image_ids').val( ids );
282
+ frame.close();
283
+
284
+ $('#' + dev7plugin.labels.post_type +'-images').html('<li class="loading"><div class="spinner"></div></li>');
285
+
286
+ $.ajax({
287
+ url: ajaxurl,
288
+ type: 'POST',
289
+ dataType: 'json',
290
+ data: { action: dev7plugin.labels.post_type + '_load_images',
291
+ id:dev7plugin.post_id,
292
+ source: dev7plugin.labels.manual_name,
293
+ image_ids: ids,
294
+ nonce: dev7plugin.nonce },
295
+ success: function(response){
296
+ if(response.error){
297
+ alert(response.message);
298
+ } else {
299
+ if (response.images) {
300
+ $('#' + dev7plugin.labels.post_type + '-images').html('');
301
+ for(var i in response.images){
302
+ var image = response.images[i];
303
+ var output = '<li id="attachment-' + image.id + '">' +
304
+ '<img src="' + image.image_src + '" alt="' + image.post_title + '" title="' + image.post_title + '" class="attachment-thumbnail" />';
305
+
306
+ $('#' + dev7plugin.labels.post_type + '-images').append(output);
307
+ }
308
+ }
309
+ }
310
+ },
311
+ error: function(response, status, error){
312
+ alert('Error: ' + error.replace(/(<([^>]+)>)/ig,""));
313
+ }
314
+ });
315
+
316
+ }
317
+ }
318
+ });
319
+ }
320
+
321
+ });
322
+
323
+ // Load images
324
+ function getImages(images) {
325
+ if (!images) images = $('#_manual_image_ids').val();
326
+
327
+ if( images ){
328
+ var shortcode = new wp.shortcode({
329
+ tag: 'gallery',
330
+ attrs: { ids: images },
331
+ type: 'single'
332
+ });
333
+
334
+ var attachments = wp.media.gallery.attachments( shortcode );
335
+
336
+
337
+ var selection = new wp.media.model.Selection( attachments.models, {
338
+ props: attachments.props.toJSON(),
339
+ multiple: true
340
+ });
341
+
342
+ selection.gallery = attachments.gallery;
343
+
344
+ // Fetch the query's attachments, and then break ties from the
345
+ // query to allow for sorting.
346
+ selection.more().done( function() {
347
+ // Break ties with the query.
348
+ selection.props.set({ query: false });
349
+ selection.unmirror();
350
+ selection.props.unset('orderby');
351
+ });
352
+
353
+ return selection;
354
+ }
355
+
356
+ return false;
357
+ }
358
+
359
+ });
includes/core/includes/admin-ajax.php ADDED
@@ -0,0 +1,305 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Admin AJAX Class
4
+ *
5
+ * @package Plugin Core
6
+ * @subpackage Admin/AJAX
7
+ * @copyright Copyright (c) 2014, Dev7studios
8
+ * @license http://opensource.org/licenses/GPL-3.0 GNU Public License
9
+ * @since 2.2
10
+ */
11
+
12
+ // Exit if accessed directly
13
+ if ( ! defined( 'ABSPATH' ) ) {
14
+ exit;
15
+ }
16
+
17
+ /**
18
+ * Admin AJAX Core Class
19
+ *
20
+ * @since 2.2
21
+ */
22
+ class Dev7_Core_Admin_AJAX {
23
+
24
+ /**
25
+ * Plugin labels
26
+ *
27
+ * @var object
28
+ * @access private
29
+ * @since 2.2
30
+ */
31
+ private $labels;
32
+
33
+ /**
34
+ * Instance of Dev7 Images Core Class
35
+ *
36
+ * @var object
37
+ * @access private
38
+ * @since 2.2
39
+ */
40
+ private $core_images;
41
+
42
+ /**
43
+ * Plugin options
44
+ *
45
+ * @var array
46
+ * @access private
47
+ * @since 2.2
48
+ */
49
+ private $options;
50
+
51
+ /**
52
+ * Main construct setting up ajax action hooks
53
+ *
54
+ * @since 2.2
55
+ *
56
+ * @param array $labels Specific plugin label data
57
+ */
58
+ public function __construct( $labels ) {
59
+ $this->labels = $labels;
60
+ $this->options = get_option( $this->labels->options_key );
61
+ $this->core_images = new Dev7_Core_Images( $this->labels );
62
+
63
+ add_action( 'wp_ajax_' . $this->labels->post_type . '_set_meta_link', array( $this, 'set_meta_link' ) );
64
+ add_action( 'wp_ajax_' . $this->labels->post_type . '_get_meta_link', array( $this, 'get_meta_link' ) );
65
+ add_action( 'wp_ajax_' . $this->labels->post_type . '_activate_license', array( $this, 'activate_license' ) );
66
+ add_action( 'wp_ajax_' . $this->labels->post_type . '_deactivate_license', array( $this, 'deactivate_license' ) );
67
+ add_action( 'wp_ajax_' . $this->labels->post_type . '_load_images', array( $this, 'load_images' ) );
68
+ add_action( 'wp_ajax_' . $this->labels->post_type . '_reattach_images', array( $this, 'reattach_images' ) );
69
+ }
70
+
71
+ /**
72
+ * Sends to the media modal the link for an image
73
+ *
74
+ * @since 2.2
75
+ * @access public
76
+ * @return string
77
+ */
78
+ public function get_meta_link() {
79
+ if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], plugin_basename( $this->labels->post_type ) ) ) {
80
+ return 0;
81
+ }
82
+
83
+ if ( ! isset( $_POST['ids'] ) ) {
84
+ return 0;
85
+ }
86
+
87
+ $attachments = explode( ',', $_POST['ids'] );
88
+
89
+ $links = array();
90
+ if ( $attachments ) {
91
+ foreach ( $attachments as $attachment ) {
92
+ $link = get_post_meta( $attachment, '_wp_attachment_image_link', true );
93
+ if ( $link != '' ) {
94
+ $links[$attachment] = $link;
95
+ }
96
+ }
97
+ }
98
+ $response = array( 'metalink' => $links );
99
+ echo json_encode( $response );
100
+ die;
101
+ }
102
+
103
+ /**
104
+ * Saves the link for an image when entered in the media modal
105
+ *
106
+ * @since 2.2
107
+ * @access public
108
+ * @return string
109
+ */
110
+ public function set_meta_link() {
111
+ if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], plugin_basename( $this->labels->post_type ) ) ) {
112
+ return 0;
113
+ }
114
+
115
+ if ( ! isset( $_POST['id'] ) || ! isset( $_POST['metalink'] ) ) {
116
+ return 0;
117
+ }
118
+
119
+ $link = get_post_meta( $_POST['id'], '_wp_attachment_image_link', true );
120
+ $new_link = stripslashes( $_POST['metalink'] );
121
+ if ( $link != $new_link ) {
122
+ $new_link = wp_strip_all_tags( $new_link, true );
123
+ $result = update_post_meta( $_POST['id'], '_wp_attachment_image_link', addslashes( $new_link ) );
124
+ }
125
+ $response = array();
126
+ echo json_encode( $response );
127
+ die;
128
+ }
129
+
130
+ /**
131
+ * Activates the plugin license with the Dev7studios EDD store
132
+ *
133
+ * @since 2.2
134
+ * @access public
135
+ * @return string
136
+ */
137
+ public function activate_license() {
138
+ if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], plugin_basename( $this->labels->post_type ) ) ) {
139
+ return 0;
140
+ }
141
+
142
+ if ( ! isset( $_POST['license_key'] ) ) {
143
+ return 0;
144
+ }
145
+
146
+ $ajax_response['error'] = false;
147
+ $ajax_response['message'] = '';
148
+
149
+ $options = $this->options;
150
+ $license = ( dev7_license_constant( $this->labels->post_type ) ) ? dev7_get_license_key( $this->labels->post_type, $options ) : trim( $_POST['license_key'] );
151
+ $options['license_key'] = $license;
152
+
153
+ $api_params = array(
154
+ 'edd_action' => 'activate_license',
155
+ 'license' => $license,
156
+ 'item_name' => urlencode( $this->labels->dev7_item_name )
157
+ );
158
+ $response = wp_remote_get(
159
+ esc_url_raw( add_query_arg( $api_params, DEV7_STORE_URL ) ), array(
160
+ 'timeout' => 15,
161
+ 'sslverify' => false
162
+ )
163
+ );
164
+ if ( is_wp_error( $response ) ) {
165
+ $ajax_response['error'] = true;
166
+ $ajax_response['message'] = $response->get_error_message();
167
+ } else {
168
+ $license_data = json_decode( wp_remote_retrieve_body( $response ) );
169
+ if ( isset( $license_data->license ) ) {
170
+ $options['license_status'] = $license_data->license;
171
+ $ajax_response['license_status'] = $license_data->license;
172
+ $ajax_response['redirect'] = admin_url( 'edit.php?post_type=' . $this->labels->post_type . '&page=' . $this->labels->post_type . '-settings' );
173
+ }
174
+ }
175
+ update_option( $this->labels->options_key, $options );
176
+ echo json_encode( $ajax_response );
177
+ die;
178
+ }
179
+
180
+ /**
181
+ * Deactivates the plugin license with the Dev7studios EDD store
182
+ *
183
+ * @since 2.2
184
+ * @access public
185
+ * @return string
186
+ */
187
+ public function deactivate_license() {
188
+ if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], plugin_basename( $this->labels->post_type ) ) ) {
189
+ return 0;
190
+ }
191
+
192
+ $ajax_response['error'] = false;
193
+ $ajax_response['message'] = '';
194
+
195
+ $options = $this->options;
196
+ $license = trim( dev7_default_val( $options, 'license_key', '' ) );
197
+
198
+ $api_params = array(
199
+ 'edd_action' => 'deactivate_license',
200
+ 'license' => $license,
201
+ 'item_name' => urlencode( $this->labels->dev7_item_name )
202
+ );
203
+ $response = wp_remote_get(
204
+ esc_url_raw( add_query_arg( $api_params, DEV7_STORE_URL ) ), array(
205
+ 'timeout' => 15,
206
+ 'sslverify' => false
207
+ )
208
+ );
209
+ if ( is_wp_error( $response ) ) {
210
+ $ajax_response['error'] = true;
211
+ $ajax_response['message'] = $response->get_error_message();
212
+ } else {
213
+ $license_data = json_decode( wp_remote_retrieve_body( $response ) );
214
+ if ( isset( $license_data->license ) ) {
215
+ unset( $options['license_key'] );
216
+ unset( $options['license_status'] );
217
+ update_option( $this->labels->options_key, $options );
218
+ $ajax_response['license_status'] = 'deactivated';
219
+ $ajax_response['redirect'] = admin_url( 'edit.php?post_type=' . $this->labels->post_type . '&page=' . $this->labels->post_type . '-settings' );
220
+ }
221
+ }
222
+ echo json_encode( $ajax_response );
223
+ die;
224
+ }
225
+
226
+ /**
227
+ * Retrieves images associated with the [gallery]
228
+ *
229
+ * @since 2.2
230
+ * @access public
231
+ * @return string
232
+ */
233
+ function load_images() {
234
+ if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], $this->labels->post_type ) || ! isset( $_POST['source'] ) ) {
235
+ return 0;
236
+ }
237
+
238
+ $response['error'] = false;
239
+ $response['message'] = '';
240
+ $response['images'] = array();
241
+
242
+ $number_images = ( isset( $_POST['number_images'] ) && $_POST['number_images'] != '' ) ? $_POST['number_images'] : - 1;
243
+
244
+ $method = ( ( isset( $_POST['method'] ) && $_POST['method'] != '' ) ) ? $_POST['method'] : null;
245
+ $param = ( ( isset( $_POST['param'] ) && $_POST['param'] != '' ) ) ? $_POST['param'] : null;
246
+ $gallery = ( ( isset( $_POST['gallery'] ) && $_POST['gallery'] != '' ) ) ? $_POST['gallery'] : null;
247
+ $category = ( ( isset( $_POST['category'] ) && $_POST['category'] != '' ) ) ? $_POST['category'] : null;
248
+ $custom = ( ( isset( $_POST['custom'] ) && $_POST['custom'] != '' ) ) ? $_POST['custom'] : null;
249
+ $image_ids = ( ( isset( $_POST['image_ids'] ) && $_POST['image_ids'] != '' ) ) ? $_POST['image_ids'] : null;
250
+
251
+ $response['images'] = $this->core_images->get_images(
252
+ $_POST['id'],
253
+ 'thumbnail',
254
+ $number_images,
255
+ $_POST['source'],
256
+ $method,
257
+ $param,
258
+ $gallery,
259
+ $category,
260
+ $custom,
261
+ $image_ids
262
+ );
263
+
264
+ echo json_encode( $response );
265
+ die;
266
+ }
267
+
268
+ /**
269
+ * Reattaches images to a manual gallery when the manual image ids are not set
270
+ *
271
+ * @since 2.2
272
+ * @access public
273
+ * @return string
274
+ */
275
+ public function reattach_images() {
276
+ if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], plugin_basename( $this->labels->post_type ) ) ) {
277
+ return 0;
278
+ }
279
+
280
+ if ( ! isset( $_POST['post_id'] ) ) {
281
+ return 0;
282
+ }
283
+
284
+ $ajax_response['error'] = false;
285
+ $ajax_response['message'] = '';
286
+
287
+ $options = get_post_meta( $_POST['post_id'], $this->labels->post_meta_key, true );;
288
+
289
+ $images = dev7_get_attached_images( $_POST['post_id'], -1 );
290
+
291
+ if ( ! $images || count( $images ) == 0 ) {
292
+ $ajax_response['error'] = true;
293
+ $ajax_response['message'] = 'No images to attach';
294
+ } else {
295
+ $ids = wp_list_pluck( $images, 'ID' );
296
+ $manual_image_ids = implode( ',', $ids );
297
+ $options['manual_image_ids'] = $manual_image_ids;
298
+ $ajax_response['redirect'] = admin_url( 'edit.php?post_type=' . $this->labels->post_type );
299
+ update_post_meta( $_POST['post_id'], $this->labels->post_meta_key, $options );
300
+ }
301
+
302
+ echo json_encode( $ajax_response );
303
+ die;
304
+ }
305
+ }
includes/core/includes/admin-edit.php ADDED
@@ -0,0 +1,512 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Admin Edit Class
4
+ *
5
+ * @package Plugin Core
6
+ * @subpackage Admin/Edit
7
+ * @copyright Copyright (c) 2014, Dev7studios
8
+ * @license http://opensource.org/licenses/GPL-3.0 GNU Public License
9
+ * @since 2.2
10
+ */
11
+
12
+ // Exit if accessed directly
13
+ if ( ! defined( 'ABSPATH' ) ) {
14
+ exit;
15
+ }
16
+
17
+ /**
18
+ * Admin Edit Core Class
19
+ *
20
+ * @since 2.2
21
+ */
22
+ class Dev7_Core_Admin_Edit {
23
+
24
+ /**
25
+ * Plugin labels
26
+ *
27
+ * @var object
28
+ * @access private
29
+ * @since 2.2
30
+ */
31
+ private $labels;
32
+
33
+ /**
34
+ * Instance of Dev7 Images Core Class
35
+ *
36
+ * @var object
37
+ * @access private
38
+ * @since 2.2
39
+ */
40
+ private $core_images;
41
+
42
+ /**
43
+ * Main construct setting up the [gallery] edit screen
44
+ *
45
+ * @since 2.2
46
+ *
47
+ * @param array $labels Specific plugin label data
48
+ */
49
+ public function __construct( $labels ) {
50
+ $this->labels = $labels;
51
+ $this->core_images = new Dev7_Core_Images( $this->labels );
52
+
53
+ add_action( 'admin_init', array( $this, 'admin_init' ) );
54
+ add_action( 'save_post', array( $this, 'save_post' ) );
55
+ }
56
+
57
+ /**
58
+ * Adds meta boxes to the edit screen
59
+ *
60
+ * @since 2.2
61
+ * @access public
62
+ */
63
+ public function admin_init() {
64
+ add_meta_box(
65
+ $this->labels->post_type . '_upload_box', sprintf( __( '%1$s Images', 'dev7core' ), $this->labels->singular ), array(
66
+ $this,
67
+ 'meta_box_upload'
68
+ ), $this->labels->post_type, 'normal'
69
+ );
70
+ add_meta_box(
71
+ $this->labels->post_type . '_settings_box', __( 'Settings', 'dev7core' ), array(
72
+ $this,
73
+ 'meta_box_settings'
74
+ ), $this->labels->post_type, 'normal'
75
+ );
76
+ add_meta_box(
77
+ $this->labels->post_type . '_shortcode_box', sprintf( __( 'Using this %1$s', 'dev7core' ), $this->labels->singular ), array(
78
+ $this,
79
+ 'meta_box_shortcode'
80
+ ), $this->labels->post_type, 'side'
81
+ );
82
+ add_meta_box(
83
+ $this->labels->post_type . '_usefullinks_box', __( 'Useful Links', 'dev7core' ), array(
84
+ $this,
85
+ 'meta_box_usefullinks'
86
+ ), $this->labels->post_type, 'side'
87
+ );
88
+ }
89
+
90
+ /**
91
+ * Adds the Shortcode meta box to the edit screen
92
+ *
93
+ * @since 2.2
94
+ * @access public
95
+ */
96
+ public function meta_box_shortcode() {
97
+ global $post;
98
+ echo '<p>' . sprintf( __( 'To use this %1$s in your posts or pages use the following shortcode:', 'dev7core' ), strtolower( $this->labels->singular ) ) . '</p>
99
+ <p><code>[' . $this->labels->shortcode . ' id="' . $post->ID . '"]</code>';
100
+ if ( $post->post_name != '' && $post->post_name <> $post->ID ) {
101
+ echo 'or</p><p><code>[' . $this->labels->shortcode . ' slug="' . $post->post_name . '"]</code>';
102
+ }
103
+ echo '</p>';
104
+ echo '<p>' . sprintf( __( 'To use this %1$s in a theme template file use the following code:', 'dev7core' ), strtolower( $this->labels->singular ) ) . '</p>
105
+ <p><code>&lt;?php ' . $this->labels->function . '( ' . $post->ID . ' ); ?></code>';
106
+ if ( $post->post_name != '' && $post->post_name <> $post->ID ) {
107
+ echo ' or</p><p><code>&lt;?php ' . $this->labels->function . '( "' . $post->post_name . '" ); ?></code>';
108
+ }
109
+ echo '</p>';
110
+ }
111
+
112
+ /**
113
+ * Adds the Useful Links meta box to the edit screen
114
+ *
115
+ * @since 2.2
116
+ * @access public
117
+ */
118
+ public function meta_box_usefullinks() {
119
+ echo '<div class="useful-links">';
120
+ echo '<p>' . __( 'Website:', 'dev7core' ) . ' <a href="' . DEV7_SITE_URL . '/products/' . $this->labels->slug . '/" target="_blank">' . $this->labels->plugin_name . '</a></p>';
121
+ echo '<p>' . __( 'Created by:', 'dev7core' ) . ' <a href="' . DEV7_SITE_URL . '" target="_blank">Dev7studios</a></p>';
122
+ echo '<p>' . __( 'Support:', 'dev7core' ) . ' <a href="' . DEV7_SITE_URL . '/support" target="_blank">Support</a></p>';
123
+ echo '<p>' . __( 'Documentation:', 'dev7core' ) . ' <a href="http://docs.dev7studios.com/wordpress-plugins/' . $this->labels->slug . '" target="_blank">Documentation</a></p>';
124
+ echo '<p>' . __( 'Changelog:', 'dev7core' ) . ' <a href="' . $this->labels->plugin_url . 'changelog.txt" target="_blank">Changelog</a></p>';
125
+ echo '</div>';
126
+ }
127
+
128
+ /**
129
+ * Adds the Image Upload meta box to the edit screen to configure the [gallery]
130
+ *
131
+ * @since 2.2
132
+ * @access public
133
+ */
134
+ public function meta_box_upload() {
135
+ global $post;
136
+ $options = get_post_meta( $post->ID, $this->labels->post_meta_key, true );
137
+ ?>
138
+ <a id="manual_images_upload" href="#" class="button">Configure</a>
139
+ <input type="hidden" id="_manual_image_ids" name="<?php echo $this->labels->post_meta_key; ?>[manual_image_ids]" value="<?php echo dev7_default_val( $options, 'manual_image_ids', '' ); ?>">
140
+ <ul id="<?php echo $this->labels->post_type; ?>-images" class="dev7plugin-images"></ul>
141
+ <?php
142
+ }
143
+
144
+ /**
145
+ * Adds the [gallery] Settings meta box to the edit screen
146
+ *
147
+ * @since 2.2
148
+ * @access public
149
+ */
150
+ public function meta_box_settings() {
151
+ global $post;
152
+ $options = get_post_meta( $post->ID, $this->labels->post_meta_key, true );
153
+ wp_nonce_field( plugin_basename( __FILE__ ), $this->labels->post_type . '_noncename' );
154
+ ?>
155
+ <table id="<?php echo $this->labels->post_type; ?>-settings" class="form-table">
156
+ <tr valign="top">
157
+ <th scope="row"><?php echo sprintf( __( '%1$s Type', 'dev7-core' ), $this->labels->singular ) ?></th>
158
+ <td>
159
+ <select name="<?php echo $this->labels->post_meta_key; ?>[<?php echo $this->labels->source_name; ?>]">
160
+ <?php
161
+ $selected_source = dev7_default_val( $options, $this->labels->source_name, $this->core_images->image_source_default() );
162
+ $images_sources = $this->core_images->get_image_sources();
163
+ if ( $images_sources ) {
164
+ foreach ( $images_sources as $source => $value ) {
165
+ echo '<option value="' . $source . '"';
166
+ if ( $selected_source == $source ) {
167
+ echo ' selected="selected"';
168
+ }
169
+ echo '>' . __( $value, 'dev7core' ) . '</option>';
170
+ }
171
+ } else {
172
+ echo '<option value="none">' . __( 'No Sources', 'dev7core' ) . '</option>';
173
+ } ?>
174
+ </select>
175
+ <br>
176
+ <span class="manual description">
177
+ <?php _e( 'Choose to manually upload images or use images from the media library.', 'dev7core' ); ?>
178
+ <br>
179
+ <?php
180
+ if ( ! dev7_mmp_active() ) {
181
+ printf( __( 'You can add images from external sources and use them as feeds with our free plugin %1$s Media Manager Plus %2$s', 'dev7core' ), '<a href="' . admin_url( 'edit.php?post_type=' . $this->labels->post_type . '&page=' . $this->labels->post_type . '-install-plugins' ) . '">', '</a>' );
182
+ } else {
183
+ printf( __( 'Connect more sources using %1$s Media Manager Plus %2$s', 'dev7core' ), '<a href="' . admin_url( 'upload.php?page=uber-media' ) . '">', '</a>' );
184
+ }
185
+ ?>
186
+ <br>
187
+ <?php do_action( $this->labels->post_type . '_manual_type_description' ); ?>
188
+ </span></td>
189
+ </tr>
190
+ <tr valign="top" id="dev7_type_gallery" class="dev7_type">
191
+ <th scope="row">- <?php _e( 'Gallery Location', 'dev7core' ); ?></th>
192
+ <td>
193
+ <select name="<?php echo $this->labels->post_meta_key; ?>[<?php echo $this->labels->type_name; ?>_gallery]">
194
+ <?php
195
+ $args = array(
196
+ 'public' => true,
197
+ );
198
+ $post_types = get_post_types( $args, 'objects' );
199
+ foreach ( $post_types as $post_key => $post_type ) {
200
+ if ( $post_key == 'attachment' ) {
201
+ continue;
202
+ }
203
+ echo '<optgroup label="' . $post_type->labels->name . '">';
204
+
205
+ $posts = get_posts( array( 'numberposts' => - 1, 'post_type' => $post_key ) );
206
+ foreach ( $posts as $post_item ) {
207
+ echo '<option value="' . $post_item->ID . '"';
208
+ if ( dev7_default_val( $options, $this->labels->type_name . '_gallery' ) == $post_item->ID ) {
209
+ echo ' selected="selected"';
210
+ }
211
+ echo '>' . $post_item->post_title . '</option>';
212
+ }
213
+ echo ' </optgroup>';
214
+ }
215
+ ?>
216
+ </select><br />
217
+ <span class="description"><?php _e( 'Select the post gallery you want to use', 'dev7core' ); ?></span>
218
+ </td>
219
+ </tr>
220
+ <tr valign="top" id="dev7_type_category" class="dev7_type">
221
+ <th scope="row">- <?php _e( 'Category', 'dev7core' ); ?></th>
222
+ <td>
223
+ <select name="<?php echo $this->labels->post_meta_key; ?>[<?php echo $this->labels->type_name; ?>_category]">
224
+ <?php
225
+ $categories = get_categories();
226
+ foreach ( $categories as $category ) {
227
+ echo '<option value="' . $category->cat_ID . '"';
228
+ if ( dev7_default_val( $options, $this->labels->type_name . '_category' ) == $category->cat_ID ) {
229
+ echo ' selected="selected"';
230
+ }
231
+ echo '>' . $category->name . '</option>';
232
+ }
233
+ ?>
234
+ </select><br />
235
+ <span class="description"><?php _e( 'Select the category you want to use for post thumbnails', 'dev7core' ); ?></span>
236
+ </td>
237
+ </tr>
238
+ <tr valign="top" id="dev7_type_custom" class="dev7_type">
239
+ <th scope="row">- <?php _e( 'Custom Post Type', 'dev7core' ); ?></th>
240
+ <td>
241
+ <select name="<?php echo $this->labels->post_meta_key; ?>[<?php echo $this->labels->type_name; ?>_custom]">
242
+ <?php
243
+ $post_types = get_post_types( array( 'public' => true, '_builtin' => false ), 'objects' );
244
+ foreach ( $post_types as $post_type ) {
245
+ echo '<option value="' . $post_type->name . '"';
246
+ if ( dev7_default_val( $options, $this->labels->type_name . '_custom' ) == $post_type->name ) {
247
+ echo ' selected="selected"';
248
+ }
249
+ echo '>' . $post_type->labels->name . '</option>';
250
+ }
251
+ ?>
252
+ </select><br />
253
+ <span class="description"><?php _e( 'Select the custom post type you want to use for post thumbnails', 'dev7core' ); ?></span>
254
+ </td>
255
+ </tr>
256
+ <?php
257
+ // MMP settings for sources
258
+ $images_sources = $this->core_images->get_image_sources();
259
+ if ( $images_sources ) {
260
+ foreach ( $images_sources as $source => $value ) {
261
+ echo $this->get_image_source_details( $source, $selected_source );
262
+ }
263
+ }
264
+ // Plugin settings
265
+ $settings = apply_filters( $this->labels->post_type . '_admin_edit_settings', array() );
266
+ foreach ( $settings as $setting ) {
267
+ $setting = (object) $setting;
268
+ $class = '';
269
+ $class .= ( isset( $setting->tr_class ) ) ? $setting->tr_class . ' ' : '';
270
+ if ( isset( $setting->parent ) ) {
271
+ if ( ! is_array( $setting->parent ) ) {
272
+ $parents = array( $setting->parent );
273
+ } else {
274
+ $parents = $setting->parent;
275
+ }
276
+
277
+ foreach( $parents as $parent ) {
278
+ $class .= 'parent-' . $parent . ' ';
279
+ }
280
+
281
+ $class .= ( isset( $setting->visible ) ) ? ' ' . $setting->visible . ' ' : '';
282
+ }
283
+ $id = ( isset( $setting->id ) ) ? $setting->id : '';
284
+ ?>
285
+ <tr valign="top" id="<?php echo $id; ?>" class="<?php echo $class; ?>">
286
+ <th scope="row"><?php echo ( isset( $setting->sub ) && $setting->sub ) ? '- ' : ''; ?><?php echo $setting->title; ?></th>
287
+ <td>
288
+ <?php
289
+
290
+ if ( ! is_array( $setting->name ) ) {
291
+ $setting->name = array( $setting->name );
292
+ }
293
+ foreach ( $setting->name as $setting_key => $setting_name ) {
294
+
295
+ $setting->default = ( isset( $setting->default ) ) ? $setting->default : '';
296
+ if ( ! is_array( $setting->default ) ) {
297
+ $setting->default = array( $setting->default );
298
+ }
299
+
300
+ $element_id = $setting_name;
301
+ $element_name = $this->labels->post_meta_key . '[' . $setting_name . ']';
302
+ $element_default = ( isset( $setting->default[$setting_key] ) ) ? $setting->default[$setting_key] : $setting->default[0];
303
+ $element_value = dev7_default_val( $options, $setting_name, $element_default );
304
+ $element_class = '';
305
+ $element_class .= ( isset( $setting->reload ) ) ? 'reload' : '';
306
+
307
+ if ( isset( $setting->pre_element ) && $setting->pre_element != '' ) {
308
+ echo $setting->pre_element;
309
+ }
310
+ switch ( $setting->type ) {
311
+
312
+ case 'text':
313
+ ?>
314
+ <input type="text" name="<?php echo $element_name; ?>" value="<?php echo $element_value; ?>" class="<?php echo $element_class; ?>" />
315
+ <?php
316
+ break;
317
+
318
+ case 'number':
319
+ ?>
320
+ <input type="number" name="<?php echo $element_name; ?>" value="<?php echo $element_value; ?>" class="<?php echo $element_class; ?>" />
321
+ <?php
322
+ break;
323
+
324
+ case 'textarea':
325
+ $rows = ( isset( $setting->rows ) ) ? $setting->rows : 20;
326
+ $cols = ( isset( $setting->cols ) ) ? $setting->cols : 80;
327
+
328
+ ?>
329
+ <textarea class="<?php echo $element_class; ?>" name="<?php echo $element_name; ?>" rows="<?php echo $rows; ?>" cols="<?php echo $cols; ?>"><?php echo $element_value; ?></textarea>
330
+ <?php
331
+ break;
332
+
333
+ case 'checkbox':
334
+ ?>
335
+ <input type="hidden" name="<?php echo $element_name; ?>" value="off" />
336
+ <input id="<?php echo $element_id; ?>" type="checkbox" name="<?php echo $element_name; ?>" value="on"<?php if ( $element_value == 'on' ) {
337
+ echo ' checked="checked"';
338
+ } ?>/>
339
+ <?php
340
+ break;
341
+
342
+ case 'select':
343
+ ?>
344
+ <select id="<?php echo $element_id; ?>" name="<?php echo $element_name; ?>" class="<?php echo $element_class; ?>">
345
+ <?php
346
+ foreach ( $setting->options as $value => $name ) {
347
+ ?>
348
+ <option value="<?php echo $value; ?>"<?php if ( $value == $element_value ) {
349
+ echo ' selected="selected"';
350
+ } ?>><?php echo $name; ?></option>
351
+ <?php } ?>
352
+ </select>
353
+ <?php
354
+ break;
355
+
356
+ case 'custom':
357
+ echo $setting->custom;
358
+ break;
359
+
360
+ }
361
+
362
+ if ( isset( $setting->connect ) && ( $setting_key + 1 ) < count( $setting->name ) ) {
363
+ echo $setting->connect;
364
+ }
365
+
366
+ if ( isset( $setting->post_element ) && $setting->post_element != '' ) {
367
+ echo $setting->post_element;
368
+ }
369
+
370
+ if ( ( $setting_key + 1 ) == count( $setting->name ) && $setting->type != 'checkbox' ) {
371
+ echo '<br>';
372
+ }
373
+ }
374
+
375
+
376
+ if ( isset( $setting->descp ) && $setting->descp != '' ) {
377
+ ?>
378
+ <span class="description"><?php echo $setting->descp; ?></span>
379
+ <?php
380
+ }
381
+
382
+ if ( isset( $setting->post_descp ) && $setting->post_descp != '' ) {
383
+ echo $setting->post_descp;
384
+ }
385
+ ?>
386
+ </td>
387
+ </tr>
388
+ <?php
389
+ }
390
+ ?>
391
+ </table>
392
+ <?php
393
+ }
394
+
395
+ /**
396
+ * Amend the settings of the [gallery] post before saving
397
+ *
398
+ * @since 2.2
399
+ *
400
+ * @param int $post_id Post ID
401
+ *
402
+ * @access public
403
+ */
404
+ public function save_post( $post_id ) {
405
+ if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
406
+ return;
407
+ }
408
+
409
+ if ( ! isset( $_POST[$this->labels->post_type . '_noncename'] ) || ! wp_verify_nonce( $_POST[$this->labels->post_type . '_noncename'], plugin_basename( __FILE__ ) ) ) {
410
+ return;
411
+ }
412
+
413
+ // Check permissions
414
+ if ( 'page' == $_POST['post_type'] ) {
415
+ if ( ! current_user_can( 'edit_page', $post_id ) ) {
416
+ return;
417
+ }
418
+ } else {
419
+ if ( ! current_user_can( 'edit_post', $post_id ) ) {
420
+ return;
421
+ }
422
+ }
423
+
424
+ // Good to go
425
+ $settings = $_POST[$this->labels->post_meta_key];
426
+ $settings = apply_filters( $this->labels->post_type . '_post_meta_save', $settings );
427
+
428
+ update_post_meta( $post_id, $this->labels->post_meta_key, $settings );
429
+ }
430
+
431
+ /**
432
+ * Amend the settings of the [gallery] post before saving
433
+ *
434
+ * @since 2.2
435
+ *
436
+ * @param string $image_source Source of the [gallery] images
437
+ * @param string $selected_source Selected source of the [gallery] images
438
+ *
439
+ * @access public
440
+ * @return string $html HTML output
441
+ */
442
+ public function get_image_source_details( $image_source, $selected_source ) {
443
+ if ( ! dev7_mmp_active() ) {
444
+ return;
445
+ }
446
+
447
+ $defaults = $this->core_images->image_sources_defaults();
448
+ if ( ! array_key_exists( $image_source, $defaults ) ) {
449
+
450
+ $var = 'media_manager_plus_source_' . $image_source;
451
+ $obj = new $var();
452
+ $settings = $obj->show_details();
453
+
454
+ global $post;
455
+ $options = get_post_meta( $post->ID, $this->labels->post_meta_key, true );
456
+
457
+ $display = ( $image_source != $selected_source ) ? 'style="display: none;"' : '';
458
+ $header = '<tr valign="top" id="dev7_type_' . $image_source . '" class="dev7_type image_source" ' . $display . '>';
459
+ $header .= '<th scope="row"> ' . ucfirst( $image_source ) . ' settings</th>';
460
+ $header .= '<td>';
461
+ $body = '<label>';
462
+ $body .= ' <select name="' . $this->labels->post_meta_key . '[' . $image_source . '_type]" class="image_source_type" >';
463
+ foreach ( $settings as $method => $value ) {
464
+ $selected = ( dev7_default_val( $options, $image_source . '_type', '' ) ) == $method ? 'selected="selected"' : '';
465
+ $body .= '<option ' . $selected . ' value="' . $method . '">' . $value['name'] . '</option>';
466
+ }
467
+ $body .= ' </select><br>';
468
+ $body .= ' <span class="description">Choose the type of images from ' . ucfirst( $image_source ) . ' </span>';
469
+ $body .= '</label>';
470
+
471
+ foreach ( $settings as $method => $value ) {
472
+ if ( isset( $value['param_type'] ) ) {
473
+ $body .= '<div id="' . $image_source . '_param_' . $method . '" class="image_source_param">';
474
+ if ( $value['param_type'] == 'text' ) {
475
+ $body .= '<br><input id="' . $image_source . '_' . $method . '" type="text" value="' . dev7_default_val( $options, $image_source . '_' . $method, '' ) . '" name="' . $this->labels->post_meta_key . '[' . $image_source . '_' . $method . ']">';
476
+ }
477
+
478
+ if ( $value['param_type'] == 'select' ) {
479
+
480
+ if ( $value['param_dynamic'] ) {
481
+ $mmp_options = get_option( 'ubermediasettings_settings', array() );
482
+ $mmp_sources = dev7_default_val( $mmp_options, 'ubermediasettings_sources_available', array() );
483
+
484
+ $source_settings = $mmp_sources[$image_source . '-settings'];
485
+ $access_token = $source_settings['access-token'];
486
+
487
+ $param_obj = new $var( $access_token['oauth_token'], $access_token['oauth_token_secret'] );
488
+ $param_choices = $param_obj->get_param_choices( $method );
489
+
490
+ } else {
491
+ $param_choices = $value['param_choices'];
492
+ }
493
+
494
+ $body .= ' <select id="' . $image_source . '_' . $method . '" name="' . $this->labels->post_meta_key . '[' . $image_source . '_' . $method . ']">';
495
+ foreach ( $param_choices as $choice_key => $choice_value ) {
496
+ $selected = ( dev7_default_val( $options, $image_source . '_' . $method, '' ) ) == $choice_key ? 'selected="selected"' : '';
497
+ $body .= '<option ' . $selected . ' value="' . $choice_key . '">' . $choice_value . '</option>';
498
+ }
499
+ $body .= ' </select>';
500
+ }
501
+
502
+ $body .= ( isset( $value['param_desc'] ) ) ? ' <span class="description">' . $value['param_desc'] . '</span>' : '';
503
+ $body .= '</div>';
504
+ }
505
+ }
506
+ $footer = '</td></tr>';
507
+ $html = $header . $body . $footer;
508
+
509
+ return $html;
510
+ }
511
+ }
512
+ }
includes/core/includes/admin-images.php ADDED
@@ -0,0 +1,254 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Admin Images Class
4
+ *
5
+ * @package Plugin Core
6
+ * @subpackage Admin/Images
7
+ * @copyright Copyright (c) 2014, Dev7studios
8
+ * @license http://opensource.org/licenses/GPL-3.0 GNU Public License
9
+ * @since 2.2
10
+ */
11
+
12
+ // Exit if accessed directly
13
+ if ( ! defined( 'ABSPATH' ) ) {
14
+ exit;
15
+ }
16
+
17
+ /**
18
+ * Admin Images Core Class
19
+ *
20
+ * @since 2.2
21
+ */
22
+ class Dev7_Core_Admin_Images {
23
+
24
+ /**
25
+ * Plugin labels
26
+ *
27
+ * @var object
28
+ * @access private
29
+ * @since 2.2
30
+ */
31
+ private $labels;
32
+
33
+ /**
34
+ * Main construct setting up the [gallery] images class
35
+ *
36
+ * @since 2.2
37
+ *
38
+ * @param array $labels Specific plugin label data
39
+ */
40
+ public function __construct( $labels ) {
41
+ $this->labels = $labels;
42
+
43
+ add_action( 'after_setup_theme', array( $this, 'theme_support_check' ), 999 );
44
+ add_filter( 'media_view_strings', array( $this, 'custom_media_string' ), 11, 2 );
45
+ add_filter( 'uber_media_pre_insert', array( $this, 'mmp_pre_insert' ) );
46
+ add_action( 'admin_footer', array( $this, 'print_media_templates' ) );
47
+ }
48
+
49
+ /**
50
+ * Checks for themes that haven't added 'post-thumbnails' support required and adds it.
51
+ *
52
+ * @since 2.3.2
53
+ *
54
+ * @access public
55
+ */
56
+ public function theme_support_check() {
57
+ $support = get_theme_support( 'post-thumbnails' );
58
+ if ( ! $support ) {
59
+ add_theme_support( 'post-thumbnails' );
60
+ }
61
+ }
62
+
63
+ /**
64
+ * Apply custom strings to the Media View for integrating with Media Manager Plus
65
+ *
66
+ * @since 2.2
67
+ *
68
+ * @param array $strings Media View strings
69
+ * @param object $post Current Post
70
+ *
71
+ * @access public
72
+ * @return array $strings
73
+ */
74
+ public function custom_media_string( $strings, $post ) {
75
+ if ( isset( $post->post_type ) && $post->post_type == $this->labels->post_type ) {
76
+ $strings['createGalleryTitle'] = sprintf( __( 'Create %1$s', 'dev7-core' ), $this->labels->singular );
77
+ $strings['createNewGallery'] = sprintf( __( 'Create %1$s', 'dev7-core' ), strtolower( $this->labels->singular ) );
78
+ $strings['addToGallery'] = sprintf( __( 'Add to %1$s', 'dev7-core' ), strtolower( $this->labels->singular ) );
79
+ $strings['addToGalleryTitle'] = sprintf( __( 'Add to %1$s', 'dev7-core' ), $this->labels->singular );
80
+ $strings['editGalleryTitle'] = sprintf( __( 'Edit %1$s', 'dev7-core' ), $this->labels->singular );
81
+ $strings['insertGallery'] = sprintf( __( 'Save %1$s', 'dev7-core' ), $this->labels->singular );
82
+ $strings['updateGallery'] = sprintf( __( 'Update %1$s', 'dev7-core' ), $this->labels->singular );
83
+ $strings['nivoSideDetails'] = __( 'Slide Details', 'dev7-core' );
84
+
85
+ $strings['ubermediaButton'] = sprintf( __( 'Add to %1$s', 'dev7-core' ), strtolower( $this->labels->singular ) );
86
+ $strings['mmp_menu'] = 'gallery';
87
+ $strings['mmp_menu_prefix'] = __( 'Add from ', 'dev7-core' );
88
+ sprintf( __( 'Update %1$s', 'dev7-core' ), $this->labels->singular );
89
+
90
+ $options = get_post_meta( $post->ID, $this->labels->post_meta_key, true );
91
+ $strings[$this->labels->post_type . 'Images'] = dev7_default_val( $options, 'manual_image_ids', '' );
92
+ }
93
+
94
+ return $strings;
95
+ }
96
+
97
+ /**
98
+ * Print custom media templates for integrating with Media Manager Plus
99
+ *
100
+ * @since 2.2
101
+ * @global object $post WordPress Post
102
+ * @access public
103
+ */
104
+ public function print_media_templates() {
105
+ global $post;
106
+ if ( isset( $post->post_type ) && $post->post_type == $this->labels->post_type ) {
107
+ ?>
108
+ <script type="text/html" id="tmpl-attachment-details">
109
+ <h3>
110
+ <?php _e('Slide Details', 'dev7-core' ); ?>
111
+ <span class="settings-save-status">
112
+ <span class="spinner"></span>
113
+ <span class="saved"><?php esc_html_e('Saved.'); ?></span>
114
+ </span>
115
+ </h3>
116
+ <div class="attachment-info">
117
+ <div class="thumbnail">
118
+ <# if ( data.uploading ) { #>
119
+ <div class="media-progress-bar">
120
+ <div></div>
121
+ </div>
122
+ <# } else if ( 'image' === data.type ) { #>
123
+ <img src="{{ data.size.url }}" draggable="false" />
124
+ <# } else { #>
125
+ <img src="{{ data.icon }}" class="icon" draggable="false" />
126
+ <# } #>
127
+ </div>
128
+ </div>
129
+ <# var maybeReadOnly = data.can.save || data.allowLocalEdits ? '' : 'readonly'; #>
130
+ <label class="setting" data-setting="caption">
131
+ <span><?php _e( 'Caption', 'dev7-core' ); ?></span>
132
+ <textarea {{ maybeReadOnly }}>{{ data.caption }}</textarea>
133
+ </label>
134
+ <# if ( 'image' === data.type ) { #>
135
+ <label class="setting" data-setting="alt">
136
+ <span><?php _e( 'Alt Text', 'dev7-core' ); ?></span>
137
+ <input type="text" value="{{ data.alt }}" {{ maybeReadOnly }} />
138
+ </label>
139
+ <# } #>
140
+ <label class="setting" data-customsetting="metalink">
141
+ <span><?php _e( 'Link', 'dev7-core' ); ?></span>
142
+ <input type="text" value="{{ data.metalink }}" {{ maybeReadOnly }} />
143
+ </label>
144
+ </script>
145
+ <script type="text/html" id="tmpl-uberimage-settings">
146
+ <div class="attachment-info">
147
+ <h3>{{{ data.selected_image.title }}}</h3>
148
+ <span id="uberload" class="spinner" style="display: block"></span>
149
+ <input id="full-uber" type="hidden" value="{{ data.selected_image.dataset.full }}" />
150
+ <input id="uber-id" type="hidden" value="{{ data.selected_image.id }}" />
151
+
152
+ <div class="thumbnail">
153
+ </div>
154
+ </div>
155
+ <?php if ( ! apply_filters( 'disable_captions', '' ) ) : ?>
156
+ <label class="setting caption">
157
+ <span><?php _e( 'Caption', 'dev7-core' ); ?></span>
158
+ <textarea id="caption-uber" data-setting="caption"></textarea>
159
+ </label>
160
+ <?php endif; ?>
161
+ <label class="setting alt-text">
162
+ <span><?php _e( 'Title', 'dev7-core' ); ?></span>
163
+ <input id="title-uber" type="text" data-setting="title" value="{{{ data.selected_image.title }}}" />
164
+ <input name="original-title" type="hidden" value="{{{ data.selected_image.title }}}" />
165
+ </label>
166
+ <label class="setting alt-text">
167
+ <span><?php _e( 'Alt Text', 'dev7-core' ); ?></span>
168
+ <input id="alt-uber" type="text" data-setting="alt" value="{{{ data.selected_image.title }}}" />
169
+ </label>
170
+ </script>
171
+ <?php
172
+ }
173
+ }
174
+
175
+ /**
176
+ * Upload to the media library and attach images added to [gallery] via Media Manager Plus
177
+ *
178
+ * @since 2.2
179
+ *
180
+ * @param array $response MMP response
181
+ *
182
+ * @access public
183
+ * @return array $response
184
+ */
185
+ public function mmp_pre_insert( $response ) {
186
+ if ( isset( $response['fields']['dev7plugin'] ) && $response['fields']['dev7plugin'] == $this->labels->post_type ) {
187
+ if ( ! isset( $response['fields']['id'] ) ) {
188
+ return $response;
189
+ }
190
+ if ( ! isset( $response['imgsrc'] ) ) {
191
+ return $response;
192
+ }
193
+
194
+ $attachment_id = $this->attach_image( $response['imgsrc'], $response['fields']['title'], $response['fields']['postid'], false );
195
+ if ( $attachment_id != '' ) {
196
+ $response['attachment_id'] = $attachment_id;
197
+ }
198
+ }
199
+
200
+ return $response;
201
+ }
202
+
203
+ /**
204
+ * Upload to the media library and attach images added to [gallery] via Media Manager Plus
205
+ *
206
+ * @since 2.2
207
+ *
208
+ * @param string $url external image url
209
+ * @param string $title external image caption
210
+ * @param int $post_id ID of [gallery] post to attach it to
211
+ * @param bool $return_src default false. True returns $src, false returns $id
212
+ *
213
+ * @access private
214
+ * @return int $id Attachment ID / string $src Attached image url
215
+ *
216
+ */
217
+ private function attach_image( $url, $title, $post_id, $return_src = true ) {
218
+ $tmp = download_url( $url );
219
+ $file = basename( $url );
220
+ $info = pathinfo( $file );
221
+
222
+ $file_name = ( $title == '' ) ? $file : $title;
223
+ $file_name = sanitize_file_name( $file_name );
224
+ $file_name = remove_accents( $file_name );
225
+ $file_name = $file_title = substr( $file_name, 0, 100 );
226
+ $file_name = $file_name . '.' . ( isset( $info['extension'] ) ? $info['extension'] : 'jpg' );
227
+ $file_array = array(
228
+ 'name' => $file_name,
229
+ 'tmp_name' => $tmp
230
+ );
231
+
232
+ if ( is_wp_error( $tmp ) ) {
233
+ @unlink( $file_array['tmp_name'] );
234
+ $file_array['tmp_name'] = '';
235
+
236
+ return '';
237
+ }
238
+
239
+ $id = media_handle_sideload( $file_array, $post_id, $file_title );
240
+
241
+ if ( is_wp_error( $id ) ) {
242
+ @unlink( $file_array['tmp_name'] );
243
+
244
+ return '';
245
+ }
246
+ if ( $return_src ) {
247
+ $src = wp_get_attachment_url( $id );
248
+
249
+ return $src;
250
+ } else {
251
+ return $id;
252
+ }
253
+ }
254
+ }
includes/core/includes/admin-settings.php ADDED
@@ -0,0 +1,397 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Admin Settings Class
4
+ *
5
+ * @package Plugin Core
6
+ * @subpackage Admin/Settings
7
+ * @copyright Copyright (c) 2014, Dev7studios
8
+ * @license http://opensource.org/licenses/GPL-3.0 GNU Public License
9
+ * @since 2.2
10
+ */
11
+
12
+ // Exit if accessed directly
13
+ if ( ! defined( 'ABSPATH' ) ) {
14
+ exit;
15
+ }
16
+
17
+ /**
18
+ * Admin Settings Core Class
19
+ *
20
+ * @since 2.2
21
+ */
22
+ class Dev7_Core_Admin_Settings {
23
+
24
+ /**
25
+ * Plugin labels
26
+ *
27
+ * @var object
28
+ * @access private
29
+ * @since 2.2
30
+ */
31
+ private $labels;
32
+
33
+ /**
34
+ * Plugin options
35
+ *
36
+ * @var array
37
+ * @access private
38
+ * @since 2.2
39
+ */
40
+ private $options;
41
+
42
+ /**
43
+ * Main construct for the [gallery] settings page
44
+ *
45
+ * @since 2.2
46
+ *
47
+ * @param array $labels Specific plugin label data
48
+ */
49
+ public function __construct( $labels ) {
50
+
51
+ $this->labels = $labels;
52
+ $this->options = get_option( $this->labels->options_key );
53
+
54
+ add_action( 'admin_menu', array( $this, 'admin_menu' ) );
55
+ add_action( 'admin_menu', array( $this, 'remove_admin_menu' ) );
56
+ add_action( 'admin_init', array( $this, 'register_settings' ) );
57
+ add_action( 'after_plugin_row_' . $this->labels->plugin_basename, array( $this, 'plugin_row' ), 11 );
58
+ add_filter( 'plugin_action_links', array( $this, 'plugin_action_links' ), 10, 2 );
59
+ }
60
+
61
+ /**
62
+ * Adds a new menu item under the plugin post type
63
+ *
64
+ * @since 2.2
65
+ * @access public
66
+ */
67
+ public function admin_menu() {
68
+ add_submenu_page(
69
+ 'edit.php?post_type=' . $this->labels->post_type, 'Settings', 'Settings', 'manage_options', $this->labels->post_type . '-settings', array(
70
+ $this,
71
+ 'settings_page'
72
+ )
73
+ );
74
+ }
75
+
76
+ /**
77
+ * Controls the visibility of the plugin menu. Can be filtered.
78
+ *
79
+ * @since 2.2
80
+ * @access public
81
+ */
82
+ public function remove_admin_menu() {
83
+ $options = $this->options;
84
+ if ( isset( $options['custom-roles'] ) ) {
85
+ $custom_roles = $options['custom-roles'];
86
+ if ( $custom_roles ) {
87
+ $allowed_roles = apply_filters( $this->labels->post_type . '_allowed_roles', $custom_roles );
88
+ global $current_user;
89
+ $user_roles = $current_user->roles;
90
+ $show = false;
91
+ foreach ( $allowed_roles as $role ) {
92
+ if ( in_array( $role, $user_roles ) ) {
93
+ $show = true;
94
+ }
95
+ }
96
+ if ( ! $show ) {
97
+ remove_menu_page( 'edit.php?post_type=' . $this->labels->post_type );
98
+ }
99
+ }
100
+ }
101
+ }
102
+
103
+ /**
104
+ * Renders the settings page for the plugin
105
+ *
106
+ * @since 2.2
107
+ * @access public
108
+ */
109
+ public function settings_page() {
110
+ ?>
111
+ <div id="<?php echo $this->labels->post_type; ?>-wrap" class="wrap">
112
+ <div id="icon-options-general" class="icon32"></div>
113
+ <h2><?php echo apply_filters( $this->labels->post_type . '_settings_page_header', 'Settings' ); ?></h2>
114
+
115
+ <form action="options.php" method="post">
116
+ <?php settings_fields( $this->labels->post_type . '-settings' ); ?>
117
+ <?php do_settings_sections( $this->labels->post_type . '-settings' ); ?>
118
+ <p class="submit">
119
+ <input type="submit" name="submit" id="submit" class="button-primary" value="<?php _e( 'Save Changes', 'dev7-core' ); ?>">
120
+ </p>
121
+ </form>
122
+ </div>
123
+ <?php
124
+ }
125
+
126
+ /**
127
+ * Registers the settings and sections
128
+ *
129
+ * @since 2.2
130
+ * @access public
131
+ */
132
+ public function register_settings() {
133
+ register_setting(
134
+ $this->labels->post_type . '-settings', $this->labels->options_key, array(
135
+ $this,
136
+ 'settings_validate'
137
+ )
138
+ );
139
+ add_settings_section(
140
+ $this->labels->post_type . '-settings', '', array(
141
+ $this,
142
+ 'display_settings_intro'
143
+ ), $this->labels->post_type . '-settings'
144
+ );
145
+
146
+ $settings[] = array( 'slug' => 'license-settings', 'title' => __( 'License', 'dev7-core' ) );
147
+ $settings[] = array( 'slug' => 'custom-roles', 'title' => __( 'Management Roles', 'dev7-core' ) );
148
+
149
+ $settings = apply_filters( $this->labels->post_type . '_register_settings', $settings );
150
+
151
+ foreach ( $settings as $setting ) {
152
+ $scope = ( isset( $setting['scope'] ) ) ? $setting['scope'] : $this;
153
+ $function = 'setting_' . str_replace( '-', '_', $setting['slug'] );
154
+ add_settings_field(
155
+ $setting['slug'], $setting['title'], array(
156
+ $scope,
157
+ $function
158
+ ), $this->labels->post_type . '-settings', $this->labels->post_type . '-settings'
159
+ );
160
+ }
161
+ }
162
+
163
+ /**
164
+ * Settings helper to render HTML settings
165
+ *
166
+ * @since 2.2
167
+ * @access public
168
+ *
169
+ * @param array $args settings array
170
+ */
171
+ public function settings_helper( $args ) {
172
+ $element_name = $this->labels->options_key . '[' . $args['name'] . ']';
173
+ $element_default = ( isset( $args['default'] ) ) ? $args['default'] : '';
174
+ $element_value = dev7_default_val( $this->options, $args['name'], $element_default );
175
+ $element_class = ( isset( $args['class'] ) ) ? $args['class'] : '';
176
+ switch ( $args['type'] ) {
177
+
178
+ case 'text':
179
+ ?>
180
+ <input type="text" name="<?php echo $element_name; ?>" value="<?php echo $element_value; ?>" class="<?php echo $element_class; ?> " />
181
+ <?php
182
+ break;
183
+
184
+ case 'textarea':
185
+ $rows = ( isset( $args['rows'] ) ) ? $args['rows'] : 5;
186
+ $cols = ( isset( $args['cols'] ) ) ? $args['cols'] : 80;
187
+
188
+ ?>
189
+ <textarea class="<?php echo $element_class; ?>" name="<?php echo $element_name; ?>" rows="<?php echo $rows; ?>" cols="<?php echo $cols; ?>"><?php echo $element_value; ?></textarea>
190
+ <?php
191
+ break;
192
+
193
+ case 'number':
194
+ ?>
195
+ <input type="number" name="<?php echo $element_name; ?>" value="<?php echo $element_value; ?>" class="<?php echo $element_class; ?> " />
196
+ <?php
197
+ break;
198
+
199
+ case 'checkbox':
200
+ ?>
201
+ <input type="hidden" name="<?php echo $element_name; ?>" value="off" />
202
+ <input type="checkbox" name="<?php echo $element_name; ?>" value="on"<?php if ( $element_value == 'on' ) {
203
+ echo ' checked="checked"';
204
+ } ?> class="<?php echo $element_class; ?> " />
205
+ <?php
206
+ break;
207
+
208
+ case 'select':
209
+ ?>
210
+ <select name="<?php echo $element_name; ?>" class="<?php echo $element_class; ?> ">
211
+ <?php
212
+ foreach ( $args['options'] as $value => $name ) {
213
+ ?>
214
+ <option value="<?php echo $value; ?>"<?php if ( $value == $element_value ) {
215
+ echo ' selected="selected"';
216
+ } ?>><?php echo $name; ?></option>
217
+ <?php } ?>
218
+ </select>
219
+ <?php
220
+ break;
221
+ }
222
+ if ( isset( $args['descp'] ) && $args['descp'] != '' ) {
223
+ ?>
224
+ <span class="description"><?php echo $args['descp']; ?></span>
225
+ <?php
226
+ }
227
+ }
228
+
229
+ /**
230
+ * Displays the introduction on the settings page
231
+ *
232
+ * @since 2.2
233
+ * @access public
234
+ */
235
+ public function display_settings_intro() {
236
+ echo apply_filters( $this->labels->post_type . '_settings_intro', '' );
237
+ }
238
+
239
+ /**
240
+ * Validation of settings on save.
241
+ *
242
+ * @since 2.2
243
+ * @access public
244
+ */
245
+ public function settings_validate( $input ) {
246
+ $options = $this->options;
247
+ if ( $options && is_array( $options ) ) {
248
+ foreach ( $options as $key => $option ) {
249
+ if ( ! array_key_exists( $key, $input ) && $key != 'license_status' && $key != 'license_key' ) {
250
+ $input[$key] = $option;
251
+ }
252
+ }
253
+ }
254
+ $input = $this->save_custom_roles( $input );
255
+
256
+ return apply_filters( $this->labels->post_type . '_settings_validate', $input );
257
+ }
258
+
259
+ /**
260
+ * Renders setting for custom roles
261
+ *
262
+ * @since 2.2
263
+ * @access public
264
+ */
265
+ public function setting_custom_roles() {
266
+ $options = $this->options;
267
+ global $wp_roles;
268
+ $role_names = $wp_roles->get_names();
269
+ if ( ! isset( $options['custom-roles'] ) ) {
270
+ $defaults = array();
271
+ foreach ( $role_names as $key => $value ) {
272
+ if ( $key != 'administrator' ) {
273
+ $defaults[] = $key;
274
+ }
275
+ }
276
+ $options['custom-roles'] = $defaults;
277
+ }
278
+ $roles = array();
279
+ foreach ( $role_names as $key => $value ) {
280
+ if ( $key != 'administrator' ) {
281
+ $roles[$key] = get_role( $key );
282
+ $roles[$key]->display_name = $value;
283
+ if ( in_array( $roles[$key]->name, $options['custom-roles'] ) ) {
284
+ $roles[$key]->selected = true;
285
+ }
286
+ }
287
+ }
288
+ echo '<input type="hidden" name="' . $this->labels->options_key . '[roles]" value="roles">';
289
+ foreach ( $roles as $role ):
290
+ echo '<input type="checkbox" id="' . $role->name . '" name="' . $this->labels->options_key . '[' . $role->name . ']" ' . ( isset( $role->selected ) && ( $role->selected ) ? ' checked="checked"' : '' ) . '/> ';
291
+ echo $role->display_name . '<br/>';
292
+ endforeach;
293
+ }
294
+
295
+ /**
296
+ * Custom save method for saving custom roles
297
+ *
298
+ * @since 2.2
299
+ * @access private
300
+ */
301
+ private function save_custom_roles( $input ) {
302
+ if ( $input && is_array( $input ) && isset( $input['roles'] ) ) {
303
+ $custom_roles = array();
304
+ global $wp_roles;
305
+ $role_names = $wp_roles->get_names();
306
+ $roles = array();
307
+ foreach ( $role_names as $key => $value ) {
308
+ if ( $key != 'administrator' ) {
309
+ $roles[$key] = get_role( $key );
310
+ $roles[$key]->display_name = $value;
311
+ }
312
+ }
313
+ foreach ( $input as $key => $value ) {
314
+ if ( array_key_exists( $key, $roles ) ) {
315
+ $custom_roles[] = $key;
316
+ unset( $input[$key] );
317
+ }
318
+ }
319
+ unset( $input['roles'] );
320
+ $custom_roles[] = 'administrator';
321
+ $input['custom-roles'] = $custom_roles;
322
+ }
323
+
324
+ return $input;
325
+ }
326
+
327
+ /**
328
+ * Renders setting for license
329
+ *
330
+ * @since 2.2
331
+ * @access public
332
+ */
333
+ public function setting_license_settings() {
334
+ $license_key = dev7_get_license_key( $this->labels->post_type, $this->options );
335
+ $status = dev7_default_val( $this->options, 'license_status', false );
336
+ echo '<div id="dev7license">';
337
+ echo '<input type="hidden" name="' . $this->labels->options_key . '[license_status]" value="' . $status . '">';
338
+ if ( $status !== false && $status == 'valid' ) {
339
+ echo '<input type="hidden" name="' . $this->labels->options_key . '[license_key]" value="' . $license_key . '">';
340
+ echo '<span style="color:green;">' . __( 'Active: ', 'dev7-core' ) . '</span>';
341
+ echo '<span class="regular-text">' . $license_key . '</span><br> ';
342
+ echo '<input id="deactivate-license" type="button" class="button-secondary" value="' . __( 'Deactivate License', 'dev7-core' ) . '"/>';
343
+ } else {
344
+ if ( dev7_license_constant( $this->labels->post_type ) ) {
345
+ echo '<input type="hidden" name="' . $this->labels->options_key . '[license_key]" value="' . $license_key . '">';
346
+ echo '<span class="regular-text">' . $license_key . '</span><br> ';
347
+ echo '<label class="description">' . __( 'Activate this license key to enable automatic upgrades', 'dev7-core' ) . '</label><br>';
348
+ } else {
349
+ echo '<input type="text" name="' . $this->labels->options_key . '[license_key]" class="regular-text" value="' . $license_key . '"><br> ';
350
+ echo '<label class="description">' . __( 'Enter a valid license key to enable automatic upgrades', 'dev7-core' ) . '</label><br>';
351
+ }
352
+ echo '<input id="activate-license" type="button" class="button-primary" value="' . __( 'Activate License', 'dev7-core' ) . '"/>';
353
+ }
354
+ echo '<span class="spinner"></span></div>';
355
+ }
356
+
357
+ /**
358
+ * Displays a custom message about license activation in the plugin table list
359
+ *
360
+ * @since 2.2
361
+ * @access public
362
+ */
363
+ public function plugin_row() {
364
+ $license_key = dev7_get_license_key( $this->labels->post_type, $this->options );
365
+ $status = dev7_default_val( $this->options, 'license_status', 'invalid' );
366
+ if ( ( empty( $license_key ) || $license_key == '' ) || $status == 'invalid' ) {
367
+ $settings_link = sprintf( '<a href="%s">%s</a>', admin_url( 'edit.php?post_type=' . $this->labels->post_type . '&page=' . $this->labels->post_type . '-settings' ), __( 'Settings', 'dev7-core' ) );
368
+ $message = 'To finish activating ' . $this->labels->plugin_name . ', please go to ' . $settings_link . ' and enter your license key and activate it to enable automatic updates.';
369
+ } else {
370
+ return;
371
+ }
372
+ ?>
373
+ <tr class="plugin-update-tr dev7-custom">
374
+ <td colspan="3" class="plugin-update">
375
+ <div class="update-message">
376
+ <?php echo $message; ?>
377
+ </div>
378
+ </td>
379
+ </tr>
380
+ <?php
381
+ }
382
+
383
+ /**
384
+ * Adds a new link to the plugin settings on the plugin table list
385
+ *
386
+ * @since 2.2
387
+ * @access public
388
+ */
389
+ public function plugin_action_links( $links, $file ) {
390
+ if ( $file == $this->labels->plugin_basename ) {
391
+ $settings_link = sprintf( '<a href="%s">%s</a>', admin_url( 'edit.php?post_type=' . $this->labels->post_type . '&page=' . $this->labels->post_type . '-settings' ), __( 'Settings', 'dev7-core' ) );
392
+ array_unshift( $links, $settings_link );
393
+ }
394
+
395
+ return $links;
396
+ }
397
+ }
includes/core/includes/admin-view.php ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Admin View Class
4
+ *
5
+ * @package Plugin Core
6
+ * @subpackage Admin/View
7
+ * @copyright Copyright (c) 2014, Dev7studios
8
+ * @license http://opensource.org/licenses/GPL-3.0 GNU Public License
9
+ * @since 2.2
10
+ */
11
+
12
+ // Exit if accessed directly
13
+ if ( ! defined( 'ABSPATH' ) ) {
14
+ exit;
15
+ }
16
+
17
+ /**
18
+ * Admin View Core Class
19
+ *
20
+ * @since 2.2
21
+ */
22
+ class Dev7_Core_Admin_View {
23
+
24
+ /**
25
+ * Plugin labels
26
+ *
27
+ * @var object
28
+ * @access private
29
+ * @since 2.2
30
+ */
31
+ private $labels;
32
+
33
+ /**
34
+ * Instance of Dev7 Images Core Class
35
+ *
36
+ * @var object
37
+ * @access private
38
+ * @since 2.2
39
+ */
40
+ private $core_images;
41
+
42
+ /**
43
+ * Main construct for the [gallery] list page
44
+ *
45
+ * @since 2.2
46
+ *
47
+ * @param array $labels Specific plugin label data
48
+ */
49
+ function __construct( $labels ) {
50
+ $this->labels = $labels;
51
+ $this->core_images = new Dev7_Core_Images( $this->labels );
52
+
53
+ add_action( 'manage_edit-' . $this->labels->post_type . '_columns', array( $this, 'edit_columns' ) );
54
+ add_action( 'manage_' . $this->labels->post_type . '_posts_custom_column', array( $this, 'custom_columns' ) );
55
+ }
56
+
57
+ /**
58
+ * Adds the custom columns to the post type admin index screen
59
+ *
60
+ * @since 2.2
61
+ * @access public
62
+ *
63
+ * @param array $columns
64
+ *
65
+ * @return array $columns
66
+ */
67
+ public function edit_columns( $columns ) {
68
+ $columns = array(
69
+ 'cb' => '<input type="checkbox" />',
70
+ 'title' => __( 'Title', 'dev7core' ),
71
+ 'shortcode' => __( 'Shortcode', 'dev7core' ),
72
+ 'type' => __( 'Type', 'dev7core' ),
73
+ 'images' => __( 'Images', 'dev7core' ),
74
+ 'author' => __( 'Author', 'dev7core' ),
75
+ 'date' => __( 'Date', 'dev7core' )
76
+ );
77
+
78
+ return apply_filters( 'dev7_edit_columns', $columns );
79
+ }
80
+
81
+ /**
82
+ * Populates the data in the custom columns
83
+ *
84
+ * @since 2.2
85
+ * @access public
86
+ *
87
+ * @param $column
88
+ */
89
+ public function custom_columns( $column ) {
90
+ global $post;
91
+
92
+ if ( $post->post_type != $this->labels->post_type ) {
93
+ return;
94
+ }
95
+ $options = get_post_meta( $post->ID, $this->labels->post_meta_key, true );
96
+
97
+ do_action( $this->labels->post_type . '_custom_column_switch', $post, $column, $options );
98
+
99
+ $type = dev7_default_val( $options, $this->labels->source_name, $this->core_images->image_source_default() );
100
+ $types = $this->core_images->get_image_sources();
101
+
102
+ switch ( $column ) {
103
+ case 'images':
104
+ $limit = 5;
105
+ if ( isset( $_GET['mode'] ) && $_GET['mode'] == 'excerpt' ) {
106
+ $limit = 20;
107
+ }
108
+ $images = $this->core_images->get_images( $post->ID, 'thumbnail', $limit );
109
+ if ( $images ) {
110
+ echo '<ul class="dev7plugin-thumbs">';
111
+ foreach ( $images as $image ) {
112
+ echo '<li><img src="' . $image['image_src'] . '" alt="' . $image['alt_text'] . '" style="width:32px;height:32px;" /></li>';
113
+ }
114
+ echo '</ul>';
115
+ } else {
116
+ if ( ( ! isset( $types[$type] ) || $type == $this->labels->manual_name ) && ( ! isset( $options['manual_image_ids'] ) || $options['manual_image_ids'] == '' ) ) {
117
+ $images = dev7_get_attached_images( $post->ID, 1 );
118
+ if ( $images ) {
119
+ echo '<a class="reattach-images" data-post="'. $post->ID .'" href="#">Reattach Images</a><div class="reattach-spinner spinner"></div>';
120
+ } else {
121
+ echo 'No images attached';
122
+ }
123
+ }
124
+ }
125
+ break;
126
+ case 'shortcode':
127
+ echo '<code>[' . $this->labels->shortcode . ' id="' . $post->ID . '"]</code>';
128
+ if ( $post->post_name != '' ) {
129
+ echo '<br /><code>[' . $this->labels->shortcode . ' slug="' . $post->post_name . '"]</code>';
130
+ }
131
+ break;
132
+ case 'type':
133
+
134
+ echo isset( $types[$type] ) ? $types[$type] : 'Manual';
135
+ switch ( $type ) {
136
+ case 'gallery':
137
+ $gallery_post = get_the_title( dev7_default_val( $options, $this->labels->type_name . '_gallery' ) );
138
+ echo '<br><em>' . $gallery_post . '</em>';
139
+ break;
140
+ case 'category':
141
+ $category = get_category( dev7_default_val( $options, $this->labels->type_name . '_category' ) );
142
+ echo '<br><em>' . $category->name . '</em>';
143
+ break;
144
+ case 'custom':
145
+ $post_type = get_post_type_object( dev7_default_val( $options, $this->labels->type_name . '_custom' ) );
146
+ echo '<br><em>' . ( ( isset( $post_type->labels->name ) ) ? $post_type->labels->name : ucfirst( $post_type ) ) . '</em>';
147
+ break;
148
+ }
149
+ break;
150
+ }
151
+ }
152
+ }
includes/core/includes/assets.php ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Assets Class
4
+ *
5
+ * @package Plugin Core
6
+ * @subpackage Assets
7
+ * @copyright Copyright (c) 2014, Dev7studios
8
+ * @license http://opensource.org/licenses/GPL-3.0 GNU Public License
9
+ * @since 2.2
10
+ */
11
+
12
+ // Exit if accessed directly
13
+ if ( ! defined( 'ABSPATH' ) ) {
14
+ exit;
15
+ }
16
+
17
+ /**
18
+ * Assets Core Class
19
+ *
20
+ * @since 2.2
21
+ */
22
+ class Dev7_Core_Assets {
23
+
24
+ /**
25
+ * Plugin labels
26
+ *
27
+ * @var object
28
+ * @access private
29
+ * @since 2.2
30
+ */
31
+ private $labels;
32
+
33
+ /**
34
+ * Main construct for the Dev7 core Assets class
35
+ *
36
+ * @since 2.2
37
+ *
38
+ * @param array $labels Specific plugin label data
39
+ */
40
+ public function __construct( $labels ) {
41
+ $this->labels = $labels;
42
+
43
+ add_action( 'init', array( $this, 'init' ) );
44
+ add_action( 'admin_print_scripts', array( $this, 'admin_print_scripts' ) );
45
+ add_action( 'admin_enqueue_scripts', array( $this, 'admin_styles' ) );
46
+ add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
47
+ }
48
+
49
+ /**
50
+ * Registers the TinyMCE plugins
51
+ *
52
+ * @since 2.2
53
+ * @access public
54
+ */
55
+ public function init() {
56
+ if ( current_user_can( 'edit_posts' ) && current_user_can( 'edit_pages' ) && get_user_option( 'rich_editing' ) == 'true' ) {
57
+ add_filter( 'mce_external_plugins', array( $this, 'mce_add_plugin' ) );
58
+ add_filter( 'mce_buttons_2', array( $this, 'mce_register_button' ) );
59
+ }
60
+ }
61
+
62
+ /**
63
+ * Registers the TinyMCE script
64
+ *
65
+ * @since 2.2
66
+ * @access public
67
+ */
68
+ public function mce_add_plugin( $plugin_array ) {
69
+ $plugin_array[$this->labels->post_type] = plugins_url( 'assets/js/tinymce.js', $this->labels->plugin_file );
70
+
71
+ return $plugin_array;
72
+ }
73
+
74
+ /**
75
+ * Registers the TinyMCE button
76
+ *
77
+ * @since 2.2
78
+ * @access public
79
+ */
80
+ public function mce_register_button( $buttons ) {
81
+ array_push( $buttons, "|", $this->labels->post_type );
82
+
83
+ return $buttons;
84
+ }
85
+
86
+ /**
87
+ * Prints the [galleries] as javascript to be used by the TinyMCE plugin
88
+ *
89
+ * @since 2.2
90
+ * @access public
91
+ */
92
+ public function admin_print_scripts() {
93
+ // Galleries list for TinyMCE dropdown
94
+ $galleries = get_posts( array( 'post_type' => $this->labels->post_type, 'posts_per_page' => - 1 ) );
95
+ $list = array();
96
+ foreach ( $galleries as $gallery ) {
97
+ $list[] = array(
98
+ 'id' => $gallery->ID,
99
+ 'name' => $gallery->post_title
100
+ );
101
+ }
102
+ $settings = array(
103
+ 'galleries' => json_encode( $list )
104
+ );
105
+ $html = "<script type='text/javascript'>\n";
106
+ $html .= 'var ' . $this->labels->post_type . ' = ' . json_encode( $settings ) . '';
107
+ $html .= "\n</script>";
108
+ echo $html;
109
+ }
110
+
111
+ /**
112
+ * Registers and enqueues the styles for the plugin
113
+ *
114
+ * @since 2.2
115
+ * @access public
116
+ */
117
+ public function admin_styles() {
118
+ global $post;
119
+ if ( ( isset( $post->post_type ) && $post->post_type == $this->labels->post_type )
120
+ || ( isset( $_GET['page'] ) && $_GET['page'] == $this->labels->post_type . '-settings' )
121
+ ) {
122
+
123
+ wp_register_style( $this->labels->post_type . '-admin', plugins_url( 'includes/core/assets/css/admin.css', $this->labels->plugin_file ), array(), $this->labels->plugin_version );
124
+ wp_enqueue_style( $this->labels->post_type . '-admin' );
125
+ }
126
+ }
127
+
128
+ /**
129
+ * Registers and enqueues the scripts for the plugin
130
+ *
131
+ * @since 2.2
132
+ * @access public
133
+ */
134
+ public function admin_scripts() {
135
+ global $post;
136
+ if ( ( isset( $post->post_type ) && $post->post_type == $this->labels->post_type )
137
+ || ( isset( $_GET['page'] ) && $_GET['page'] == $this->labels->post_type . '-settings' )
138
+ ) {
139
+
140
+ wp_register_script( $this->labels->post_type . '-core-admin', plugins_url( 'includes/core/assets/js/admin.js', $this->labels->plugin_file ), array( 'jquery' ), $this->labels->plugin_version );
141
+ wp_enqueue_script( $this->labels->post_type . '-core-admin' );
142
+
143
+ wp_register_script(
144
+ $this->labels->post_type . '-image-admin', plugins_url( 'includes/core/assets/js/image-admin.js', $this->labels->plugin_file ), array(
145
+ 'jquery',
146
+ $this->labels->post_type . '-core-admin'
147
+ ), $this->labels->plugin_version
148
+ );
149
+ wp_enqueue_script( $this->labels->post_type . '-image-admin' );
150
+
151
+ $settings = array(
152
+ 'post_id' => ( isset( $post->ID ) ) ? $post->ID : '',
153
+ 'labels' => $this->labels,
154
+ 'nonce' => wp_create_nonce( $this->labels->post_type ),
155
+ );
156
+ $settings = apply_filters( $this->labels->post_type . '_script_settings', $settings );
157
+ wp_localize_script( $this->labels->post_type . '-core-admin', 'dev7plugin', $settings );
158
+
159
+ do_action( $this->labels->post_type . '_admin_scripts' );
160
+ }
161
+ }
162
+ }
includes/core/includes/edd_sl_plugin_updater.php ADDED
@@ -0,0 +1,339 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // uncomment this line for testing
4
+ //set_site_transient( 'update_plugins', null );
5
+
6
+ /**
7
+ * Allows plugins to use their own update API.
8
+ *
9
+ * @author Pippin Williamson
10
+ * @version 1.6
11
+ */
12
+ if ( ! class_exists( 'Dev7_EDD_SL_Plugin_Updater_16' ) ) {
13
+ class Dev7_EDD_SL_Plugin_Updater_16 {
14
+ private $api_url = '';
15
+ private $api_data = array();
16
+ private $name = '';
17
+ private $slug = '';
18
+
19
+ /**
20
+ * Class constructor.
21
+ *
22
+ * @uses plugin_basename()
23
+ * @uses hook()
24
+ *
25
+ * @param string $_api_url The URL pointing to the custom API endpoint.
26
+ * @param string $_plugin_file Path to the plugin file.
27
+ * @param array $_api_data Optional data to send with API calls.
28
+ * @return void
29
+ */
30
+ function __construct( $_api_url, $_plugin_file, $_api_data = null ) {
31
+ $this->api_url = trailingslashit( $_api_url );
32
+ $this->api_data = $_api_data;
33
+ $this->name = plugin_basename( $_plugin_file );
34
+ $this->slug = basename( $_plugin_file, '.php' );
35
+ $this->version = $_api_data['version'];
36
+ $this->plugin = plugin_basename( $_plugin_file );
37
+
38
+ // Set up hooks.
39
+ $this->init();
40
+ add_action( 'admin_init', array( $this, 'show_changelog' ) );
41
+ }
42
+
43
+ /**
44
+ * Set up WordPress filters to hook into WP's update process.
45
+ *
46
+ * @uses add_filter()
47
+ *
48
+ * @return void
49
+ */
50
+ public function init() {
51
+
52
+ add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
53
+ add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 );
54
+
55
+ add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 );
56
+ }
57
+
58
+ /**
59
+ * Check for Updates at the defined API endpoint and modify the update array.
60
+ *
61
+ * This function dives into the update API just when WordPress creates its update array,
62
+ * then adds a custom API call and injects the custom plugin data retrieved from the API.
63
+ * It is reassembled from parts of the native WordPress plugin update code.
64
+ * See wp-includes/update.php line 121 for the original wp_update_plugins() function.
65
+ *
66
+ * @uses api_request()
67
+ *
68
+ * @param array $_transient_data Update array build by WordPress.
69
+ * @return array Modified update array with custom plugin data.
70
+ */
71
+ function check_update( $_transient_data ) {
72
+
73
+ global $pagenow;
74
+
75
+ if( ! is_object( $_transient_data ) ) {
76
+ $_transient_data = new stdClass;
77
+ }
78
+
79
+ if( 'plugins.php' == $pagenow && is_multisite() ) {
80
+ return $_transient_data;
81
+ }
82
+
83
+ if ( empty( $_transient_data->response ) || empty( $_transient_data->response[ $this->name ] ) ) {
84
+
85
+ $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) );
86
+ $version_info->plugin = $this->plugin;
87
+
88
+ if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) {
89
+
90
+ $this->did_check = true;
91
+
92
+ if( version_compare( $this->version, $version_info->new_version, '<' ) ) {
93
+
94
+ $_transient_data->response[ $this->name ] = $version_info;
95
+
96
+ }
97
+
98
+ $_transient_data->last_checked = time();
99
+ $_transient_data->checked[ $this->name ] = $this->version;
100
+
101
+ }
102
+ }
103
+
104
+ return $_transient_data;
105
+ }
106
+
107
+ /**
108
+ * show update nofication row -- needed for multisite subsites, because WP won't tell you otherwise!
109
+ *
110
+ * @param string $file
111
+ * @param array $plugin
112
+ */
113
+ public function show_update_notification( $file, $plugin ) {
114
+
115
+ if ( ! current_user_can( 'update_plugins' ) ) {
116
+ return;
117
+ }
118
+
119
+ if ( ! is_multisite() ) {
120
+ return;
121
+ }
122
+
123
+ if ( $this->name != $file ) {
124
+ return;
125
+ }
126
+
127
+ // Remove our filter on the site transient
128
+ remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 );
129
+
130
+ $update_cache = get_site_transient( 'update_plugins' );
131
+
132
+ if ( ! is_object( $update_cache ) || empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) {
133
+
134
+ $cache_key = md5( 'edd_plugin_' .sanitize_key( $this->name ) . '_version_info' );
135
+ $version_info = get_transient( $cache_key );
136
+
137
+ if( false === $version_info ) {
138
+
139
+ $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) );
140
+
141
+ set_transient( $cache_key, $version_info, 3600 );
142
+ }
143
+
144
+
145
+ if ( ! is_object( $version_info ) ) {
146
+ return;
147
+ }
148
+
149
+ if ( version_compare( $this->version, $version_info->new_version, '<' ) ) {
150
+
151
+ $update_cache->response[ $this->name ] = $version_info;
152
+
153
+ }
154
+
155
+ $update_cache->last_checked = time();
156
+ $update_cache->checked[ $this->name ] = $this->version;
157
+
158
+ set_site_transient( 'update_plugins', $update_cache );
159
+
160
+ } else {
161
+
162
+ $version_info = $update_cache->response[ $this->name ];
163
+
164
+ }
165
+
166
+ // Restore our filter
167
+ add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
168
+
169
+ if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) {
170
+
171
+ // build a plugin list row, with update notification
172
+ $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
173
+ echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">';
174
+
175
+ $changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' );
176
+
177
+ if ( empty( $version_info->download_link ) ) {
178
+ printf(
179
+ __( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a>.', 'edd' ),
180
+ esc_html( $version_info->name ),
181
+ esc_url( $changelog_link ),
182
+ esc_html( $version_info->new_version )
183
+ );
184
+ } else {
185
+ printf(
186
+ __( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a> or <a href="%4$s">update now</a>.', 'edd' ),
187
+ esc_html( $version_info->name ),
188
+ esc_url( $changelog_link ),
189
+ esc_html( $version_info->new_version ),
190
+ esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) )
191
+ );
192
+ }
193
+
194
+ echo '</div></td></tr>';
195
+ }
196
+ }
197
+
198
+
199
+ /**
200
+ * Updates information on the "View version x.x details" page with custom data.
201
+ *
202
+ * @uses api_request()
203
+ *
204
+ * @param mixed $_data
205
+ * @param string $_action
206
+ * @param object $_args
207
+ * @return object $_data
208
+ */
209
+ function plugins_api_filter( $_data, $_action = '', $_args = null ) {
210
+
211
+ if ( $_action != 'plugin_information' ) {
212
+
213
+ return $_data;
214
+
215
+ }
216
+
217
+ if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) {
218
+
219
+ return $_data;
220
+
221
+ }
222
+
223
+ $to_send = array(
224
+ 'slug' => $this->slug,
225
+ 'is_ssl' => is_ssl(),
226
+ 'fields' => array(
227
+ 'banners' => false, // These will be supported soon hopefully
228
+ 'reviews' => false,
229
+ )
230
+ );
231
+
232
+ $api_response = $this->api_request( 'plugin_information', $to_send );
233
+
234
+ if ( false !== $api_response ) {
235
+ $_data = $api_response;
236
+ }
237
+
238
+ return $_data;
239
+ }
240
+
241
+
242
+ /**
243
+ * Disable SSL verification in order to prevent download update failures
244
+ *
245
+ * @param array $args
246
+ * @param string $url
247
+ * @return object $array
248
+ */
249
+ function http_request_args( $args, $url ) {
250
+ // If it is an https request and we are performing a package download, disable ssl verification
251
+ if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) {
252
+ $args['sslverify'] = false;
253
+ }
254
+ return $args;
255
+ }
256
+
257
+ /**
258
+ * Calls the API and, if successfull, returns the object delivered by the API.
259
+ *
260
+ * @uses get_bloginfo()
261
+ * @uses wp_remote_post()
262
+ * @uses is_wp_error()
263
+ *
264
+ * @param string $_action The requested action.
265
+ * @param array $_data Parameters for the API action.
266
+ * @return false||object
267
+ */
268
+ private function api_request( $_action, $_data ) {
269
+
270
+ global $wp_version;
271
+
272
+ $data = array_merge( $this->api_data, $_data );
273
+
274
+ if ( $data['slug'] != $this->slug ) {
275
+ return;
276
+ }
277
+
278
+ if ( empty( $data['license'] ) ) {
279
+ return;
280
+ }
281
+
282
+ if( $this->api_url == home_url() ) {
283
+ return false; // Don't allow a plugin to ping itself
284
+ }
285
+
286
+ $api_params = array(
287
+ 'edd_action' => 'get_version',
288
+ 'license' => $data['license'],
289
+ 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false,
290
+ 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false,
291
+ 'slug' => $data['slug'],
292
+ 'author' => $data['author'],
293
+ 'url' => home_url()
294
+ );
295
+
296
+ $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
297
+
298
+ if ( ! is_wp_error( $request ) ) {
299
+ $request = json_decode( wp_remote_retrieve_body( $request ) );
300
+ }
301
+
302
+ if ( $request && isset( $request->sections ) ) {
303
+ $request->sections = maybe_unserialize( $request->sections );
304
+ } else {
305
+ $request = false;
306
+ }
307
+
308
+ return $request;
309
+ }
310
+
311
+ public function show_changelog() {
312
+
313
+ if ( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) {
314
+ return;
315
+ }
316
+
317
+ if ( empty( $_REQUEST['plugin'] ) ) {
318
+ return;
319
+ }
320
+
321
+ if ( empty( $_REQUEST['slug'] ) ) {
322
+ return;
323
+ }
324
+
325
+ if ( ! current_user_can( 'update_plugins' ) ) {
326
+ wp_die( __( 'You do not have permission to install plugin updates', 'edd' ), __( 'Error', 'edd' ), array( 'response' => 403 ) );
327
+ }
328
+
329
+ $response = $this->api_request( 'plugin_latest_version', array( 'slug' => $_REQUEST['slug'] ) );
330
+
331
+ if ( $response && isset( $response->sections['changelog'] ) ) {
332
+ echo '<div style="background:#fff;padding:10px;">' . $response->sections['changelog'] . '</div>';
333
+ }
334
+
335
+ exit;
336
+ }
337
+
338
+ }
339
+ }
includes/core/includes/functions.php ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Functions
4
+ *
5
+ * @package Plugin Core
6
+ * @subpackage Core
7
+ * @copyright Copyright (c) 2014, Dev7studios
8
+ * @license http://opensource.org/licenses/GPL-3.0 GNU Public License
9
+ * @since 2.2
10
+ */
11
+
12
+ // Exit if accessed directly
13
+ if ( ! defined( 'ABSPATH' ) ) {
14
+ exit;
15
+ }
16
+
17
+ /**
18
+ * Default value helper function
19
+ *
20
+ * @since 2.2
21
+ *
22
+ * @param $options
23
+ * @param $value
24
+ * @param string $default
25
+ *
26
+ * @return string
27
+ */
28
+ if ( ! function_exists( 'dev7_default_val' ) ) {
29
+ function dev7_default_val( $options, $value, $default = '' ) {
30
+ if ( ! isset( $options[$value] ) ) {
31
+ return $default;
32
+ } else {
33
+ return $options[$value];
34
+ }
35
+ }
36
+ }
37
+
38
+ /**
39
+ * Checks if a plugin is installed and active
40
+ *
41
+ * @since 2.2
42
+ *
43
+ * @param $plugin
44
+ *
45
+ * @return bool
46
+ */
47
+ if ( ! function_exists( 'dev7_plugin_is_active' ) ) {
48
+ function dev7_plugin_is_active( $plugin ) {
49
+ return in_array( $plugin, (array) get_option( 'active_plugins', array() ) );
50
+ }
51
+ }
52
+
53
+ /**
54
+ * Checks if Media Manager Plus is installed and active
55
+ *
56
+ * @since 2.2
57
+ * @return bool
58
+ */
59
+ if ( ! function_exists( 'dev7_mmp_active' ) ) {
60
+ function dev7_mmp_active() {
61
+ $mmp_path = 'uber-media/uber-media.php';
62
+
63
+ return dev7_plugin_is_active( $mmp_path );
64
+ }
65
+ }
66
+
67
+ /**
68
+ * Checks if a license for the plugin has been set as a constant
69
+ *
70
+ * @since 2.2
71
+ * @return bool
72
+ */
73
+ if ( ! function_exists( 'dev7_license_constant' ) ) {
74
+ function dev7_license_constant( $post_type ) {
75
+ return apply_filters( $post_type . '_check_license_constant', false );
76
+ }
77
+ }
78
+
79
+ /**
80
+ * Returns the license key for the plugin
81
+ *
82
+ * @since 2.2
83
+ *
84
+ * @param string $post_type
85
+ * @param array $options
86
+ *
87
+ * @return string $license
88
+ */
89
+ if ( ! function_exists( 'dev7_get_license_key' ) ) {
90
+ function dev7_get_license_key( $post_type, $options ) {
91
+ if ( dev7_license_constant( $post_type ) ) {
92
+ $license = apply_filters( $post_type . '_get_license_constant', '' );
93
+ } else {
94
+ $license = dev7_default_val( $options, 'license_key', '' );
95
+ }
96
+
97
+ return trim( $license );
98
+ }
99
+ }
100
+
101
+ /**
102
+ * Checks to see if content has the plugin shortcode
103
+ *
104
+ * @since 2.2
105
+ *
106
+ * @param string $content
107
+ * @param array $shortcode
108
+ *
109
+ * @return bool $found
110
+ */
111
+ if ( ! function_exists( 'dev7_has_shortcode_wrap' ) ) {
112
+ function dev7_has_shortcode_wrap( $content, $shortcode = '' ) {
113
+
114
+ if ( function_exists( 'has_shortcode' ) ) {
115
+ return has_shortcode( $content, $shortcode );
116
+ }
117
+
118
+ $found = false;
119
+
120
+ if ( ! $shortcode ) {
121
+ return $found;
122
+ }
123
+ if ( stripos( $content, '[' . $shortcode ) !== false ) {
124
+ $found = true;
125
+ }
126
+
127
+ return $found;
128
+ }
129
+ }
130
+
131
+ /**
132
+ * Returns the images attached to a [gallery] post
133
+ *
134
+ * @since 2.2
135
+ *
136
+ * @param string $post_id
137
+ * @param array $limit
138
+ *
139
+ * @return array
140
+ */
141
+ if ( ! function_exists( 'dev7_get_attached_images' ) ) {
142
+ function dev7_get_attached_images( $post_id, $limit ) {
143
+ $args = array(
144
+ 'orderby' => 'menu_order ID',
145
+ 'order' => 'ASC',
146
+ 'post_type' => 'attachment',
147
+ 'post_parent' => $post_id,
148
+ 'post_mime_type' => 'image',
149
+ 'post_status' => null,
150
+ 'numberposts' => $limit
151
+ );
152
+
153
+ return get_posts( $args );
154
+ }
155
+ }
156
+
157
+ /**
158
+ * Gets the [gallery] images attached as a gallery or just attached the to the post
159
+ *
160
+ * @since 2.2
161
+ *
162
+ * @param string $post
163
+ * @param array $limit
164
+ *
165
+ * @return array
166
+ */
167
+ if ( ! function_exists( 'dev7_grab_attachment_ids_from_gallery' ) ) {
168
+ function dev7_grab_attachment_ids_from_gallery( $post, $limit ) {
169
+ if ( ! $post = get_post( $post ) ) {
170
+ return array();
171
+ }
172
+
173
+ if ( ! dev7_has_shortcode_wrap( $post->post_content, 'gallery' ) ) {
174
+ return dev7_get_attached_images( $post->ID, $limit );
175
+ }
176
+
177
+ $count = 0;
178
+ $attachments = array();
179
+ if ( preg_match_all( '/' . get_shortcode_regex() . '/s', $post->post_content, $matches, PREG_SET_ORDER ) ) {
180
+ foreach ( $matches as $shortcode ) {
181
+ if ( 'gallery' === $shortcode[2] ) {
182
+ $atts = shortcode_parse_atts( $shortcode[3] );
183
+ if ( isset( $atts['ids'] ) ) {
184
+ $attachment_ids = explode( ',', $atts['ids'] );
185
+ }
186
+ foreach ( $attachment_ids as $att_id ) {
187
+ $count ++;
188
+ if ( $limit != - 1 && $count > $limit ) {
189
+ break;
190
+ }
191
+ $attachment = new stdClass();
192
+ $attachment->ID = $att_id;
193
+ $attachments[] = $attachment;
194
+ }
195
+ }
196
+ }
197
+ }
198
+
199
+ return $attachments;
200
+ }
201
+ }
includes/core/includes/images.php ADDED
@@ -0,0 +1,534 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Images Class
4
+ *
5
+ * @package Plugin Core
6
+ * @subpackage Images
7
+ * @copyright Copyright (c) 2014, Dev7studios
8
+ * @license http://opensource.org/licenses/GPL-3.0 GNU Public License
9
+ * @since 2.2
10
+ */
11
+
12
+ // Exit if accessed directly
13
+ if ( ! defined( 'ABSPATH' ) ) {
14
+ exit;
15
+ }
16
+
17
+ /**
18
+ * Images Core Class
19
+ *
20
+ * @since 2.2
21
+ */
22
+ class Dev7_Core_Images {
23
+
24
+ /**
25
+ * Plugin labels
26
+ *
27
+ * @var object
28
+ * @access private
29
+ * @since 2.2
30
+ */
31
+ private $labels;
32
+
33
+ /**
34
+ * Main construct for the Dev7 core Images class
35
+ *
36
+ * @since 2.2
37
+ *
38
+ * @param array $labels Specific plugin label data
39
+ */
40
+ public function __construct( $labels ) {
41
+ $this->labels = $labels;
42
+ }
43
+
44
+ /**
45
+ * Returns the images sizes for the site
46
+ *
47
+ * @since 2.2
48
+ * @access public static
49
+ * @return array
50
+ */
51
+ public static function get_image_sizes() {
52
+ global $_wp_additional_image_sizes;
53
+ $image_sizes = array('thumbnail', 'medium', 'large', 'full'); // Standard sizes
54
+ if ( isset( $_wp_additional_image_sizes ) && count( $_wp_additional_image_sizes ) )
55
+ $image_sizes = array_merge( $image_sizes, array_keys( $_wp_additional_image_sizes ) );
56
+
57
+ $image_sizes = apply_filters( 'intermediate_image_sizes', $image_sizes );
58
+ $all_sizes = array();
59
+ foreach ( $image_sizes as $size ) {
60
+ $all_sizes[$size] = ucfirst( $size );
61
+ }
62
+ return $all_sizes;
63
+ }
64
+
65
+ /**
66
+ * Returns the default selected image source for the plugin
67
+ *
68
+ * @since 2.2
69
+ * @access public
70
+ * @return string
71
+ */
72
+ public function image_source_default() {
73
+ return apply_filters( $this->labels->post_type . '_image_source_default', $this->labels->manual_name );
74
+ }
75
+
76
+ /**
77
+ * Returns the default images sources for the plugin available
78
+ *
79
+ * @since 2.2
80
+ * @access public
81
+ * @return array $defaults image sources
82
+ */
83
+ public function image_sources_defaults() {
84
+ $defaults = array(
85
+ $this->labels->manual_name => __( 'Manual', 'dev7core' ),
86
+ 'gallery' => __( 'Gallery', 'dev7core' ),
87
+ 'category' => __( 'Category', 'dev7core' ),
88
+ 'sticky' => __( 'Sticky Posts', 'dev7core' )
89
+ );
90
+ $post_types = get_post_types(
91
+ array(
92
+ 'public' => true,
93
+ '_builtin' => false
94
+ ),
95
+ 'objects'
96
+ );
97
+ if ( sizeof( $post_types ) > 0 ) {
98
+ $defaults['custom'] = __( 'Custom Post Type', 'dev7core' );
99
+ }
100
+
101
+ return apply_filters( $this->labels->post_type . '_image_sources_defaults', $defaults );
102
+ }
103
+
104
+ /**
105
+ * Returns the images sources for the plugin available, including those from Media Manager Plus
106
+ *
107
+ * @since 2.2
108
+ * @access public
109
+ * @return array $sources image sources
110
+ */
111
+ function get_image_sources() {
112
+ $sources = $this->image_sources_defaults();
113
+ $exclude = apply_filters( 'mmp_feed_exclude', array() );
114
+ if ( dev7_mmp_active() ) {
115
+ $mmp_options = get_option( 'ubermediasettings_settings', array() );
116
+ $mmp_sources = dev7_default_val( $mmp_options, 'ubermediasettings_sources_available', array() );
117
+ if ( $mmp_sources ) {
118
+ foreach ( $mmp_sources as $mmp_source => $mmp_settings ) {
119
+ $mmp_source_name = str_replace( '-settings', '', $mmp_source );
120
+ if ( ! class_exists( 'media_manager_plus_source_' . $mmp_source_name ) ) {
121
+ continue;
122
+ }
123
+ if ( array_key_exists( $mmp_source_name, $exclude ) ) {
124
+ continue;
125
+ }
126
+ $sources[$mmp_source_name] = ucfirst( $mmp_source_name ) . ' Feed';
127
+ }
128
+ }
129
+ }
130
+
131
+ return apply_filters( $this->labels->post_type . '_get_image_sources', $sources );
132
+ }
133
+
134
+ /**
135
+ * Prepares the attached image url
136
+ *
137
+ * @since 2.2
138
+ * @access private
139
+ *
140
+ * @param $url
141
+ *
142
+ * @return string $url
143
+ */
144
+ private function prepare_attachment_link( $url ) {
145
+ $url = trim( strip_tags( $url ) );
146
+ if ( false === strpos( $url, '://' ) && $url != '' ) {
147
+ $url = 'http://' . $url;
148
+ }
149
+
150
+ return $url;
151
+ }
152
+
153
+ /**
154
+ * Returns the images for a [gallery]
155
+ *
156
+ * @since 2.2
157
+ *
158
+ * @param $post_id
159
+ * @param $size
160
+ * @param $limit
161
+ * @param $source
162
+ * @param $method
163
+ * @param $param
164
+ * @param $gallery
165
+ * @param $category
166
+ * @param $custom
167
+ * @param $image_ids
168
+ *
169
+ * @access public
170
+ * @return array $images images
171
+ */
172
+ public function get_images(
173
+ $post_id,
174
+ $size = '',
175
+ $limit = null,
176
+ $source = null,
177
+ $method = null,
178
+ $param = null,
179
+ $gallery = null,
180
+ $category = null,
181
+ $custom = null,
182
+ $image_ids = null
183
+ ) {
184
+
185
+ $options = get_post_meta( $post_id, $this->labels->post_meta_key, true );
186
+ if ( ! $options ) {
187
+ $options = array();
188
+ }
189
+
190
+ if ( $size == '' ) {
191
+ $size = dev7_default_val( $options, 'wp_image_size', 'full' );
192
+ }
193
+
194
+ $images = array();
195
+
196
+ $sources = $this->get_image_sources();
197
+
198
+ if ( ! isset( $options[$this->labels->source_name] ) || ! array_key_exists( $options[$this->labels->source_name], $sources ) ) {
199
+ $image_source = $this->image_source_default();
200
+ } else {
201
+ $image_source = dev7_default_val( $options, $this->labels->source_name, $this->image_source_default() );
202
+ }
203
+
204
+ if ( $source ) {
205
+ $image_source = $source;
206
+ }
207
+
208
+ if ( $limit ) {
209
+ $limit = $limit;
210
+ } else {
211
+ $limit = ( isset( $options['number_images'] ) && $options['number_images'] != '' ) ? $options['number_images'] : - 1;
212
+ }
213
+
214
+ if ( $image_source == $this->labels->manual_name ) {
215
+
216
+ if ( $image_ids ) {
217
+ $attach_str = $image_ids;
218
+ $options['manual_image_ids'] = $attach_str;
219
+ update_post_meta( $post_id, $this->labels->post_meta_key, $options );
220
+ } else {
221
+ $attach_str = dev7_default_val( $options, 'manual_image_ids', '' );
222
+ }
223
+ $attachments = explode( ',', $attach_str );
224
+ $count = 0;
225
+ if ( $attachments ) {
226
+ foreach ( $attachments as $attachment_id ) {
227
+ if ( $attachment_id == '' ) {
228
+ continue;
229
+ }
230
+ $count ++;
231
+ $attachment = get_post( $attachment_id );
232
+
233
+ if ( $limit != '-1' && $count > $limit ) {
234
+ break;
235
+ }
236
+ $image = wp_get_attachment_image_src( $attachment->ID, $size );
237
+ $thumbnail = wp_get_attachment_image_src( $attachment->ID, 'thumbnail' );
238
+
239
+ $url = $this->prepare_attachment_link( get_post_meta( $attachment->ID, '_wp_attachment_image_link', true ) );
240
+
241
+ $images[] = array(
242
+ 'image_src' => $image[0],
243
+ 'post_permalink' => $url,
244
+ 'post_title' => wptexturize( $attachment->post_excerpt ),
245
+ 'alt_text' => trim( strip_tags( get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ) ) ),
246
+ 'attachment_id' => $attachment->ID,
247
+ 'thumbnail' => $thumbnail[0]
248
+ );
249
+ }
250
+ }
251
+ } else if ( $image_source == 'gallery' ) {
252
+ $gallery = ( $gallery ) ? $gallery : $options[$this->labels->type_name . '_gallery'];
253
+ $attachments = dev7_grab_attachment_ids_from_gallery( $gallery, $limit );
254
+ if ( $attachments ) {
255
+ foreach ( $attachments as $attachment ) {
256
+ $image = wp_get_attachment_image_src( $attachment->ID, $size );
257
+ $meta = wp_get_attachment_metadata( $attachment->ID );
258
+ $caption = get_post_field( 'post_excerpt', $attachment->ID );
259
+ $link = get_attachment_link( $attachment->ID );
260
+ $thumbnail = wp_get_attachment_image_src( $attachment->ID, 'thumbnail' );
261
+ $images[] = array(
262
+ 'image_src' => $image[0],
263
+ 'post_permalink' => $link,
264
+ 'post_title' => $caption,
265
+ 'alt_text' => $caption,
266
+ 'attachment_id' => $attachment->ID,
267
+ 'thumbnail' => $thumbnail[0]
268
+ );
269
+ }
270
+ }
271
+ } else if ( $image_source == 'category' ) {
272
+ $category = ( $category ) ? $category : $options[$this->labels->type_name . '_category'];
273
+ $args = array(
274
+ 'post_type' => 'post',
275
+ 'numberposts' => $limit,
276
+ 'category' => $category
277
+ );
278
+ $posts = get_posts( $args );
279
+ if ( $posts ) {
280
+ foreach ( $posts as $post ) {
281
+ if ( has_post_thumbnail( $post->ID ) ) {
282
+ $attachment_id = get_post_thumbnail_id( $post->ID );
283
+ $image = wp_get_attachment_image_src( $attachment_id, $size );
284
+ $thumbnail = wp_get_attachment_image_src( $attachment_id, 'thumbnail' );
285
+ $title = get_the_title( $post->ID );
286
+ $link = ( get_post_meta( $attachment_id, '_wp_attachment_image_link', true ) ? $this->prepare_attachment_link( get_post_meta( $attachment_id, '_wp_attachment_image_link', true ) ) : get_permalink( $post->ID ) );
287
+ $images[] = array(
288
+ 'image_src' => $image[0],
289
+ 'post_permalink' => $link,
290
+ 'post_title' => $title,
291
+ 'alt_text' => $title,
292
+ 'attachment_id' => $attachment_id,
293
+ 'thumbnail' => $thumbnail[0]
294
+ );
295
+ }
296
+ }
297
+ }
298
+ } else if ( $image_source == 'sticky' ) {
299
+ $sticky = get_option( 'sticky_posts' );
300
+ $args = array(
301
+ 'post_type' => 'post',
302
+ 'numberposts' => $limit,
303
+ 'post__in' => $sticky
304
+ );
305
+ $posts = get_posts( $args );
306
+ if ( $posts ) {
307
+ foreach ( $posts as $post ) {
308
+ if ( has_post_thumbnail( $post->ID ) ) {
309
+ $attachment_id = get_post_thumbnail_id( $post->ID );
310
+ $image = wp_get_attachment_image_src( $attachment_id, $size );
311
+ $thumbnail = wp_get_attachment_image_src( $attachment_id, 'thumbnail' );
312
+ $link = ( get_post_meta( $attachment_id, '_wp_attachment_image_link', true ) ? $this->prepare_attachment_link( get_post_meta( $attachment_id, '_wp_attachment_image_link', true ) ) : get_permalink( $post->ID ) );
313
+ $title = get_the_title( $post->ID );
314
+ $images[] = array(
315
+ 'image_src' => $image[0],
316
+ 'post_permalink' => $link,
317
+ 'post_title' => $title,
318
+ 'alt_text' => $title,
319
+ 'attachment_id' => $attachment_id,
320
+ 'thumbnail' => $thumbnail[0]
321
+ );
322
+ }
323
+ }
324
+ }
325
+ } else {
326
+ if ( $image_source == 'custom' ) {
327
+ $custom = ( $custom ) ? $custom : $options[$this->labels->type_name . '_custom'];
328
+ $args = array(
329
+ 'post_type' => $custom,
330
+ 'numberposts' => $limit
331
+ );
332
+ $posts = get_posts( $args );
333
+ if ( $posts ) {
334
+ foreach ( $posts as $post ) {
335
+ if ( has_post_thumbnail( $post->ID ) ) {
336
+ $attachment_id = get_post_thumbnail_id( $post->ID );
337
+ $image = wp_get_attachment_image_src( $attachment_id, $size );
338
+ $thumbnail = wp_get_attachment_image_src( $attachment_id, 'thumbnail' );
339
+ $title = get_the_title( $post->ID );
340
+ $link = ( get_post_meta( $attachment_id, '_wp_attachment_image_link', true ) ? $this->prepare_attachment_link( get_post_meta( $attachment_id, '_wp_attachment_image_link', true ) ) : get_permalink( $post->ID ) );
341
+ $images[] = array(
342
+ 'image_src' => $image[0],
343
+ 'post_permalink' => $link,
344
+ 'post_title' => $title,
345
+ 'alt_text' => $title,
346
+ 'attachment_id' => $attachment_id,
347
+ 'thumbnail' => $thumbnail[0]
348
+ );
349
+ }
350
+ }
351
+ }
352
+ } else {
353
+ if ( ! dev7_mmp_active() ) {
354
+ return $images;
355
+ }
356
+
357
+ $mmp_options = get_option( 'ubermediasettings_settings', array() );
358
+ $mmp_sources = dev7_default_val( $mmp_options, 'ubermediasettings_sources_available', array() );
359
+
360
+ if ( isset( $mmp_sources[$image_source . '-settings'] ) ) {
361
+ $source_settings = $mmp_sources[$image_source . '-settings'];
362
+ $access_token = $source_settings['access-token'];
363
+ $var = 'media_manager_plus_source_' . $image_source;
364
+ $obj = new $var( $access_token['oauth_token'], $access_token['oauth_token_secret'] );
365
+
366
+ $method = ( $method ) ? $method : ( ( isset( $options[$image_source . '_type'] ) ) ? $options[$image_source . '_type'] : '' );
367
+ if ( $method == '' ) {
368
+ return $images;
369
+ }
370
+
371
+ $params = array();
372
+ if ( $param ) {
373
+ $params[] = $param;
374
+ } else {
375
+ if ( isset( $options[$image_source . '_' . $method] ) ) {
376
+ $params[] = $options[$image_source . '_' . $method];
377
+ }
378
+ }
379
+ $count = ( $limit == '-1' ) ? '20' : $limit;
380
+ if ( $count != '' ) {
381
+ $params['count'] = $count;
382
+ }
383
+ $params['page'] = 1;
384
+
385
+ $safemode = dev7_default_val( $mmp_options, 'ubermediasettings_general_safe-mode', 1 );
386
+ $params['safemode'] = $safemode;
387
+
388
+ if ( $size != 'thumbnail' ) {
389
+ $size = 'full';
390
+ }
391
+
392
+ $source_images = call_user_func_array( array( $obj, $method ), $params );
393
+
394
+ if ( $source_images && isset( $source_images['images'] ) ) {
395
+ foreach ( $source_images['images'] as $mmp_image ) {
396
+ $images[] = array(
397
+ 'image_src' => $mmp_image[$size],
398
+ 'post_permalink' => $mmp_image['link'],
399
+ 'post_title' => $mmp_image['caption'],
400
+ 'alt_text' => $mmp_image['caption'],
401
+ 'thumbnail' => $mmp_image['thumbnail']
402
+ );
403
+
404
+ }
405
+ }
406
+ }
407
+ }
408
+ }
409
+
410
+ return $images;
411
+ }
412
+
413
+ /*
414
+ * Resize images dynamically using wp built in functions
415
+ * Victor Teixeira
416
+ *
417
+ * php 5.2+
418
+ *
419
+ * Example usage:
420
+ *
421
+ * <?php
422
+ * $thumb = get_post_thumbnail_id();
423
+ * $image = resize_image( $thumb, '', 140, 110, true );
424
+ * ?>
425
+ * <img src="<?php echo $image[url]; ?>" width="<?php echo $image[width]; ?>" height="<?php echo $image[height]; ?>" />
426
+ *
427
+ * @param int $attach_id
428
+ * @param string $img_url
429
+ * @param int $width
430
+ * @param int $height
431
+ * @param bool $crop
432
+ * @return array
433
+ */
434
+ public static function resize_image( $attach_id = null, $img_url = null, $width, $height, $crop = false ) {
435
+ // this is an attachment, so we have the ID
436
+ if ( $attach_id ) {
437
+ $image_src = wp_get_attachment_image_src( $attach_id, 'full' );
438
+ $file_path = get_attached_file( $attach_id );
439
+
440
+ // this is not an attachment, let's use the image url
441
+ } else if ( $img_url ) {
442
+
443
+ $file_path = parse_url( $img_url );
444
+ $file_path = $_SERVER['DOCUMENT_ROOT'] . $file_path['path'];
445
+
446
+ if ( ! file_exists( $file_path ) ) {
447
+ return new WP_Error( 'broke', __( 'File doesn\'t exist: ' . $file_path, 'dev7-core' ) );
448
+ }
449
+
450
+ $orig_size = getimagesize( $file_path );
451
+
452
+ $image_src[0] = $img_url;
453
+ $image_src[1] = $orig_size[0];
454
+ $image_src[2] = $orig_size[1];
455
+ }
456
+ $file_info = pathinfo( $file_path );
457
+ $extension = '.' . $file_info['extension'];
458
+ // the image path without the extension
459
+ $no_ext_path = $file_info['dirname'] . '/' . $file_info['filename'];
460
+ $cropped_img_path = $no_ext_path . '-' . $width . 'x' . $height . strtolower( $extension );
461
+ // checking if the file size is larger than the target size
462
+ // if it is smaller or the same size, stop right here and return
463
+ if ( $image_src[1] > $width || $image_src[2] > $height ) {
464
+ // the file is larger, check if the resized version already exists (for $crop = true but will also work for $crop = false if the sizes match)
465
+
466
+ if ( file_exists( $cropped_img_path ) ) {
467
+ $cropped_img_url = str_replace( basename( $image_src[0] ), basename( $cropped_img_path ), $image_src[0] );
468
+
469
+ $vt_image = array(
470
+ 'url' => $cropped_img_url,
471
+ 'width' => $width,
472
+ 'height' => $height
473
+ );
474
+
475
+ return $vt_image;
476
+ }
477
+ // $crop = false
478
+ if ( $crop == false ) {
479
+
480
+ // calculate the size proportionaly
481
+ $proportional_size = wp_constrain_dimensions( $image_src[1], $image_src[2], $width, $height );
482
+ $resized_img_path = $no_ext_path . '-' . $proportional_size[0] . 'x' . $proportional_size[1] . $extension;
483
+ // checking if the file already exists
484
+ if ( file_exists( $resized_img_path ) ) {
485
+
486
+ $resized_img_url = str_replace( basename( $image_src[0] ), basename( $resized_img_path ), $image_src[0] );
487
+ $vt_image = array(
488
+ 'url' => $resized_img_url,
489
+ 'width' => $proportional_size[0],
490
+ 'height' => $proportional_size[1]
491
+ );
492
+
493
+ return $vt_image;
494
+ }
495
+ }
496
+
497
+ // no cache files - let's finally resize it
498
+ $editor = wp_get_image_editor( $file_path );
499
+ if ( is_wp_error( $editor ) )
500
+ return $editor;
501
+
502
+ $editor->set_quality( 90 );
503
+
504
+ $resized = $editor->resize( $width, $height, $crop );
505
+ if ( is_wp_error( $resized ) )
506
+ return $resized;
507
+
508
+ $new_img_path = $editor->generate_filename( $width . 'x' . $height, null );
509
+ $saved = $editor->save( $new_img_path );
510
+
511
+ if ( is_wp_error( $saved ) )
512
+ return $saved;
513
+
514
+ $new_img_size = getimagesize( $new_img_path );
515
+ $new_img = str_replace( basename( $image_src[0] ), basename( $new_img_path ), $image_src[0] );
516
+ // resized output
517
+ $vt_image = array(
518
+ 'url' => $new_img,
519
+ 'width' => $new_img_size[0],
520
+ 'height' => $new_img_size[1]
521
+ );
522
+
523
+ return $vt_image;
524
+ }
525
+ // default output - without resizing
526
+ $vt_image = array(
527
+ 'url' => $image_src[0],
528
+ 'width' => $image_src[1],
529
+ 'height' => $image_src[2]
530
+ );
531
+
532
+ return $vt_image;
533
+ }
534
+ }
includes/core/includes/post-type.php ADDED
@@ -0,0 +1,184 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Post Type Class
4
+ *
5
+ * @package Plugin Core
6
+ * @subpackage Post Type
7
+ * @copyright Copyright (c) 2014, Dev7studios
8
+ * @license http://opensource.org/licenses/GPL-3.0 GNU Public License
9
+ * @since 2.2
10
+ */
11
+
12
+ // Exit if accessed directly
13
+ if ( ! defined( 'ABSPATH' ) ) {
14
+ exit;
15
+ }
16
+
17
+
18
+ /**
19
+ * Post Type Core Class
20
+ *
21
+ * @since 1.0
22
+ */
23
+ class Dev7_Core_Post_Type {
24
+
25
+ /**
26
+ * Plugin labels
27
+ *
28
+ * @var object
29
+ * @access private
30
+ * @since 2.2
31
+ */
32
+ private $labels;
33
+
34
+ /**
35
+ * Main construct for the Dev7 core Post Type class
36
+ *
37
+ * @since 2.2
38
+ *
39
+ * @param array $labels Specific plugin label data
40
+ */
41
+ public function __construct( $labels ) {
42
+ $this->labels = $labels;
43
+
44
+ add_action( 'init', array( $this, 'register_post_type' ) );
45
+ add_filter( 'post_updated_messages', array( $this, 'post_updated_messages' ) );
46
+ }
47
+
48
+ /**
49
+ * Registers the post type for the plugin
50
+ *
51
+ * @since 2.2
52
+ * @access public
53
+ */
54
+ function register_post_type() {
55
+ $labels = array(
56
+ 'name' => '%2$s',
57
+ 'singular_name' => '%1$s',
58
+ 'add_new' => __( 'Add New', 'dev7-core' ),
59
+ 'add_new_item' => __( 'Add New %1$s', 'dev7-core' ),
60
+ 'edit_item' => __( 'Edit %1$s', 'dev7-core' ),
61
+ 'new_item' => __( 'New %1$s', 'dev7-core' ),
62
+ 'all_items' => __( 'All %2$s', 'dev7-core' ),
63
+ 'view_item' => __( 'View %1$s', 'dev7-core' ),
64
+ 'search_items' => __( 'Search %2$s', 'dev7-core' ),
65
+ 'not_found' => __( 'No %2$s found', 'dev7-core' ),
66
+ 'not_found_in_trash' => __( 'No %2$s found in Trash', 'dev7-core' ),
67
+ 'parent_item_colon' => '',
68
+ 'menu_name' => __( '%2$s', 'dev7-core' )
69
+ );
70
+
71
+ foreach ( $labels as $key => $value ) {
72
+ $labels[$key] = sprintf( $value, $this->get_label_singular(), $this->get_label_plural() );
73
+ }
74
+
75
+ $labels = apply_filters( $this->labels->post_type . '_post_type_labels', $labels );
76
+
77
+ $supports = array( 'title', 'thumbnail' );
78
+ $supports = array_merge( $supports, apply_filters( 'dev7_post_type_supports', array() ) );
79
+
80
+ $post_type_args = array(
81
+ 'labels' => $labels,
82
+ 'public' => false,
83
+ 'show_ui' => true,
84
+ 'menu_position' => apply_filters( $this->labels->post_type . '_post_type_menu_position', 100 ),
85
+ 'supports' => $supports,
86
+ 'menu_icon' => apply_filters( $this->labels->post_type . '_post_type_menu_icon', '' )
87
+ );
88
+ register_post_type( $this->labels->post_type, apply_filters( $this->labels->post_type . '_post_type_args', $post_type_args ) );
89
+ }
90
+
91
+ /**
92
+ * Sets the messages for the post type
93
+ *
94
+ * @since 2.2
95
+ * @access public
96
+ *
97
+ * @param array $messages
98
+ *
99
+ * @return array $messages
100
+ */
101
+ public function post_updated_messages( $messages ) {
102
+ global $post, $post_ID;
103
+
104
+ $message_data = array(
105
+ 0 => '',
106
+ 1 => __( '%1$s updated.', 'dev7-core' ),
107
+ 2 => __( 'Custom field updated.', 'dev7-core' ),
108
+ 3 => __( 'Custom field deleted.', 'dev7-core' ),
109
+ 4 => __( '%1$s updated.', 'dev7-core' ),
110
+ 5 => '',
111
+ 6 => __( '%1$s published.', 'dev7-core' ),
112
+ 7 => __( '%1$s saved.', 'dev7-core' ),
113
+ 8 => __( '%1$s submitted.', 'dev7-core' ),
114
+ 9 => __( '%1$s scheduled for: <strong>%2$s</strong>. <a target="_blank" href="%2$s">Preview %1$s</a>', 'dev7-core' ),
115
+ 10 => __( '%1$s draft updated.', 'dev7-core' )
116
+ );
117
+
118
+ foreach ( $message_data as $key => $value ) {
119
+ if ( $key == 9 ) {
120
+ $value = sprintf( $value, $this->get_label_singular(), date_i18n( __( 'M j, Y @ G:i', 'dev7-core' ), strtotime( $post->post_date ) ), esc_url( get_permalink( $post_ID ) ) );
121
+ } else {
122
+ if ( $key == 5 ) {
123
+ if ( isset( $_GET['revision'] ) ) {
124
+ $value = sprintf( __( '%1$s restored to revision from %2$s', 'dev7-core' ), $this->get_label_singular(), wp_post_revision_title( (int) $_GET['revision'], false ) );
125
+ }
126
+ } else {
127
+ $value = sprintf( $value, $this->get_label_singular() );
128
+ }
129
+ }
130
+ $message_data[$key] = $value;
131
+ }
132
+ $messages[$this->labels->post_type] = apply_filters( $this->labels->post_type . '_post_type_messages', $message_data );
133
+
134
+ return $messages;
135
+ }
136
+
137
+ /**
138
+ * Gets the default labels for plugin post type
139
+ *
140
+ * @since 2.2
141
+ * @access private
142
+ * @return array
143
+ */
144
+ private function get_default_labels() {
145
+ $defaults = array(
146
+ 'singular' => __( 'Gallery', 'edd' ),
147
+ 'plural' => __( 'Galleries', 'edd' )
148
+ );
149
+
150
+ return ( $this->labels ) ? (array) $this->labels : $defaults;
151
+ }
152
+
153
+ /**
154
+ * Get Singular Label
155
+ *
156
+ * @since 2.2
157
+ * @access private
158
+ *
159
+ * @param bool $lowercase
160
+ *
161
+ * @return string $defaults['singular'] Singular label
162
+ */
163
+ private function get_label_singular( $lowercase = false ) {
164
+ $defaults = $this->get_default_labels();
165
+
166
+ return ( $lowercase ) ? strtolower( $defaults['singular'] ) : $defaults['singular'];
167
+ }
168
+
169
+ /**
170
+ * Get Plural Label
171
+ *
172
+ * @since 2.2
173
+ * @access private
174
+ *
175
+ * @param bool $lowercase
176
+ *
177
+ * @return string $defaults['plural'] Plural label
178
+ */
179
+ private function get_label_plural( $lowercase = false ) {
180
+ $defaults = $this->get_default_labels();
181
+
182
+ return ( $lowercase ) ? strtolower( $defaults['plural'] ) : $defaults['plural'];
183
+ }
184
+ }
includes/core/includes/shortcode.php ADDED
@@ -0,0 +1,317 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Shortcode Class
4
+ *
5
+ * @package Plugin Core
6
+ * @subpackage Shortcode
7
+ * @copyright Copyright (c) 2014, Dev7studios
8
+ * @license http://opensource.org/licenses/GPL-3.0 GNU Public License
9
+ * @since 2.2
10
+ */
11
+
12
+ // Exit if accessed directly
13
+ if ( ! defined( 'ABSPATH' ) ) {
14
+ exit;
15
+ }
16
+
17
+ /**
18
+ * Shortcode Core Class
19
+ *
20
+ * @since 1.0
21
+ */
22
+ class Dev7_Core_Shortcode {
23
+
24
+ /**
25
+ * Plugin labels
26
+ *
27
+ * @var object
28
+ * @access private
29
+ * @since 2.2
30
+ */
31
+ private $labels;
32
+
33
+ /**
34
+ * Shortcode core scripts
35
+ *
36
+ * @var array
37
+ * @access private
38
+ * @since 2.2
39
+ */
40
+ private $core_scripts;
41
+
42
+ /**
43
+ * Shortcode scripts
44
+ *
45
+ * @var array
46
+ * @access private
47
+ * @since 2.2
48
+ */
49
+ private $scripts;
50
+
51
+ /**
52
+ * Shortcode core styles
53
+ *
54
+ * @var array
55
+ * @access private
56
+ * @since 2.2
57
+ */
58
+ private $core_styles;
59
+
60
+ /**
61
+ * Shortcode styles
62
+ *
63
+ * @var array
64
+ * @access private
65
+ * @since 2.2
66
+ */
67
+ private $styles;
68
+
69
+ /**
70
+ * Instance of Dev7 Images Core Class
71
+ *
72
+ * @var object
73
+ * @access private
74
+ * @since 2.2
75
+ */
76
+ private $core_images;
77
+
78
+ /**
79
+ * Whether or not core styles and scripts have been enqueued
80
+ *
81
+ * @var boolean
82
+ * @access private
83
+ * @since 2.4.3
84
+ */
85
+ private $core_enqueued = false;
86
+
87
+ /**
88
+ * Main construct for the Dev7 core Images class
89
+ *
90
+ * @since 2.2
91
+ *
92
+ * @param array $labels Specific plugin label data
93
+ */
94
+ public function __construct( $labels ) {
95
+
96
+ $this->labels = $labels;
97
+ $this->core_images = new Dev7_Core_Images( $this->labels );
98
+
99
+ $this->core_scripts = apply_filters( $this->labels->post_type . '_shortcode_core_scripts', array() );
100
+ $this->core_styles = apply_filters( $this->labels->post_type . '_shortcode_core_styles', array() );
101
+
102
+ $this->scripts = apply_filters( $this->labels->post_type . '_shortcode_scripts', array() );
103
+ $this->styles = apply_filters( $this->labels->post_type . '_shortcode_styles', array() );
104
+
105
+ add_shortcode( $this->labels->shortcode, array( $this, 'shortcode' ) );
106
+
107
+ // Enqueues core styles and scripts only when a shortcode is present.
108
+ add_filter( 'the_posts', array( $this, 'shortcode_enqueue_core' ) );
109
+
110
+ add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts' ) );
111
+ add_action( 'wp_enqueue_scripts', array( $this, 'register_styles' ) );
112
+ }
113
+
114
+ /**
115
+ * Shortcode output for the plugin
116
+ *
117
+ * @since 2.2
118
+ *
119
+ * @param array $atts
120
+ *
121
+ * @access public
122
+ * @return string $output
123
+ */
124
+ public function shortcode( $atts ) {
125
+ extract(
126
+ shortcode_atts(
127
+ array(
128
+ 'id' => 0,
129
+
130
+ // Here for backwards compatibility, has the same function as force below.
131
+ 'template' => false,
132
+
133
+ // To force the enqueue of core scripts, pass [... force="true"].
134
+ 'force' => false,
135
+ 'slug' => ''
136
+ ), $atts
137
+ )
138
+ );
139
+
140
+ if ( ! $id && ! $slug ) {
141
+ return sprintf( __( 'Invalid %1$s', 'dev7core' ), $this->labels->singular );
142
+ }
143
+
144
+ if ( ! $id ) {
145
+ $object = get_page_by_path( $slug, OBJECT, $this->labels->post_type );
146
+ if ( $object ) {
147
+ $id = $object->ID;
148
+ } else {
149
+ return sprintf( __( 'Invalid %1$s Slug', 'dev7core' ), $this->labels->singular );
150
+ }
151
+ }
152
+
153
+ $output = '';
154
+ $options = get_post_meta( $id, $this->labels->post_meta_key, true );
155
+ $type = $options[$this->labels->source_name];
156
+
157
+ $defaults = $this->core_images->image_sources_defaults();
158
+ $slider_type = ( ! array_key_exists( $type, $defaults ) ) ? 'external' : '';
159
+
160
+ $images = $this->core_images->get_images( $id );
161
+
162
+ // Force enqueue of core scripts (good for do_shortcode() in templates).
163
+ if ( $template || $force ) {
164
+ $this->enqueue_core_scripts( true );
165
+ $this->enqueue_core_styles( true );
166
+ }
167
+
168
+ $this->enqueue_scripts( $options );
169
+ $this->enqueue_styles( $options );
170
+
171
+ // generate unique prefix for $id to avoid clashes with multiple same shortcode use
172
+ $prefix = wp_generate_password( 5, false );
173
+ $id = $prefix . '-' . $id;
174
+
175
+ if ( $images ) {
176
+ $output = apply_filters( $this->labels->post_type . '_shortcode_output', $id, $output, $options, $images, $slider_type );
177
+ }
178
+
179
+ return $output;
180
+ }
181
+
182
+ /**
183
+ * Tests each post for a specific shortcode and enqueues core styles and scripts.
184
+ *
185
+ * Because we can't always trust `global $post` on `is_home()` or `is_archive()`
186
+ * we use this method with the `the_posts` filter to test each post being shown
187
+ * for the shortcode and enqueue the core styles. This saves us from having
188
+ * to enqueue the core scripts when they are un-necessary.
189
+ *
190
+ * Any list of posts that does not use the shortcode will result in the core
191
+ * styles not being enqueued.
192
+ *
193
+ * @since 2.4.3
194
+ *
195
+ * @param array $posts Posts sent from `the_posts` filter.
196
+ *
197
+ * @access public
198
+ * @return object $posts Does not modify Posts.
199
+ */
200
+ public function shortcode_enqueue_core( $posts ) {
201
+ foreach ( $posts as $post ) {
202
+ if ( ! $this->core_enqueued && dev7_has_shortcode_wrap( $post->post_content, $this->labels->shortcode ) ) {
203
+ add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_core_scripts' ) );
204
+ add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_core_styles' ) );
205
+
206
+ // Tell this instance that it's been enqueued so we don't do this for every post.
207
+ $this->core_enqueued = true;
208
+ }
209
+ }
210
+ return $posts;
211
+ }
212
+
213
+ /**
214
+ * Enqueues core shortcode scripts in <head>
215
+ *
216
+ * @param bool $force
217
+ *
218
+ * @since 2.2
219
+ * @access public
220
+ */
221
+ public function enqueue_core_scripts( $force = false ) {
222
+ if ( $this->core_scripts && count( $this->core_scripts ) > 0 ) {
223
+ $required = array( 'jquery' );
224
+
225
+ // Enqueue our required scripts.
226
+ wp_enqueue_script( $required );
227
+
228
+ // Enqueue all the scripts.
229
+ foreach ( $this->core_scripts as $name => $url ) {
230
+ wp_enqueue_script( $name, $url, $required, $this->labels->plugin_version );
231
+ $required[] = $name;
232
+ }
233
+ }
234
+ }
235
+
236
+ /**
237
+ * Enqueues core shortcode styles in <head>
238
+ *
239
+ * @param bool $force
240
+ *
241
+ * @since 2.2
242
+ * @access public
243
+ */
244
+ public function enqueue_core_styles( $force = false ) {
245
+ if ( $this->core_styles && count( $this->core_styles ) > 0 ) {
246
+ foreach ( $this->core_styles as $name => $url ) {
247
+ wp_enqueue_style( $name, $url, array(), $this->labels->plugin_version );
248
+ }
249
+ }
250
+ }
251
+
252
+ /**
253
+ * Enqueue shortcode scripts that are dependant on plugin options in <footer>
254
+ *
255
+ * @since 2.2
256
+ *
257
+ * @param array $options
258
+ *
259
+ * @access private
260
+ */
261
+ private function enqueue_scripts( $options ) {
262
+ $scripts = apply_filters( $this->labels->post_type . '_shortcode_scripts_enqueue', $this->scripts, $options );
263
+ if ( $scripts && count( $scripts ) > 0 ) {
264
+ foreach ( $scripts as $name => $url ) {
265
+ wp_enqueue_script( $name );
266
+ }
267
+ }
268
+ }
269
+
270
+ /**
271
+ * Enqueue shortcode styles
272
+ *
273
+ * @since 2.2
274
+ *
275
+ * @param array $options
276
+ *
277
+ * @access private
278
+ */
279
+ private function enqueue_styles( $options ) {
280
+ $styles = apply_filters( $this->labels->post_type . '_shortcode_styles_enqueue', $this->styles, $options );
281
+ if ( $styles && count( $styles ) > 0 ) {
282
+ foreach ( $styles as $name => $url ) {
283
+ wp_enqueue_style( $name );
284
+ }
285
+ }
286
+ }
287
+
288
+ /**
289
+ * Register shortcode scripts
290
+ *
291
+ * @since 2.2
292
+ * @access public
293
+ */
294
+ public function register_scripts() {
295
+ if ( $this->scripts && count( $this->scripts ) > 0 ) {
296
+ $required = array( 'jquery' );
297
+ foreach ( $this->scripts as $name => $url ) {
298
+ wp_register_script( $name, $url, $required, $this->labels->plugin_version );
299
+ $required[] = $name;
300
+ }
301
+ }
302
+ }
303
+
304
+ /**
305
+ * Register shortcode styles
306
+ *
307
+ * @since 2.2
308
+ * @access public
309
+ */
310
+ public function register_styles() {
311
+ if ( $this->styles && count( $this->styles ) > 0 ) {
312
+ foreach ( $this->styles as $name => $url ) {
313
+ wp_register_style( $name, $url, array(), $this->labels->plugin_version );
314
+ }
315
+ }
316
+ }
317
+ }
includes/core/plugin.php ADDED
@@ -0,0 +1,173 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Dev7studios Plugin Core
4
+ *
5
+ * @package Plugin Core
6
+ * @subpackage Core
7
+ * @copyright Copyright (c) 2014, Dev7studios
8
+ * @license http://opensource.org/licenses/GPL-3.0 GNU Public License
9
+ * @since 2.2
10
+ */
11
+
12
+ // Exit if accessed directly
13
+ if ( ! defined( 'ABSPATH' ) ) {
14
+ exit;
15
+ }
16
+
17
+ /**
18
+ * Main Plugin Core Class
19
+ *
20
+ * @since 2.2
21
+ */
22
+ abstract class Dev7_Core_Plugin {
23
+
24
+ /**
25
+ * All of the specific plugin data
26
+ *
27
+ * @var object
28
+ * @access private
29
+ * @since 2.2
30
+ */
31
+ private $labels;
32
+
33
+ /**
34
+ * Is this plugin a "lite" plugin
35
+ *
36
+ * @var bool
37
+ * @access private
38
+ * @since 2.4.8
39
+ */
40
+ private $is_lite;
41
+
42
+ /**
43
+ * Plugin options
44
+ *
45
+ * @var array
46
+ * @access private
47
+ * @since 2.2
48
+ */
49
+ private $options;
50
+
51
+ /**
52
+ * Instance of Dev7 Admin Settings Core Class
53
+ *
54
+ * @var object
55
+ * @access private
56
+ * @since 2.2
57
+ */
58
+ private $settings_class;
59
+
60
+ /**
61
+ * Main construct
62
+ *
63
+ * @since 2.2
64
+ *
65
+ * @param array $labels Specific plugin label data
66
+ */
67
+ public function __construct( $labels, $is_lite = false ) {
68
+ $this->labels = (object) $labels;
69
+ $this->is_lite = $is_lite;
70
+ $this->options = get_option( $this->labels->options_key );
71
+ $this->setup_constants();
72
+ $this->includes();
73
+ $this->updater();
74
+ $this->loader();
75
+ }
76
+
77
+ /**
78
+ * Setup core constants
79
+ *
80
+ * @access private
81
+ * @since 2.2
82
+ */
83
+ private function setup_constants() {
84
+ if ( ! defined( 'DEV7_SITE_URL' ) ) {
85
+ define( 'DEV7_SITE_URL', 'https://dev7studios.com' );
86
+ }
87
+ if ( ! defined( 'DEV7_STORE_URL' ) ) {
88
+ define( 'DEV7_STORE_URL', 'http://dev7studios.com' );
89
+ }
90
+ // Core Folder Path
91
+ if ( ! defined( 'DEV7_CORE_DIR' ) ) {
92
+ define( 'DEV7_CORE_DIR', dirname( __FILE__ ) );
93
+ }
94
+ // Core Folder URL
95
+ if ( ! defined( 'DEV7_CORE_DIR' ) ) {
96
+ define( 'DEV7_CORE_DIR', dirname( __FILE__ ) );
97
+ }
98
+ }
99
+
100
+ /**
101
+ * Include required core files
102
+ *
103
+ * @access private
104
+ * @since 2.2
105
+ */
106
+ private function includes() {
107
+ if ( ! $this->is_lite ) {
108
+ require_once DEV7_CORE_DIR . '/includes/edd_sl_plugin_updater.php';
109
+ }
110
+ require_once DEV7_CORE_DIR . '/includes/functions.php';
111
+ require_once DEV7_CORE_DIR . '/includes/assets.php';
112
+ require_once DEV7_CORE_DIR . '/includes/post-type.php';
113
+ require_once DEV7_CORE_DIR . '/includes/admin-settings.php';
114
+ require_once DEV7_CORE_DIR . '/includes/admin-view.php';
115
+ require_once DEV7_CORE_DIR . '/includes/admin-edit.php';
116
+ require_once DEV7_CORE_DIR . '/includes/admin-ajax.php';
117
+ require_once DEV7_CORE_DIR . '/includes/admin-images.php';
118
+ require_once DEV7_CORE_DIR . '/includes/shortcode.php';
119
+ require_once DEV7_CORE_DIR . '/includes/images.php';
120
+ }
121
+
122
+ /**
123
+ * Instantiate the EDD Plugin Updater
124
+ *
125
+ * @access private
126
+ * @uses EDD_SL_Plugin_Updater()
127
+ * @since 2.2
128
+ */
129
+ private function updater() {
130
+ if ( ! $this->is_lite ) {
131
+ $license_key = dev7_get_license_key( $this->labels->post_type, $this->options );
132
+ new Dev7_EDD_SL_Plugin_Updater_16( DEV7_STORE_URL, $this->labels->plugin_file, array(
133
+ 'version' => $this->labels->plugin_version,
134
+ 'license' => $license_key,
135
+ 'item_name' => $this->labels->dev7_item_name,
136
+ 'author' => 'Dev7studios',
137
+ ) );
138
+ }
139
+ }
140
+
141
+ /**
142
+ * Loads all the Dev7 Core classes
143
+ *
144
+ * @access private
145
+ * @since 2.2
146
+ */
147
+ private function loader() {
148
+ new Dev7_Core_Assets( $this->labels );
149
+ new Dev7_Core_Post_Type( $this->labels );
150
+ $this->settings_class = new Dev7_Core_Admin_Settings( $this->labels );
151
+ new Dev7_Core_Admin_View( $this->labels );
152
+ new Dev7_Core_Admin_Edit( $this->labels );
153
+ new Dev7_Core_Admin_AJAX( $this->labels );
154
+ new Dev7_Core_Admin_Images( $this->labels );
155
+ new Dev7_Core_Shortcode( $this->labels );
156
+ }
157
+
158
+ /**
159
+ * Makes public the settings helper from the Dev7 Settings class
160
+ *
161
+ * @access public
162
+ * @uses Dev7_Core_Admin_Settings::settings_helper()
163
+ *
164
+ * @param array $args Settings arguments to be rendered as HTML
165
+ *
166
+ * @since 2.2
167
+ */
168
+ public function settings_helper( $args ) {
169
+ $this->settings_class->settings_helper( $args );
170
+ }
171
+ }
172
+
173
+
includes/plugin.php ADDED
@@ -0,0 +1,829 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // Exit if accessed directly
4
+ if ( ! defined( 'ABSPATH' ) ) {
5
+ exit;
6
+ }
7
+
8
+ if ( ! class_exists( 'Dev7_Core_Plugin' ) ) {
9
+ require_once NIVO_SLIDER_LITE_PLUGIN_DIR . 'includes/core/plugin.php';
10
+ }
11
+
12
+ /**
13
+ * Main Plugin Class
14
+ */
15
+ class Dev7_Nivo_Slider_Lite extends Dev7_Core_Plugin {
16
+
17
+ /**
18
+ * Plugin Version
19
+ *
20
+ * @var string
21
+ * @access private
22
+ * @since 2.2
23
+ */
24
+ private $version;
25
+
26
+ /**
27
+ * Post Type
28
+ *
29
+ * @var string
30
+ * @access private
31
+ * @since 2.2
32
+ */
33
+ private $post_type;
34
+
35
+ /**
36
+ * Plugin labels
37
+ *
38
+ * @var object
39
+ * @access private
40
+ * @since 2.2
41
+ */
42
+ private $labels;
43
+
44
+ /**
45
+ * Main construct
46
+ *
47
+ * @since 2.2
48
+ *
49
+ * @param string $version
50
+ */
51
+ public function __construct( $version ) {
52
+ $this->version = $version;
53
+ $this->labels = array(
54
+ 'dev7_item_name' => 'Nivo Slider Lite WordPress Plugin',
55
+ 'plugin_name' => 'Nivo Slider Lite',
56
+ 'plugin_version' => $version,
57
+ 'plugin_file' => NIVO_SLIDER_LITE_PLUGIN_FILE,
58
+ 'plugin_basename' => NIVO_SLIDER_LITE_PLUGIN_BASENAME,
59
+ 'plugin_url' => NIVO_SLIDER_LITE_PLUGIN_URL,
60
+ 'post_type' => 'nivoslider',
61
+ 'shortcode' => 'nivoslider',
62
+ 'function' => 'nivo_slider',
63
+ 'slug' => 'nivo-slider',
64
+ 'post_meta_key' => 'nivo_settings',
65
+ 'options_key' => 'nivoslider_settings',
66
+ 'source_name' => 'type',
67
+ 'manual_name' => 'manual',
68
+ 'type_name' => 'type',
69
+ 'singular' => __( 'Slider', 'nivo-slider' ),
70
+ 'plural' => __( 'Sliders', 'nivo-slider' ),
71
+ );
72
+ $this->post_type = $this->labels['post_type'];
73
+
74
+ $this->add_filters();
75
+ $this->add_actions();
76
+
77
+ parent::__construct( $this->labels );
78
+ }
79
+
80
+ /**
81
+ * Adds custom filters for the plugin
82
+ *
83
+ * @since 2.2
84
+ * @access private
85
+ */
86
+ private function add_filters() {
87
+ add_filter( 'plugin_action_links', array( $this, 'plugin_action_links' ), 11, 2 );
88
+ add_filter( $this->post_type . '_post_type_labels', array( $this, 'post_type_labels' ) );
89
+ add_filter( $this->post_type . '_post_type_menu_icon', array( $this, 'post_type_menu_icon' ) );
90
+ add_filter( $this->post_type . '_settings_page_header', array( $this, 'settings_page_header' ) );
91
+ add_filter( $this->post_type . '_settings_intro', array( $this, 'settings_intro' ) );
92
+ add_filter( $this->post_type . '_admin_edit_settings', array( $this, 'admin_edit_settings' ) );
93
+ add_filter( $this->post_type . '_post_meta_save', array( $this, 'post_meta_save' ) );
94
+ add_filter( $this->post_type . '_script_settings', array( $this, 'script_settings' ) );
95
+ add_filter( $this->post_type . '_shortcode_core_styles', array( $this, 'shortcode_core_styles' ) );
96
+ add_filter( $this->post_type . '_shortcode_scripts', array( $this, 'shortcode_scripts' ) );
97
+ add_filter( $this->post_type . '_shortcode_styles', array( $this, 'shortcode_styles' ) );
98
+ add_filter( $this->post_type . '_shortcode_styles_enqueue', array( $this, 'shortcode_styles_enqueue' ), 10, 2 );
99
+ add_filter( $this->post_type . '_shortcode_output', array( $this, 'shortcode_output' ), 10, 5 );
100
+ add_filter( $this->post_type . '_get_image_sources', array( $this, 'get_image_sources' ) );
101
+ }
102
+
103
+ /**
104
+ * Adds custom actions for the plugin
105
+ *
106
+ * @since 2.2
107
+ * @access private
108
+ */
109
+ private function add_actions() {
110
+ add_action( 'admin_init', array( $this, 'admin_init' ) );
111
+ add_action( 'admin_menu', array( $this, 'remove_settings_menu' ), 11 );
112
+ add_action( 'admin_enqueue_scripts', array( $this, 'admin_styles' ) );
113
+ add_action( $this->post_type . '_admin_scripts', array( $this, 'admin_scripts' ) );
114
+ add_action( $this->post_type . '_manual_type_description', array( $this, 'manual_type_description' ) );
115
+ }
116
+
117
+ /**
118
+ * Add Upgrade metabox to the edit screen
119
+ */
120
+ public function admin_init() {
121
+ add_meta_box( $this->post_type . '_upgrade_box', __( 'Upgrade to Pro', 'nivo-slider' ), array(
122
+ $this,
123
+ 'meta_box_upgrade',
124
+ ), $this->post_type, 'side' );
125
+ }
126
+
127
+ /**
128
+ * Remove the settings page for the Lite plugin
129
+ */
130
+ public function remove_settings_menu() {
131
+ remove_submenu_page( 'edit.php?post_type=' . $this->post_type, 'nivoslider-settings' );
132
+ }
133
+
134
+ /**
135
+ * Registers and enqueues custom admin scripts
136
+ *
137
+ * @since 2.2
138
+ * @access public
139
+ */
140
+ public function admin_scripts() {
141
+ wp_register_script( $this->post_type . '-lite-admin', plugins_url( 'assets/js/admin.js', dirname( __FILE__ ) ), array(
142
+ 'jquery',
143
+ $this->post_type . '-core-admin',
144
+ ), $this->version );
145
+ wp_enqueue_script( $this->post_type . '-lite-admin' );
146
+ }
147
+
148
+ /**
149
+ * Registers and enqueues custom admin styles
150
+ */
151
+ public function admin_styles() {
152
+ wp_register_style( $this->post_type . '-lite-admin', plugins_url( 'assets/css/admin.css', dirname( __FILE__ ) ), array(), $this->version );
153
+ wp_enqueue_style( $this->post_type . '-lite-admin' );
154
+ }
155
+
156
+ /**
157
+ * Adds custom scripts to Shortcode script array for conditional loading
158
+ *
159
+ * @since 2.2
160
+ * @access public
161
+ *
162
+ * @param array $scripts
163
+ *
164
+ * @return array $scripts
165
+ */
166
+ public function shortcode_scripts( $scripts ) {
167
+ $scripts = array( 'dev7-ns-nivoslider' => plugins_url( 'assets/js/jquery.nivo.slider.pack.js', dirname( __FILE__ ) ) );
168
+
169
+ return $scripts;
170
+ }
171
+
172
+ /**
173
+ * Adds custom styles to Shortcode style array for loading to <head>
174
+ *
175
+ * @since 2.2
176
+ * @access public
177
+ *
178
+ * @param array $styles
179
+ *
180
+ * @return array $styles
181
+ */
182
+ public function shortcode_core_styles( $styles ) {
183
+ return array( 'dev7-ns-nivoslider' => plugins_url( 'assets/css/nivo-slider.css', dirname( __FILE__ ) ) );
184
+ }
185
+
186
+ /**
187
+ * Adds custom styles to Shortcode style array for conditional loading
188
+ *
189
+ * @since 2.2
190
+ * @access public
191
+ *
192
+ * @param array $styles
193
+ *
194
+ * @return array $styles
195
+ */
196
+ public function shortcode_styles( $styles ) {
197
+ $styles = array();
198
+ $themes = $this->get_themes();
199
+ foreach ( $themes as $theme ) {
200
+ $styles[ 'nivoslider-theme-' . $theme['theme_name'] ] = $theme['theme_url'];
201
+ }
202
+
203
+ return $styles;
204
+ }
205
+
206
+ /**
207
+ * Custom shortcode enqueuing of scripts for selected Nivo theme
208
+ *
209
+ * @since 2.2
210
+ * @access public
211
+ *
212
+ * @param array $styles
213
+ * @param array $options
214
+ *
215
+ * @return array $styles
216
+ */
217
+ public function shortcode_styles_enqueue( $styles, $options ) {
218
+ $slider_theme = 'nivoslider-theme-' . dev7_default_val( $options, 'theme' );
219
+ if ( $styles ) {
220
+ foreach ( $styles as $name => $url ) {
221
+ if ( substr( $name, 0, 17 ) == 'nivoslider-theme-' ) {
222
+ if ( $name != $slider_theme ) {
223
+ unset( $styles[ $name ] );
224
+ }
225
+ }
226
+ }
227
+ }
228
+
229
+ return $styles;
230
+ }
231
+
232
+ /**
233
+ * Custom post type labels
234
+ *
235
+ * @since 2.2
236
+ * @access public
237
+ *
238
+ * @param array $labels
239
+ *
240
+ * @return array $labels
241
+ */
242
+ public function post_type_labels( $labels ) {
243
+ $name = __( 'Nivo Slider', 'nivo-slider' );
244
+ $labels['name'] = $labels['singular_name'] = $labels['menu_name'] = $name;
245
+
246
+ return $labels;
247
+ }
248
+
249
+ /**
250
+ * Custom post type menu icon url
251
+ *
252
+ * @since 2.2
253
+ * @access public
254
+ *
255
+ * @param string $icon_url
256
+ *
257
+ * @return string $icon_url
258
+ */
259
+ public function post_type_menu_icon( $icon_url ) {
260
+ return NIVO_SLIDER_LITE_PLUGIN_URL . 'assets/images/favicon.png';
261
+ }
262
+
263
+ /**
264
+ * Custom settings page header
265
+ *
266
+ * @since 2.2
267
+ * @access public
268
+ * @return string
269
+ */
270
+ public function settings_page_header() {
271
+ return 'Nivo Slider Lite Settings';
272
+ }
273
+
274
+ /**
275
+ * Custom settings page intro
276
+ *
277
+ * @since 2.2
278
+ * @access public
279
+ * @return string
280
+ */
281
+ public function settings_intro() {
282
+ return '';
283
+ }
284
+
285
+ /**
286
+ * Adds custom settings to the plugin's printed javascript object
287
+ *
288
+ * @since 2.2
289
+ * @access public
290
+ *
291
+ * @param array $settings
292
+ *
293
+ * @return array $settings
294
+ */
295
+ public function script_settings( $settings ) {
296
+ $themes = $this->get_themes();
297
+ $settings['themes'] = $themes;
298
+
299
+ return $settings;
300
+ }
301
+
302
+ /**
303
+ * Custom post meta settings saving logic
304
+ *
305
+ * @since 2.2
306
+ * @access public
307
+ *
308
+ * @param array $settings
309
+ *
310
+ * @return array $settings
311
+ */
312
+ public function post_meta_save( $settings ) {
313
+ if ( ! is_numeric( $settings['dim_x'] ) || $settings['dim_x'] <= 0 ) {
314
+ $settings['dim_x'] = 400;
315
+ }
316
+ if ( ! is_numeric( $settings['dim_y'] ) || $settings['dim_y'] <= 0 ) {
317
+ $settings['dim_y'] = 150;
318
+ }
319
+ if ( ! is_numeric( $settings['slices'] ) || $settings['slices'] <= 0 ) {
320
+ $settings['slices'] = 15;
321
+ }
322
+ if ( ! is_numeric( $settings['boxCols'] ) || $settings['boxCols'] <= 0 ) {
323
+ $settings['boxCols'] = 8;
324
+ }
325
+ if ( ! is_numeric( $settings['boxRows'] ) || $settings['boxRows'] <= 0 ) {
326
+ $settings['boxRows'] = 4;
327
+ }
328
+ if ( ! is_numeric( $settings['animSpeed'] ) || $settings['animSpeed'] <= 0 ) {
329
+ $settings['animSpeed'] = 500;
330
+ }
331
+ if ( ! is_numeric( $settings['pauseTime'] ) || $settings['pauseTime'] <= 0 ) {
332
+ $settings['pauseTime'] = 3000;
333
+ }
334
+ if ( ! is_numeric( $settings['startSlide'] ) || $settings['startSlide'] < 0 ) {
335
+ $settings['startSlide'] = 0;
336
+ }
337
+ if ( ! is_numeric( $settings['thumbSizeWidth'] ) || $settings['thumbSizeWidth'] <= 0 ) {
338
+ $settings['thumbSizeWidth'] = 70;
339
+ }
340
+ if ( ! is_numeric( $settings['thumbSizeHeight'] ) || $settings['thumbSizeHeight'] <= 0 ) {
341
+ $settings['thumbSizeHeight'] = 50;
342
+ }
343
+
344
+ return $settings;
345
+ }
346
+
347
+ /**
348
+ * Post edit screen settings
349
+ *
350
+ * @since 2.2
351
+ * @access public
352
+ *
353
+ * @param array $settings
354
+ *
355
+ * @return array $settings
356
+ */
357
+ public function admin_edit_settings( $settings ) {
358
+ $settings = array();
359
+ $settings[] = array(
360
+ 'name' => 'enable_captions',
361
+ 'default' => 'on',
362
+ 'type' => 'checkbox',
363
+ 'title' => __( 'Enable Captions', 'nivo-slider' ),
364
+ 'descp' => __( 'Enable automatic captions from post titles', 'nivo-slider' ),
365
+ 'sub' => true,
366
+ 'tr_class' => 'dev7_captions',
367
+ );
368
+ $settings[] = array(
369
+ 'name' => 'number_images',
370
+ 'default' => '',
371
+ 'type' => 'text',
372
+ 'title' => __( 'Number of Images', 'nivo-slider' ),
373
+ 'descp' => __( 'The number of images to use in the slider. Leave blank for all images. External sources default to 20', 'nivo-slider' ),
374
+ 'sub' => true,
375
+ 'tr_class' => 'dev7_non_manual',
376
+ 'reload' => true,
377
+ );
378
+ $settings[] = array(
379
+ 'name' => 'sizing',
380
+ 'default' => 'fixed',
381
+ 'type' => 'select',
382
+ 'title' => __( 'Slider Sizing', 'nivo-slider' ),
383
+ 'descp' => '<span class="dev7-pro-feature">' . sprintf( '<strong>%s</strong> %s <a href="%s" target="_blank">%s</a>', __( 'Pro Feature:', 'nivo-slider' ), __( 'Create fully <strong>responsive</strong> sliders.', 'nivo-slider' ), 'https://dev7studios.com/products/nivo-slider-wordpress-plugin/?utm_source=wp_plugin&utm_medium=upgrade_link&utm_content=size_setting&utm_campaign=' . $this->post_type . '_lite_plugin', __( 'Upgrade to Pro', 'nivo-slider' ) ) . '</span>',
384
+ 'options' => array(
385
+ 'fixed' => __( 'Fixed Size', 'nivo-slider' ),
386
+ ),
387
+ );
388
+ $settings[] = array(
389
+ 'name' => 'wp_image_size',
390
+ 'default' => 'full',
391
+ 'type' => 'select',
392
+ 'title' => __( 'Image Size', 'nivo-slider' ),
393
+ 'descp' => __( 'Select the size of image from the WordPress media library', 'nivo-slider' ),
394
+ 'options' => Dev7_Core_Images::get_image_sizes(),
395
+ 'tr_class' => 'wp-image-size',
396
+ );
397
+ $settings[] = array(
398
+ 'name' => array( 'dim_x', 'dim_y' ),
399
+ 'default' => array( 400, 150 ),
400
+ 'type' => 'number',
401
+ 'title' => __( 'Slider Size', 'nivo-slider' ),
402
+ 'descp' => __( '(Size in px) Images will be cropped to these dimensions (eg 400 x 150)', 'nivo-slider' ),
403
+ 'connect' => ' x ',
404
+ 'parent' => 'sizing',
405
+ 'visible' => 'fixed',
406
+ );
407
+ $settings[] = array(
408
+ 'name' => 'theme',
409
+ 'default' => 'default',
410
+ 'type' => 'select',
411
+ 'title' => __( 'Slider Theme', 'nivo-slider' ),
412
+ 'descp' => '<span class="dev7-pro-feature">' . sprintf( '<strong>%s</strong> %s <a href="%s" target="_blank">%s</a>', __( 'Pro Feature:', 'nivo-slider' ), __( 'Select from our selection of beautiful <strong>pre-built themes</strong> or provide your own.', 'nivo-slider' ), 'https://dev7studios.com/products/nivo-slider-wordpress-plugin/?utm_source=wp_plugin&utm_medium=upgrade_link&utm_content=themes_setting&utm_campaign=' . $this->post_type . '_lite_plugin', __( 'Upgrade to Pro', 'nivo-slider' ) ) . '</span>',
413
+ 'options' => array(
414
+ '' => __( 'None', 'nivo-slider' ),
415
+ 'default' => __( 'Nivo Slider Default Theme', 'nivo-slider' ),
416
+ ),
417
+ );
418
+ $effects = array(
419
+ 'fade' => __( 'Fade', 'nivo-slider' ),
420
+ 'fold' => __( 'Fold', 'nivo-slider' ),
421
+ 'sliceDown' => __( 'Slice Down', 'nivo-slider' ),
422
+ 'sliceUp' => __( 'Slice Up', 'nivo-slider' ),
423
+ 'sliceUpDown' => __( 'Slice Up/Down', 'nivo-slider' ),
424
+ );
425
+ $settings[] = array(
426
+ 'name' => 'effect',
427
+ 'default' => 'fade',
428
+ 'type' => 'select',
429
+ 'title' => __( 'Transition Effect', 'nivo-slider' ),
430
+ 'descp' => '<span class="dev7-pro-feature">' . sprintf( '<strong>%s</strong> %s <a href="%s" target="_blank">%s</a>', __( 'Pro Feature:', 'nivo-slider' ), __( 'Enable all <strong>16 stunning transition effects</strong>.', 'nivo-slider' ), 'https://dev7studios.com/products/nivo-slider-wordpress-plugin/?utm_source=wp_plugin&utm_medium=upgrade_link&utm_content=transition_setting&utm_campaign=' . $this->post_type . '_lite_plugin', __( 'Upgrade to Pro', 'nivo-slider' ) ) . '</span>',
431
+ 'options' => $effects,
432
+ );
433
+ $settings[] = array(
434
+ 'name' => 'slices',
435
+ 'default' => '15',
436
+ 'type' => 'number',
437
+ 'title' => __( 'Slices', 'nivo-slider' ),
438
+ 'descp' => __( 'The number of slices to use in the "Slice" transitions (eg 15)', 'nivo-slider' ),
439
+ );
440
+ $settings[] = array(
441
+ 'name' => array( 'boxCols', 'boxRows' ),
442
+ 'default' => array( 8, 4 ),
443
+ 'type' => 'number',
444
+ 'title' => __( 'Box (Cols x Rows)', 'nivo-slider' ),
445
+ 'descp' => __( 'The number of columns and rows to use in the "Box" transitions (eg 8 x 4)', 'nivo-slider' ),
446
+ 'connect' => ' x ',
447
+ );
448
+ $settings[] = array(
449
+ 'name' => 'animSpeed',
450
+ 'default' => '500',
451
+ 'type' => 'number',
452
+ 'title' => __( 'Animation Speed', 'nivo-slider' ),
453
+ 'descp' => __( 'The speed of the transition animation in milliseconds (eg 500)', 'nivo-slider' ),
454
+ );
455
+ $settings[] = array(
456
+ 'name' => 'controlNavThumbs',
457
+ 'default' => 'off',
458
+ 'type' => 'custom',
459
+ 'title' => __( 'Enable Thumbnail Navigation', 'nivo-slider' ),
460
+ 'descp' => '<span class="dev7-pro-feature">' . sprintf( '<strong>%s</strong> %s <a href="%s" target="_blank">%s</a>', __( 'Pro Feature:', 'nivo-slider' ), __( 'Enable <strong>thumbnail navigation</strong> and control thumb sizes.', 'nivo-slider' ), 'https://dev7studios.com/products/nivo-slider-wordpress-plugin/?utm_source=wp_plugin&utm_medium=upgrade_link&utm_content=thumbnail_setting&utm_campaign=' . $this->post_type . '_lite_plugin', __( 'Upgrade to Pro', 'nivo-slider' ) ) . '</span>',
461
+ );
462
+ $settings[] = array(
463
+ 'name' => 'pauseTime',
464
+ 'default' => '3000',
465
+ 'type' => 'number',
466
+ 'title' => __( 'Pause Time', 'nivo-slider' ),
467
+ 'descp' => __( 'The amount of time to show each slide in milliseconds (eg 3000)', 'nivo-slider' ),
468
+ );
469
+ $settings[] = array(
470
+ 'name' => 'startSlide',
471
+ 'default' => '0',
472
+ 'type' => 'number',
473
+ 'title' => __( 'Start Slide', 'nivo-slider' ),
474
+ 'descp' => __( 'Set which slide the slider starts from (zero based index: usually 0)', 'nivo-slider' ),
475
+ );
476
+ $settings[] = array(
477
+ 'name' => 'directionNav',
478
+ 'default' => 'on',
479
+ 'type' => 'checkbox',
480
+ 'title' => __( 'Enable Direction Navigation', 'nivo-slider' ),
481
+ 'descp' => __( 'Prev &amp; Next arrows', 'nivo-slider' ),
482
+ );
483
+ $settings[] = array(
484
+ 'name' => 'controlNav',
485
+ 'default' => 'on',
486
+ 'type' => 'checkbox',
487
+ 'title' => __( 'Enable Control Navigation', 'nivo-slider' ),
488
+ 'descp' => __( 'eg 1,2,3...', 'nivo-slider' ),
489
+ );
490
+ $settings[] = array(
491
+ 'name' => 'imageLink',
492
+ 'default' => 'on',
493
+ 'type' => 'checkbox',
494
+ 'title' => __( 'Enable Images Links', 'nivo-slider' ),
495
+ 'descp' => __( 'If a link has been added to an image when configuring, the image links to the url.', 'nivo-slider' ),
496
+ );
497
+ $settings[] = array(
498
+ 'name' => 'targetBlank',
499
+ 'default' => 'on',
500
+ 'type' => 'checkbox',
501
+ 'title' => __( 'Open Links in New Window', 'nivo-slider' ),
502
+ 'descp' => __( 'Open the links in a new window.', 'nivo-slider' ),
503
+ 'parent' => 'imageLink',
504
+ 'visible' => 'on',
505
+ );
506
+ $settings[] = array(
507
+ 'name' => 'pauseOnHover',
508
+ 'default' => 'on',
509
+ 'type' => 'checkbox',
510
+ 'title' => __( 'Pause the Slider on Hover', 'nivo-slider' ),
511
+ );
512
+ $settings[] = array(
513
+ 'name' => 'manualAdvance',
514
+ 'default' => 'off',
515
+ 'type' => 'checkbox',
516
+ 'title' => __( 'Manual Transitions', 'nivo-slider' ),
517
+ 'descp' => __( 'Slider is always paused', 'nivo-slider' ),
518
+ );
519
+ $settings[] = array(
520
+ 'name' => 'randomStart',
521
+ 'default' => 'off',
522
+ 'type' => 'custom',
523
+ 'title' => __( 'Random Start Slide', 'nivo-slider' ),
524
+ 'descp' => '<span class="dev7-pro-feature">' . sprintf( '<strong>%s</strong> %s <a href="%s" target="_blank">%s</a>', __( 'Pro Feature:', 'nivo-slider' ), __( 'Enable <strong>random start slide</strong>.', 'nivo-slider' ), 'https://dev7studios.com/products/nivo-slider-wordpress-plugin/?utm_source=wp_plugin&utm_medium=upgrade_link&utm_content=random_setting&utm_campaign=' . $this->post_type . '_lite_plugin', __( 'Upgrade to Pro', 'nivo-slider' ) ) . '</span>',
525
+ );
526
+
527
+ return $settings;
528
+ }
529
+
530
+ /**
531
+ * Get Nivo themes and any custom themes from uploads/nivo-themes/
532
+ *
533
+ * @since 2.2
534
+ * @access private
535
+ *
536
+ * @param bool $select
537
+ *
538
+ * @return array $themes
539
+ */
540
+ private function get_themes( $select = false ) {
541
+ $nivo_theme_specs = array(
542
+ 'SkinName' => 'Skin Name',
543
+ 'SkinURI' => 'Skin URI',
544
+ 'Description' => 'Description',
545
+ 'Version' => 'Version',
546
+ 'Author' => 'Author',
547
+ 'AuthorURI' => 'Author URI',
548
+ 'SupportsThumbs' => 'Supports Thumbs',
549
+ );
550
+
551
+ $plugin_themes = glob( NIVO_SLIDER_LITE_PLUGIN_DIR . '/assets/themes/*', GLOB_ONLYDIR );
552
+
553
+ $upload_dir = wp_upload_dir();
554
+ $upload_path = $upload_dir['basedir'];
555
+ $upload_url = $upload_dir['baseurl'];
556
+
557
+ if ( strpos( $upload_path, 'uploads/sites/' ) !== false && is_multisite() ) {
558
+ $upload_path = substr( $upload_path, 0, strpos( $upload_path, '/sites/' ) );
559
+ $upload_url = substr( $upload_url, 0, strpos( $upload_url, '/sites/' ) );
560
+ }
561
+ $custom_themes = glob( $upload_path . '/nivo-themes/*', GLOB_ONLYDIR );
562
+
563
+ if ( ! is_array( $plugin_themes ) ) {
564
+ $plugin_themes = array();
565
+ }
566
+ if ( ! is_array( $custom_themes ) ) {
567
+ $custom_themes = array();
568
+ }
569
+ $nivo_themes = array_merge( $plugin_themes, $custom_themes );
570
+
571
+ $themes = array();
572
+ if ( $nivo_themes ) {
573
+ foreach ( $nivo_themes as $theme_dir ) {
574
+ $theme_name = basename( $theme_dir );
575
+ $theme_path = $theme_dir . '/' . $theme_name . '.css';
576
+ if ( file_exists( $theme_path ) ) {
577
+ if ( strpos( $theme_dir, 'uploads/nivo-themes' ) !== false ) {
578
+ $theme_url = $upload_url . '/nivo-themes/' . $theme_name . '/' . $theme_name . '.css';
579
+ } else {
580
+ $theme_url = plugins_url( 'assets/themes/' . $theme_name . '/' . $theme_name . '.css', NIVO_SLIDER_LITE_PLUGIN_FILE );
581
+ }
582
+ $themes[ $theme_name ] = array(
583
+ 'theme_name' => $theme_name,
584
+ 'theme_path' => $theme_path,
585
+ 'theme_url' => $theme_url,
586
+ 'theme_details' => get_file_data( $theme_path, $nivo_theme_specs ),
587
+ );
588
+ }
589
+ }
590
+ }
591
+
592
+ if ( $select ) {
593
+ $options = array();
594
+ foreach ( $themes as $theme ) {
595
+ $options[ $theme['theme_name'] ] = $theme['theme_details']['SkinName'];
596
+ }
597
+
598
+ return $options;
599
+ }
600
+
601
+ return $themes;
602
+ }
603
+
604
+ /**
605
+ * Remove link to the plugin settings on the plugin table list
606
+ *
607
+ * @since 2.2
608
+ * @access public
609
+ */
610
+ public function plugin_action_links( $links, $file ) {
611
+ if ( basename( $file, '.php' ) == 'nivo-slider-lite' ) {
612
+ if ( isset( $links[0] ) ) {
613
+ unset( $links[0] );
614
+ }
615
+ }
616
+
617
+ return $links;
618
+ }
619
+
620
+ /**
621
+ * Override the type manual description
622
+ */
623
+ public function manual_type_description() {
624
+ echo '<span class="dev7-pro-feature">' . sprintf( '<strong>%s</strong> %s <a href="%s" target="_blank">%s</a>', __( 'Pro Feature:', 'nivo-slider' ), __( 'Automatically populate sliders from <strong>posts galleries</strong>, <strong>posts in categories</strong> and <strong>sticky posts</strong>.', 'nivo-slider' ), 'https://dev7studios.com/products/nivo-slider-wordpress-plugin/?utm_source=wp_plugin&utm_medium=upgrade_link&utm_content=type_setting&utm_campaign=' . $this->post_type . '_lite_plugin', __( 'Upgrade to Pro', 'nivo-slider' ) ) . '</span>';
625
+ }
626
+
627
+ /**
628
+ * Restrict image sources
629
+ *
630
+ * @param $sources
631
+ *
632
+ * @return array
633
+ */
634
+ public function get_image_sources( $sources ) {
635
+ $new_sources = array();
636
+ $new_sources['manual'] = $sources['manual'];
637
+
638
+ return $new_sources;
639
+ }
640
+
641
+ /**
642
+ * Adds the Upgrade meta box to the edit screen
643
+ */
644
+ public function meta_box_upgrade() {
645
+ echo '<p>' . __( 'Get more awesome features by upgrading to the full plugin:', 'nivo-slider' ) . '</p>';
646
+ echo '<ul>';
647
+ echo '<li>' . __( 'Create sliders from Galleries, Categories and Sticky Posts', 'nivo-slider' ) . '</li>';
648
+ echo '<li>' . __( 'Responsive sliders', 'nivo-slider' ) . '</li>';
649
+ echo '<li>' . __( 'Pre-built and custom themes', 'nivo-slider' ) . '</li>';
650
+ echo '<li>' . __( 'All 16 transition effects', 'nivo-slider' ) . '</li>';
651
+ echo '<li>' . __( 'Thumbnail navigation', 'nivo-slider' ) . '</li>';
652
+ echo '<li>' . __( 'Random start slide', 'nivo-slider' ) . '</li>';
653
+ echo '<li>' . __( 'Nivo Slider Widget', 'nivo-slider' ) . '</li>';
654
+ echo '<li>' . __( 'Media Manager Plus integration', 'nivo-slider' ) . '</li>';
655
+ echo '<li>' . __( 'Access to our support Help Desk', 'nivo-slider' ) . '</li>';
656
+ echo '</ul>';
657
+ echo '<a href="https://dev7studios.com/products/nivo-slider-wordpress-plugin/?utm_source=wp_plugin&utm_medium=upgrade_link&utm_content=upgrade_metabox&utm_campaign=' . $this->post_type . '_lite_plugin" target="_blank" class="button-primary">' . __( 'Upgrade Now', 'nivo-slider' ) . '</a>';
658
+ }
659
+
660
+ /**
661
+ * Custom shortcode plugin output
662
+ *
663
+ * @since 2.2
664
+ * @access public
665
+ *
666
+ * @param int $id
667
+ * @param string $output
668
+ * @param array $options
669
+ * @param array $images
670
+ * @param string $slider_type
671
+ *
672
+ * @return string $output
673
+ */
674
+ public function shortcode_output( $id, $output, $options, $images, $slider_type ) {
675
+ $captions = array();
676
+ $output .= '<div class="slider-wrapper';
677
+ if ( isset( $options['theme'] ) && $options['theme'] != '' ) {
678
+ $output .= ' theme-' . $options['theme'];
679
+ }
680
+ if ( isset( $options['controlNavThumbs'] ) && $options['controlNavThumbs'] == 'on' ) {
681
+ $output .= ' controlnav-thumbs';
682
+ }
683
+ $output .= '"><div class="ribbon"></div>';
684
+ $output .= '<div id="nivoslider-' . $id . '" class="nivoSlider"';
685
+ if ( $options['sizing'] == 'fixed' ) {
686
+ $output .= ' style="width:' . $options['dim_x'] . 'px;height:' . $options['dim_y'] . 'px;"';
687
+ }
688
+ $output .= '>';
689
+ $i = 0;
690
+ foreach ( $images as $image ) {
691
+
692
+ $image_link = dev7_default_val( $options, 'imageLink', 'on' );
693
+ $target_blank = dev7_default_val( $options, 'targetBlank', 'on' );
694
+ if ( ( isset( $image['post_permalink'] ) && $image['post_permalink'] != '' ) && $image_link == 'on' ) {
695
+ $target = ( $target_blank == 'on' ) ? ' target="_blank"' : '';
696
+ $output .= '<a ' . $target . ' href="' . $image['post_permalink'] . '">';
697
+ }
698
+
699
+ if ( $options['sizing'] == 'fixed' && isset( $image['attachment_id'] ) ) {
700
+ $resized_image = Dev7_Core_Images::resize_image( $image['attachment_id'], '', $options['dim_x'], $options['dim_y'], true );
701
+ if ( is_wp_error( $resized_image ) ) {
702
+ echo '<p>Error: ' . $resized_image->get_error_message() . '</p>';
703
+ $output .= '<img src="" ';
704
+ } else {
705
+ $output .= '<img src="' . $resized_image['url'] . '" ';
706
+ }
707
+ } else {
708
+ $output .= '<img src="' . $image['image_src'] . '" ';
709
+ }
710
+
711
+ if ( ( $options['type'] == 'manual' || $options['type'] == 'gallery' ) && isset( $image['post_title'] ) && $image['post_title'] != '' ) {
712
+ $captions[] = $image['post_title'];
713
+ $output .= 'title="#nivoslider-' . $id . '-caption-' . $i . '" ';
714
+ $i++;
715
+ }
716
+ if ( ( $options['type'] == 'category' || $options['type'] == 'sticky' || $options['type'] == 'custom' ) && $options['enable_captions'] == 'on' && isset( $image['post_title'] ) && $image['post_title'] != '' ) {
717
+ $captions[] = $image['post_title'];
718
+ $output .= 'title="#nivoslider-' . $id . '-caption-' . $i . '" ';
719
+ $i++;
720
+ }
721
+
722
+ if ( isset( $options['controlNavThumbs'] ) && $options['controlNavThumbs'] == 'on' ) {
723
+ if ( isset( $image['thumbnail'] ) ) {
724
+ $output .= 'data-thumb="' . $image['thumbnail'] . '" ';
725
+ } else {
726
+ $resized_image = Dev7_Core_Images::resize_image( $image['attachment_id'], '', $options['thumbSizeWidth'], $options['thumbSizeHeight'], true );
727
+ if ( is_wp_error( $resized_image ) ) {
728
+ echo '<p>Error: ' . $resized_image->get_error_message() . '</p>';
729
+ $output .= 'data-thumb="" ';
730
+ } else {
731
+ $output .= 'data-thumb="' . $resized_image['url'] . '" ';
732
+ }
733
+ }
734
+ }
735
+
736
+ $output .= 'alt="' . __( $image['alt_text'] ) . '" />';
737
+ if ( isset( $image['post_permalink'] ) && $image['post_permalink'] != '' ) {
738
+ $output .= '</a>';
739
+ }
740
+ }
741
+ $output .= '</div></div>';
742
+
743
+ if ( isset( $options['controlNavThumbs'] ) && 'on' == $options['controlNavThumbs'] ) {
744
+
745
+ // Get the height and width.
746
+ $thumbnail_height = $options['thumbSizeHeight'];
747
+ $thumbnail_width = $options['thumbSizeWidth'];
748
+
749
+ // Force the height/width of thumbnails set in slider settings.
750
+ $output .= "<style type='text/css' media='screen'> \n";
751
+ $output .= ".theme-default .nivo-controlNav.nivo-thumbs-enabled img, \n";
752
+ $output .= ".nivo-thumbs-enabled img { \n";
753
+ $output .= " width: {$thumbnail_width}px !important; \n";
754
+ $output .= " height: {$thumbnail_height}px !important; \n";
755
+ $output .= "} \n";
756
+ $output .= "</style> \n";
757
+ }
758
+
759
+ $i = 0;
760
+ foreach ( $captions as $caption ) {
761
+ $output .= '<div id="nivoslider-' . $id . '-caption-' . $i . '" class="nivo-html-caption">';
762
+ $output .= __( $caption );
763
+ $output .= '</div>';
764
+ $i++;
765
+ }
766
+
767
+ if ( count( $images ) > 1 ) {
768
+ $output .= '<script type="text/javascript">' . "\n";
769
+ $output .= 'jQuery(window).load(function(){' . "\n";
770
+ $output .= ' jQuery("#nivoslider-' . $id . '").nivoSlider({' . "\n";
771
+ $output .= ' effect:"' . $options['effect'] . '",' . "\n";
772
+ $output .= ' slices:' . $options['slices'] . ',' . "\n";
773
+ $output .= ' boxCols:' . $options['boxCols'] . ',' . "\n";
774
+ $output .= ' boxRows:' . $options['boxRows'] . ',' . "\n";
775
+ $output .= ' animSpeed:' . $options['animSpeed'] . ',' . "\n";
776
+ $output .= ' pauseTime:' . $options['pauseTime'] . ',' . "\n";
777
+ if ( isset( $options['randomStart'] ) && $options['randomStart'] == 'on' ) {
778
+ $output .= ' startSlide:' . floor( rand( 0, count( $images ) ) ) . ',' . "\n";
779
+ } else {
780
+ $output .= ' startSlide:' . $options['startSlide'] . ',' . "\n";
781
+ }
782
+ $output .= ' directionNav:' . ( ( $options['directionNav'] == 'on' ) ? 'true' : 'false' ) . ',' . "\n";
783
+ $output .= ' controlNav:' . ( ( $options['controlNav'] == 'on' ) ? 'true' : 'false' ) . ',' . "\n";
784
+ $output .= ' controlNavThumbs:' . ( ( isset( $options['controlNavThumbs'] ) && $options['controlNavThumbs'] == 'on' ) ? 'true' : 'false' ) . ',' . "\n";
785
+ $output .= ' pauseOnHover:' . ( ( $options['pauseOnHover'] == 'on' ) ? 'true' : 'false' ) . ',' . "\n";
786
+ $output .= ' manualAdvance:' . ( ( $options['manualAdvance'] == 'on' ) ? 'true' : 'false' ) . "\n";
787
+ $output .= ' });' . "\n";
788
+ $output .= '});' . "\n";
789
+ $output .= '</script>' . "\n";
790
+ } else {
791
+ $output .= '<script type="text/javascript">' . "\n";
792
+ $output .= 'jQuery(window).load(function(){' . "\n";
793
+ $output .= ' jQuery("#nivoslider-' . $id . ' img").css("position","relative").show();' . "\n";
794
+ $output .= '});' . "\n";
795
+ $output .= '</script>' . "\n";
796
+ }
797
+
798
+ return $output;
799
+ }
800
+
801
+ }
802
+
803
+ /**
804
+ * Template function to wrap the plugin shortcode
805
+ *
806
+ * @since 2.2
807
+ *
808
+ * @param mixed $slider
809
+ * @param bool $return
810
+ */
811
+ if ( ! function_exists( 'nivo_slider' ) ) {
812
+ function nivo_slider( $slider, $return = false ) {
813
+
814
+ $slug = '';
815
+ $id = 0;
816
+
817
+ if ( is_numeric( $slider ) ) {
818
+ $id = $slider;
819
+ } else {
820
+ $slug = $slider;
821
+ }
822
+
823
+ if ( $return ) {
824
+ return do_shortcode( '[nivoslider slug="' . $slug . '" id="' . $id . '" template="1"]' );
825
+ } else {
826
+ echo do_shortcode( '[nivoslider slug="' . $slug . '" id="' . $id . '" template="1"]' );
827
+ }
828
+ }
829
+ }
license.txt ADDED
@@ -0,0 +1,674 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+ Preamble
9
+
10
+ The GNU General Public License is a free, copyleft license for
11
+ software and other kinds of works.
12
+
13
+ The licenses for most software and other practical works are designed
14
+ to take away your freedom to share and change the works. By contrast,
15
+ the GNU General Public License is intended to guarantee your freedom to
16
+ share and change all versions of a program--to make sure it remains free
17
+ software for all its users. We, the Free Software Foundation, use the
18
+ GNU General Public License for most of our software; it applies also to
19
+ any other work released this way by its authors. You can apply it to
20
+ your programs, too.
21
+
22
+ When we speak of free software, we are referring to freedom, not
23
+ price. Our General Public Licenses are designed to make sure that you
24
+ have the freedom to distribute copies of free software (and charge for
25
+ them if you wish), that you receive source code or can get it if you
26
+ want it, that you can change the software or use pieces of it in new
27
+ free programs, and that you know you can do these things.
28
+
29
+ To protect your rights, we need to prevent others from denying you
30
+ these rights or asking you to surrender the rights. Therefore, you have
31
+ certain responsibilities if you distribute copies of the software, or if
32
+ you modify it: responsibilities to respect the freedom of others.
33
+
34
+ For example, if you distribute copies of such a program, whether
35
+ gratis or for a fee, you must pass on to the recipients the same
36
+ freedoms that you received. You must make sure that they, too, receive
37
+ or can get the source code. And you must show them these terms so they
38
+ know their rights.
39
+
40
+ Developers that use the GNU GPL protect your rights with two steps:
41
+ (1) assert copyright on the software, and (2) offer you this License
42
+ giving you legal permission to copy, distribute and/or modify it.
43
+
44
+ For the developers' and authors' protection, the GPL clearly explains
45
+ that there is no warranty for this free software. For both users' and
46
+ authors' sake, the GPL requires that modified versions be marked as
47
+ changed, so that their problems will not be attributed erroneously to
48
+ authors of previous versions.
49
+
50
+ Some devices are designed to deny users access to install or run
51
+ modified versions of the software inside them, although the manufacturer
52
+ can do so. This is fundamentally incompatible with the aim of
53
+ protecting users' freedom to change the software. The systematic
54
+ pattern of such abuse occurs in the area of products for individuals to
55
+ use, which is precisely where it is most unacceptable. Therefore, we
56
+ have designed this version of the GPL to prohibit the practice for those
57
+ products. If such problems arise substantially in other domains, we
58
+ stand ready to extend this provision to those domains in future versions
59
+ of the GPL, as needed to protect the freedom of users.
60
+
61
+ Finally, every program is threatened constantly by software patents.
62
+ States should not allow patents to restrict development and use of
63
+ software on general-purpose computers, but in those that do, we wish to
64
+ avoid the special danger that patents applied to a free program could
65
+ make it effectively proprietary. To prevent this, the GPL assures that
66
+ patents cannot be used to render the program non-free.
67
+
68
+ The precise terms and conditions for copying, distribution and
69
+ modification follow.
70
+
71
+ TERMS AND CONDITIONS
72
+
73
+ 0. Definitions.
74
+
75
+ "This License" refers to version 3 of the GNU General Public License.
76
+
77
+ "Copyright" also means copyright-like laws that apply to other kinds of
78
+ works, such as semiconductor masks.
79
+
80
+ "The Program" refers to any copyrightable work licensed under this
81
+ License. Each licensee is addressed as "you". "Licensees" and
82
+ "recipients" may be individuals or organizations.
83
+
84
+ To "modify" a work means to copy from or adapt all or part of the work
85
+ in a fashion requiring copyright permission, other than the making of an
86
+ exact copy. The resulting work is called a "modified version" of the
87
+ earlier work or a work "based on" the earlier work.
88
+
89
+ A "covered work" means either the unmodified Program or a work based
90
+ on the Program.
91
+
92
+ To "propagate" a work means to do anything with it that, without
93
+ permission, would make you directly or secondarily liable for
94
+ infringement under applicable copyright law, except executing it on a
95
+ computer or modifying a private copy. Propagation includes copying,
96
+ distribution (with or without modification), making available to the
97
+ public, and in some countries other activities as well.
98
+
99
+ To "convey" a work means any kind of propagation that enables other
100
+ parties to make or receive copies. Mere interaction with a user through
101
+ a computer network, with no transfer of a copy, is not conveying.
102
+
103
+ An interactive user interface displays "Appropriate Legal Notices"
104
+ to the extent that it includes a convenient and prominently visible
105
+ feature that (1) displays an appropriate copyright notice, and (2)
106
+ tells the user that there is no warranty for the work (except to the
107
+ extent that warranties are provided), that licensees may convey the
108
+ work under this License, and how to view a copy of this License. If
109
+ the interface presents a list of user commands or options, such as a
110
+ menu, a prominent item in the list meets this criterion.
111
+
112
+ 1. Source Code.
113
+
114
+ The "source code" for a work means the preferred form of the work
115
+ for making modifications to it. "Object code" means any non-source
116
+ form of a work.
117
+
118
+ A "Standard Interface" means an interface that either is an official
119
+ standard defined by a recognized standards body, or, in the case of
120
+ interfaces specified for a particular programming language, one that
121
+ is widely used among developers working in that language.
122
+
123
+ The "System Libraries" of an executable work include anything, other
124
+ than the work as a whole, that (a) is included in the normal form of
125
+ packaging a Major Component, but which is not part of that Major
126
+ Component, and (b) serves only to enable use of the work with that
127
+ Major Component, or to implement a Standard Interface for which an
128
+ implementation is available to the public in source code form. A
129
+ "Major Component", in this context, means a major essential component
130
+ (kernel, window system, and so on) of the specific operating system
131
+ (if any) on which the executable work runs, or a compiler used to
132
+ produce the work, or an object code interpreter used to run it.
133
+
134
+ The "Corresponding Source" for a work in object code form means all
135
+ the source code needed to generate, install, and (for an executable
136
+ work) run the object code and to modify the work, including scripts to
137
+ control those activities. However, it does not include the work's
138
+ System Libraries, or general-purpose tools or generally available free
139
+ programs which are used unmodified in performing those activities but
140
+ which are not part of the work. For example, Corresponding Source
141
+ includes interface definition files associated with source files for
142
+ the work, and the source code for shared libraries and dynamically
143
+ linked subprograms that the work is specifically designed to require,
144
+ such as by intimate data communication or control flow between those
145
+ subprograms and other parts of the work.
146
+
147
+ The Corresponding Source need not include anything that users
148
+ can regenerate automatically from other parts of the Corresponding
149
+ Source.
150
+
151
+ The Corresponding Source for a work in source code form is that
152
+ same work.
153
+
154
+ 2. Basic Permissions.
155
+
156
+ All rights granted under this License are granted for the term of
157
+ copyright on the Program, and are irrevocable provided the stated
158
+ conditions are met. This License explicitly affirms your unlimited
159
+ permission to run the unmodified Program. The output from running a
160
+ covered work is covered by this License only if the output, given its
161
+ content, constitutes a covered work. This License acknowledges your
162
+ rights of fair use or other equivalent, as provided by copyright law.
163
+
164
+ You may make, run and propagate covered works that you do not
165
+ convey, without conditions so long as your license otherwise remains
166
+ in force. You may convey covered works to others for the sole purpose
167
+ of having them make modifications exclusively for you, or provide you
168
+ with facilities for running those works, provided that you comply with
169
+ the terms of this License in conveying all material for which you do
170
+ not control copyright. Those thus making or running the covered works
171
+ for you must do so exclusively on your behalf, under your direction
172
+ and control, on terms that prohibit them from making any copies of
173
+ your copyrighted material outside their relationship with you.
174
+
175
+ Conveying under any other circumstances is permitted solely under
176
+ the conditions stated below. Sublicensing is not allowed; section 10
177
+ makes it unnecessary.
178
+
179
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180
+
181
+ No covered work shall be deemed part of an effective technological
182
+ measure under any applicable law fulfilling obligations under article
183
+ 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184
+ similar laws prohibiting or restricting circumvention of such
185
+ measures.
186
+
187
+ When you convey a covered work, you waive any legal power to forbid
188
+ circumvention of technological measures to the extent such circumvention
189
+ is effected by exercising rights under this License with respect to
190
+ the covered work, and you disclaim any intention to limit operation or
191
+ modification of the work as a means of enforcing, against the work's
192
+ users, your or third parties' legal rights to forbid circumvention of
193
+ technological measures.
194
+
195
+ 4. Conveying Verbatim Copies.
196
+
197
+ You may convey verbatim copies of the Program's source code as you
198
+ receive it, in any medium, provided that you conspicuously and
199
+ appropriately publish on each copy an appropriate copyright notice;
200
+ keep intact all notices stating that this License and any
201
+ non-permissive terms added in accord with section 7 apply to the code;
202
+ keep intact all notices of the absence of any warranty; and give all
203
+ recipients a copy of this License along with the Program.
204
+
205
+ You may charge any price or no price for each copy that you convey,
206
+ and you may offer support or warranty protection for a fee.
207
+
208
+ 5. Conveying Modified Source Versions.
209
+
210
+ You may convey a work based on the Program, or the modifications to
211
+ produce it from the Program, in the form of source code under the
212
+ terms of section 4, provided that you also meet all of these conditions:
213
+
214
+ a) The work must carry prominent notices stating that you modified
215
+ it, and giving a relevant date.
216
+
217
+ b) The work must carry prominent notices stating that it is
218
+ released under this License and any conditions added under section
219
+ 7. This requirement modifies the requirement in section 4 to
220
+ "keep intact all notices".
221
+
222
+ c) You must license the entire work, as a whole, under this
223
+ License to anyone who comes into possession of a copy. This
224
+ License will therefore apply, along with any applicable section 7
225
+ additional terms, to the whole of the work, and all its parts,
226
+ regardless of how they are packaged. This License gives no
227
+ permission to license the work in any other way, but it does not
228
+ invalidate such permission if you have separately received it.
229
+
230
+ d) If the work has interactive user interfaces, each must display
231
+ Appropriate Legal Notices; however, if the Program has interactive
232
+ interfaces that do not display Appropriate Legal Notices, your
233
+ work need not make them do so.
234
+
235
+ A compilation of a covered work with other separate and independent
236
+ works, which are not by their nature extensions of the covered work,
237
+ and which are not combined with it such as to form a larger program,
238
+ in or on a volume of a storage or distribution medium, is called an
239
+ "aggregate" if the compilation and its resulting copyright are not
240
+ used to limit the access or legal rights of the compilation's users
241
+ beyond what the individual works permit. Inclusion of a covered work
242
+ in an aggregate does not cause this License to apply to the other
243
+ parts of the aggregate.
244
+
245
+ 6. Conveying Non-Source Forms.
246
+
247
+ You may convey a covered work in object code form under the terms
248
+ of sections 4 and 5, provided that you also convey the
249
+ machine-readable Corresponding Source under the terms of this License,
250
+ in one of these ways:
251
+
252
+ a) Convey the object code in, or embodied in, a physical product
253
+ (including a physical distribution medium), accompanied by the
254
+ Corresponding Source fixed on a durable physical medium
255
+ customarily used for software interchange.
256
+
257
+ b) Convey the object code in, or embodied in, a physical product
258
+ (including a physical distribution medium), accompanied by a
259
+ written offer, valid for at least three years and valid for as
260
+ long as you offer spare parts or customer support for that product
261
+ model, to give anyone who possesses the object code either (1) a
262
+ copy of the Corresponding Source for all the software in the
263
+ product that is covered by this License, on a durable physical
264
+ medium customarily used for software interchange, for a price no
265
+ more than your reasonable cost of physically performing this
266
+ conveying of source, or (2) access to copy the
267
+ Corresponding Source from a network server at no charge.
268
+
269
+ c) Convey individual copies of the object code with a copy of the
270
+ written offer to provide the Corresponding Source. This
271
+ alternative is allowed only occasionally and noncommercially, and
272
+ only if you received the object code with such an offer, in accord
273
+ with subsection 6b.
274
+
275
+ d) Convey the object code by offering access from a designated
276
+ place (gratis or for a charge), and offer equivalent access to the
277
+ Corresponding Source in the same way through the same place at no
278
+ further charge. You need not require recipients to copy the
279
+ Corresponding Source along with the object code. If the place to
280
+ copy the object code is a network server, the Corresponding Source
281
+ may be on a different server (operated by you or a third party)
282
+ that supports equivalent copying facilities, provided you maintain
283
+ clear directions next to the object code saying where to find the
284
+ Corresponding Source. Regardless of what server hosts the
285
+ Corresponding Source, you remain obligated to ensure that it is
286
+ available for as long as needed to satisfy these requirements.
287
+
288
+ e) Convey the object code using peer-to-peer transmission, provided
289
+ you inform other peers where the object code and Corresponding
290
+ Source of the work are being offered to the general public at no
291
+ charge under subsection 6d.
292
+
293
+ A separable portion of the object code, whose source code is excluded
294
+ from the Corresponding Source as a System Library, need not be
295
+ included in conveying the object code work.
296
+
297
+ A "User Product" is either (1) a "consumer product", which means any
298
+ tangible personal property which is normally used for personal, family,
299
+ or household purposes, or (2) anything designed or sold for incorporation
300
+ into a dwelling. In determining whether a product is a consumer product,
301
+ doubtful cases shall be resolved in favor of coverage. For a particular
302
+ product received by a particular user, "normally used" refers to a
303
+ typical or common use of that class of product, regardless of the status
304
+ of the particular user or of the way in which the particular user
305
+ actually uses, or expects or is expected to use, the product. A product
306
+ is a consumer product regardless of whether the product has substantial
307
+ commercial, industrial or non-consumer uses, unless such uses represent
308
+ the only significant mode of use of the product.
309
+
310
+ "Installation Information" for a User Product means any methods,
311
+ procedures, authorization keys, or other information required to install
312
+ and execute modified versions of a covered work in that User Product from
313
+ a modified version of its Corresponding Source. The information must
314
+ suffice to ensure that the continued functioning of the modified object
315
+ code is in no case prevented or interfered with solely because
316
+ modification has been made.
317
+
318
+ If you convey an object code work under this section in, or with, or
319
+ specifically for use in, a User Product, and the conveying occurs as
320
+ part of a transaction in which the right of possession and use of the
321
+ User Product is transferred to the recipient in perpetuity or for a
322
+ fixed term (regardless of how the transaction is characterized), the
323
+ Corresponding Source conveyed under this section must be accompanied
324
+ by the Installation Information. But this requirement does not apply
325
+ if neither you nor any third party retains the ability to install
326
+ modified object code on the User Product (for example, the work has
327
+ been installed in ROM).
328
+
329
+ The requirement to provide Installation Information does not include a
330
+ requirement to continue to provide support service, warranty, or updates
331
+ for a work that has been modified or installed by the recipient, or for
332
+ the User Product in which it has been modified or installed. Access to a
333
+ network may be denied when the modification itself materially and
334
+ adversely affects the operation of the network or violates the rules and
335
+ protocols for communication across the network.
336
+
337
+ Corresponding Source conveyed, and Installation Information provided,
338
+ in accord with this section must be in a format that is publicly
339
+ documented (and with an implementation available to the public in
340
+ source code form), and must require no special password or key for
341
+ unpacking, reading or copying.
342
+
343
+ 7. Additional Terms.
344
+
345
+ "Additional permissions" are terms that supplement the terms of this
346
+ License by making exceptions from one or more of its conditions.
347
+ Additional permissions that are applicable to the entire Program shall
348
+ be treated as though they were included in this License, to the extent
349
+ that they are valid under applicable law. If additional permissions
350
+ apply only to part of the Program, that part may be used separately
351
+ under those permissions, but the entire Program remains governed by
352
+ this License without regard to the additional permissions.
353
+
354
+ When you convey a copy of a covered work, you may at your option
355
+ remove any additional permissions from that copy, or from any part of
356
+ it. (Additional permissions may be written to require their own
357
+ removal in certain cases when you modify the work.) You may place
358
+ additional permissions on material, added by you to a covered work,
359
+ for which you have or can give appropriate copyright permission.
360
+
361
+ Notwithstanding any other provision of this License, for material you
362
+ add to a covered work, you may (if authorized by the copyright holders of
363
+ that material) supplement the terms of this License with terms:
364
+
365
+ a) Disclaiming warranty or limiting liability differently from the
366
+ terms of sections 15 and 16 of this License; or
367
+
368
+ b) Requiring preservation of specified reasonable legal notices or
369
+ author attributions in that material or in the Appropriate Legal
370
+ Notices displayed by works containing it; or
371
+
372
+ c) Prohibiting misrepresentation of the origin of that material, or
373
+ requiring that modified versions of such material be marked in
374
+ reasonable ways as different from the original version; or
375
+
376
+ d) Limiting the use for publicity purposes of names of licensors or
377
+ authors of the material; or
378
+
379
+ e) Declining to grant rights under trademark law for use of some
380
+ trade names, trademarks, or service marks; or
381
+
382
+ f) Requiring indemnification of licensors and authors of that
383
+ material by anyone who conveys the material (or modified versions of
384
+ it) with contractual assumptions of liability to the recipient, for
385
+ any liability that these contractual assumptions directly impose on
386
+ those licensors and authors.
387
+
388
+ All other non-permissive additional terms are considered "further
389
+ restrictions" within the meaning of section 10. If the Program as you
390
+ received it, or any part of it, contains a notice stating that it is
391
+ governed by this License along with a term that is a further
392
+ restriction, you may remove that term. If a license document contains
393
+ a further restriction but permits relicensing or conveying under this
394
+ License, you may add to a covered work material governed by the terms
395
+ of that license document, provided that the further restriction does
396
+ not survive such relicensing or conveying.
397
+
398
+ If you add terms to a covered work in accord with this section, you
399
+ must place, in the relevant source files, a statement of the
400
+ additional terms that apply to those files, or a notice indicating
401
+ where to find the applicable terms.
402
+
403
+ Additional terms, permissive or non-permissive, may be stated in the
404
+ form of a separately written license, or stated as exceptions;
405
+ the above requirements apply either way.
406
+
407
+ 8. Termination.
408
+
409
+ You may not propagate or modify a covered work except as expressly
410
+ provided under this License. Any attempt otherwise to propagate or
411
+ modify it is void, and will automatically terminate your rights under
412
+ this License (including any patent licenses granted under the third
413
+ paragraph of section 11).
414
+
415
+ However, if you cease all violation of this License, then your
416
+ license from a particular copyright holder is reinstated (a)
417
+ provisionally, unless and until the copyright holder explicitly and
418
+ finally terminates your license, and (b) permanently, if the copyright
419
+ holder fails to notify you of the violation by some reasonable means
420
+ prior to 60 days after the cessation.
421
+
422
+ Moreover, your license from a particular copyright holder is
423
+ reinstated permanently if the copyright holder notifies you of the
424
+ violation by some reasonable means, this is the first time you have
425
+ received notice of violation of this License (for any work) from that
426
+ copyright holder, and you cure the violation prior to 30 days after
427
+ your receipt of the notice.
428
+
429
+ Termination of your rights under this section does not terminate the
430
+ licenses of parties who have received copies or rights from you under
431
+ this License. If your rights have been terminated and not permanently
432
+ reinstated, you do not qualify to receive new licenses for the same
433
+ material under section 10.
434
+
435
+ 9. Acceptance Not Required for Having Copies.
436
+
437
+ You are not required to accept this License in order to receive or
438
+ run a copy of the Program. Ancillary propagation of a covered work
439
+ occurring solely as a consequence of using peer-to-peer transmission
440
+ to receive a copy likewise does not require acceptance. However,
441
+ nothing other than this License grants you permission to propagate or
442
+ modify any covered work. These actions infringe copyright if you do
443
+ not accept this License. Therefore, by modifying or propagating a
444
+ covered work, you indicate your acceptance of this License to do so.
445
+
446
+ 10. Automatic Licensing of Downstream Recipients.
447
+
448
+ Each time you convey a covered work, the recipient automatically
449
+ receives a license from the original licensors, to run, modify and
450
+ propagate that work, subject to this License. You are not responsible
451
+ for enforcing compliance by third parties with this License.
452
+
453
+ An "entity transaction" is a transaction transferring control of an
454
+ organization, or substantially all assets of one, or subdividing an
455
+ organization, or merging organizations. If propagation of a covered
456
+ work results from an entity transaction, each party to that
457
+ transaction who receives a copy of the work also receives whatever
458
+ licenses to the work the party's predecessor in interest had or could
459
+ give under the previous paragraph, plus a right to possession of the
460
+ Corresponding Source of the work from the predecessor in interest, if
461
+ the predecessor has it or can get it with reasonable efforts.
462
+
463
+ You may not impose any further restrictions on the exercise of the
464
+ rights granted or affirmed under this License. For example, you may
465
+ not impose a license fee, royalty, or other charge for exercise of
466
+ rights granted under this License, and you may not initiate litigation
467
+ (including a cross-claim or counterclaim in a lawsuit) alleging that
468
+ any patent claim is infringed by making, using, selling, offering for
469
+ sale, or importing the Program or any portion of it.
470
+
471
+ 11. Patents.
472
+
473
+ A "contributor" is a copyright holder who authorizes use under this
474
+ License of the Program or a work on which the Program is based. The
475
+ work thus licensed is called the contributor's "contributor version".
476
+
477
+ A contributor's "essential patent claims" are all patent claims
478
+ owned or controlled by the contributor, whether already acquired or
479
+ hereafter acquired, that would be infringed by some manner, permitted
480
+ by this License, of making, using, or selling its contributor version,
481
+ but do not include claims that would be infringed only as a
482
+ consequence of further modification of the contributor version. For
483
+ purposes of this definition, "control" includes the right to grant
484
+ patent sublicenses in a manner consistent with the requirements of
485
+ this License.
486
+
487
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
488
+ patent license under the contributor's essential patent claims, to
489
+ make, use, sell, offer for sale, import and otherwise run, modify and
490
+ propagate the contents of its contributor version.
491
+
492
+ In the following three paragraphs, a "patent license" is any express
493
+ agreement or commitment, however denominated, not to enforce a patent
494
+ (such as an express permission to practice a patent or covenant not to
495
+ sue for patent infringement). To "grant" such a patent license to a
496
+ party means to make such an agreement or commitment not to enforce a
497
+ patent against the party.
498
+
499
+ If you convey a covered work, knowingly relying on a patent license,
500
+ and the Corresponding Source of the work is not available for anyone
501
+ to copy, free of charge and under the terms of this License, through a
502
+ publicly available network server or other readily accessible means,
503
+ then you must either (1) cause the Corresponding Source to be so
504
+ available, or (2) arrange to deprive yourself of the benefit of the
505
+ patent license for this particular work, or (3) arrange, in a manner
506
+ consistent with the requirements of this License, to extend the patent
507
+ license to downstream recipients. "Knowingly relying" means you have
508
+ actual knowledge that, but for the patent license, your conveying the
509
+ covered work in a country, or your recipient's use of the covered work
510
+ in a country, would infringe one or more identifiable patents in that
511
+ country that you have reason to believe are valid.
512
+
513
+ If, pursuant to or in connection with a single transaction or
514
+ arrangement, you convey, or propagate by procuring conveyance of, a
515
+ covered work, and grant a patent license to some of the parties
516
+ receiving the covered work authorizing them to use, propagate, modify
517
+ or convey a specific copy of the covered work, then the patent license
518
+ you grant is automatically extended to all recipients of the covered
519
+ work and works based on it.
520
+
521
+ A patent license is "discriminatory" if it does not include within
522
+ the scope of its coverage, prohibits the exercise of, or is
523
+ conditioned on the non-exercise of one or more of the rights that are
524
+ specifically granted under this License. You may not convey a covered
525
+ work if you are a party to an arrangement with a third party that is
526
+ in the business of distributing software, under which you make payment
527
+ to the third party based on the extent of your activity of conveying
528
+ the work, and under which the third party grants, to any of the
529
+ parties who would receive the covered work from you, a discriminatory
530
+ patent license (a) in connection with copies of the covered work
531
+ conveyed by you (or copies made from those copies), or (b) primarily
532
+ for and in connection with specific products or compilations that
533
+ contain the covered work, unless you entered into that arrangement,
534
+ or that patent license was granted, prior to 28 March 2007.
535
+
536
+ Nothing in this License shall be construed as excluding or limiting
537
+ any implied license or other defenses to infringement that may
538
+ otherwise be available to you under applicable patent law.
539
+
540
+ 12. No Surrender of Others' Freedom.
541
+
542
+ If conditions are imposed on you (whether by court order, agreement or
543
+ otherwise) that contradict the conditions of this License, they do not
544
+ excuse you from the conditions of this License. If you cannot convey a
545
+ covered work so as to satisfy simultaneously your obligations under this
546
+ License and any other pertinent obligations, then as a consequence you may
547
+ not convey it at all. For example, if you agree to terms that obligate you
548
+ to collect a royalty for further conveying from those to whom you convey
549
+ the Program, the only way you could satisfy both those terms and this
550
+ License would be to refrain entirely from conveying the Program.
551
+
552
+ 13. Use with the GNU Affero General Public License.
553
+
554
+ Notwithstanding any other provision of this License, you have
555
+ permission to link or combine any covered work with a work licensed
556
+ under version 3 of the GNU Affero General Public License into a single
557
+ combined work, and to convey the resulting work. The terms of this
558
+ License will continue to apply to the part which is the covered work,
559
+ but the special requirements of the GNU Affero General Public License,
560
+ section 13, concerning interaction through a network will apply to the
561
+ combination as such.
562
+
563
+ 14. Revised Versions of this License.
564
+
565
+ The Free Software Foundation may publish revised and/or new versions of
566
+ the GNU General Public License from time to time. Such new versions will
567
+ be similar in spirit to the present version, but may differ in detail to
568
+ address new problems or concerns.
569
+
570
+ Each version is given a distinguishing version number. If the
571
+ Program specifies that a certain numbered version of the GNU General
572
+ Public License "or any later version" applies to it, you have the
573
+ option of following the terms and conditions either of that numbered
574
+ version or of any later version published by the Free Software
575
+ Foundation. If the Program does not specify a version number of the
576
+ GNU General Public License, you may choose any version ever published
577
+ by the Free Software Foundation.
578
+
579
+ If the Program specifies that a proxy can decide which future
580
+ versions of the GNU General Public License can be used, that proxy's
581
+ public statement of acceptance of a version permanently authorizes you
582
+ to choose that version for the Program.
583
+
584
+ Later license versions may give you additional or different
585
+ permissions. However, no additional obligations are imposed on any
586
+ author or copyright holder as a result of your choosing to follow a
587
+ later version.
588
+
589
+ 15. Disclaimer of Warranty.
590
+
591
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592
+ APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593
+ HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594
+ OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596
+ PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597
+ IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598
+ ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599
+
600
+ 16. Limitation of Liability.
601
+
602
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604
+ THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605
+ GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606
+ USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607
+ DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608
+ PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609
+ EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610
+ SUCH DAMAGES.
611
+
612
+ 17. Interpretation of Sections 15 and 16.
613
+
614
+ If the disclaimer of warranty and limitation of liability provided
615
+ above cannot be given local legal effect according to their terms,
616
+ reviewing courts shall apply local law that most closely approximates
617
+ an absolute waiver of all civil liability in connection with the
618
+ Program, unless a warranty or assumption of liability accompanies a
619
+ copy of the Program in return for a fee.
620
+
621
+ END OF TERMS AND CONDITIONS
622
+
623
+ How to Apply These Terms to Your New Programs
624
+
625
+ If you develop a new program, and you want it to be of the greatest
626
+ possible use to the public, the best way to achieve this is to make it
627
+ free software which everyone can redistribute and change under these terms.
628
+
629
+ To do so, attach the following notices to the program. It is safest
630
+ to attach them to the start of each source file to most effectively
631
+ state the exclusion of warranty; and each file should have at least
632
+ the "copyright" line and a pointer to where the full notice is found.
633
+
634
+ <one line to give the program's name and a brief idea of what it does.>
635
+ Copyright (C) <year> <name of author>
636
+
637
+ This program is free software: you can redistribute it and/or modify
638
+ it under the terms of the GNU General Public License as published by
639
+ the Free Software Foundation, either version 3 of the License, or
640
+ (at your option) any later version.
641
+
642
+ This program is distributed in the hope that it will be useful,
643
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
644
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645
+ GNU General Public License for more details.
646
+
647
+ You should have received a copy of the GNU General Public License
648
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
649
+
650
+ Also add information on how to contact you by electronic and paper mail.
651
+
652
+ If the program does terminal interaction, make it output a short
653
+ notice like this when it starts in an interactive mode:
654
+
655
+ <program> Copyright (C) <year> <name of author>
656
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657
+ This is free software, and you are welcome to redistribute it
658
+ under certain conditions; type `show c' for details.
659
+
660
+ The hypothetical commands `show w' and `show c' should show the appropriate
661
+ parts of the General Public License. Of course, your program's commands
662
+ might be different; for a GUI interface, you would use an "about box".
663
+
664
+ You should also get your employer (if you work as a programmer) or school,
665
+ if any, to sign a "copyright disclaimer" for the program, if necessary.
666
+ For more information on this, and how to apply and follow the GNU GPL, see
667
+ <http://www.gnu.org/licenses/>.
668
+
669
+ The GNU General Public License does not permit incorporating your program
670
+ into proprietary programs. If your program is a subroutine library, you
671
+ may consider it more useful to permit linking proprietary applications with
672
+ the library. If this is what you want to do, use the GNU Lesser General
673
+ Public License instead of this License. But first, please read
674
+ <http://www.gnu.org/philosophy/why-not-lgpl.html>.
nivo-slider-lite.php ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Plugin Name: Nivo Slider Lite
4
+ * Plugin URI: https://dev7studios.com/products/nivo-slider-wordpress-plugin
5
+ * Description: The official WordPress plugin for the Nivo Slider (Lite)
6
+ * Version: 1.0.0
7
+ * Author: Dev7studios
8
+ * Author URI: https://dev7studios.com
9
+ * Text Domain: nivo-slider
10
+ * Domain Path: languages
11
+ **/
12
+
13
+ // Exit if accessed directly
14
+ if ( ! defined( 'ABSPATH' ) ) {
15
+ exit;
16
+ }
17
+
18
+ /**
19
+ * Main WordPress_Nivo_Slider_Lite Class
20
+ */
21
+ class WordPress_Nivo_Slider_Lite {
22
+
23
+ /**
24
+ * Plugin Version
25
+ *
26
+ * @var string
27
+ * @access private
28
+ */
29
+ private $version = '1.0.0';
30
+
31
+ public function __construct() {
32
+ $this->setup_constants();
33
+ $this->loader();
34
+
35
+ add_action( 'plugins_loaded', array( $this, 'compat_check' ) );
36
+ }
37
+
38
+ public function compat_check() {
39
+ if ( class_exists( 'WordPress_Nivo_Slider' ) ) {
40
+ include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
41
+ if ( is_plugin_active( 'nivo-slider/nivo-slider.php' ) ) {
42
+ return;
43
+ }
44
+ }
45
+
46
+ new Dev7_Nivo_Slider_Lite( $this->version );
47
+ }
48
+
49
+ /**
50
+ * Setup plugin constants
51
+ */
52
+ private function setup_constants() {
53
+ // Plugin Folder Path
54
+ if ( ! defined( 'NIVO_SLIDER_LITE_PLUGIN_DIR' ) ) {
55
+ define( 'NIVO_SLIDER_LITE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
56
+ }
57
+
58
+ // Plugin Folder URL
59
+ if ( ! defined( 'NIVO_SLIDER_LITE_PLUGIN_URL' ) ) {
60
+ define( 'NIVO_SLIDER_LITE_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
61
+ }
62
+
63
+ // Plugin Root File
64
+ if ( ! defined( 'NIVO_SLIDER_LITE_PLUGIN_FILE' ) ) {
65
+ define( 'NIVO_SLIDER_LITE_PLUGIN_FILE', __FILE__ );
66
+ }
67
+
68
+ // Plugin Basename
69
+ if ( ! defined( 'NIVO_SLIDER_LITE_PLUGIN_BASENAME' ) ) {
70
+ define( 'NIVO_SLIDER_LITE_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
71
+ }
72
+ }
73
+
74
+ /**
75
+ * Load core plugin files
76
+ */
77
+ private function loader() {
78
+ require_once NIVO_SLIDER_LITE_PLUGIN_DIR . 'includes/plugin.php';
79
+ }
80
+ }
81
+
82
+ // Let's go!
83
+ $WordPress_Nivo_Slider_Lite = new WordPress_Nivo_Slider_Lite();
readme.txt ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Nivo Slider Lite ===
2
+ Contributors: dev7studios
3
+ Tags: image, slider, nivo
4
+ Requires at least: 3.0
5
+ Tested up to: 4.3
6
+ Stable tag: 1.0.0
7
+ License: GPLv3
8
+
9
+ The official WordPress plugin for the Nivo Slider (Lite).
10
+
11
+ == Description ==
12
+
13
+ The Nivo Slider is the worlds most popular image slider plugin, downloaded over **3,000,000** times since it's inception. This
14
+ is the "Lite" version of the official [Nivo Slider WordPress plugin](https://dev7studios.com/products/nivo-slider-wordpress-plugin/?utm_source=wordpress.org&utm_medium=web&utm_content=description_link&utm_campaign=nivoslider_lite_plugin)
15
+ which comes with email support and more features.
16
+
17
+ **Get more awesome features by upgrading to the full plugin:**
18
+
19
+ * Create sliders from **Galleries, Categories and Sticky Posts**
20
+ * **Responsive** sliders
21
+ * Pre-built and custom **themes**
22
+ * All **16 transition effects**
23
+ * **Thumbnail** navigation
24
+ * Random start slide
25
+ * Nivo Slider **Widget**
26
+ * [Media Manager Plus](https://dev7studios.com/media-manager-plus/?utm_source=wordpress.org&utm_medium=web&utm_content=mmp_link&utm_campaign=nivoslider_lite_plugin) integration
27
+ * Access to our support [Help Desk](https://dev7studios.com/support/help-desk/?utm_source=wordpress.org&utm_medium=web&utm_content=support_link&utm_campaign=nivoslider_lite_plugin)
28
+
29
+ **[Click here to purchase the full plugin](https://dev7studios.com/products/nivo-slider-wordpress-plugin/?utm_source=wordpress.org&utm_medium=web&utm_content=purchase_link&utm_campaign=nivoslider_lite_plugin)**
30
+
31
+ == Installation ==
32
+
33
+ 1. Use WordPress' built-in installer
34
+ 2. Start adding your sliders in the "Nivo Slider" menu that appears
35
+
36
+ == Frequently Asked Questions ==
37
+
38
+ = I'd like access to more features and support. How can I get them? =
39
+
40
+ You can get access to more features and support by visiting the Dev7studios website and
41
+ [purchasing a license](https://dev7studios.com/products/nivo-slider-wordpress-plugin/?utm_source=wordpress.org&utm_medium=web&utm_content=faq_link&utm_campaign=nivoslider_lite_plugin).
42
+ Purchasing a license gets you access to the full version of the Nivo Slider WordPress plugin, automatic updates and support.
43
+
44
+ == Screenshots ==
45
+
46
+ 1. Slider list screen
47
+ 2. Edit slider screen
48
+ 3. Configuring images
49
+ 4. The final result
50
+
51
+ == Changelog ==
52
+
53
+ = 1.0.0 =
54
+ * Initial release