My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<?php
/*
Plugin Name: WP FancyBox
Plugin URI: http://code.google.com/p/wp-fancybox/
Description: Overlay images on pages using FancyBox. <em>FancyBox wrote by <a href="http://fancy.klade.lv/">Janis Skarnelis</a></em>.
Author: Dmitry Chestnykh
Version: 1.4
Author URI: http://www.codingrobots.com/
*/
/*

License (MIT-style)

FancyBox - Copyright (C) 2008 Janis Skarnelis
WP FancyBox - Copyright (C) 2008 Dmitry Chestnykh

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/


function fancybox_config_page() {
?>
<div class="wrap">
<h2>WP FancyBox</h2>

<form method="post" action="options.php">
<?php wp_nonce_field('update-options'); ?>

<h3><?php _e('Appearance') ?></h3>

<table class="form-table">
<tr valign="top">
<th scope="row"><?php _e('Hide on content click') ?></th>
<td><input type="checkbox" name="fancybox_hideOnContentClick" <?php if(get_option('fancybox_hideOnContentClick')) echo "checked"; ?> value="1" /></td>
</tr>

<tr valign="top">
<th scope="row"><?php _e('Show overlay') ?></th>
<td><input type="checkbox" name="fancybox_overlayShow" <?php if(get_option('fancybox_overlayShow')) echo "checked"; ?> value="1" /></td>
</tr>

<tr valign="top">
<th scope="row"><?php _e('Overlay opacity') ?></th>
<td><input type="text" name="fancybox_overlayOpacity" value="<?php echo get_option('fancybox_overlayOpacity'); ?>" />
&nbsp; <em><?php _e('From 0 to 1') ?></em></td>
</tr>


<tr valign="top">
<th scope="row"><?php _e('Zoom in speed') ?></th>
<td><input type="text" name="fancybox_zoomSpeedIn" value="<?php echo get_option('fancybox_zoomSpeedIn'); ?>" /> &nbsp; <em><?php _e('milliseconds') ?></td>
</tr>

<tr valign="top">
<th scope="row"><?php _e('Zoom out speed') ?></th>
<td><input type="text" name="fancybox_zoomSpeedOut" value="<?php echo get_option('fancybox_zoomSpeedOut'); ?>" /> &nbsp; <em><?php _e('milliseconds') ?></td>
</tr>
</table>

<h3><?php _e('Advanced') ?></h3>

<table class="form-table">
<tr valign="top">
<th scope="row"><?php _e('jQuery expression') ?></th>
<td><input type="text" name="fancybox_expression" value="<?php echo htmlspecialchars(get_option('fancybox_expression')); ?>" /> &nbsp; <em><?php _e('Default is ') ?><code style="color: navy">jQuery("img.size-thumbnail").parent()<code></td>
</tr>
</table>


<input type="hidden" name="action" value="update" />
<input type="hidden" name="page_options" value="fancybox_hideOnContentClick,fancybox_overlayShow,fancybox_overlayOpacity,fancybox_zoomSpeedIn,fancybox_zoomSpeedOut,fancybox_expression,fancybox_pngfix" />

<p class="submit">
<input type="submit" name="Submit" value="<?php _e('Save Changes') ?>" />
</p>

</form>
</div>
<?php
}


function fancybox_add_menu_item()
{
add_options_page('WP FancyBox', 'FancyBox', 'manage_options', 'fancybox', 'fancybox_config_page');
}


function fancybox_write_headers()
{
/* Stylesheet */
echo '<link rel="stylesheet" href="'.get_option('home').'/wp-content/plugins/wp-fancybox/fancy.min.css?ver=1.4" type="text/css">';
echo "\n";

/* JS */
$options = array();
if (get_option('fancybox_hideOnContentClick'))
$options[] = '"hideOnContentClick":true';
if (get_option('fancybox_overlayShow'))
$options[] = '"overlayShow":true';
if (get_option('fancybox_overlayOpacity') != '')
$options[] = '"overlayOpacity":'.get_option('fancybox_overlayOpacity');
if (get_option('fancybox_zoomSpeedIn') != '')
$options[] = '"zoomSpeedIn":'.get_option('fancybox_zoomSpeedIn');
if (get_option('fancybox_zoomSpeedOut') != '')
$options[] = '"zoomSpeedOut":'.get_option('fancybox_zoomSpeedOut');

$expr = get_option('fancybox_expression');
if (empty($expr))
$expr = 'jQuery("img.size-thumbnail").parent()'; // set default

echo '<script type="text/javascript">jQuery(document).ready(function(){'.$expr.
'.fancybox({'.implode(',', $options).'});});</script>';
echo "\n";
}

if (!is_admin()) {
wp_enqueue_script('fancybox', '/wp-content/plugins/wp-fancybox/jquery.fancybox.min.js', array('jquery'), '1.4');

add_action('wp_head', 'fancybox_write_headers');
}
add_action('admin_menu', 'fancybox_add_menu_item');

?>

Change log

r25 by dchest on Aug 19, 2010   Diff
Fix issue with  Issue 7  fix.
Go to: 
Sign in to write a code review

Older revisions

r24 by dchest on Aug 19, 2010   Diff
Fix  Issue 6  and  Issue 7 .
r20 by dchest on Feb 10, 2009   Diff
Back to using hard-coded string for
version numbers
r19 by dchest on Feb 10, 2009   Diff
Update script and css link version
numbers in wp-fancybox.php
All revisions of this file

File info

Size: 5100 bytes, 140 lines
Powered by Google Project Hosting