PluginProbe ʕ •ᴥ•ʔ
WPFront Scroll Top / 1.5
WPFront Scroll Top v1.5
1.5 1.6 1.6.1 1.6.2 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.1 2.1.1 2.2 3.0.0 3.0.1 trunk 1.0 1.0.1 1.1 1.1.1 1.2 1.3 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5
wpfront-scroll-top / classes / class-wpfront-scroll-top-options.php
wpfront-scroll-top / classes Last commit date
base 9 years ago class-wpfront-scroll-top-options.php 9 years ago class-wpfront-scroll-top.php 9 years ago
class-wpfront-scroll-top-options.php
128 lines
1 <?php
2
3 /*
4 WPFront Scroll Top Plugin
5 Copyright (C) 2013, WPFront.com
6 Website: wpfront.com
7 Contact: syam@wpfront.com
8
9 WPFront Scroll Top Plugin is distributed under the GNU General Public License, Version 3,
10 June 2007. Copyright (C) 2007 Free Software Foundation, Inc., 51 Franklin
11 St, Fifth Floor, Boston, MA 02110, USA
12
13 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
14 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
17 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */
24
25 require_once("base/class-wpfront-options-base.php");
26
27 if (!class_exists('WPFront_Scroll_Top_Options')) {
28
29 /**
30 * Options class for WPFront Scroll Top plugin
31 *
32 * @author Syam Mohan <syam@wpfront.com>
33 * @copyright 2013 WPFront.com
34 */
35 class WPFront_Scroll_Top_Options extends WPFront_Options_Base {
36
37 function __construct($optionName, $pluginSlug) {
38 parent::__construct($optionName, $pluginSlug);
39
40 //add the options required for this plugin
41 $this->addOption('enabled', 'bit', FALSE)->__('Enabled');
42 $this->addOption('javascript_async', 'bit', FALSE)->__('JavaScript Async');
43 $this->addOption('scroll_offset', 'int', 100, array($this, 'validate_zero_positive'))->__('Scroll Offset');
44 $this->addOption('button_width', 'int', 0, array($this, 'validate_zero_positive'));
45 $this->addOption('button_height', 'int', 0, array($this, 'validate_zero_positive'));
46 $this->addOption('button_opacity', 'int', 80, array($this, 'validate_range_0_100'))->__('Button Opacity');
47 $this->addOption('button_fade_duration', 'int', 200, array($this, 'validate_zero_positive'))->__('Button Fade Duration');
48 $this->addOption('scroll_duration', 'int', 400, array($this, 'validate_zero_positive'))->__('Scroll Duration');
49 $this->addOption('auto_hide', 'bit', FALSE)->__('Auto Hide');
50 $this->addOption('auto_hide_after', 'float', 2, array($this, 'validate_zero_positive'))->__('Auto Hide After');
51 $this->addOption('hide_small_device', 'bit', FALSE)->__('Hide on Small Devices');
52 $this->addOption('small_device_width', 'int', 640, array($this, 'validate_zero_positive'))->__('Small Device Max Width');
53 $this->addOption('hide_small_window', 'bit', FALSE)->__('Hide on Small Window');
54 $this->addOption('small_window_width', 'int', 640, array($this, 'validate_zero_positive'))->__('Small Window Max Width');
55 $this->addOption('button_style', 'string', 'image', array($this, 'validate_button_style'))->__('Button Style');
56 $this->addOption('image_alt', 'string', '')->__('Image ALT');
57 $this->addOption('hide_wpadmin', 'bit', FALSE)->__('Hide on WP-ADMIN');
58 $this->addOption('hide_iframe', 'bit', FALSE)->__('Hide on iframes');
59
60 $this->addOption('location', 'int', 1, array($this, 'validate_range_1_4'))->__('Location');
61 $this->addOption('marginX', 'int', 20)->__('Margin X');
62 $this->addOption('marginY', 'int', 20)->__('Margin Y');
63
64 $this->addOption('text_button_text', 'string', '')->__('Text');
65 $this->addOption('text_button_text_color', 'string', '#ffffff', array($this, 'validate_color'))->__('Text Color');
66 $this->addOption('text_button_background_color', 'string', '#000000', array($this, 'validate_color'))->__('Background Color');
67 $this->addOption('text_button_css', 'string', '')->__('Custom CSS');
68
69 $this->addOption('display_pages', 'int', '1', array($this, 'validate_display_pages'))->__('Display on Pages');
70 $this->addOption('include_pages', 'string', '');
71 $this->addOption('exclude_pages', 'string', '');
72
73 $this->addOption('image', 'string', '1.png');
74 $this->addOption('custom_url', 'string', '');
75 }
76
77 protected function validate_range_0_100($arg) {
78 if ($arg < 0)
79 return 0;
80
81 if ($arg > 100)
82 return 100;
83
84 return $arg;
85 }
86
87 protected function validate_range_1_4($arg) {
88 if ($arg < 1)
89 return 1;
90
91 if ($arg > 4)
92 return 4;
93
94 return $arg;
95 }
96
97 protected function validate_button_style($arg) {
98 if ($arg == 'text')
99 return $arg;
100
101 return 'image';
102 }
103
104 protected function validate_color($arg) {
105 if (strlen($arg) != 7)
106 return '#ffffff';
107
108 if (strpos($arg, '#') != 0)
109 return '#ffffff';
110
111 return $arg;
112 }
113
114 protected function validate_display_pages($arg) {
115 if ($arg < 1) {
116 return 1;
117 }
118
119 if ($arg > 3) {
120 return 3;
121 }
122
123 return $arg;
124 }
125
126 }
127
128 }