Dynamic "To Top" Plugin - Version 3.2

Version Description

  • Fixes the speed slider/attribute.
  • Code improvements.
Download this release

Release Info

Developer sksmatt
Plugin Icon wp plugin Dynamic "To Top" Plugin
Version 3.2
Comparing to
See all releases

Code changes from version 3.1.9.1 to 3.2

dynamic-to-top.php CHANGED
@@ -1,13 +1,13 @@
1
  <?php
2
  /*
3
  Plugin Name: Dynamic To Top
4
- Version: 3.1.9.1
5
  Plugin URI: http://www.mattvarone.com/featured-content/dynamic-to-top/
6
  Description: Adds an automatic and dynamic "To Top" button to scroll long pages back to the top.
7
  Author: Matt Varone
8
  Author URI: http://www.mattvarone.com
9
 
10
- Copyright 2011 ( email: contact@mattvarone.com )
11
 
12
  This program is free software; you can redistribute it and/or modify
13
  it under the terms of the GNU General Public License as published by
@@ -24,65 +24,65 @@ along with this program; if not, write to the Free Software
24
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25
  */
26
 
27
- /**
28
- * Dynamic To Top Initialize
29
- *
30
- * @package Dynamic To Top
31
- * @author Matt Varone
32
- */
33
-
34
  /*
35
  |--------------------------------------------------------------------------
36
  | DYNAMIC TO TOP CONSTANTS
37
  |--------------------------------------------------------------------------
38
  */
39
 
40
- define( 'MV_DYNAMIC_TO_TOP_BASENAME', plugin_basename( __FILE__ ) );
41
- define( 'MV_DYNAMIC_TO_TOP_URL', plugins_url( '', __FILE__ ) );
42
- define( 'MV_DYNAMIC_TO_TOP_VERSION', '3.1.9.1' );
43
 
44
  /*
45
  |--------------------------------------------------------------------------
46
- | DYNAMIC TO TOP INTERNALIZATION
47
  |--------------------------------------------------------------------------
48
  */
49
 
50
- load_plugin_textdomain( 'dynamic-to-top', false, '/' . basename( dirname( __FILE__ ) ) . '/lan' );
51
-
52
- /*
53
- |--------------------------------------------------------------------------
54
- | DYNAMIC TO TOP INCLUDES
55
- |--------------------------------------------------------------------------
 
 
 
56
  */
57
 
58
- if ( is_admin() )
59
- require_once( plugin_dir_path( __FILE__ ) . 'inc/dynamic-to-top-options.php' );
60
- else
61
- require_once( plugin_dir_path( __FILE__ ) . 'inc/dynamic-to-top-class.php' );
62
-
 
 
 
 
 
63
  /*
64
  |--------------------------------------------------------------------------
65
- | DYNAMIC TO TOP ON ACTIVATION
66
  |--------------------------------------------------------------------------
67
  */
68
-
69
  /**
70
- * Dynamic To Top Activation
71
- *
72
- * @package Dynamic To Top
73
- * @since 3.1.5
 
74
  */
75
- if ( ! function_exists( 'mv_dynamic_to_top_activation' ) )
76
- {
77
- function mv_dynamic_to_top_activation()
78
- {
79
- // check compatibility
80
- if ( version_compare( get_bloginfo( 'version' ), '3.0' ) >= 0 )
81
- deactivate_plugins( basename( __FILE__ ) );
82
-
83
- // refresh cache
84
- delete_transient( 'dynamic_to_top_transient_css' );
85
- }
86
-
87
- register_activation_hook( __FILE__, 'mv_dynamic_to_top_activation' );
88
- }
1
  <?php
2
  /*
3
  Plugin Name: Dynamic To Top
4
+ Version: 3.2
5
  Plugin URI: http://www.mattvarone.com/featured-content/dynamic-to-top/
6
  Description: Adds an automatic and dynamic "To Top" button to scroll long pages back to the top.
7
  Author: Matt Varone
8
  Author URI: http://www.mattvarone.com
9
 
10
+ Copyright 2011 ( email: contact@mattvarone.com )
11
 
12
  This program is free software; you can redistribute it and/or modify
13
  it under the terms of the GNU General Public License as published by
24
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25
  */
26
 
 
 
 
 
 
 
 
27
  /*
28
  |--------------------------------------------------------------------------
29
  | DYNAMIC TO TOP CONSTANTS
30
  |--------------------------------------------------------------------------
31
  */
32
 
33
+ define( 'MV_DYNAMIC_TO_TOP_VERSION', '3.2' );
 
 
34
 
35
  /*
36
  |--------------------------------------------------------------------------
37
+ | DYNAMIC INITIALIZATION
38
  |--------------------------------------------------------------------------
39
  */
40
 
41
+ /**
42
+ * Plugins Loaded
43
+ *
44
+ * Launches on plugins_loaded. Loads internationalization,
45
+ * requires the necessary files.
46
+ *
47
+ * @package Dynamic To Top
48
+ * @since 3.2
49
+ * @return void
50
  */
51
 
52
+ if ( ! function_exists( 'mv_dynamic_to_top_plugins_loaded' ) ) {
53
+ function mv_dynamic_to_top_plugins_loaded() {
54
+ if ( is_admin() )
55
+ require_once( plugin_dir_path( __FILE__ ) . 'inc/dynamic-to-top-options.php' );
56
+ else
57
+ require_once( plugin_dir_path( __FILE__ ) . 'inc/dynamic-to-top-class.php' );
58
+ }
59
+ }
60
+ add_action( 'plugins_loaded', 'mv_dynamic_to_top_plugins_loaded' );
61
+
62
  /*
63
  |--------------------------------------------------------------------------
64
+ | DYNAMIC TO TOP ACTIVATION
65
  |--------------------------------------------------------------------------
66
  */
67
+
68
  /**
69
+ * Dynamic To Top Activation
70
+ *
71
+ * @package Dynamic To Top
72
+ * @since 3.1.5
73
+ * @return void
74
  */
75
+
76
+ if ( ! function_exists( 'mv_dynamic_to_top_activation' ) ) {
77
+ function mv_dynamic_to_top_activation() {
78
+
79
+ // check compatibility
80
+ if ( version_compare( get_bloginfo( 'version' ), '3.0' ) >= 0 )
81
+ deactivate_plugins( basename( __FILE__ ) );
82
+
83
+ // refresh cache
84
+ delete_transient( 'dynamic_to_top_transient_css' );
85
+
86
+ }
87
+ }
88
+ register_activation_hook( __FILE__, 'mv_dynamic_to_top_activation' );
inc/dynamic-to-top-class.php CHANGED
@@ -1,514 +1,525 @@
1
  <?php
2
  /**
3
- * Dynamic To Top Class
4
- *
5
- * @package Dynamic To Top
6
- * @author Matt Varone
 
7
  */
8
 
9
  global $OBJ_dynamic_to_top;
10
 
11
- if ( ! class_exists( 'MV_Dynamic_To_Top' ) )
12
- {
13
-
14
- class MV_Dynamic_To_Top
15
- {
16
- public $options;
17
- private $defaults = array(
18
- 'speed' => 1000,
19
- 'distance' => 200,
20
- 'easing' => 'in-out',
21
- 'position' => 'bottom-right',
22
- 'padding_top_bottom' => '21',
23
- 'padding_left_right' => '20',
24
- 'font_size' => '1',
25
- 'text_color' => '#fff',
26
- 'bold' => '0',
27
- 'text_shadow' => '0',
28
- 'shadow_color' => '#111',
29
- 'background_color' => '#272727',
30
- 'border_color' => '#000',
31
- 'border_width' => '1',
32
- 'radius' => '9',
33
- 'shadow' => '1',
34
- 'inset' => '1',
35
- 'text' => '0',
36
- 'margin'=> 20,
37
- 'text_version' => '0',
38
- );
 
39
 
40
- /**
41
- * Dynamic To Top
42
- *
43
- * Construct class. calls for options and assets.
44
- *
45
- * @package Dynamic To Top
46
- * @subpackage Main Class
47
- * @since 3.0
48
- *
49
- */
50
-
51
- function __construct() {
52
- add_action( 'init', array( &$this, 'init' ) );
53
- }
54
-
55
- /**
56
- * Dynamic To Top
57
- *
58
- * Init function calls for options and assets.
59
- *
60
- * @package Dynamic To Top
61
- * @subpackage Main Class
62
- * @since 4.0
63
- *
64
- */
65
-
66
- function init() {
67
- // Get options.
68
- $this->get_options();
69
-
70
- // Enqueue CSS and JS.
71
- $this->enqueue_assets();
72
- }
73
- /**
74
- * Get Options
75
- *
76
- * Sets and parses the db options with the default values.
77
- *
78
- * @package Dynamic To Top
79
- * @subpackage Main Class
80
- * @since 3.0
81
- */
82
-
83
- function get_options() {
84
- $this->options = wp_parse_args( get_option( 'dynamic_to_top' ), $this->defaults );
85
- }
86
-
87
- /**
88
- * Enqueue Assets
89
- *
90
- * Adds JS and CSS assets actions.
91
- * Checks if its needed to prevent on mobile browsers.
92
- *
93
- * @package Dynamic To Top
94
- * @subpackage Main Class
95
- * @since 3.0
96
- */
97
-
98
- function enqueue_assets() {
99
- if ( $this->is_checked( 'prevent_on_mobile' ) ) {
100
- if ( $this->is_mobile() )
101
- return;
102
- }
103
-
104
- add_action( 'wp_enqueue_scripts', array( &$this,'enqueue_style' ) );
105
- add_action( 'wp_enqueue_scripts', array( &$this,'enqueue_script' ) );
106
- }
107
-
108
- /**
109
- * Enqueue Style
110
- *
111
- * @package Dynamic To Top
112
- * @subpackage Main Class
113
- * @since 3.0
114
- */
115
-
116
- function enqueue_style() {
117
- wp_enqueue_style( 'dynamic-to-top', MV_DYNAMIC_TO_TOP_URL . '/css/dynamic-to-top-css.php', false, MV_DYNAMIC_TO_TOP_VERSION, 'all' );
118
- }
119
-
120
- /**
121
- * Enqueue Script
122
- *
123
- * @package Dynamic To Top
124
- * @subpackage Main Class
125
- * @since 3.0
126
- */
127
-
128
- function enqueue_script() {
 
 
 
 
 
 
 
129
 
130
- wp_enqueue_script( 'jquery-easing', MV_DYNAMIC_TO_TOP_URL . '/js/libs/jquery.easing.js', array( 'jquery' ), '1.3', true );
131
 
132
- $env = ( WP_DEBUG ) ? 'dev' : 'min';
133
- wp_enqueue_script( 'dynamic-to-top', MV_DYNAMIC_TO_TOP_URL . '/js/dynamic.to.top.' . $env . '.js', array( 'jquery' ), MV_DYNAMIC_TO_TOP_VERSION, true );
134
-
135
- $params = array(
136
- 'text' => $this->options['text'],
137
- 'version' => $this->options['text_version'],
138
- 'min' => $this->options['distance'],
139
- 'speed' => $this->options['speed'],
140
- 'easing' => $this->get_easing_type(),
141
- 'margin' => $this->options['margin'],
142
- );
143
-
144
- $params = apply_filters( 'mv_dynamic_to_top_js_params', $params );
145
-
146
- wp_localize_script( 'dynamic-to-top', 'mv_dynamic_to_top', $params );
147
- }
148
-
149
- /**
150
- * Get CSS
151
- *
152
- * Returns CSS declarations.
153
- * Checks for transient CSS or generates and sets a new one.
154
- *
155
- * @package Dynamic To Top
156
- * @subpackage Main Class
157
- * @since 3.0
158
- * @return string $css CSS Declarations.
159
- */
160
-
161
- function get_css( $css = "" ) {
162
- $css = get_transient( 'dynamic_to_top_transient_css' );
163
-
164
- if ( ! $css ) {
165
- $css = $this->minify( $this->generate_custom_css() );
166
- set_transient( 'dynamic_to_top_transient_css', $css, 60*60*24*90 );
167
- }
168
-
169
- $css = apply_filters( 'mv_dynamic_to_top_css', $css );
170
-
171
- return $css;
172
- }
173
-
174
-
175
- /**
176
- * Generate Custom CSS
177
- *
178
- * Returns Dynamic To Top custom CSS styles.
179
- *
180
- * @package Dynamic To Top
181
- * @subpackage Main Class
182
- * @since 3.0
183
- * @return string $css CSS declarations.
184
- */
185
-
186
- function generate_custom_css( $css = "" ) {
187
-
188
- $css .= "/* Dynamic To Top Plugin ver. ".MV_DYNAMIC_TO_TOP_VERSION." - http://www.mattvarone.com */\n\n";
189
-
190
- $css .= "body { position:relative; }
191
-
192
- #dynamic-to-top {
193
- display:none;
194
- overflow:hidden;
195
- width:auto;
196
- z-index:90;
197
- position:fixed;
198
- ".$this->get_position()."
199
-
200
- font-family: sans-serif;
201
- font-size:".$this->options['font_size']."em;
202
- color:".$this->options['text_color'].";
203
- text-decoration:none;\n";
204
 
205
- if ( $this->is_checked( 'text_shadow' ) )
206
- $css .= "text-shadow:0 1px 0 ".$this->options['shadow_color'].";\n";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
207
 
208
- if ( $this->is_checked( 'bold' ) )
209
- $css .="font-weight:bold;\n";
210
-
211
- $css.= "padding:".$this->options['padding_top_bottom']."px ".$this->options['padding_left_right']."px;
212
- border:".$this->options['border_width']."px solid ".$this->options['border_color'].";
213
- background:".$this->options['background_color'].";
214
-
215
- -webkit-background-origin:border;
216
- -moz-background-origin:border;
217
- -icab-background-origin:border;
218
- -khtml-background-origin:border;
219
- -o-background-origin:border;
220
- background-origin:border;
221
-
222
- -webkit-background-clip:padding-box;
223
- -moz-background-clip:padding-box;
224
- -icab-background-clip:padding-box;
225
- -khtml-background-clip:padding-box;
226
- -o-background-clip:padding-box;
227
- background-clip:padding-box;\n";
228
-
229
- $box_shadow = "";
230
 
231
- if ( $this->is_checked( 'shadow' ) )
232
- $box_shadow .= "0 1px 3px rgba( 0,0,0,0.4 )";
 
 
233
 
234
- if ( $this->is_checked( 'inset' ) ) {
235
- if ( $box_shadow != "" ) $box_shadow = $box_shadow.",";
236
- $box_shadow .= "inset 0 0 0 1px rgba( 0,0,0,0.2 ), inset 0 1px 0 rgba( 255,255,255,.4 ),inset 0 10px 10px rgba( 255,255,255,.1 )";
237
- }
 
 
 
 
238
 
239
- if ( strlen( $box_shadow ) > 1 )
240
- $css .= "-webkit-box-shadow:".$box_shadow.";
241
- -ms-box-shadow:".$box_shadow.";
242
- -moz-box-shadow:".$box_shadow.";
243
- -o-box-shadow:".$box_shadow.";
244
- -khtml-box-shadow:".$box_shadow.";
245
- -icab-box-shadow:".$box_shadow.";
246
- box-shadow:".$box_shadow.";\n\n";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
247
 
248
- $css .= "-webkit-border-radius: ".$this->options['radius']."px;
249
- -moz-border-radius: ".$this->options['radius']."px;
250
- -icab-border-radius: ".$this->options['radius']."px;
251
- -khtml-border-radius: ".$this->options['radius']."px;
252
- border-radius: ".$this->options['radius']."px;\n}\n\n";
253
-
254
- $css .= "#dynamic-to-top:hover {
255
- background: ".$this->get_ligther_hex( $this->options['background_color'] ).";
256
- background: ".$this->options['background_color']." -webkit-gradient( linear, 0% 0%, 0% 100%, from( rgba( 255,255,255,.2 ) ),to( rgba( 0,0,0,0 ) ) );
257
- background: ".$this->options['background_color']." -webkit-linear-gradient( top, rgba( 255,255,255,.2 ), rgba( 0,0,0,0 ) );
258
- background: ".$this->options['background_color']." -khtml-linear-gradient( top, rgba( 255,255,255,.2 ), rgba( 0,0,0,0 ) );
259
- background: ".$this->options['background_color']." -moz-linear-gradient( top, rgba( 255,255,255,.2 ), rgba( 0,0,0,0 ) );
260
- background: ".$this->options['background_color']." -o-linear-gradient( top, rgba( 255,255,255,.2 ), rgba( 0,0,0,0 ) );
261
- background: ".$this->options['background_color']." -ms-linear-gradient( top, rgba( 255,255,255,.2 ), rgba( 0,0,0,0 ) );
262
- background: ".$this->options['background_color']." -icab-linear-gradient( top, rgba( 255,255,255,.2 ), rgba( 0,0,0,0 ) );
263
- background: ".$this->options['background_color']." linear-gradient( top, rgba( 255,255,255,.2 ), rgba( 0,0,0,0 ) );
264
- cursor:pointer;
265
- }
266
-
267
- #dynamic-to-top:active {
268
- background: ".$this->options['background_color'].";
269
- background: ".$this->options['background_color']." -webkit-gradient( linear, 0% 0%, 0% 100%, from( rgba( 0,0,0,.3 ) ), to( rgba( 0,0,0,0 ) ) );
270
- background: ".$this->options['background_color']." -webkit-linear-gradient( top, rgba( 0,0,0,.1 ), rgba( 0,0,0,0 ) );
271
- background: ".$this->options['background_color']." -moz-linear-gradient( top, rgba( 0,0,0,.1 ), rgba( 0,0,0,0 ) );
272
- background: ".$this->options['background_color']." -khtml-linear-gradient( top, rgba( 0,0,0,.1 ), rgba( 0,0,0,0 ) );
273
- background: ".$this->options['background_color']." -o-linear-gradient( top, rgba( 0,0,0,.1 ), rgba( 0,0,0,0 ) );
274
- background: ".$this->options['background_color']." -ms-linear-gradient( top, rgba( 0,0,0,.1 ), rgba( 0,0,0,0 ) );
275
- background: ".$this->options['background_color']." -icab-linear-gradient( top, rgba( 0,0,0,.1 ), rgba( 0,0,0,0 ) );
276
- background: ".$this->options['background_color']." linear-gradient( top, rgba( 0,0,0,.1 ), rgba( 0,0,0,0 ) );
277
- }
278
 
279
- #dynamic-to-top,#dynamic-to-top:active,
280
- #dynamic-to-top:focus,#dynamic-to-top:hover
281
- {
282
- outline:none
283
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
284
 
285
- #dynamic-to-top span {
286
- display:block;
287
- overflow:hidden;
288
- width:14px;
289
- height:12px;
290
- background:url( " . MV_DYNAMIC_TO_TOP_URL . "/css/images/up.png ) no-repeat center center;
291
- }";
292
-
293
- return $css;
294
- }
295
-
296
- /**
297
- * Get Easing Type
298
- *
299
- * Returns the easing type function name.
300
- * Used on the JS script. Old values support for backwards compatibility.
301
- *
302
- * @package Dynamic To Top
303
- * @subpackage Main Class
304
- * @since 3.0
305
- * @return string $easing Name of easing function.
306
- */
307
-
308
- function get_easing_type( $easing = "linear" ) {
309
- switch ( $this->options['easing'] )
310
- {
311
- case ( $this->options['easing'] == 'Bounce' || $this->options['easing'] == 'bounce' ):
312
- $easing = "easeOutBounce";
313
- break;
314
-
315
- case ( $this->options['easing'] == 'Elastic' || $this->options['easing'] == 'elastic' ):
316
- $easing = "easeInElastic";
317
- break;
318
-
319
- case ( $this->options['easing'] == 'In' || $this->options['easing'] == 'in' ):
320
- $easing = "easeInExpo";
321
- break;
322
-
323
- case ( $this->options['easing'] == 'In Out' || $this->options['easing'] == 'in-out' ):
324
- $easing = "easeInOutExpo";
325
- break;
326
-
327
- case ( $this->options['easing'] == 'Out' || $this->options['easing'] == 'out' ):
328
- $easing = "easeOutExpo";
329
- break;
330
- }
331
- return $easing;
332
- }
333
-
334
- /**
335
- * Get Position
336
- *
337
- * Returns CSS properties for the selected position.
338
- * Used on the CSS style. Old values support for backwards compatibility.
339
- *
340
- * @package Dynamic To Top
341
- * @subpackage Main Class
342
- * @since 3.0
343
- * @return string $position Properties of the position selected.
344
- */
345
-
346
- function get_position( $position = "" ) {
347
- switch ( $this->options['position'] )
348
- {
349
- case ( $this->options['position'] == 'Bottom Right' || $this->options['position'] == 'bottom-right' ):
350
- $position = "bottom:".$this->options['margin']."px;right:".$this->options['margin']."px;top:auto;left:auto;";
351
- break;
352
-
353
- case ( $this->options['position'] == 'Bottom Left' || $this->options['position'] == 'bottom-left' ):
354
- $position = "bottom:".$this->options['margin']."px;left:".$this->options['margin']."px;top:auto;right:auto;";
355
- break;
356
-
357
- case ( $this->options['position'] == 'Top Right' || $this->options['position'] == 'top-right' ):
358
- $position = "top:".$this->options['margin']."px;right:".$this->options['margin']."px;bottom:auto;left:auto;";
359
- break;
360
-
361
- case ( $this->options['position'] == 'Top Left' || $this->options['position'] == 'top-left' ):
362
- $position = "top:".$this->options['margin']."px;left:".$this->options['margin']."px;bottom:auto;right:auto;";
363
- break;
364
- }
365
 
366
- return $position;
367
- }
368
-
369
- /**
370
- * Is Checked
371
- *
372
- * Conditional method to validate checked options.
373
- *
374
- * @package Dynamic To Top
375
- * @subpackage Main Class
376
- * @since 3.0
377
- * @param string $option Option name.
378
- * @return boolean
379
- */
380
-
381
- function is_checked( $option = "" ) {
382
- if ( $option == "" )
383
- return false;
384
-
385
- if ( ! isset( $this->options[$option] ) )
386
- return false;
387
-
388
- // Old values support for backwards compatibility.
389
- if ( $this->options[$option] == '1' || $this->options[$option] == 'yes' || $this->options[$option] == 'Yes' )
390
- return true;
391
- else
392
- return false;
393
- }
394
-
395
- /**
396
- * Is Mobile
397
- *
398
- * Checks if the browser is mobile.
399
- *
400
- * @package Dynamic To Top
401
- * @subpackage Main Class
402
- * @since 3.0
403
- * @author Reverb Studios
404
- * @link http://www.reverbstudios.ie/
405
- * @return boolean.
406
- */
407
-
408
- function is_mobile() {
409
 
410
- if( isset( $_SERVER["HTTP_X_WAP_PROFILE"] ) )
411
- return true;
412
 
413
- if( preg_match( "/wap\.|\.wap/i",$_SERVER["HTTP_ACCEPT"] ) )
414
- return true;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
415
 
416
- if( isset( $_SERVER["HTTP_USER_AGENT"] ) ) {
417
- $user_agents = array(
418
- "midp", "j2me", "iphone","avantg", "docomo", "novarra", "palmos",
419
- "palmsource", "240x320", "opwv", "chtml", "pda", "windows\ ce", "mmp\/",
420
- "blackberry", "mib\/", "symbian", "wireless", "nokia", "hand", "mobi",
421
- "phone", "cdm", "up\.b", "audio", "SIE\-", "SEC\-", "samsung", "HTC",
422
- "mot\-", "mitsu", "sagem", "sony", "alcatel", "lg", "erics", "vx", "NEC",
423
- "philips", "mmm", "xx", "panasonic", "sharp", "wap", "sch", "rover",
424
- "pocket", "benq", "java", "pt", "pg", "vox", "amoi", "bird", "compal",
425
- "kg", "voda", "sany", "kdd", "dbt", "sendo", "sgh", "gradi", "jb", "\d\d\di", "moto" );
426
-
427
- foreach( $user_agents as $user_string ) {
428
- if( preg_match( "/" . $user_string . "/i", $_SERVER["HTTP_USER_AGENT"] ) )
429
- return true;
430
- }
431
- }
432
-
433
- do_action( 'mv_dynamic_to_top_check_mobile' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
434
 
435
- return false;
436
- }
437
-
438
- /**
439
- * Get Lighter Hex
440
- *
441
- * Returns a lighter version of an Hex color.
442
- *
443
- * @package Dynamic To Top
444
- * @subpackage Main Class
445
- * @since 3.0
446
- * @author Justin French
447
- * @link http://justinfrench.com/
448
- * @return boolean.
449
- */
450
-
451
- function get_ligther_hex( $hex,$factor = 30 ) {
452
-
453
- $new_hex = '#';
454
-
455
- if ( strlen( $hex ) == 7 ) {
456
- $base['R'] = hexdec( $hex{0}.$hex{1} );
457
- $base['G'] = hexdec( $hex{2}.$hex{3} );
458
- $base['B'] = hexdec( $hex{4}.$hex{5} );
459
- } else {
460
- $base['R'] = hexdec( $hex{0}.$hex{0} );
461
- $base['G'] = hexdec( $hex{1}.$hex{1} );
462
- $base['B'] = hexdec( $hex{2}.$hex{2} );
463
- }
464
- foreach ( $base as $k=>$v ) {
465
- $amount = 255 - $v;
466
- $amount = $amount / 100;
467
- $amount = round( $amount * $factor );
468
- $new_decimal = $v + $amount;
469
 
470
- $new_hex_component = dechex( $new_decimal );
471
-
472
- if( strlen( $new_hex_component ) < 2 )
473
- $new_hex_component = "0" . $new_hex_component;
474
-
475
- $new_hex .= $new_hex_component;
476
- }
477
-
478
- $new_hex = apply_filters( 'mv_dynamic_to_top_new_hex', $new_hex );
479
-
480
- return $new_hex;
481
- }
482
 
483
- /**
484
- *
485
- * Simple Minify CSS
486
- *
487
- * Minifies CSS.
488
- *
489
- * @package Dynamic To Top
490
- * @subpackage Main Class
491
- * @since 3.0
492
- * @author Karthik Viswanathan
493
- * @link http://www.lateralcode.com/css-minifier/
494
- * @return string.
495
- */
496
-
497
- function minify( $css ) {
498
- $css = preg_replace( '#\s+#', ' ', $css );
499
- $css = preg_replace( '#/\*.*?\*/#s', '', $css );
500
- $css = str_replace( array( '; ', ': ', ' {', '{ ', ', ', '} ', ';}' ), array( ';', ':', '{', '{', ',', '}', '}' ), $css );
501
- return trim( $css );
502
- }
503
-
504
-
505
- }
506
-
507
- /*
508
- |--------------------------------------------------------------------------
509
- | DYNAMIC TO TOP CLASS INITIALIZE
510
- |--------------------------------------------------------------------------
511
- */
512
 
513
- $OBJ_dynamic_to_top = new MV_Dynamic_To_Top();
514
  }
1
  <?php
2
  /**
3
+ * Dynamic To Top Class
4
+ *
5
+ * @package Dynamic To Top
6
+ * @subpackage Main Class
7
+ * @author Matt Varone
8
  */
9
 
10
  global $OBJ_dynamic_to_top;
11
 
12
+ if ( ! class_exists( 'MV_Dynamic_To_Top' ) ) {
13
+ class MV_Dynamic_To_Top
14
+ {
15
+ /* Holds the current options */
16
+ public $options;
17
+
18
+ /* Holds the default options */
19
+ private $defaults = array(
20
+ 'speed' => 1000,
21
+ 'distance' => 200,
22
+ 'easing' => 'in-out',
23
+ 'position' => 'bottom-right',
24
+ 'padding_top_bottom' => '21',
25
+ 'padding_left_right' => '20',
26
+ 'font_size' => '1',
27
+ 'text_color' => '#fff',
28
+ 'bold' => '0',
29
+ 'text_shadow' => '0',
30
+ 'shadow_color' => '#111',
31
+ 'background_color' => '#272727',
32
+ 'border_color' => '#000',
33
+ 'border_width' => '1',
34
+ 'radius' => '9',
35
+ 'shadow' => '1',
36
+ 'inset' => '1',
37
+ 'text' => '0',
38
+ 'margin'=> 20,
39
+ 'text_version' => '0',
40
+ );
41
 
42
+
43
+ /**
44
+ * Dynamic To Top
45
+ *
46
+ * Construct class. calls for options and assets.
47
+ *
48
+ * @package Dynamic To Top
49
+ * @subpackage Main Class
50
+ * @since 3.0
51
+ * @return void
52
+ */
53
+
54
+ function __construct() {
55
+ add_action( 'init', array( &$this, 'init' ) );
56
+ }
57
+
58
+
59
+ /**
60
+ * Dynamic To Top
61
+ *
62
+ * Init function calls for options and assets.
63
+ *
64
+ * @package Dynamic To Top
65
+ * @subpackage Main Class
66
+ * @since 4.0
67
+ * @return void
68
+ */
69
+
70
+ function init() {
71
+ // Get options.
72
+ $this->get_options();
73
+
74
+ // Enqueue CSS and JS.
75
+ $this->enqueue_assets();
76
+ }
77
+
78
+
79
+ /**
80
+ * Get Options
81
+ *
82
+ * Sets and parses the db options with the default values.
83
+ *
84
+ * @package Dynamic To Top
85
+ * @subpackage Main Class
86
+ * @since 3.0
87
+ */
88
+
89
+ function get_options() {
90
+ $this->options = wp_parse_args( get_option( 'dynamic_to_top' ), $this->defaults );
91
+ }
92
+
93
+
94
+ /**
95
+ * Enqueue Assets
96
+ *
97
+ * Adds JS and CSS assets actions.
98
+ * Checks if its needed to prevent on mobile browsers.
99
+ *
100
+ * @package Dynamic To Top
101
+ * @subpackage Main Class
102
+ * @since 3.0
103
+ */
104
+
105
+ function enqueue_assets() {
106
+ if ( $this->is_checked( 'prevent_on_mobile' ) ) {
107
+ if ( $this->is_mobile() )
108
+ return;
109
+ }
110
+
111
+ add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_style' ) );
112
+ add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_script' ) );
113
+ }
114
+
115
+
116
+ /**
117
+ * Enqueue Style
118
+ *
119
+ * @package Dynamic To Top
120
+ * @subpackage Main Class
121
+ * @since 3.0
122
+ */
123
+
124
+ function enqueue_style() {
125
+ wp_enqueue_style( 'dynamic-to-top', plugin_dir_url( dirname( __FILE__ ) ) . 'css/dynamic-to-top-css.php', false, MV_DYNAMIC_TO_TOP_VERSION, 'all' );
126
+ }
127
+
128
+
129
+ /**
130
+ * Enqueue Script
131
+ *
132
+ * @package Dynamic To Top
133
+ * @subpackage Main Class
134
+ * @since 3.0
135
+ */
136
+
137
+ function enqueue_script() {
138
 
139
+ wp_enqueue_script( 'jquery-easing', plugin_dir_url( dirname( __FILE__ ) ) . 'js/libs/jquery.easing.js', array( 'jquery' ), '1.3', true );
140
 
141
+ $env = ( WP_DEBUG || SCRIPT_DEBUG ) ? 'dev' : 'min';
142
+ wp_enqueue_script( 'dynamic-to-top', plugin_dir_url( dirname( __FILE__ ) ) . 'js/dynamic.to.top.' . $env . '.js', array( 'jquery' ), MV_DYNAMIC_TO_TOP_VERSION, true );
143
+
144
+ $params = array(
145
+ 'text' => $this->options['text'],
146
+ 'version' => $this->options['text_version'],
147
+ 'min' => $this->options['distance'],
148
+ 'speed' => $this->options['speed'],
149
+ 'easing' => $this->get_easing_type(),
150
+ 'margin' => $this->options['margin'],
151
+ );
152
+
153
+ wp_localize_script( 'dynamic-to-top', 'mv_dynamic_to_top', apply_filters( 'mv_dynamic_to_top_js_params', $params ) );
154
+ }
155
+
156
+
157
+ /**
158
+ * Get CSS
159
+ *
160
+ * Returns CSS declarations.
161
+ * Checks for transient CSS or generates and sets a new one.
162
+ *
163
+ * @package Dynamic To Top
164
+ * @subpackage Main Class
165
+ * @since 3.0
166
+ * @return string $css CSS Declarations.
167
+ */
168
+
169
+ function get_css( $css = "" ) {
170
+ $css = get_transient( 'dynamic_to_top_transient_css' );
171
+
172
+ if ( ! $css ) {
173
+ $css = $this->minify( $this->generate_custom_css() );
174
+ set_transient( 'dynamic_to_top_transient_css', $css, 60*60*24*90 );
175
+ }
176
+
177
+ return apply_filters( 'mv_dynamic_to_top_css', $css );
178
+
179
+ }
180
+
181
+
182
+ /**
183
+ * Generate Custom CSS
184
+ *
185
+ * Returns Dynamic To Top custom CSS styles.
186
+ *
187
+ * @package Dynamic To Top
188
+ * @subpackage Main Class
189
+ * @since 3.0
190
+ * @return string $css CSS declarations.
191
+ */
192
+
193
+ function generate_custom_css( $css = "" ) {
194
+
195
+ $css .= "/* Dynamic To Top Plugin ver. ".MV_DYNAMIC_TO_TOP_VERSION." - http://www.mattvarone.com */\n\n";
196
+
197
+ $css .= "body { position:relative; }
198
+
199
+ #dynamic-to-top {
200
+ display:none;
201
+ overflow:hidden;
202
+ width:auto;
203
+ z-index:90;
204
+ position:fixed;
205
+ ".$this->get_position()."
206
+
207
+ font-family: sans-serif;
208
+ font-size:".$this->options['font_size']."em;
209
+ color:".$this->options['text_color'].";
210
+ text-decoration:none;\n";
 
 
211
 
212
+ if ( $this->is_checked( 'text_shadow' ) )
213
+ $css .= "text-shadow:0 1px 0 ".$this->options['shadow_color'].";\n";
214
+
215
+ if ( $this->is_checked( 'bold' ) )
216
+ $css .="font-weight:bold;\n";
217
+
218
+ $css.= "padding:".$this->options['padding_top_bottom']."px ".$this->options['padding_left_right']."px;
219
+ border:".$this->options['border_width']."px solid ".$this->options['border_color'].";
220
+ background:".$this->options['background_color'].";
221
+
222
+ -webkit-background-origin:border;
223
+ -moz-background-origin:border;
224
+ -icab-background-origin:border;
225
+ -khtml-background-origin:border;
226
+ -o-background-origin:border;
227
+ background-origin:border;
228
+
229
+ -webkit-background-clip:padding-box;
230
+ -moz-background-clip:padding-box;
231
+ -icab-background-clip:padding-box;
232
+ -khtml-background-clip:padding-box;
233
+ -o-background-clip:padding-box;
234
+ background-clip:padding-box;\n";
235
+
236
+ $box_shadow = "";
237
 
238
+ if ( $this->is_checked( 'shadow' ) )
239
+ $box_shadow .= "0 1px 3px rgba( 0, 0, 0, 0.4 )";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
240
 
241
+ if ( $this->is_checked( 'inset' ) ) {
242
+ if ( $box_shadow != "" ) $box_shadow = $box_shadow.", ";
243
+ $box_shadow .= "inset 0 0 0 1px rgba( 0, 0, 0, 0.2 ), inset 0 1px 0 rgba( 255, 255, 255, .4 ), inset 0 10px 10px rgba( 255, 255, 255, .1 )";
244
+ }
245
 
246
+ if ( strlen( $box_shadow ) > 1 )
247
+ $css .= "-webkit-box-shadow:".$box_shadow.";
248
+ -ms-box-shadow:".$box_shadow.";
249
+ -moz-box-shadow:".$box_shadow.";
250
+ -o-box-shadow:".$box_shadow.";
251
+ -khtml-box-shadow:".$box_shadow.";
252
+ -icab-box-shadow:".$box_shadow.";
253
+ box-shadow:".$box_shadow.";\n\n";
254
 
255
+ $css .= "-webkit-border-radius: ".$this->options['radius']."px;
256
+ -moz-border-radius: ".$this->options['radius']."px;
257
+ -icab-border-radius: ".$this->options['radius']."px;
258
+ -khtml-border-radius: ".$this->options['radius']."px;
259
+ border-radius: ".$this->options['radius']."px;\n}\n\n";
260
+
261
+ $css .= "#dynamic-to-top:hover {
262
+ background: ".$this->get_ligther_hex( $this->options['background_color'] ).";
263
+ background: ".$this->options['background_color']." -webkit-gradient( linear, 0% 0%, 0% 100%, from( rgba( 255, 255, 255, .2 ) ), to( rgba( 0, 0, 0, 0 ) ) );
264
+ background: ".$this->options['background_color']." -webkit-linear-gradient( top, rgba( 255, 255, 255, .2 ), rgba( 0, 0, 0, 0 ) );
265
+ background: ".$this->options['background_color']." -khtml-linear-gradient( top, rgba( 255, 255, 255, .2 ), rgba( 0, 0, 0, 0 ) );
266
+ background: ".$this->options['background_color']." -moz-linear-gradient( top, rgba( 255, 255, 255, .2 ), rgba( 0, 0, 0, 0 ) );
267
+ background: ".$this->options['background_color']." -o-linear-gradient( top, rgba( 255, 255, 255, .2 ), rgba( 0, 0, 0, 0 ) );
268
+ background: ".$this->options['background_color']." -ms-linear-gradient( top, rgba( 255, 255, 255, .2 ), rgba( 0, 0, 0, 0 ) );
269
+ background: ".$this->options['background_color']." -icab-linear-gradient( top, rgba( 255, 255, 255, .2 ), rgba( 0, 0, 0, 0 ) );
270
+ background: ".$this->options['background_color']." linear-gradient( top, rgba( 255, 255, 255, .2 ), rgba( 0, 0, 0, 0 ) );
271
+ cursor:pointer;
272
+ }
273
+
274
+ #dynamic-to-top:active {
275
+ background: ".$this->options['background_color'].";
276
+ background: ".$this->options['background_color']." -webkit-gradient( linear, 0% 0%, 0% 100%, from( rgba( 0, 0, 0, .3 ) ), to( rgba( 0, 0, 0, 0 ) ) );
277
+ background: ".$this->options['background_color']." -webkit-linear-gradient( top, rgba( 0, 0, 0, .1 ), rgba( 0, 0, 0, 0 ) );
278
+ background: ".$this->options['background_color']." -moz-linear-gradient( top, rgba( 0, 0, 0, .1 ), rgba( 0, 0, 0, 0 ) );
279
+ background: ".$this->options['background_color']." -khtml-linear-gradient( top, rgba( 0, 0, 0, .1 ), rgba( 0, 0, 0, 0 ) );
280
+ background: ".$this->options['background_color']." -o-linear-gradient( top, rgba( 0, 0, 0, .1 ), rgba( 0, 0, 0, 0 ) );
281
+ background: ".$this->options['background_color']." -ms-linear-gradient( top, rgba( 0, 0, 0, .1 ), rgba( 0, 0, 0, 0 ) );
282
+ background: ".$this->options['background_color']." -icab-linear-gradient( top, rgba( 0, 0, 0, .1 ), rgba( 0, 0, 0, 0 ) );
283
+ background: ".$this->options['background_color']." linear-gradient( top, rgba( 0, 0, 0, .1 ), rgba( 0, 0, 0, 0 ) );
284
+ }
285
 
286
+ #dynamic-to-top, #dynamic-to-top:active,
287
+ #dynamic-to-top:focus, #dynamic-to-top:hover
288
+ {
289
+ outline:none
290
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
291
 
292
+ #dynamic-to-top span {
293
+ display:block;
294
+ overflow:hidden;
295
+ width:14px;
296
+ height:12px;
297
+ background:url( " . plugin_dir_url( dirname( __FILE__ ) ) . "css/images/up.png ) no-repeat center center;
298
+ }";
299
+
300
+ return $css;
301
+ }
302
+
303
+
304
+ /**
305
+ * Get Easing Type
306
+ *
307
+ * Returns the easing type function name.
308
+ * Used on the JS script. Old values support for backwards compatibility.
309
+ *
310
+ * @package Dynamic To Top
311
+ * @subpackage Main Class
312
+ * @since 3.0
313
+ * @return string $easing Name of easing function.
314
+ */
315
+
316
+ function get_easing_type( $easing = "linear" ) {
317
+ switch ( $this->options['easing'] )
318
+ {
319
+ case ( $this->options['easing'] == 'Bounce' || $this->options['easing'] == 'bounce' ):
320
+ $easing = "easeOutBounce";
321
+ break;
322
+
323
+ case ( $this->options['easing'] == 'Elastic' || $this->options['easing'] == 'elastic' ):
324
+ $easing = "easeInElastic";
325
+ break;
326
+
327
+ case ( $this->options['easing'] == 'In' || $this->options['easing'] == 'in' ):
328
+ $easing = "easeInExpo";
329
+ break;
330
+
331
+ case ( $this->options['easing'] == 'In Out' || $this->options['easing'] == 'in-out' ):
332
+ $easing = "easeInOutExpo";
333
+ break;
334
+
335
+ case ( $this->options['easing'] == 'Out' || $this->options['easing'] == 'out' ):
336
+ $easing = "easeOutExpo";
337
+ break;
338
+ }
339
+ return $easing;
340
+ }
341
+
342
+
343
+ /**
344
+ * Get Position
345
+ *
346
+ * Returns CSS properties for the selected position.
347
+ * Used on the CSS style. Old values support for backwards compatibility.
348
+ *
349
+ * @package Dynamic To Top
350
+ * @subpackage Main Class
351
+ * @since 3.0
352
+ * @return string $position Properties of the position selected.
353
+ */
354
+
355
+ function get_position( $position = "" ) {
356
+ switch ( $this->options['position'] )
357
+ {
358
+ case ( $this->options['position'] == 'Bottom Right' || $this->options['position'] == 'bottom-right' ):
359
+ $position = "bottom:".$this->options['margin']."px;right:".$this->options['margin']."px;top:auto;left:auto;";
360
+ break;
361
+
362
+ case ( $this->options['position'] == 'Bottom Left' || $this->options['position'] == 'bottom-left' ):
363
+ $position = "bottom:".$this->options['margin']."px;left:".$this->options['margin']."px;top:auto;right:auto;";
364
+ break;
365
+
366
+ case ( $this->options['position'] == 'Top Right' || $this->options['position'] == 'top-right' ):
367
+ $position = "top:".$this->options['margin']."px;right:".$this->options['margin']."px;bottom:auto;left:auto;";
368
+ break;
369
+
370
+ case ( $this->options['position'] == 'Top Left' || $this->options['position'] == 'top-left' ):
371
+ $position = "top:".$this->options['margin']."px;left:".$this->options['margin']."px;bottom:auto;right:auto;";
372
+ break;
373
+ }
374
 
375
+ return $position;
376
+ }
377
+
378
+
379
+ /**
380
+ * Is Checked
381
+ *
382
+ * Conditional method to validate checked options.
383
+ *
384
+ * @package Dynamic To Top
385
+ * @subpackage Main Class
386
+ * @since 3.0
387
+ * @param string $option Option name.
388
+ * @return boolean
389
+ */
390
+
391
+ function is_checked( $option = "" ) {
392
+ if ( $option == "" )
393
+ return false;
394
+
395
+ if ( ! isset( $this->options[$option] ) )
396
+ return false;
397
+
398
+ // Old values support for backwards compatibility.
399
+ if ( $this->options[$option] == '1' || $this->options[$option] == 'yes' || $this->options[$option] == 'Yes' )
400
+ return true;
401
+ else
402
+ return false;
403
+ }
404
+
405
+
406
+ /**
407
+ * Is Mobile
408
+ *
409
+ * Checks if the browser is mobile.
410
+ *
411
+ * @package Dynamic To Top
412
+ * @subpackage Main Class
413
+ * @since 3.0
414
+ * @author Reverb Studios
415
+ * @link http://www.reverbstudios.ie/
416
+ * @return boolean
417
+ */
418
+
419
+ function is_mobile() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
420
 
421
+ if( isset( $_SERVER["HTTP_X_WAP_PROFILE"] ) )
422
+ return true;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
423
 
424
+ if( preg_match( "/wap\.|\.wap/i", $_SERVER["HTTP_ACCEPT"] ) )
425
+ return true;
426
 
427
+ if( isset( $_SERVER["HTTP_USER_AGENT"] ) ) {
428
+ $user_agents = array(
429
+ "midp", "j2me", "iphone", "avantg", "docomo", "novarra", "palmos",
430
+ "palmsource", "240x320", "opwv", "chtml", "pda", "windows\ ce", "mmp\/",
431
+ "blackberry", "mib\/", "symbian", "wireless", "nokia", "hand", "mobi",
432
+ "phone", "cdm", "up\.b", "audio", "SIE\-", "SEC\-", "samsung", "HTC",
433
+ "mot\-", "mitsu", "sagem", "sony", "alcatel", "lg", "erics", "vx", "NEC",
434
+ "philips", "mmm", "xx", "panasonic", "sharp", "wap", "sch", "rover",
435
+ "pocket", "benq", "java", "pt", "pg", "vox", "amoi", "bird", "compal",
436
+ "kg", "voda", "sany", "kdd", "dbt", "sendo", "sgh", "gradi", "jb", "\d\d\di", "moto" );
437
+
438
+ foreach( $user_agents as $user_string ) {
439
+ if( preg_match( "/" . $user_string . "/i", $_SERVER["HTTP_USER_AGENT"] ) )
440
+ return true;
441
+ }
442
+ }
443
+
444
+ do_action( 'mv_dynamic_to_top_check_mobile' );
445
 
446
+ return false;
447
+ }
448
+
449
+
450
+ /**
451
+ * Get Lighter Hex
452
+ *
453
+ * Returns a lighter version of an Hex color.
454
+ *
455
+ * @package Dynamic To Top
456
+ * @subpackage Main Class
457
+ * @since 3.0
458
+ * @author Justin French
459
+ * @link http://justinfrench.com/
460
+ * @return boolean
461
+ */
462
+
463
+ function get_ligther_hex( $hex, $factor = 30 ) {
464
+
465
+ $new_hex = '#';
466
+
467
+ if ( strlen( $hex ) == 7 ) {
468
+ $base['R'] = hexdec( $hex{0}.$hex{1} );
469
+ $base['G'] = hexdec( $hex{2}.$hex{3} );
470
+ $base['B'] = hexdec( $hex{4}.$hex{5} );
471
+ } else {
472
+ $base['R'] = hexdec( $hex{0}.$hex{0} );
473
+ $base['G'] = hexdec( $hex{1}.$hex{1} );
474
+ $base['B'] = hexdec( $hex{2}.$hex{2} );
475
+ }
476
+ foreach ( $base as $k=>$v ) {
477
+ $amount = 255 - $v;
478
+ $amount = $amount / 100;
479
+ $amount = round( $amount * $factor );
480
+ $new_decimal = $v + $amount;
481
 
482
+ $new_hex_component = dechex( $new_decimal );
483
+
484
+ if( strlen( $new_hex_component ) < 2 )
485
+ $new_hex_component = "0" . $new_hex_component;
486
+
487
+ $new_hex .= $new_hex_component;
488
+ }
489
+
490
+ return apply_filters( 'mv_dynamic_to_top_new_hex', $new_hex );
491
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
492
 
 
 
 
 
 
 
 
 
 
 
 
 
493
 
494
+ /**
495
+ *
496
+ * Simple Minify CSS
497
+ *
498
+ * Minifies CSS.
499
+ *
500
+ * @package Dynamic To Top
501
+ * @subpackage Main Class
502
+ * @since 3.0
503
+ * @author Karthik Viswanathan
504
+ * @link http://www.lateralcode.com/css-minifier/
505
+ * @return string
506
+ */
507
+
508
+ function minify( $css ) {
509
+ $css = preg_replace( '#\s+#', ' ', $css );
510
+ $css = preg_replace( '#/\*.*?\*/#s', '', $css );
511
+ $css = str_replace( array( '; ', ': ', ' {', '{ ', ', ', '} ', ';}' ), array( ';', ':', '{', '{', ', ', '}', '}' ), $css );
512
+ return trim( $css );
513
+ }
514
+
515
+
516
+ }
517
+
518
+ /*
519
+ |--------------------------------------------------------------------------
520
+ | DYNAMIC TO TOP CLASS INITIALIZE
521
+ |--------------------------------------------------------------------------
522
+ */
523
 
524
+ $OBJ_dynamic_to_top = new MV_Dynamic_To_Top();
525
  }
inc/dynamic-to-top-options.php CHANGED
@@ -1,261 +1,256 @@
1
  <?php
2
  /**
3
- * Dynamic To Top Options
4
- *
5
- * @package Dynamic To Top
6
- * @subpackage Options
7
- * @author Matt Varone
8
  */
9
 
10
- add_action( 'admin_menu', 'mv_dynamic_to_top_create_options_page' );
11
- add_action( 'admin_init', 'mv_dynamic_to_top_register_and_build_fields' );
12
-
13
- if ( ! function_exists( 'mv_dynamic_to_top_create_options_page' ) )
14
- {
15
-
16
- /**
17
- * Create Options Page
18
- *
19
- * @package Dynamic To Top
20
- * @subpackage Options
21
- * @since 3.0
22
- *
23
- */
24
-
25
- function mv_dynamic_to_top_create_options_page() {
26
- // Create Options Page
27
- add_theme_page( __( 'Dynamic To Top Options', 'dynamic-to-top' ), __( 'To Top', 'dynamic-to-top' ), 'manage_options', __FILE__, 'mv_dynamic_to_top_options_page' );
28
- }
29
- }
30
-
31
- if ( ! function_exists( 'mv_dynamic_to_top_register_and_build_fields' ) )
32
- {
33
-
34
- /**
35
- * Register and Build Fields
36
- *
37
- * Register fields and sections.
38
- *
39
- * @package Dynamic To Top
40
- * @subpackage Options
41
- * @since 3.0
42
- *
43
- */
44
-
45
- function mv_dynamic_to_top_register_and_build_fields() {
46
- register_setting( 'dynamic_to_top', 'dynamic_to_top', 'mv_dynamic_to_top_save_settings' );
47
-
48
- add_settings_section( 'settings_section', __( 'Behavior', 'dynamic-to-top' ), '__return_true', __FILE__ );
49
- add_settings_section( 'appearance_section', __( 'Appearance', 'dynamic-to-top' ), 'mv_dynamic_to_top_appearance_section', __FILE__ );
50
-
51
- add_settings_field( 'speed', __( 'Scroll time', 'dynamic-to-top' ), 'mv_dynamic_to_top_field_scroll_time', __FILE__, 'settings_section' );
52
- add_settings_field( 'distance', __( 'Fade-in distance', 'dynamic-to-top' ), 'mv_dynamic_to_top_field_distance', __FILE__, 'settings_section' );
53
- add_settings_field( 'easing', __( 'Easing', 'dynamic-to-top' ), 'mv_dynamic_to_top_field_easing', __FILE__, 'settings_section' );
54
- add_settings_field( 'position', __( 'Position', 'dynamic-to-top' ), 'mv_dynamic_to_top_field_position', __FILE__, 'settings_section' );
55
- add_settings_field( 'prevent_on_mobile', __( 'Prevent on mobile', 'dynamic-to-top' ), 'mv_dynamic_to_top_field_prevent_on_mobile', __FILE__, 'settings_section' );
56
-
57
- add_settings_field( 'text_version', __( 'Text version', 'dynamic-to-top' ), 'mv_dynamic_to_top_field_text_version', __FILE__, 'appearance_section' );
58
- add_settings_field( 'text', __( 'Button text', 'dynamic-to-top' ), 'mv_dynamic_to_top_field_text', __FILE__, 'appearance_section' );
59
- add_settings_field( 'padding_top_bottom', __( 'Top/bottom padding', 'dynamic-to-top' ), 'mv_dynamic_to_top_field_padding_top_bottom', __FILE__, 'appearance_section' );
60
- add_settings_field( 'padding_left_right', __( 'Sides padding', 'dynamic-to-top' ), 'mv_dynamic_to_top_field_padding_left_right', __FILE__, 'appearance_section' );
61
- add_settings_field( 'font_size', __( 'Font size', 'dynamic-to-top' ), 'mv_dynamic_to_top_field_font_size', __FILE__, 'appearance_section' );
62
- add_settings_field( 'text_color', __( 'Text color', 'dynamic-to-top' ), 'mv_dynamic_to_top_field_text_color', __FILE__, 'appearance_section' );
63
- add_settings_field( 'bold', __( 'Bold Text', 'dynamic-to-top' ), 'mv_dynamic_to_top_field_bold', __FILE__, 'appearance_section' );
64
- add_settings_field( 'text_shadow', __( 'Text shadow', 'dynamic-to-top' ), 'mv_dynamic_to_top_field_text_shadow', __FILE__, 'appearance_section' );
65
- add_settings_field( 'shadow_color', __( 'Text shadow color', 'dynamic-to-top' ), 'mv_dynamic_to_top_field_text_shadow_color', __FILE__, 'appearance_section' );
66
- add_settings_field( 'background_color', __( 'Background color', 'dynamic-to-top' ), 'mv_dynamic_to_top_field_background_color', __FILE__, 'appearance_section' );
67
- add_settings_field( 'border_color', __( 'Border color', 'dynamic-to-top' ), 'mv_dynamic_to_top_field_border_color', __FILE__, 'appearance_section' );
68
- add_settings_field( 'border_width', __( 'Border width', 'dynamic-to-top' ), 'mv_dynamic_to_top_field_border_width', __FILE__, 'appearance_section' );
69
- add_settings_field( 'radius', __( 'Border radius', 'dynamic-to-top' ), 'mv_dynamic_to_top_field_border_radius', __FILE__, 'appearance_section' );
70
- add_settings_field( 'inset', __( 'Inset highlighting', 'dynamic-to-top' ), 'mv_dynamic_to_top_field_inset', __FILE__, 'appearance_section' );
71
- add_settings_field( 'shadow', __( 'Shadow', 'dynamic-to-top' ), 'mv_dynamic_to_top_field_shadow', __FILE__, 'appearance_section' );
72
-
73
- }
74
- }
75
-
76
  /*
77
  |--------------------------------------------------------------------------
78
  | DYNAMIC TO TOP OPTIONS PAGE
79
  |--------------------------------------------------------------------------
80
  */
81
 
82
- if ( ! function_exists( 'mv_dynamic_to_top_options_page' ) )
83
- {
84
- /**
85
- * Options Page
86
- *
87
- * Options page layout.
88
- *
89
- * @package Dynamic To Top
90
- * @subpackage Options
91
- * @since 3.0
92
- *
93
- */
94
-
95
- function mv_dynamic_to_top_options_page() {
96
- ?>
97
- <div class="wrap">
98
- <?php screen_icon(); ?>
99
- <h2><?php _e( 'Dynamic To Top Options', 'dynamic-to-top' ); ?></h2>
100
-
101
- <p><?php _e( 'Welcome to the <strong>Dynamic To Top</strong> plugin settings. Click <a href="http://www.mattvarone.com/featured-content/dynamic-to-top/" target="_blank">here</a> to learn more about this plugin.', 'dynamic-to-top' ); ?></p>
102
-
103
-
104
- <form method="post" action="options.php" enctype="multipart/form-data">
105
- <?php settings_fields( 'dynamic_to_top' ); ?>
106
- <?php do_settings_sections( __FILE__ ); ?>
107
-
108
- <p class="submit">
109
- <input name="Submit" type="submit" class="button-primary" value="<?php _e( 'Save Changes', 'dynamic-to-top' ); ?>" />
110
- </p>
111
-
112
- <p><small><?php _e( '<strong>Dynamic To Top</strong> plugin brought to you by', 'dynamic-to-top' ); ?> <a href="http://www.mattvarone.com" title="Matt Varone" target="_blank"><strong>Matt Varone</strong></a> | <a href="http://www.mattvarone.com/donate" title="Tea for Matt!" target="_blank"><strong><?php _e( 'Donate', 'dynamic-to-top' ); ?></strong></a> &hearts;.</small></p>
113
-
114
- </form>
115
- </div>
116
- <?php
117
- }
118
- }
119
-
120
- if ( ! function_exists( 'mv_dynamic_to_top_appearance_section' ) ) {
121
-
122
- /**
123
- * Appearance Section
124
- *
125
- * @package Dynamic To Top
126
- * @subpackage Options
127
- * @since 3.0
128
- *
129
- */
130
-
131
- function mv_dynamic_to_top_appearance_section() {
132
- echo '<div id="dynamic-to-top-preview"><div id="dynamic-to-top-button"><span id="dtt-text"></span><span id="dtt-image"></span></div></div>';
133
- echo '<p class="ddt-bg-colors"><small>'.__( 'Preview over', 'dynamic-to-top' ).' <a href="#" title="black">'.__( 'black', 'dynamic-to-top' ).'</a>, <a href="#" title="lightgrey">'.__( 'grey', 'dynamic-to-top' ).'</a> or <a href="#" title="white">'.__( 'white', 'dynamic-to-top' ).'</a>.</small></p>';
134
- }
135
  }
 
136
 
137
- if ( ! function_exists( 'mv_dynamic_to_top_save_settings' ) ) {
138
-
139
- /**
140
- * Save Settings Check
141
- *
142
- * @package Dynamic To Top
143
- * @subpackage Options
144
- * @since 3.0
145
- *
146
- */
147
-
148
- function mv_dynamic_to_top_save_settings( $options ) {
149
- delete_transient( 'dynamic_to_top_transient_css' );
150
- delete_transient( 'dynamic_to_top_transient_js' );
151
-
152
- if ( ! isset($options['prevent_on_mobile']))
153
- $options['prevent_on_mobile'] = "0";
154
-
155
- if ( ! isset($options['text_version']))
156
- $options['text_version'] = "0";
157
-
158
- if ( ! isset($options['inset']))
159
- $options['inset'] = "0";
160
-
161
- if ( ! isset($options['shadow']))
162
- $options['shadow'] = "0";
163
-
164
- if ( ! isset($options['bold']))
165
- $options['bold'] = "0";
166
-
167
- if ( ! isset($options['text_shadow']))
168
- $options['text_shadow'] = "0";
169
-
170
- return $options;
171
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
172
  }
173
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
174
  /*
175
  |--------------------------------------------------------------------------
176
  | DYNAMIC TO TOP OPTIONS PAGE ASSETS
177
  |--------------------------------------------------------------------------
178
  */
179
 
180
- if ( ! function_exists( 'mv_dynamic_to_top_styles' ) ) {
181
- /**
182
- * Options page enqueue style.
183
- *
184
- * @package Dynamic To Top
185
- * @subpackage Options
186
- * @since 3.0
187
- *
188
- */
189
-
190
- function mv_dynamic_to_top_styles() {
191
- if ( mv_dynamic_to_top_is_page_options() ) {
192
- wp_enqueue_style( 'farbtastic' );
193
- wp_enqueue_style( 'dynamic-to-top-jquery-ui', MV_DYNAMIC_TO_TOP_URL.'/css/dynamic-to-top-jquery-ui.css', array(), '1.8.13' );
194
- wp_enqueue_style( 'dynamic-to-top-admin', MV_DYNAMIC_TO_TOP_URL.'/css/dynamic-to-top-admin.css', array( 'dynamic-to-top-jquery-ui' ), MV_DYNAMIC_TO_TOP_VERSION );
195
- }
196
- }
197
-
198
- add_action( 'admin_enqueue_scripts', 'mv_dynamic_to_top_styles' );
199
- }
200
-
201
- if ( ! function_exists( 'mv_dynamic_to_top_scripts' ) ) {
202
-
203
- /**
204
- * Options page enqueue script.
205
- *
206
- * @package Dynamic To Top
207
- * @subpackage Options
208
- * @since 3.0
209
- *
210
- */
211
-
212
- function mv_dynamic_to_top_scripts() {
213
- if ( mv_dynamic_to_top_is_page_options() ) {
214
- if ( version_compare( get_bloginfo( 'version' ),'3.2.9.9','<' ) ) {
215
- wp_enqueue_script( 'jquery-ui-widget', MV_DYNAMIC_TO_TOP_URL.'/js/libs/jquery.ui.widget.js', array( 'jquery-ui-core' ), '1.8.14' );
216
- wp_enqueue_script( 'jquery-ui-mouse', MV_DYNAMIC_TO_TOP_URL.'/js/libs/jquery.ui.mouse.js', array( 'jquery-ui-widget' ), '1.8.14' );
217
- wp_enqueue_script( 'jquery-ui-slider', MV_DYNAMIC_TO_TOP_URL.'/js/libs/jquery.ui.slider.js', array( 'jquery-ui-mouse' ), '1.8.14' );
218
- }
219
- wp_enqueue_script( 'dynamic-to-top-settings', MV_DYNAMIC_TO_TOP_URL.'/js/dynamic.to.top.settings.js', array( 'jquery-ui-slider', 'farbtastic' ), '1.0', true );
220
- }
221
- }
222
-
223
- add_action( 'admin_enqueue_scripts', 'mv_dynamic_to_top_scripts' );
224
- }
225
-
226
- if ( ! function_exists( 'mv_dynamic_to_top_is_page_options' ) ) {
227
-
228
- /**
229
- * Is dynamic to top page options?
230
- *
231
- * @package Dynamic To Top
232
- * @subpackage Options
233
- * @since 3.0
234
- * @return boolean
235
- *
236
- */
237
-
238
- function mv_dynamic_to_top_is_page_options()
239
- {
240
- global $pagenow;
241
-
242
- if ( function_exists( 'get_current_screen' ) ) {
243
- $screen = get_current_screen();
244
-
245
- if ( isset( $screen->base ) && $screen->base == 'appearance_page_' . basename( dirname( dirname( __FILE__ ) ) ) . '/inc/dynamic-to-top-options' )
246
- return true;
247
- else
248
- return false;
249
- }
250
- else {
251
- $pages = array( 'themes.php' );
252
-
253
- if ( in_array( $pagenow, $pages ) && isset( $_GET['page'] ) && $_GET['page'] == basename( dirname( dirname( __FILE__ ) ) ) . '/inc/dynamic-to-top-options.php' )
254
- return true;
255
- }
256
-
257
- return false;
258
- }
259
  }
260
 
261
  /*
@@ -264,324 +259,323 @@ if ( ! function_exists( 'mv_dynamic_to_top_is_page_options' ) ) {
264
  |--------------------------------------------------------------------------
265
  */
266
 
267
- // COLOR PICKERS /////////////////////////
 
 
 
 
 
 
 
268
 
269
- if ( ! function_exists( 'mv_dynamic_to_top_field_border_color' ) ) {
270
-
271
- /**
272
- * @package Dynamic To Top
273
- * @subpackage Options
274
- * @since 3.0
275
- *
276
- */
277
-
278
- function mv_dynamic_to_top_field_border_color() {
279
- echo mv_dynamic_to_top_do_textfield_color( 'border_color', '#000', __( 'Color for the button border.', 'dynamic-to-top' ) );
280
- }
281
  }
282
 
 
 
 
 
 
 
 
 
283
  if ( ! function_exists( 'mv_dynamic_to_top_field_background_color' ) ) {
284
-
285
- /**
286
- * @package Dynamic To Top
287
- * @subpackage Options
288
- * @since 3.0
289
- *
290
- */
291
-
292
- function mv_dynamic_to_top_field_background_color() {
293
- echo mv_dynamic_to_top_do_textfield_color( 'background_color', '#111', __( 'Background color for the button.', 'dynamic-to-top' ) );
294
- }
295
  }
296
 
 
 
 
 
 
 
 
 
297
  if ( ! function_exists( 'mv_dynamic_to_top_field_text_color' ) ) {
298
-
299
- /**
300
- * @package Dynamic To Top
301
- * @subpackage Options
302
- * @since 3.0
303
- *
304
- */
305
-
306
- function mv_dynamic_to_top_field_text_color() {
307
- echo mv_dynamic_to_top_do_textfield_color( 'text_color', '#fff', __( 'Button text color.', 'dynamic-to-top' ) );
308
- }
309
  }
310
 
 
 
 
 
 
 
 
 
311
  if ( ! function_exists( 'mv_dynamic_to_top_field_text_shadow_color' ) ) {
312
-
313
- /**
314
- * @package Dynamic To Top
315
- * @subpackage Options
316
- * @since 3.0
317
- *
318
- */
319
-
320
- function mv_dynamic_to_top_field_text_shadow_color() {
321
- echo mv_dynamic_to_top_do_textfield_color( 'shadow_color', '#333', __( 'Text shadow color.', 'dynamic-to-top' ) );
322
- }
323
  }
324
 
 
 
 
 
 
 
 
 
325
  if ( ! function_exists( 'mv_dynamic_to_top_field_box_shadow_color' ) ) {
326
-
327
- /**
328
- * @package Dynamic To Top
329
- * @subpackage Options
330
- * @since 3.0
331
- *
332
- */
333
-
334
- function mv_dynamic_to_top_field_box_shadow_color() {
335
- echo mv_dynamic_to_top_do_textfield_color( 'box_shadow_color', '#333', __( 'Text shadow color.', 'dynamic-to-top' ) );
336
- }
337
  }
338
 
339
  // SELECT BOXES /////////////////////////
340
 
341
- if ( ! function_exists( 'mv_dynamic_to_top_field_easing' ) ) {
342
 
343
- /**
344
- * @package Dynamic To Top
345
- * @subpackage Options
346
- * @since 3.0
347
- *
348
- */
349
-
350
- function mv_dynamic_to_top_field_easing() {
351
- $options = array(
352
- 'linear' => __( 'Linear', 'dynamic-to-top' ),
353
- 'in' => __( 'In', 'dynamic-to-top' ),
354
- 'out' => __( 'Out', 'dynamic-to-top' ),
355
- 'in-out' => __( 'In Out', 'dynamic-to-top' ),
356
- 'bounce' => __( 'Bounce', 'dynamic-to-top' ),
357
- 'elastic' => __( 'Elastic', 'dynamic-to-top' )
358
- );
359
-
360
- echo mv_dynamic_to_top_do_select( 'easing', $options, 'in', __( '<a href="http://gsgd.co.uk/sandbox/jquery/easing" title="Easing type">Easing type</a> used to scroll the page up.', 'dynamic-to-top' ) );
361
- }
362
- }
363
 
364
- if ( ! function_exists( 'mv_dynamic_to_top_field_position' ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
365
 
366
- /**
367
- * @package Dynamic To Top
368
- * @subpackage Options
369
- * @since 3.0
370
- *
371
- */
372
-
373
- function mv_dynamic_to_top_field_position() {
374
- $options = array(
375
- 'top-left' => __( 'Top Left', 'dynamic-to-top' ),
376
- 'top-right' => __( 'Top Right', 'dynamic-to-top' ),
377
- 'bottom-left' => __( 'Bottom Left', 'dynamic-to-top' ),
378
- 'bottom-right' => __( 'Bottom Right', 'dynamic-to-top' ),
379
- );
380
-
381
- echo mv_dynamic_to_top_do_select( 'position', $options, 'bottom-right', __( 'Button position.', 'dynamic-to-top' ) );
382
- }
383
  }
384
 
385
  // SLIDERS UI /////////////////////////
386
 
387
- if ( ! function_exists( 'mv_dynamic_to_top_field_scroll_time' ) ) {
388
 
389
- /**
390
- * @package Dynamic To Top
391
- * @subpackage Options
392
- * @since 3.0
393
- *
394
- */
395
 
396
- function mv_dynamic_to_top_field_scroll_time() {
397
- echo mv_dynamic_to_top_do_slider( 'speed', 1100, __( 'Time it takes for the page to scroll up. Less for faster. ( <span id="speed-val"></span> Milliseconds )', 'dynamic-to-top' ) );
398
- }
 
399
  }
400
 
401
- if ( ! function_exists( 'mv_dynamic_to_top_field_font_size' ) ) {
402
 
403
- /**
404
- * @package Dynamic To Top
405
- * @subpackage Options
406
- * @since 3.0
407
- *
408
- */
409
 
410
- function mv_dynamic_to_top_field_font_size() {
411
- echo mv_dynamic_to_top_do_slider( 'font_size', 1, __( 'Button text size. ( <span id="font-size-val"></span> Em/s )', 'dynamic-to-top' ) );
412
- }
 
413
  }
414
 
415
- if ( ! function_exists( 'mv_dynamic_to_top_field_padding_top_bottom' ) ) {
416
 
417
- /**
418
- * @package Dynamic To Top
419
- * @subpackage Options
420
- * @since 3.0
421
- *
422
- */
423
 
424
- function mv_dynamic_to_top_field_padding_top_bottom() {
425
- echo mv_dynamic_to_top_do_slider( 'padding_top_bottom', 21, __( 'Spacing on Top and Bottom. ( <span id="padding-top-bottom-val"></span>px )', 'dynamic-to-top' ) );
426
- }
 
427
  }
428
 
429
- if ( ! function_exists( 'mv_dynamic_to_top_field_padding_left_right' ) ) {
430
 
431
- /**
432
- * @package Dynamic To Top
433
- * @subpackage Options
434
- * @since 3.0
435
- *
436
- */
437
 
438
- function mv_dynamic_to_top_field_padding_left_right() {
439
- echo mv_dynamic_to_top_do_slider( 'padding_left_right', 19, __( 'Spacing on Left and Right. ( <span id="padding-left-right-val"></span>px )', 'dynamic-to-top' ) );
440
- }
 
441
  }
442
 
443
- if ( ! function_exists( 'mv_dynamic_to_top_field_border_width' ) ) {
444
 
445
- /**
446
- * @package Dynamic To Top
447
- * @subpackage Options
448
- * @since 3.0
449
- *
450
- */
451
 
452
- function mv_dynamic_to_top_field_border_width() {
453
- echo mv_dynamic_to_top_do_slider( 'border_width', '1', __( 'Button border width', 'dynamic-to-top' ).' <span id="border-val"></span>px.' );
454
- }
 
455
  }
456
 
457
- if ( ! function_exists( 'mv_dynamic_to_top_field_border_radius' ) ) {
458
 
459
- /**
460
- * @package Dynamic To Top
461
- * @subpackage Options
462
- * @since 3.0
463
- *
464
- */
465
 
466
- function mv_dynamic_to_top_field_border_radius() {
467
- echo mv_dynamic_to_top_do_slider( 'radius', '9', __( 'Button border radius', 'dynamic-to-top' ).' <span id="radius-val"></span>px.' );
468
- }
 
469
  }
470
 
471
  // TEXTFIELDS /////////////////////////
472
 
473
- if ( ! function_exists( 'mv_dynamic_to_top_field_distance' ) ) {
474
 
475
- /**
476
- * @package Dynamic To Top
477
- * @subpackage Options
478
- * @since 3.0
479
- *
480
- */
481
 
482
- function mv_dynamic_to_top_field_distance() {
483
- echo mv_dynamic_to_top_do_textfield( 'distance', 300, __( 'Distance from top to show the button. ( Pixels )', 'dynamic-to-top' ) );
484
- }
 
485
  }
486
 
487
- if ( ! function_exists( 'mv_dynamic_to_top_field_text' ) ) {
488
-
489
- /**
490
- * @package Dynamic To Top
491
- * @subpackage Options
492
- * @since 3.0
493
- *
494
- */
495
-
496
- function mv_dynamic_to_top_field_text() {
497
- echo mv_dynamic_to_top_do_textfield( 'text', __( 'To Top', 'dynamic-to-top' ), __( 'Text displayed on the button.', 'dynamic-to-top' ), 'regular-text' );
498
- }
499
  }
500
 
501
  // CHECKBOXES /////////////////////////
502
 
503
- if ( ! function_exists( 'mv_dynamic_to_top_field_prevent_on_mobile' ) ) {
504
-
505
- /**
506
- * @package Dynamic To Top
507
- * @subpackage Options
508
- * @since 3.0
509
- *
510
- */
511
-
512
- function mv_dynamic_to_top_field_prevent_on_mobile() {
513
- echo mv_dynamic_to_top_do_checkbox( 'prevent_on_mobile', __( 'Yes', 'dynamic-to-top' ), false, __( 'Disable the button on mobile browsers.', 'dynamic-to-top' ) );
514
- }
515
- }
516
-
517
- if ( ! function_exists( 'mv_dynamic_to_top_field_text_version' ) ) {
518
-
519
- /**
520
- * @package Dynamic To Top
521
- * @subpackage Options
522
- * @since 3.0
523
- *
524
- */
525
-
526
- function mv_dynamic_to_top_field_text_version() {
527
- echo mv_dynamic_to_top_do_checkbox( 'text_version', __( 'Yes', 'dynamic-to-top' ), false, __( 'Show a text version instead of the arrow up icon.', 'dynamic-to-top' ) );
528
- }
529
- }
530
-
531
- if ( ! function_exists( 'mv_dynamic_to_top_field_inset' ) ) {
532
-
533
- /**
534
- * @package Dynamic To Top
535
- * @subpackage Options
536
- * @since 3.0
537
- *
538
- */
539
-
540
- function mv_dynamic_to_top_field_inset() {
541
- echo mv_dynamic_to_top_do_checkbox( 'inset', __( 'Yes', 'dynamic-to-top' ), true, __( 'Add CSS3 inset-highlight.', 'dynamic-to-top' ) );
542
- }
543
- }
544
-
545
- if ( ! function_exists( 'mv_dynamic_to_top_field_shadow' ) ) {
546
-
547
- /**
548
- * @package Dynamic To Top
549
- * @subpackage Options
550
- * @since 3.0
551
- *
552
- */
553
-
554
- function mv_dynamic_to_top_field_shadow() {
555
- echo mv_dynamic_to_top_do_checkbox( 'shadow', __( 'Yes', 'dynamic-to-top' ), true, __( 'Add a CSS3 shadow.', 'dynamic-to-top' ) );
556
- }
557
- }
558
-
559
- if ( ! function_exists( 'mv_dynamic_to_top_field_weight' ) ) {
560
-
561
- /**
562
- * @package Dynamic To Top
563
- * @subpackage Options
564
- * @since 3.0
565
- *
566
- */
567
-
568
- function mv_dynamic_to_top_field_bold() {
569
- echo mv_dynamic_to_top_do_checkbox( 'bold', __( 'Yes', 'dynamic-to-top' ), true, __( 'Make the text bold.', 'dynamic-to-top' ) );
570
- }
571
- }
572
-
573
- if ( ! function_exists( 'mv_dynamic_to_top_field_text_shadow' ) ) {
574
-
575
- /**
576
- * @package Dynamic To Top
577
- * @subpackage Options
578
- * @since 3.0
579
- *
580
- */
581
-
582
- function mv_dynamic_to_top_field_text_shadow() {
583
- echo mv_dynamic_to_top_do_checkbox( 'text_shadow', __( 'Yes', 'dynamic-to-top' ), true, __( 'Add a subtle text shadow.', 'dynamic-to-top' ) );
584
- }
585
  }
586
  /*
587
  |--------------------------------------------------------------------------
@@ -589,196 +583,192 @@ if ( ! function_exists( 'mv_dynamic_to_top_field_text_shadow' ) ) {
589
  |--------------------------------------------------------------------------
590
  */
591
 
592
- if ( ! function_exists( 'mv_dynamic_to_top_do_checkbox' ) ) {
593
-
594
- /**
595
- * Do Checkbox
596
- *
597
- * Generates a checkbox.
598
- *
599
- * @package Dynamic To Top
600
- * @subpackage Options
601
- * @since 3.0
602
- *
603
- */
604
-
605
- function mv_dynamic_to_top_do_checkbox( $meta, $label="Yes", $checked=false, $desc="" )
606
- {
607
-
608
- $options_db = get_option( 'dynamic_to_top' );
609
-
610
- if ( isset( $options_db[$meta] ) ) {
611
- // Old values support for backwards compatibility.
612
- if ( $options_db[$meta] == "1" || $options_db[$meta] == 'yes' || $options_db[$meta] == 'Yes' )
613
- $c = 'checked="checked"';
614
- else
615
- $c = '';
616
- } else {
617
- if ( $checked == true )
618
- $c = 'checked="checked"';
619
- else
620
- $c = '';
621
- }
622
-
623
- if ( $desc != "" )
624
- $desc = '<div class="desc">'.$desc.'</div>';
625
-
626
- $sanitized_meta_title = str_replace( '_', '-', sanitize_title( $meta ) );
627
-
628
- return '<input type="checkbox" name="dynamic_to_top['.$meta.']" value="1" '.$c.' id="checkbox-'.$sanitized_meta_title.'" /> '.$label.$desc;
629
- }
630
- }
631
-
632
- if ( ! function_exists( 'mv_dynamic_to_top_do_textfield' ) ) {
633
-
634
- /**
635
- * Do Textfield
636
- *
637
- * Generates a Textfield.
638
- *
639
- * @package Dynamic To Top
640
- * @subpackage Options
641
- * @since 3.0
642
- *
643
- */
644
-
645
- function mv_dynamic_to_top_do_textfield( $meta, $value="", $desc="", $class="" )
646
- {
647
-
648
- $options_db = get_option( 'dynamic_to_top' );
649
-
650
- if ( isset( $options_db[$meta] ) )
651
- $value = $options_db[$meta];
652
-
653
- if ( $desc != "" )
654
- $desc = '<div class="desc">'.$desc.'</div>';
655
-
656
- if ( $class != "" )
657
- $class = 'class="'.$class.'"';
658
-
659
- $sanitized_meta_title = str_replace( '_', '-', sanitize_title( $meta ) );
660
-
661
- return '<input type="text" id="text-'.$sanitized_meta_title.'" name="dynamic_to_top['.$meta.']" '.$class.' value="'.$value.'" /> '.$desc;
662
- }
663
- }
664
-
665
- if ( ! function_exists( 'mv_dynamic_to_top_do_select' ) ) {
666
-
667
- /**
668
- * Do Select Box
669
- *
670
- * Generate a select box.
671
- *
672
- * @package Dynamic To Top
673
- * @subpackage Options
674
- * @since 3.0
675
- *
676
- */
677
-
678
- function mv_dynamic_to_top_do_select( $meta, $options=array(), $value="", $desc="" )
679
- {
680
-
681
- $options_out = "";
682
-
683
- $options_db = get_option( 'dynamic_to_top' );
684
-
685
- if ( isset( $options_db[$meta] ) )
686
- $value = $options_db[$meta];
687
-
688
- $value = sanitize_title( $value );
689
-
690
- foreach ( $options as $option => $label )
691
- {
692
- $selected = "";
693
-
694
- $option_slug = sanitize_title( $option );
695
-
696
- if ( $value == $option_slug )
697
- $selected = 'selected="selected"';
698
-
699
- $options_out .= '<option name="'.sanitize_title( $option ).'" '.$selected.' >'.$label.'</option>';
700
- }
701
-
702
- if ( $desc != "" )
703
- $desc = '<div class="desc">'.$desc.'</div>';
704
-
705
- $sanitized_meta_title = str_replace( '_', '-', sanitize_title( $meta ) );
706
-
707
- return '<select name="dynamic_to_top['.$meta.']" id="select-'.$sanitized_meta_title.'"> '.$options_out.'</select>'.$desc;
708
- }
709
- }
710
-
711
- if ( ! function_exists( 'mv_dynamic_to_top_do_textfield_color' ) ) {
712
-
713
- /**
714
- * Do Textfield Color
715
- *
716
- * Generates a Textfield with Farbtastic.
717
- *
718
- * @package Dynamic To Top
719
- * @subpackage Options
720
- * @since 3.0
721
- *
722
- */
723
-
724
- function mv_dynamic_to_top_do_textfield_color( $meta, $value="", $desc="", $class="" )
725
- {
726
-
727
- $options_db = get_option( 'dynamic_to_top' );
728
-
729
- if ( isset( $options_db[$meta] ) )
730
- $value = $options_db[$meta];
731
-
732
- if ( $desc != "" )
733
- $desc = '<div class="desc">'.$desc.'</div>';
734
-
735
- if ( $class != "" )
736
- $class .= " ";
737
-
738
- $class = 'class="'.$class.'colorvalue"';
739
-
740
- $sanitized_meta_title = str_replace( '_', '-', sanitize_title( $meta ) );
741
-
742
- $out = '<input type="text" name="dynamic_to_top['.$meta.']" id="farbtastic-'.$sanitized_meta_title.'" '.$class.' value="'.$value.'" />';
743
- $out .= '<a class="picker hide-if-no-js" href="#" data-closed="'.__( 'close', 'dynamic-to-top' ).'" data-open="'.__( 'select a color', 'dynamic-to-top' ).'">'.__( 'select a color', 'dynamic-to-top' ).'</a>';
744
- $out .= '<div id="farbtastic-picker-'.$sanitized_meta_title.'" class="dtt-farbtastic"></div>';
745
- $out .= $desc;
746
-
747
- return $out;
748
- }
749
- }
750
-
751
- if ( ! function_exists( 'mv_dynamic_to_top_do_slider' ) ) {
752
-
753
- /**
754
- * Do Textfield Color
755
- *
756
- * Generates a Textfield with a slider.
757
- *
758
- * @package Dynamic To Top
759
- * @subpackage Options
760
- * @since 3.0
761
- *
762
- */
763
-
764
- function mv_dynamic_to_top_do_slider( $meta, $value="", $desc="", $class="" )
765
- {
766
-
767
- $options_db = get_option( 'dynamic_to_top' );
768
-
769
- if ( isset( $options_db[$meta] ) )
770
- $value = $options_db[$meta];
771
-
772
- if ( $desc != "" )
773
- $desc = '<div class="desc">'.$desc.'</div>';
774
-
775
- if ( $class != "" )
776
- $class .= " ";
777
-
778
- $class = 'class="'.$class.'to-top-slider"';
779
-
780
- $sanitized_meta_title = str_replace( '_', '-', sanitize_title( $meta ) );
781
-
782
- return '<div id="slider-picker-'.$sanitized_meta_title.'" class="dtt-slider"></div><input type="text" name="dynamic_to_top['.$meta.']" id="slider-'.$sanitized_meta_title.'" '.$class.' value="'.$value.'" />'.$desc;
783
- }
784
  }
1
  <?php
2
  /**
3
+ * Dynamic To Top Options
4
+ *
5
+ * @package Dynamic To Top
6
+ * @subpackage Options
7
+ * @author Matt Varone
8
  */
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  /*
11
  |--------------------------------------------------------------------------
12
  | DYNAMIC TO TOP OPTIONS PAGE
13
  |--------------------------------------------------------------------------
14
  */
15
 
16
+
17
+ /**
18
+ * Create Options Page
19
+ *
20
+ * @package Dynamic To Top
21
+ * @subpackage Options
22
+ * @since 3.0
23
+ * @return void
24
+ */
25
+
26
+ if ( ! function_exists( 'mv_dynamic_to_top_create_options_page' ) ) {
27
+ function mv_dynamic_to_top_create_options_page() {
28
+ // Create Options Page
29
+ add_theme_page( __( 'Dynamic To Top Options', 'dynamic-to-top' ), __( 'To Top', 'dynamic-to-top' ), 'manage_options', __FILE__, 'mv_dynamic_to_top_options_page' );
30
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  }
32
+ add_action( 'admin_menu', 'mv_dynamic_to_top_create_options_page' );
33
 
34
+
35
+ /**
36
+ * Register and Build Fields
37
+ *
38
+ * Register fields and sections.
39
+ *
40
+ * @package Dynamic To Top
41
+ * @subpackage Options
42
+ * @since 3.0
43
+ * @return void
44
+ */
45
+
46
+ if ( ! function_exists( 'mv_dynamic_to_top_register_and_build_fields' ) ) {
47
+ function mv_dynamic_to_top_register_and_build_fields() {
48
+ register_setting( 'dynamic_to_top', 'dynamic_to_top', 'mv_dynamic_to_top_save_settings' );
49
+
50
+ add_settings_section( 'settings_section', __( 'Behavior', 'dynamic-to-top' ), '__return_true', __FILE__ );
51
+ add_settings_section( 'appearance_section', __( 'Appearance', 'dynamic-to-top' ), 'mv_dynamic_to_top_appearance_section', __FILE__ );
52
+
53
+ add_settings_field( 'speed', __( 'Scroll time', 'dynamic-to-top' ), 'mv_dynamic_to_top_field_scroll_time', __FILE__, 'settings_section' );
54
+ add_settings_field( 'distance', __( 'Fade-in distance', 'dynamic-to-top' ), 'mv_dynamic_to_top_field_distance', __FILE__, 'settings_section' );
55
+ add_settings_field( 'easing', __( 'Easing', 'dynamic-to-top' ), 'mv_dynamic_to_top_field_easing', __FILE__, 'settings_section' );
56
+ add_settings_field( 'position', __( 'Position', 'dynamic-to-top' ), 'mv_dynamic_to_top_field_position', __FILE__, 'settings_section' );
57
+ add_settings_field( 'prevent_on_mobile', __( 'Prevent on mobile', 'dynamic-to-top' ), 'mv_dynamic_to_top_field_prevent_on_mobile', __FILE__, 'settings_section' );
58
+
59
+ add_settings_field( 'text_version', __( 'Text version', 'dynamic-to-top' ), 'mv_dynamic_to_top_field_text_version', __FILE__, 'appearance_section' );
60
+ add_settings_field( 'text', __( 'Button text', 'dynamic-to-top' ), 'mv_dynamic_to_top_field_text', __FILE__, 'appearance_section' );
61
+ add_settings_field( 'padding_top_bottom', __( 'Top/bottom padding', 'dynamic-to-top' ), 'mv_dynamic_to_top_field_padding_top_bottom', __FILE__, 'appearance_section' );
62
+ add_settings_field( 'padding_left_right', __( 'Sides padding', 'dynamic-to-top' ), 'mv_dynamic_to_top_field_padding_left_right', __FILE__, 'appearance_section' );
63
+ add_settings_field( 'font_size', __( 'Font size', 'dynamic-to-top' ), 'mv_dynamic_to_top_field_font_size', __FILE__, 'appearance_section' );
64
+ add_settings_field( 'text_color', __( 'Text color', 'dynamic-to-top' ), 'mv_dynamic_to_top_field_text_color', __FILE__, 'appearance_section' );
65
+ add_settings_field( 'bold', __( 'Bold Text', 'dynamic-to-top' ), 'mv_dynamic_to_top_field_bold', __FILE__, 'appearance_section' );
66
+ add_settings_field( 'text_shadow', __( 'Text shadow', 'dynamic-to-top' ), 'mv_dynamic_to_top_field_text_shadow', __FILE__, 'appearance_section' );
67
+ add_settings_field( 'shadow_color', __( 'Text shadow color', 'dynamic-to-top' ), 'mv_dynamic_to_top_field_text_shadow_color', __FILE__, 'appearance_section' );
68
+ add_settings_field( 'background_color', __( 'Background color', 'dynamic-to-top' ), 'mv_dynamic_to_top_field_background_color', __FILE__, 'appearance_section' );
69
+ add_settings_field( 'border_color', __( 'Border color', 'dynamic-to-top' ), 'mv_dynamic_to_top_field_border_color', __FILE__, 'appearance_section' );
70
+ add_settings_field( 'border_width', __( 'Border width', 'dynamic-to-top' ), 'mv_dynamic_to_top_field_border_width', __FILE__, 'appearance_section' );
71
+ add_settings_field( 'radius', __( 'Border radius', 'dynamic-to-top' ), 'mv_dynamic_to_top_field_border_radius', __FILE__, 'appearance_section' );
72
+ add_settings_field( 'inset', __( 'Inset highlighting', 'dynamic-to-top' ), 'mv_dynamic_to_top_field_inset', __FILE__, 'appearance_section' );
73
+ add_settings_field( 'shadow', __( 'Shadow', 'dynamic-to-top' ), 'mv_dynamic_to_top_field_shadow', __FILE__, 'appearance_section' );
74
+ }
75
+ }
76
+ add_action( 'admin_init', 'mv_dynamic_to_top_register_and_build_fields' );
77
+
78
+
79
+ /**
80
+ * Options Page
81
+ *
82
+ * Options page layout.
83
+ *
84
+ * @package Dynamic To Top
85
+ * @subpackage Options
86
+ * @since 3.0
87
+ * @return string
88
+ */
89
+
90
+ if ( ! function_exists( 'mv_dynamic_to_top_options_page' ) ) {
91
+ function mv_dynamic_to_top_options_page() {
92
+ ?>
93
+ <div class="wrap">
94
+ <?php screen_icon(); ?>
95
+ <h2><?php _e( 'Dynamic To Top Options', 'dynamic-to-top' ); ?></h2>
96
+
97
+ <p><?php printf( __( 'Welcome to the <strong>Dynamic To Top</strong> plugin settings. Click %s to learn more about this plugin.', 'dynamic-to-top' ), sprintf( '<a href="http://www.mattvarone.com/featured-content/dynamic-to-top/" target="_blank">%s</a>', __( 'here', 'dynamic-to-top' ) ) ); ?></p>
98
+
99
+
100
+ <form method="post" action="options.php" enctype="multipart/form-data">
101
+ <?php settings_fields( 'dynamic_to_top' ); ?>
102
+ <?php do_settings_sections( __FILE__ ); ?>
103
+
104
+ <p class="submit">
105
+ <input name="Submit" type="submit" class="button-primary" value="<?php _e( 'Save Changes', 'dynamic-to-top' ); ?>" />
106
+ </p>
107
+
108
+ <p><small><?php _e( '<strong>Dynamic To Top</strong> plugin brought to you by', 'dynamic-to-top' ); ?> <a href="http://www.mattvarone.com" title="Matt Varone" target="_blank"><strong>Matt Varone</strong></a> | <a href="http://www.mattvarone.com/donate" title="Tea for Matt! " target="_blank"><strong><?php _e( 'Donate', 'dynamic-to-top' ); ?></strong></a> &hearts;.</small></p>
109
+
110
+ </form>
111
+ </div>
112
+ <?php
113
+ }
114
+ }
115
+
116
+
117
+ /**
118
+ * Appearance Section
119
+ *
120
+ * @package Dynamic To Top
121
+ * @subpackage Options
122
+ * @since 3.0
123
+ * @return void
124
+ */
125
+
126
+ if ( ! function_exists( 'mv_dynamic_to_top_appearance_section' ) ) {
127
+ function mv_dynamic_to_top_appearance_section() {
128
+ echo '<div id="dynamic-to-top-preview"><div id="dynamic-to-top-button"><span id="dtt-text"></span><span id="dtt-image"></span></div></div>';
129
+ echo '<p class="ddt-bg-colors"><small>'.__( 'Preview over', 'dynamic-to-top' ).' <a href="#" title="black">'.__( 'black', 'dynamic-to-top' ).'</a>, <a href="#" title="lightgrey">'.__( 'grey', 'dynamic-to-top' ).'</a> or <a href="#" title="white">'.__( 'white', 'dynamic-to-top' ).'</a>.</small></p>';
130
+ }
131
  }
132
 
133
+
134
+ /**
135
+ * Save Settings Check
136
+ *
137
+ * @package Dynamic To Top
138
+ * @subpackage Options
139
+ * @since 3.0
140
+ *
141
+ */
142
+
143
+ if ( ! function_exists( 'mv_dynamic_to_top_save_settings' ) ) {
144
+ function mv_dynamic_to_top_save_settings( $options ) {
145
+ delete_transient( 'dynamic_to_top_transient_css' );
146
+ delete_transient( 'dynamic_to_top_transient_js' );
147
+
148
+ if ( ! isset( $options['prevent_on_mobile'] ) )
149
+ $options['prevent_on_mobile'] = "0";
150
+
151
+ if ( ! isset( $options['text_version'] ) )
152
+ $options['text_version'] = "0";
153
+
154
+ if ( ! isset( $options['inset'] ) )
155
+ $options['inset'] = "0";
156
+
157
+ if ( ! isset( $options['shadow'] ) )
158
+ $options['shadow'] = "0";
159
+
160
+ if ( ! isset( $options['bold'] ) )
161
+ $options['bold'] = "0";
162
+
163
+ if ( ! isset( $options['text_shadow'] ) )
164
+ $options['text_shadow'] = "0";
165
+
166
+ return $options;
167
+ }
168
+ }
169
+
170
+
171
  /*
172
  |--------------------------------------------------------------------------
173
  | DYNAMIC TO TOP OPTIONS PAGE ASSETS
174
  |--------------------------------------------------------------------------
175
  */
176
 
177
+
178
+ /**
179
+ * Options page enqueue style.
180
+ *
181
+ * @package Dynamic To Top
182
+ * @subpackage Options
183
+ * @since 3.0
184
+ *
185
+ */
186
+
187
+ if ( ! function_exists( 'mv_dynamic_to_top_styles' ) ) {
188
+ function mv_dynamic_to_top_styles() {
189
+ if ( mv_dynamic_to_top_is_page_options() ) {
190
+ wp_enqueue_style( 'farbtastic' );
191
+ wp_enqueue_style( 'dynamic-to-top-jquery-ui', plugin_dir_url( dirname( __FILE__ ) ) . 'css/dynamic-to-top-jquery-ui.css', array(), '1.8.13' );
192
+ wp_enqueue_style( 'dynamic-to-top-admin', plugin_dir_url( dirname( __FILE__ ) ) . 'css/dynamic-to-top-admin.css', array( 'dynamic-to-top-jquery-ui' ), MV_DYNAMIC_TO_TOP_VERSION );
193
+ }
194
+ }
195
+ }
196
+ add_action( 'admin_enqueue_scripts', 'mv_dynamic_to_top_styles' );
197
+
198
+
199
+ /**
200
+ * Options page enqueue script.
201
+ *
202
+ * @package Dynamic To Top
203
+ * @subpackage Options
204
+ * @since 3.0
205
+ *
206
+ */
207
+
208
+ if ( ! function_exists( 'mv_dynamic_to_top_scripts' ) ) {
209
+ function mv_dynamic_to_top_scripts() {
210
+ if ( mv_dynamic_to_top_is_page_options() ) {
211
+ if ( version_compare( get_bloginfo( 'version' ), '3.2.9.9', '<' ) ) {
212
+ wp_enqueue_script( 'jquery-ui-widget', plugin_dir_url( dirname( __FILE__ ) ) . 'js/libs/jquery.ui.widget.js', array( 'jquery-ui-core' ), '1.8.14' );
213
+ wp_enqueue_script( 'jquery-ui-mouse', plugin_dir_url( dirname( __FILE__ ) ) . 'js/libs/jquery.ui.mouse.js', array( 'jquery-ui-widget' ), '1.8.14' );
214
+ wp_enqueue_script( 'jquery-ui-slider', plugin_dir_url( dirname( __FILE__ ) ) . 'js/libs/jquery.ui.slider.js', array( 'jquery-ui-mouse' ), '1.8.14' );
215
+ }
216
+ wp_enqueue_script( 'dynamic-to-top-settings', plugin_dir_url( dirname( __FILE__ ) ) . 'js/dynamic.to.top.settings.js', array( 'jquery-ui-slider', 'farbtastic' ), '1.0', true );
217
+ }
218
+ }
219
+ }
220
+ add_action( 'admin_enqueue_scripts', 'mv_dynamic_to_top_scripts' );
221
+
222
+
223
+ /**
224
+ * Is dynamic to top page options?
225
+ *
226
+ * @package Dynamic To Top
227
+ * @subpackage Options
228
+ * @since 3.0
229
+ * @return boolean
230
+ */
231
+
232
+ if ( ! function_exists( 'mv_dynamic_to_top_is_page_options' ) ) {
233
+ function mv_dynamic_to_top_is_page_options()
234
+ {
235
+ global $pagenow;
236
+
237
+ if ( function_exists( 'get_current_screen' ) ) {
238
+ $screen = get_current_screen();
239
+
240
+ if ( isset( $screen->base ) && $screen->base == 'appearance_page_' . basename( dirname( dirname( __FILE__ ) ) ) . '/inc/dynamic-to-top-options' )
241
+ return true;
242
+ else
243
+ return false;
244
+ }
245
+ else {
246
+ $pages = array( 'themes.php' );
247
+
248
+ if ( in_array( $pagenow, $pages ) && isset( $_GET['page'] ) && $_GET['page'] == basename( dirname( dirname( __FILE__ ) ) ) . '/inc/dynamic-to-top-options.php' )
249
+ return true;
250
+ }
251
+
252
+ return false;
253
+ }
 
 
254
  }
255
 
256
  /*
259
  |--------------------------------------------------------------------------
260
  */
261
 
262
+ // COLOR PICKERS /////////////////////////
263
+
264
+ /**
265
+ * @package Dynamic To Top
266
+ * @subpackage Options
267
+ * @since 3.0
268
+ * @return string
269
+ */
270
 
271
+ if ( ! function_exists( 'mv_dynamic_to_top_field_border_color' ) ) {
272
+ function mv_dynamic_to_top_field_border_color() {
273
+ echo mv_dynamic_to_top_do_textfield_color( 'border_color', '#000', __( 'Color for the button border.', 'dynamic-to-top' ) );
274
+ }
 
 
 
 
 
 
 
 
275
  }
276
 
277
+
278
+ /**
279
+ * @package Dynamic To Top
280
+ * @subpackage Options
281
+ * @since 3.0
282
+ * @return string
283
+ */
284
+
285
  if ( ! function_exists( 'mv_dynamic_to_top_field_background_color' ) ) {
286
+ function mv_dynamic_to_top_field_background_color() {
287
+ echo mv_dynamic_to_top_do_textfield_color( 'background_color', '#111', __( 'Background color for the button.', 'dynamic-to-top' ) );
288
+ }
 
 
 
 
 
 
 
 
289
  }
290
 
291
+
292
+ /**
293
+ * @package Dynamic To Top
294
+ * @subpackage Options
295
+ * @since 3.0
296
+ * @return string
297
+ */
298
+
299
  if ( ! function_exists( 'mv_dynamic_to_top_field_text_color' ) ) {
300
+ function mv_dynamic_to_top_field_text_color() {
301
+ echo mv_dynamic_to_top_do_textfield_color( 'text_color', '#fff', __( 'Button text color.', 'dynamic-to-top' ) );
302
+ }
 
 
 
 
 
 
 
 
303
  }
304
 
305
+
306
+ /**
307
+ * @package Dynamic To Top
308
+ * @subpackage Options
309
+ * @since 3.0
310
+ * @return string
311
+ */
312
+
313
  if ( ! function_exists( 'mv_dynamic_to_top_field_text_shadow_color' ) ) {
314
+ function mv_dynamic_to_top_field_text_shadow_color() {
315
+ echo mv_dynamic_to_top_do_textfield_color( 'shadow_color', '#333', __( 'Text shadow color.', 'dynamic-to-top' ) );
316
+ }
 
 
 
 
 
 
 
 
317
  }
318
 
319
+
320
+ /**
321
+ * @package Dynamic To Top
322
+ * @subpackage Options
323
+ * @since 3.0
324
+ * @return string
325
+ */
326
+
327
  if ( ! function_exists( 'mv_dynamic_to_top_field_box_shadow_color' ) ) {
328
+ function mv_dynamic_to_top_field_box_shadow_color() {
329
+ echo mv_dynamic_to_top_do_textfield_color( 'box_shadow_color', '#333', __( 'Text shadow color.', 'dynamic-to-top' ) );
330
+ }
 
 
 
 
 
 
 
 
331
  }
332
 
333
  // SELECT BOXES /////////////////////////
334
 
 
335
 
336
+ /**
337
+ * @package Dynamic To Top
338
+ * @subpackage Options
339
+ * @since 3.0
340
+ * @return string
341
+ */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
342
 
343
+ if ( ! function_exists( 'mv_dynamic_to_top_field_easing' ) ) {
344
+ function mv_dynamic_to_top_field_easing() {
345
+ $options = array(
346
+ 'linear' => __( 'Linear', 'dynamic-to-top' ),
347
+ 'in' => __( 'In', 'dynamic-to-top' ),
348
+ 'out' => __( 'Out', 'dynamic-to-top' ),
349
+ 'in-out' => __( 'In Out', 'dynamic-to-top' ),
350
+ 'bounce' => __( 'Bounce', 'dynamic-to-top' ),
351
+ 'elastic' => __( 'Elastic', 'dynamic-to-top' )
352
+ );
353
+
354
+ echo mv_dynamic_to_top_do_select( 'easing', $options, 'in', __( '<a href="http://gsgd.co.uk/sandbox/jquery/easing" title="Easing type">Easing type</a> used to scroll the page up.', 'dynamic-to-top' ) );
355
+ }
356
+ }
357
+
358
+
359
+ /**
360
+ * @package Dynamic To Top
361
+ * @subpackage Options
362
+ * @since 3.0
363
+ * @return string
364
+ */
365
 
366
+ if ( ! function_exists( 'mv_dynamic_to_top_field_position' ) ) {
367
+ function mv_dynamic_to_top_field_position() {
368
+ $options = array(
369
+ 'top-left' => __( 'Top Left', 'dynamic-to-top' ),
370
+ 'top-right' => __( 'Top Right', 'dynamic-to-top' ),
371
+ 'bottom-left' => __( 'Bottom Left', 'dynamic-to-top' ),
372
+ 'bottom-right' => __( 'Bottom Right', 'dynamic-to-top' ),
373
+ );
374
+
375
+ echo mv_dynamic_to_top_do_select( 'position', $options, 'bottom-right', __( 'Button position.', 'dynamic-to-top' ) );
376
+ }
 
 
 
 
 
 
377
  }
378
 
379
  // SLIDERS UI /////////////////////////
380
 
 
381
 
382
+ /**
383
+ * @package Dynamic To Top
384
+ * @subpackage Options
385
+ * @since 3.0
386
+ * @return string
387
+ */
388
 
389
+ if ( ! function_exists( 'mv_dynamic_to_top_field_scroll_time' ) ) {
390
+ function mv_dynamic_to_top_field_scroll_time() {
391
+ echo mv_dynamic_to_top_do_slider( 'speed', 1100, __( 'Time it takes for the page to scroll up. Less for faster. ( <span id="speed-val"></span> Milliseconds )', 'dynamic-to-top' ) );
392
+ }
393
  }
394
 
 
395
 
396
+ /**
397
+ * @package Dynamic To Top
398
+ * @subpackage Options
399
+ * @since 3.0
400
+ * @return string
401
+ */
402
 
403
+ if ( ! function_exists( 'mv_dynamic_to_top_field_font_size' ) ) {
404
+ function mv_dynamic_to_top_field_font_size() {
405
+ echo mv_dynamic_to_top_do_slider( 'font_size', 1, __( 'Button text size. ( <span id="font-size-val"></span> Em/s )', 'dynamic-to-top' ) );
406
+ }
407
  }
408
 
 
409
 
410
+ /**
411
+ * @package Dynamic To Top
412
+ * @subpackage Options
413
+ * @since 3.0
414
+ * @return string
415
+ */
416
 
417
+ if ( ! function_exists( 'mv_dynamic_to_top_field_padding_top_bottom' ) ) {
418
+ function mv_dynamic_to_top_field_padding_top_bottom() {
419
+ echo mv_dynamic_to_top_do_slider( 'padding_top_bottom', 21, __( 'Spacing on Top and Bottom. ( <span id="padding-top-bottom-val"></span>px )', 'dynamic-to-top' ) );
420
+ }
421
  }
422
 
 
423
 
424
+ /**
425
+ * @package Dynamic To Top
426
+ * @subpackage Options
427
+ * @since 3.0
428
+ * @return string
429
+ */
430
 
431
+ if ( ! function_exists( 'mv_dynamic_to_top_field_padding_left_right' ) ) {
432
+ function mv_dynamic_to_top_field_padding_left_right() {
433
+ echo mv_dynamic_to_top_do_slider( 'padding_left_right', 19, __( 'Spacing on Left and Right. ( <span id="padding-left-right-val"></span>px )', 'dynamic-to-top' ) );
434
+ }
435
  }
436
 
 
437
 
438
+ /**
439
+ * @package Dynamic To Top
440
+ * @subpackage Options
441
+ * @since 3.0
442
+ * @return string
443
+ */
444
 
445
+ if ( ! function_exists( 'mv_dynamic_to_top_field_border_width' ) ) {
446
+ function mv_dynamic_to_top_field_border_width() {
447
+ echo mv_dynamic_to_top_do_slider( 'border_width', '1', __( 'Button border width', 'dynamic-to-top' ).' <span id="border-val"></span>px.' );
448
+ }
449
  }
450
 
 
451
 
452
+ /**
453
+ * @package Dynamic To Top
454
+ * @subpackage Options
455
+ * @since 3.0
456
+ * @return string
457
+ */
458
 
459
+ if ( ! function_exists( 'mv_dynamic_to_top_field_border_radius' ) ) {
460
+ function mv_dynamic_to_top_field_border_radius() {
461
+ echo mv_dynamic_to_top_do_slider( 'radius', '9', __( 'Button border radius', 'dynamic-to-top' ).' <span id="radius-val"></span>px.' );
462
+ }
463
  }
464
 
465
  // TEXTFIELDS /////////////////////////
466
 
 
467
 
468
+ /**
469
+ * @package Dynamic To Top
470
+ * @subpackage Options
471
+ * @since 3.0
472
+ * @return string
473
+ */
474
 
475
+ if ( ! function_exists( 'mv_dynamic_to_top_field_distance' ) ) {
476
+ function mv_dynamic_to_top_field_distance() {
477
+ echo mv_dynamic_to_top_do_textfield( 'distance', 300, __( 'Distance from top to show the button. ( Pixels )', 'dynamic-to-top' ) );
478
+ }
479
  }
480
 
481
+
482
+ /**
483
+ * @package Dynamic To Top
484
+ * @subpackage Options
485
+ * @since 3.0
486
+ * @return string
487
+ */
488
+
489
+ if ( ! function_exists( 'mv_dynamic_to_top_field_text' ) ) {
490
+ function mv_dynamic_to_top_field_text() {
491
+ echo mv_dynamic_to_top_do_textfield( 'text', __( 'To Top', 'dynamic-to-top' ), __( 'Text displayed on the button.', 'dynamic-to-top' ), 'regular-text' );
492
+ }
493
  }
494
 
495
  // CHECKBOXES /////////////////////////
496
 
497
+
498
+ /**
499
+ * @package Dynamic To Top
500
+ * @subpackage Options
501
+ * @since 3.0
502
+ * @return string
503
+ */
504
+
505
+ if ( ! function_exists( 'mv_dynamic_to_top_field_prevent_on_mobile' ) ) {
506
+ function mv_dynamic_to_top_field_prevent_on_mobile() {
507
+ echo mv_dynamic_to_top_do_checkbox( 'prevent_on_mobile', __( 'Yes', 'dynamic-to-top' ), false, __( 'Disable the button on mobile browsers.', 'dynamic-to-top' ) );
508
+ }
509
+ }
510
+
511
+
512
+ /**
513
+ * @package Dynamic To Top
514
+ * @subpackage Options
515
+ * @since 3.0
516
+ * @return string
517
+ */
518
+
519
+ if ( ! function_exists( 'mv_dynamic_to_top_field_text_version' ) ) {
520
+ function mv_dynamic_to_top_field_text_version() {
521
+ echo mv_dynamic_to_top_do_checkbox( 'text_version', __( 'Yes', 'dynamic-to-top' ), false, __( 'Show a text version instead of the arrow up icon.', 'dynamic-to-top' ) );
522
+ }
523
+ }
524
+
525
+
526
+ /**
527
+ * @package Dynamic To Top
528
+ * @subpackage Options
529
+ * @since 3.0
530
+ * @return string
531
+ */
532
+
533
+ if ( ! function_exists( 'mv_dynamic_to_top_field_inset' ) ) {
534
+ function mv_dynamic_to_top_field_inset() {
535
+ echo mv_dynamic_to_top_do_checkbox( 'inset', __( 'Yes', 'dynamic-to-top' ), true, __( 'Add CSS3 inset-highlight.', 'dynamic-to-top' ) );
536
+ }
537
+ }
538
+
539
+
540
+ /**
541
+ * @package Dynamic To Top
542
+ * @subpackage Options
543
+ * @since 3.0
544
+ * @return string
545
+ */
546
+
547
+ if ( ! function_exists( 'mv_dynamic_to_top_field_shadow' ) ) {
548
+ function mv_dynamic_to_top_field_shadow() {
549
+ echo mv_dynamic_to_top_do_checkbox( 'shadow', __( 'Yes', 'dynamic-to-top' ), true, __( 'Add a CSS3 shadow.', 'dynamic-to-top' ) );
550
+ }
551
+ }
552
+
553
+
554
+ /**
555
+ * @package Dynamic To Top
556
+ * @subpackage Options
557
+ * @since 3.0
558
+ * @return string
559
+ */
560
+
561
+ if ( ! function_exists( 'mv_dynamic_to_top_field_weight' ) ) {
562
+ function mv_dynamic_to_top_field_bold() {
563
+ echo mv_dynamic_to_top_do_checkbox( 'bold', __( 'Yes', 'dynamic-to-top' ), true, __( 'Make the text bold.', 'dynamic-to-top' ) );
564
+ }
565
+ }
566
+
567
+
568
+ /**
569
+ * @package Dynamic To Top
570
+ * @subpackage Options
571
+ * @since 3.0
572
+ * @return string
573
+ */
574
+
575
+ if ( ! function_exists( 'mv_dynamic_to_top_field_text_shadow' ) ) {
576
+ function mv_dynamic_to_top_field_text_shadow() {
577
+ echo mv_dynamic_to_top_do_checkbox( 'text_shadow', __( 'Yes', 'dynamic-to-top' ), true, __( 'Add a subtle text shadow.', 'dynamic-to-top' ) );
578
+ }
579
  }
580
  /*
581
  |--------------------------------------------------------------------------
583
  |--------------------------------------------------------------------------
584
  */
585
 
586
+
587
+ /**
588
+ * Do Checkbox
589
+ *
590
+ * Generates a checkbox.
591
+ *
592
+ * @package Dynamic To Top
593
+ * @subpackage Options
594
+ * @since 3.0
595
+ * @return string
596
+ */
597
+
598
+ if ( ! function_exists( 'mv_dynamic_to_top_do_checkbox' ) ) {
599
+ function mv_dynamic_to_top_do_checkbox( $meta, $label="Yes", $checked=false, $desc = "" )
600
+ {
601
+
602
+ $options_db = get_option( 'dynamic_to_top' );
603
+
604
+ if ( isset( $options_db[$meta] ) ) {
605
+
606
+ // Old values support for backwards compatibility.
607
+ if ( $options_db[$meta] == "1" || $options_db[$meta] == 'yes' || $options_db[$meta] == 'Yes' )
608
+ $c = 'checked="checked"';
609
+ else
610
+ $c = '';
611
+ } else {
612
+ if ( $checked == true )
613
+ $c = 'checked="checked"';
614
+ else
615
+ $c = '';
616
+ }
617
+
618
+ if ( $desc != "" )
619
+ $desc = '<div class="desc">'.$desc.'</div>';
620
+
621
+ $sanitized_meta_title = str_replace( '_', '-', sanitize_title( $meta ) );
622
+
623
+ return '<input type="checkbox" name="dynamic_to_top['.$meta.']" value="1" '.$c.' id="checkbox-'.$sanitized_meta_title.'" /> '.$label.$desc;
624
+ }
625
+ }
626
+
627
+
628
+ /**
629
+ * Do Textfield
630
+ *
631
+ * Generates a Textfield.
632
+ *
633
+ * @package Dynamic To Top
634
+ * @subpackage Options
635
+ * @since 3.0
636
+ * @return string
637
+ */
638
+
639
+ if ( ! function_exists( 'mv_dynamic_to_top_do_textfield' ) ) {
640
+ function mv_dynamic_to_top_do_textfield( $meta, $value = "", $desc = "", $class = "" )
641
+ {
642
+
643
+ $options_db = get_option( 'dynamic_to_top' );
644
+
645
+ if ( isset( $options_db[$meta] ) )
646
+ $value = $options_db[$meta];
647
+
648
+ if ( $desc != "" )
649
+ $desc = '<div class="desc">'.$desc.'</div>';
650
+
651
+ if ( $class != "" )
652
+ $class = 'class="'.$class.'"';
653
+
654
+ $sanitized_meta_title = str_replace( '_', '-', sanitize_title( $meta ) );
655
+
656
+ return '<input type="text" id="text-'.$sanitized_meta_title.'" name="dynamic_to_top['.$meta.']" '.$class.' value="'.$value.'" /> '.$desc;
657
+ }
658
+ }
659
+
660
+
661
+ /**
662
+ * Do Select Box
663
+ *
664
+ * Generate a select box.
665
+ *
666
+ * @package Dynamic To Top
667
+ * @subpackage Options
668
+ * @since 3.0
669
+ * @return string
670
+ */
671
+
672
+ if ( ! function_exists( 'mv_dynamic_to_top_do_select' ) ) {
673
+ function mv_dynamic_to_top_do_select( $meta, $options = array(), $value = "", $desc = "" )
674
+ {
675
+ $options_out = "";
676
+
677
+ $options_db = get_option( 'dynamic_to_top' );
678
+
679
+ if ( isset( $options_db[$meta] ) )
680
+ $value = $options_db[$meta];
681
+
682
+ $value = sanitize_title( $value );
683
+
684
+ foreach ( $options as $option => $label ) {
685
+ $selected = "";
686
+
687
+ $option_slug = sanitize_title( $option );
688
+
689
+ if ( $value == $option_slug )
690
+ $selected = 'selected="selected"';
691
+
692
+ $options_out .= '<option name="'.sanitize_title( $option ).'" '.$selected.' >'.$label.'</option>';
693
+ }
694
+
695
+ if ( $desc != "" )
696
+ $desc = '<div class="desc">'.$desc.'</div>';
697
+
698
+ $sanitized_meta_title = str_replace( '_', '-', sanitize_title( $meta ) );
699
+
700
+ return '<select name="dynamic_to_top['.$meta.']" id="select-'.$sanitized_meta_title.'"> '.$options_out.'</select>'.$desc;
701
+ }
702
+ }
703
+
704
+
705
+ /**
706
+ * Do Textfield Color
707
+ *
708
+ * Generates a Textfield with Farbtastic.
709
+ *
710
+ * @package Dynamic To Top
711
+ * @subpackage Options
712
+ * @since 3.0
713
+ * @return string
714
+ */
715
+
716
+ if ( ! function_exists( 'mv_dynamic_to_top_do_textfield_color' ) ) {
717
+ function mv_dynamic_to_top_do_textfield_color( $meta, $value = "", $desc = "", $class = "" )
718
+ {
719
+ $options_db = get_option( 'dynamic_to_top' );
720
+
721
+ if ( isset( $options_db[$meta] ) )
722
+ $value = $options_db[$meta];
723
+
724
+ if ( $desc != "" )
725
+ $desc = '<div class="desc">'.$desc.'</div>';
726
+
727
+ if ( $class != "" )
728
+ $class .= " ";
729
+
730
+ $class = 'class="'.$class.'colorvalue"';
731
+
732
+ $sanitized_meta_title = str_replace( '_', '-', sanitize_title( $meta ) );
733
+
734
+ $out = '<input type="text" name="dynamic_to_top['.$meta.']" id="farbtastic-'.$sanitized_meta_title.'" '.$class.' value="'.$value.'" />';
735
+ $out .= '<a class="picker hide-if-no-js" href="#" data-closed="'.__( 'close', 'dynamic-to-top' ).'" data-open="'.__( 'select a color', 'dynamic-to-top' ).'">'.__( 'select a color', 'dynamic-to-top' ).'</a>';
736
+ $out .= '<div id="farbtastic-picker-'.$sanitized_meta_title.'" class="dtt-farbtastic"></div>';
737
+ $out .= $desc;
738
+
739
+ return $out;
740
+ }
741
+ }
742
+
743
+
744
+ /**
745
+ * Do Textfield Color
746
+ *
747
+ * Generates a Textfield with a slider.
748
+ *
749
+ * @package Dynamic To Top
750
+ * @subpackage Options
751
+ * @return string
752
+ */
753
+
754
+ if ( ! function_exists( 'mv_dynamic_to_top_do_slider' ) ) {
755
+ function mv_dynamic_to_top_do_slider( $meta, $value = "", $desc = "", $class = "" )
756
+ {
757
+ $options_db = get_option( 'dynamic_to_top' );
758
+
759
+ if ( isset( $options_db[$meta] ) )
760
+ $value = $options_db[$meta];
761
+
762
+ if ( $desc != "" )
763
+ $desc = '<div class="desc">'.$desc.'</div>';
764
+
765
+ if ( $class != "" )
766
+ $class .= " ";
767
+
768
+ $class = 'class="'.$class.'to-top-slider"';
769
+
770
+ $sanitized_meta_title = str_replace( '_', '-', sanitize_title( $meta ) );
771
+
772
+ return '<div id="slider-picker-'.$sanitized_meta_title.'" class="dtt-slider"></div><input type="text" name="dynamic_to_top['.$meta.']" id="slider-'.$sanitized_meta_title.'" '.$class.' value="'.$value.'" />'.$desc;
773
+ }
 
 
 
 
774
  }
js/dynamic.to.top.dev.js CHANGED
@@ -11,10 +11,10 @@ var mv_dynamic_to_top;
11
  jQuery.fn.DynamicToTop = function (options) {
12
  var defaults = {
13
  text: mv_dynamic_to_top.text,
14
- min: mv_dynamic_to_top.min,
15
  fade_in: 600,
16
  fade_out: 400,
17
- speed: mv_dynamic_to_top.speed,
18
  easing: mv_dynamic_to_top.easing,
19
  version: mv_dynamic_to_top.version,
20
  id: 'dynamic-to-top'
11
  jQuery.fn.DynamicToTop = function (options) {
12
  var defaults = {
13
  text: mv_dynamic_to_top.text,
14
+ min: parseInt(mv_dynamic_to_top.min, 10),
15
  fade_in: 600,
16
  fade_out: 400,
17
+ speed: parseInt(mv_dynamic_to_top.speed, 10),
18
  easing: mv_dynamic_to_top.easing,
19
  version: mv_dynamic_to_top.version,
20
  id: 'dynamic-to-top'
js/dynamic.to.top.min.js CHANGED
@@ -6,6 +6,7 @@
6
  * @sksmatt
7
  *
8
  */
9
- var mv_dynamic_to_top;(function($){jQuery.fn.DynamicToTop=function(options){var defaults={text:mv_dynamic_to_top.text,min:mv_dynamic_to_top.min,fade_in:600,fade_out:400,speed:mv_dynamic_to_top.speed,easing:mv_dynamic_to_top.easing,version:mv_dynamic_to_top.version,id:'dynamic-to-top'},settings=$.extend(defaults,options);if(settings.version===""||settings.version==="0"){settings.text='<span>&nbsp;</span>';}
10
- var $toTop=$('<a href=\"#\" id=\"'+settings.id+'\"></a>').html(settings.text);$('body').append($toTop);$toTop.hide().click(function(){$('html, body').stop().animate({scrollTop:0},settings.speed,settings.easing);return false;});$(window).scroll(function(){var sd=jQuery(window).scrollTop();if(typeof document.body.style.maxHeight==="undefined"){$toTop.css({'position':'absolute','top':jQuery(window).scrollTop()+$(window).height()-mv_dynamic_to_top.margin});}
11
- if(sd>settings.min){$toTop.fadeIn(settings.fade_in);}else{$toTop.fadeOut(settings.fade_out);}});};$('body').DynamicToTop();})(jQuery);
 
6
  * @sksmatt
7
  *
8
  */
9
+ var mv_dynamic_to_top;(function($,mv_dynamic_to_top){jQuery.fn.DynamicToTop=function(options){var defaults={text:mv_dynamic_to_top.text,min:parseInt(mv_dynamic_to_top.min,10),fade_in:600,fade_out:400,speed:parseInt(mv_dynamic_to_top.speed,10),easing:mv_dynamic_to_top.easing,version:mv_dynamic_to_top.version,id:'dynamic-to-top'},settings=$.extend(defaults,options);if(settings.version===""||settings.version==='0'){settings.text='<span>&nbsp;</span>';}
10
+ if(!$.isFunction(settings.easing)){settings.easing='linear';}
11
+ var $toTop=$('<a href=\"#\" id=\"'+settings.id+'\"></a>').html(settings.text);$toTop.hide().appendTo('body').click(function(){$('html, body').stop().animate({scrollTop:0},settings.speed,settings.easing);return false;});$(window).scroll(function(){var sd=jQuery(window).scrollTop();if(typeof document.body.style.maxHeight==="undefined"){$toTop.css({'position':'absolute','top':sd+$(window).height()-mv_dynamic_to_top.margin});}
12
+ if(sd>settings.min){$toTop.fadeIn(settings.fade_in);}else{$toTop.fadeOut(settings.fade_out);}});};$('body').DynamicToTop();})(jQuery,mv_dynamic_to_top);
js/dynamic.to.top.settings.js CHANGED
@@ -8,14 +8,13 @@
8
  */
9
  jQuery(document).ready(function ($) {
10
 
11
- // GRABA GRABA
12
  /////////////////////////////////////////////////////////
13
 
14
  var preview = $('#dynamic-to-top-button'),
15
  preview_button_version = $('#dynamic-to-top-button #dtt-image'),
16
  preview_text_version = $('#dynamic-to-top-button #dtt-text'),
17
- hide_on_button = $('#text-text, #slider-font-size, #checkbox-bold, #checkbox-text-shadow, #farbtastic-text-color, #farbtastic-shadow-color').parent().parent(),
18
- update_fields = '#checkbox-bold, #checkbox-inset, #checkbox-shadow, #checkbox-text-shadow, .colorvalue';
19
 
20
  // INITIALIZE
21
  /////////////////////////////////////////////////////////
@@ -30,28 +29,30 @@ jQuery(document).ready(function ($) {
30
  $('#checkbox-text-version').on('click', function () {
31
  toggle_text_version();
32
  });
33
-
34
- $(update_fields).on('change', function () {
35
  update_preview()
36
  });
 
37
  $('#select-position').on('change', function () {
38
  update_position();
39
  });
 
40
  $('#text-text').on('keyup', function () {
41
  update_preview()
42
  });
 
43
  $('.ddt-bg-colors a').on('click',function (e) {
44
  e.preventDefault();
45
- var color = $(this).attr('title');
46
- $('#dynamic-to-top-preview').css('background-color', color);
47
  });
48
 
49
  // SLIDERS
50
  /////////////////////////////////////////////////////////
51
 
52
- // Slider Radius
53
- var slider = jQuery("#slider-radius").hide();
54
- var slider_val = jQuery('span#radius-val').html(slider.val());
55
 
56
  jQuery('#slider-picker-radius').slider({
57
  range: "min",
@@ -65,9 +66,9 @@ jQuery(document).ready(function ($) {
65
  }
66
  });
67
 
68
- // Slider Border Width
69
- var slider_2 = jQuery("#slider-border-width").hide();
70
- var slider_val_2 = jQuery('span#border-val').html(slider_2.val());
71
 
72
  jQuery('#slider-picker-border-width').slider({
73
  range: "min",
@@ -81,14 +82,14 @@ jQuery(document).ready(function ($) {
81
  }
82
  });
83
 
84
- // Slider Speed
85
- var slider_3 = jQuery('#slider-speed').hide();
86
- var slider_val_3 = jQuery('span#speed-val').html(slider_3.val());
87
 
88
  jQuery('#slider-picker-speed').slider({
89
  range: "max",
90
  value: slider_3.val(),
91
- min: 600,
92
  step: 100,
93
  max: 3000,
94
  slide: function (event, ui) {
@@ -97,9 +98,9 @@ jQuery(document).ready(function ($) {
97
  }
98
  });
99
 
100
- // Slider Padding Top/Bottom
101
- var slider_4 = jQuery("#slider-padding-top-bottom").hide();
102
- var slider_val_4 = jQuery('span#padding-top-bottom-val').html(slider_4.val());
103
 
104
  jQuery('#slider-picker-padding-top-bottom').slider({
105
  range: "min",
@@ -116,9 +117,9 @@ jQuery(document).ready(function ($) {
116
  }
117
  });
118
 
119
- // Slider Padding Left/Right
120
- var slider_5 = jQuery("#slider-padding-left-right").hide();
121
- var slider_val_5 = jQuery('span#padding-left-right-val').html(slider_5.val());
122
 
123
  jQuery('#slider-picker-padding-left-right').slider({
124
  range: "min",
@@ -135,9 +136,9 @@ jQuery(document).ready(function ($) {
135
  }
136
  });
137
 
138
- // Slider Font Size
139
- var slider_6 = jQuery("#slider-font-size").hide();
140
- var slider_val_6 = jQuery('span#font-size-val').html(slider_6.val());
141
 
142
  jQuery('#slider-picker-font-size').slider({
143
  range: "min",
@@ -156,6 +157,7 @@ jQuery(document).ready(function ($) {
156
 
157
  jQuery('.dtt-slider').css('width', '25em');
158
 
 
159
  // PICKERS
160
  /////////////////////////////////////////////////////////
161
 
@@ -179,6 +181,18 @@ jQuery(document).ready(function ($) {
179
  });
180
  },
181
  tooglePicker = function() {
 
 
 
 
 
 
 
 
 
 
 
 
182
  this.picker.toggle();
183
  var open = this.anchor.attr('data-open');
184
  if (this.anchor.html() === open) {
@@ -260,7 +274,6 @@ jQuery(document).ready(function ($) {
260
  }
261
 
262
  function update_preview() {
263
- prevew = new Object;
264
  preview.text = $('#text-text').val();
265
  preview.border_width = $('#slider-border-width').val();
266
  preview.border_radius = $('#slider-radius').val();
@@ -314,7 +327,5 @@ jQuery(document).ready(function ($) {
314
  } else {
315
  preview.css('text-shadow', '');
316
  }
317
-
318
  }
319
-
320
  });
8
  */
9
  jQuery(document).ready(function ($) {
10
 
11
+ // GRAB ELEMENTS
12
  /////////////////////////////////////////////////////////
13
 
14
  var preview = $('#dynamic-to-top-button'),
15
  preview_button_version = $('#dynamic-to-top-button #dtt-image'),
16
  preview_text_version = $('#dynamic-to-top-button #dtt-text'),
17
+ hide_on_button = $('#text-text, #slider-font-size, #checkbox-bold, #checkbox-text-shadow, #farbtastic-text-color, #farbtastic-shadow-color').parent().parent();
 
18
 
19
  // INITIALIZE
20
  /////////////////////////////////////////////////////////
29
  $('#checkbox-text-version').on('click', function () {
30
  toggle_text_version();
31
  });
32
+
33
+ $('#checkbox-bold, #checkbox-inset, #checkbox-shadow, #checkbox-text-shadow, .colorvalue').on('change', function () {
34
  update_preview()
35
  });
36
+
37
  $('#select-position').on('change', function () {
38
  update_position();
39
  });
40
+
41
  $('#text-text').on('keyup', function () {
42
  update_preview()
43
  });
44
+
45
  $('.ddt-bg-colors a').on('click',function (e) {
46
  e.preventDefault();
47
+ $('#dynamic-to-top-preview').css('background-color', $(this).attr('title') || 'white');
 
48
  });
49
 
50
  // SLIDERS
51
  /////////////////////////////////////////////////////////
52
 
53
+ // Radius
54
+ var slider = jQuery("#slider-radius").hide(),
55
+ slider_val = jQuery('span#radius-val').html(slider.val());
56
 
57
  jQuery('#slider-picker-radius').slider({
58
  range: "min",
66
  }
67
  });
68
 
69
+ // Border Width
70
+ var slider_2 = jQuery("#slider-border-width").hide(),
71
+ slider_val_2 = jQuery('span#border-val').html(slider_2.val());
72
 
73
  jQuery('#slider-picker-border-width').slider({
74
  range: "min",
82
  }
83
  });
84
 
85
+ // Speed
86
+ var slider_3 = jQuery('#slider-speed').hide(),
87
+ slider_val_3 = jQuery('span#speed-val').html(slider_3.val());
88
 
89
  jQuery('#slider-picker-speed').slider({
90
  range: "max",
91
  value: slider_3.val(),
92
+ min: 300,
93
  step: 100,
94
  max: 3000,
95
  slide: function (event, ui) {
98
  }
99
  });
100
 
101
+ // Padding Top/Bottom
102
+ var slider_4 = jQuery("#slider-padding-top-bottom").hide(),
103
+ slider_val_4 = jQuery('span#padding-top-bottom-val').html(slider_4.val());
104
 
105
  jQuery('#slider-picker-padding-top-bottom').slider({
106
  range: "min",
117
  }
118
  });
119
 
120
+ // Padding Left/Right
121
+ var slider_5 = jQuery("#slider-padding-left-right").hide(),
122
+ slider_val_5 = jQuery('span#padding-left-right-val').html(slider_5.val());
123
 
124
  jQuery('#slider-picker-padding-left-right').slider({
125
  range: "min",
136
  }
137
  });
138
 
139
+ // Font Size
140
+ var slider_6 = jQuery("#slider-font-size").hide(),
141
+ slider_val_6 = jQuery('span#font-size-val').html(slider_6.val());
142
 
143
  jQuery('#slider-picker-font-size').slider({
144
  range: "min",
157
 
158
  jQuery('.dtt-slider').css('width', '25em');
159
 
160
+
161
  // PICKERS
162
  /////////////////////////////////////////////////////////
163
 
181
  });
182
  },
183
  tooglePicker = function() {
184
+ var id = this.picker.attr('id');
185
+ $('.dtt-farbtastic').each(function(){
186
+ if ( $(this).attr('id') != id ) {
187
+ var other_prev = $(this).prev();
188
+ if ( other_prev.hasClass('picker-opened') ) {
189
+ var open = other_prev.attr('data-open');
190
+ other_prev.removeClass('picker-opened');
191
+ other_prev.html(open);
192
+ $(this).toggle();
193
+ }
194
+ }
195
+ });
196
  this.picker.toggle();
197
  var open = this.anchor.attr('data-open');
198
  if (this.anchor.html() === open) {
274
  }
275
 
276
  function update_preview() {
 
277
  preview.text = $('#text-text').val();
278
  preview.border_width = $('#slider-border-width').val();
279
  preview.border_radius = $('#slider-radius').val();
327
  } else {
328
  preview.css('text-shadow', '');
329
  }
 
330
  }
 
331
  });
js/libs/jquery.ui.mouse.js CHANGED
@@ -8,7 +8,7 @@
8
  * http://docs.jquery.com/UI/Mouse
9
  *
10
  * Depends:
11
- * jquery.ui.widget.js
12
  */
13
  (function( $, undefined ) {
14
 
8
  * http://docs.jquery.com/UI/Mouse
9
  *
10
  * Depends:
11
+ * jquery.ui.widget.js
12
  */
13
  (function( $, undefined ) {
14
 
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: sksmatt
3
  Donate link: http://www.mattvarone.com/donate/
4
  Tags: Scroll, To top, Button, jQuery, Dynamic, UI, Automatic, Enhance, UX
5
  Requires at least: 3.3
6
- Tested up to: 3.3
7
- Stable tag: 3.1.9.1
8
 
9
  Adds an automatic and dynamic "To Top" button to easily scroll long pages back to the top.
10
 
@@ -23,6 +23,8 @@ It features an intuitive control panel to style and adjust to each website's nee
23
  * Uninstall included.
24
  * Ships with Spanish, French, Arabic and Bulgarian translations.
25
 
 
 
26
  == Installation ==
27
 
28
  1. Unzip files.
@@ -41,6 +43,10 @@ It features an intuitive control panel to style and adjust to each website's nee
41
 
42
  == Change log ==
43
 
 
 
 
 
44
  = 3.1.9.1 =
45
  * Code fix.
46
 
3
  Donate link: http://www.mattvarone.com/donate/
4
  Tags: Scroll, To top, Button, jQuery, Dynamic, UI, Automatic, Enhance, UX
5
  Requires at least: 3.3
6
+ Tested up to: 3.3.2
7
+ Stable tag: 3.2
8
 
9
  Adds an automatic and dynamic "To Top" button to easily scroll long pages back to the top.
10
 
23
  * Uninstall included.
24
  * Ships with Spanish, French, Arabic and Bulgarian translations.
25
 
26
+ Would you like to help translate the plugin into more languages? [Contact Matt](http://www.mattvarone.com/contact/ "Contact Matt").
27
+
28
  == Installation ==
29
 
30
  1. Unzip files.
43
 
44
  == Change log ==
45
 
46
+ = 3.2 =
47
+ * Fixes the speed slider/attribute.
48
+ * Code improvements.
49
+
50
  = 3.1.9.1 =
51
  * Code fix.
52
 
uninstall.php CHANGED
@@ -2,12 +2,14 @@
2
  /**
3
  * Dynamic To Top Uninstall
4
  *
5
- * @package Dynamic To Top
6
- * @author Matt Varone
 
7
  */
8
 
9
  // If uninstall not called from WordPress exit
10
  if( ! defined( 'WP_UNINSTALL_PLUGIN' ) )
11
  exit();
 
12
  // Delete option from options table
13
  delete_option( 'dynamic_to_top' );
2
  /**
3
  * Dynamic To Top Uninstall
4
  *
5
+ * @package Dynamic To Top
6
+ * @subpackage Uninstall
7
+ * @author Matt Varone
8
  */
9
 
10
  // If uninstall not called from WordPress exit
11
  if( ! defined( 'WP_UNINSTALL_PLUGIN' ) )
12
  exit();
13
+
14
  // Delete option from options table
15
  delete_option( 'dynamic_to_top' );