Theme Test Drive - Version 2.6

Version Description

Download this release

Release Info

Developer freediver
Plugin Icon 128x128 Theme Test Drive
Version 2.6
Comparing to
See all releases

Code changes from version 2.5.2 to 2.6

help.png → i/help.png RENAMED
File without changes
home.png → i/home.png RENAMED
File without changes
idea.png → i/idea.png RENAMED
File without changes
more.png → i/more.png RENAMED
File without changes
p1.png → i/p1.png RENAMED
File without changes
rate.png → i/rate.png RENAMED
File without changes
previewbubble.js ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Preview Bubble Javascript by Juan Xavier Larrea <xavier@websnapr.com>
3
+ http://www.websnapr.com
4
+
5
+ ---
6
+
7
+ Ingenier�a inversa por Javier P�rez <javier.perez.m@gmail.com>
8
+ http://javierperez.eu
9
+
10
+ ---
11
+
12
+ WordPress 2+ Plugin by Andufo <info@andufo.com>
13
+ http://andufo.com
14
+ */
15
+
16
+ if(typeof Array.prototype.push!="function") {
17
+ Array.prototype.push=ArrayPush;
18
+ function ArrayPush(_1) {
19
+ this[this.length] = _1;
20
+ }
21
+ }
22
+ function WSR_getElementsByClassName(node, tag_name, class_name) {
23
+ if (!node)
24
+ return;
25
+ var nodes =(tag_name=="*" && node.all) ? node.all : node.getElementsByTagName(tag_name);
26
+ var data = new Array();
27
+ class_name = class_name.replace(/\-/g,"\\-");
28
+ var find_class = new RegExp("(^|\\s)" + class_name + "(\\s|$)");
29
+ var n;
30
+ for(var i=0;i<nodes.length;i++){
31
+ n = nodes[i];
32
+ if(find_class.test(n.className)) {
33
+ data.push(n);
34
+ }
35
+ }
36
+ return(data);
37
+ }
38
+ function bindBubbles(e) {
39
+ var entries = WSR_getElementsByClassName(document.getElementById("theme_preview"), "div", "theme_links");
40
+ if (!entries) return;
41
+ for(var i=0;i<entries.length;i++) {
42
+ var nodes = entries[i].getElementsByTagName('a');
43
+ for(var j=0;j<nodes.length;j++) {
44
+ str = new String(nodes[j]);
45
+ var myDomain = "http://"+document.domain;
46
+ var flgExternal = str.search(myDomain);
47
+ var flgFtp = str.search("ftp://");
48
+ var flgMailto = str.search("mailto:");
49
+ if( flgFtp==-1 && flgMailto==-1) {
50
+ var flgNoFile = 1;
51
+ if(str.substr(str.lastIndexOf(".")+1).match(/zip|exe|rar|swf|mp3|wav|mid|avi|mov|mpg|mpeg|wmv|pdf|doc|ppt|xls|jpeg|jpg|gif|png/)) flgNoFile = 0;
52
+ if(flgNoFile) {
53
+ if(window.addEventListener) {
54
+ nodes[j].addEventListener("mouseover",attachBubble,false);
55
+ nodes[j].addEventListener("mouseout",detachBubble,false);
56
+ } else {
57
+ nodes[j].attachEvent("onmouseover",attachBubble);
58
+ nodes[j].attachEvent("onmouseout",detachBubble);
59
+ }
60
+ }
61
+ }
62
+ }
63
+ }
64
+ }
65
+ function attachBubble(_b, url_image) {
66
+ var _c;
67
+ if(_b["srcElement"]) {
68
+ _c=_b["srcElement"];
69
+ } else {
70
+ _c=_b["target"];
71
+ }
72
+ var _d=_c.href;
73
+ var _e=findPos(_c)[0]+5;
74
+ var _f=findPos(_c)[1]+17;
75
+ var _10=document.createElement("div");
76
+ _10.className="previewbubble";
77
+ _10.setAttribute("style","text-align: left;z-index: 99999;position: absolute;top: "+_f+"px ;left: "+_e+"px ;background: url("+ bubbleImagePath +");width: 461px;height: 330px;padding-top: 40px;padding-left: 40px;padding-bottom: 0;padding-right: 0;margin: 0;");
78
+ _10.style.width="441px";
79
+ _10.style.position="absolute";
80
+ _10.style.top=_f;
81
+ _10.style.zIndex=99999;
82
+ _10.style.left=_e;
83
+ _10.style.textAlign="left";
84
+ _10.style.height="320px";
85
+ _10.style.paddingTop="55px";
86
+ _10.style.paddingLeft="50px";
87
+ _10.style.paddingBottom="0";
88
+ _10.style.paddingRight="0";
89
+ _10.style.marginTop="0";
90
+ _10.style.marginLeft="0";
91
+ _10.style.marginBottom="0";
92
+ _10.style.marginRight="0";
93
+ _10.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + bubbleImagePath + "',sizingMethod='scale')";
94
+ var img=document.createElement("img");
95
+ img.setAttribute("style","margin: 0;padding: 0;border: 0");
96
+ img.style.paddingTop="0";
97
+ img.style.paddingLeft="0";
98
+ img.style.paddingBottom="0";
99
+ img.style.paddingRight="0";
100
+ img.style.marginTop="0";
101
+ img.style.marginLeft="0";
102
+ img.style.marginBottom="0";
103
+ img.style.marginRight="0";
104
+ img.style.borderTop="0";
105
+ img.style.borderLeft="0";
106
+ img.style.borderBottom="0";
107
+ img.style.borderRight="0";
108
+ img.setAttribute("src", url_image ? url_image :("http://images.websnapr.com/?size=m&key=42d1W6HhpB0B&url="+_d));
109
+ img.setAttribute("width",400);
110
+ img.setAttribute("height",300);
111
+ img.setAttribute("alt","Snapshot");
112
+ _10.appendChild(img);
113
+ document.getElementsByTagName("body")[0].appendChild(_10);
114
+ }
115
+ function detachBubble(_12) {
116
+ lbActions=WSR_getElementsByClassName(document,"div","previewbubble");
117
+ for(i=0;i<lbActions.length;i++) {
118
+ lbActions[i].parentNode.removeChild(lbActions[i]);
119
+ }
120
+ }
121
+ if(window.addEventListener){
122
+ addEventListener("load",bindBubbles,false);
123
+ } else {
124
+ attachEvent("onload",bindBubbles);
125
+ }
126
+ function findPos(obj) {
127
+ var _14=curtop=0;
128
+ if(obj.offsetParent) {
129
+ _14=obj.offsetLeft;
130
+ curtop=obj.offsetTop;
131
+ while(obj=obj.offsetParent) {
132
+ _14+=obj.offsetLeft;
133
+ curtop+=obj.offsetTop;
134
+ }
135
+ }
136
+ return [_14,curtop];
137
+ }
readme.txt CHANGED
@@ -19,6 +19,8 @@ Best part is you can even set the testing theme options (if it has them) in the
19
  You can also preview any theme by adding "?theme=xxx" to your blog URL. For example http://www.myblog.com/?theme=Default
20
 
21
  Changelog:
 
 
22
  v2.5.2: removed the thumbnail preview
23
 
24
  v2.5:
19
  You can also preview any theme by adding "?theme=xxx" to your blog URL. For example http://www.myblog.com/?theme=Default
20
 
21
  Changelog:
22
+ v2.6: Added user access level
23
+
24
  v2.5.2: removed the thumbnail preview
25
 
26
  v2.5:
screenshot-2.png ADDED
Binary file
themedrive.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Theme Test Drive
4
  Plugin URI: http://www.prelovac.com/vladimir/wordpress-plugins/theme-test-drive
5
  Description: Safely test drive any theme while visitors are using the default one. Includes instant theme preview via thumbnail.
6
  Author: Vladimir Prelovac
7
- Version: 2.5.2
8
  Author URI: http://www.prelovac.com/vladimir/
9
 
10
  To-Do:
@@ -15,7 +15,9 @@ To-Do:
15
 
16
  // // // PLUGIN CODE // // //
17
 
18
- $themedrive_localversion="2.5.2";
 
 
19
 
20
  function themedrive_handle_theme($package)
21
  {
@@ -182,11 +184,22 @@ function themedrive_get_theme()
182
  }
183
  }
184
 
 
 
 
 
 
 
 
 
 
 
 
185
  function themedrive_determine_theme()
186
  {
187
 
188
  if (!isset($_GET['theme'])) {
189
- if (! current_user_can('level_10') ) { // not admin
190
  return false;
191
  } else {
192
  $theme = themedrive_get_theme();
@@ -323,6 +336,7 @@ function themedrive_is_enabled()
323
  function themedrive_options_page()
324
  {
325
  global $themedrive_localversion;
 
326
 
327
  $status=themedrive_getinfo();
328
 
@@ -339,6 +353,9 @@ function themedrive_options_page()
339
 
340
  $themedrive = $_POST['td_themes'];
341
  update_option('td_themes', $themedrive);
 
 
 
342
  $msg_status = "Theme Test Drive Enabled for administrator with ".$themedrive.' theme.';
343
 
344
 
@@ -380,6 +397,12 @@ function themedrive_options_page()
380
 
381
  ');
382
  }
 
 
 
 
 
 
383
 
384
  // Configuration Page
385
  _e('
@@ -393,16 +416,16 @@ function themedrive_options_page()
393
  <fieldset id="about" class="dbx-box">
394
  <h3 class="dbx-handle">Information</h3>
395
  <div id="dbx-content">
396
- <img src="'. trailingslashit(get_option('siteurl')). 'wp-content/plugins/theme-test-drive/home.png"><a href="http://www.prelovac.com/vladimir/wordpress-plugins/theme-test-drive"> Theme Test Drive Home</a><br /><br />
397
- <img src="'. trailingslashit(get_option('siteurl')). 'wp-content/plugins/theme-test-drive/help.png"><a href="http://www.prelovac.com/vladimir/wordpress-plugins/theme-test-drive#comments"> Suggest a Feature</a><br /><br />
398
- <img src="'. trailingslashit(get_option('siteurl')). 'wp-content/plugins/theme-test-drive/rate.png"><a href="http://wordpress.org/extend/plugins/theme-test-drive/"> Rate this plugin</a><br /><br />
399
- <img src="'. trailingslashit(get_option('siteurl')). 'wp-content/plugins/theme-test-drive/more.png"><a href="http://www.prelovac.com/vladimir/wordpress-plugins"> My WordPress Plugins</a><br /><br />
400
  <br />
401
 
402
  <p align="center">
403
- <img src="'. trailingslashit(get_option('siteurl')). 'wp-content/plugins/theme-test-drive/p1.png"></p>
404
 
405
- <p> <img src="'. trailingslashit(get_option('siteurl')). 'wp-content/plugins/theme-test-drive/idea.png"><a href="http://www.prelovac.com/vladimir/services"> Need a WordPress Expert?</a></p>
406
  </div>
407
  </div>
408
  </div>
@@ -448,6 +471,7 @@ _e('
448
  <br>
449
  <input class="button" type="submit" name="theme_install" value="Install theme &raquo;" />
450
  <br><br><br>
 
451
  <div class="dbx-h-andle-wrapper">
452
  <h3 class="dbx-handle">Usage</h3>
453
  </div>
@@ -462,7 +486,8 @@ _e('
462
 
463
 
464
  _e('
465
-
 
466
  <p>
467
  <strong>Disabling:</strong> If you wish to stop using Theme Test Drive, press <em>Disable</em> button.
468
  Alternatively, disabling this plug-in should also do the trick.
4
  Plugin URI: http://www.prelovac.com/vladimir/wordpress-plugins/theme-test-drive
5
  Description: Safely test drive any theme while visitors are using the default one. Includes instant theme preview via thumbnail.
6
  Author: Vladimir Prelovac
7
+ Version: 2.6
8
  Author URI: http://www.prelovac.com/vladimir/
9
 
10
  To-Do:
15
 
16
  // // // PLUGIN CODE // // //
17
 
18
+ $themedrive_localversion="2.6";
19
+
20
+ $wp_themedrive_plugin_url = trailingslashit( get_bloginfo('wpurl') ).PLUGINDIR.'/'. dirname( plugin_basename(__FILE__) );
21
 
22
  function themedrive_handle_theme($package)
23
  {
184
  }
185
  }
186
 
187
+ function themedrive_get_level()
188
+ {
189
+ $getlevel=get_option('td_level');
190
+
191
+ if (!empty($getlevel)) {
192
+ return 'level_'.$getlevel;
193
+ } else {
194
+ return 'level_10';
195
+ }
196
+ }
197
+
198
  function themedrive_determine_theme()
199
  {
200
 
201
  if (!isset($_GET['theme'])) {
202
+ if (! current_user_can(themedrive_get_level()) ) { // not admin
203
  return false;
204
  } else {
205
  $theme = themedrive_get_theme();
336
  function themedrive_options_page()
337
  {
338
  global $themedrive_localversion;
339
+ global $wp_themedrive_plugin_url;
340
 
341
  $status=themedrive_getinfo();
342
 
353
 
354
  $themedrive = $_POST['td_themes'];
355
  update_option('td_themes', $themedrive);
356
+
357
+ $access_level = (int) $_POST['access_level'];
358
+ update_option('td_level', $access_level);
359
  $msg_status = "Theme Test Drive Enabled for administrator with ".$themedrive.' theme.';
360
 
361
 
397
 
398
  ');
399
  }
400
+
401
+ $access_level=get_option('td_level');
402
+ if (empty($access_level))
403
+ $access_level='10';
404
+
405
+ $imgpath=$wp_themedrive_plugin_url.'/i';
406
 
407
  // Configuration Page
408
  _e('
416
  <fieldset id="about" class="dbx-box">
417
  <h3 class="dbx-handle">Information</h3>
418
  <div id="dbx-content">
419
+ <img src="'. $imgpath.'/home.png"><a href="http://www.prelovac.com/vladimir/wordpress-plugins/theme-test-drive"> Theme Test Drive Home</a><br /><br />
420
+ <img src="'. $imgpath.'/help.png"><a href="http://www.prelovac.com/vladimir/forum"> Plugin Forums</a><br /><br />
421
+ <img src="'. $imgpath.'/rate.png"><a href="http://wordpress.org/extend/plugins/theme-test-drive/"> Rate this plugin</a><br /><br />
422
+ <img src="'. $imgpath.'/more.png"><a href="http://www.prelovac.com/vladimir/wordpress-plugins"> My WordPress Plugins</a><br /><br />
423
  <br />
424
 
425
  <p align="center">
426
+ <img src="'. $imgpath.'/p1.png"></p>
427
 
428
+ <p> <img src="'. $imgpath.'/idea.png"><a href="http://www.prelovac.com/vladimir/services"> Need a WordPress Expert?</a></p>
429
  </div>
430
  </div>
431
  </div>
471
  <br>
472
  <input class="button" type="submit" name="theme_install" value="Install theme &raquo;" />
473
  <br><br><br>
474
+
475
  <div class="dbx-h-andle-wrapper">
476
  <h3 class="dbx-handle">Usage</h3>
477
  </div>
486
 
487
 
488
  _e('
489
+ <p>You can specify the level of users to have access to the selected theme preview. By default it is set to 10 (admin only). Level 7 are editors, level 4 are authors and level 1 are contributors. The access level is ignored for accessing the site with ?theme=xxx paramaeter. </p><br />
490
+ <input style="border:1px solid #D1D1D1;width:100px;" name="access_level" id="access_level" value="'.$access_level.'" /> Access level<br /><br />
491
  <p>
492
  <strong>Disabling:</strong> If you wish to stop using Theme Test Drive, press <em>Disable</em> button.
493
  Alternatively, disabling this plug-in should also do the trick.