WPFront Scroll Top - Version 2.0.1

Version Description

  • Link to element.
  • Link to page.
  • Select image from media library easily.
  • Performance improvements.
Download this release

Release Info

Developer syammohanm
Plugin Icon 128x128 WPFront Scroll Top
Version 2.0.1
Comparing to
See all releases

Code changes from version 1.6.2 to 2.0.1

classes/base/class-wpfront-base.php DELETED
@@ -1,203 +0,0 @@
1
- <?php
2
-
3
- /*
4
- WPFront Plugins Base
5
- Copyright (C) 2013, WPFront.com
6
- Website: wpfront.com
7
- Contact: syam@wpfront.com
8
-
9
- WPFront Plugins are 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
- namespace WPFront\Scroll_Top;
26
-
27
- require_once("class-wpfront-static.php");
28
-
29
- /**
30
- * Plugin framework base class
31
- *
32
- * @author Syam Mohan <syam@wpfront.com>
33
- * @copyright 2013 WPFront.com
34
- */
35
- class WPFront_Base_ST {
36
-
37
- private $plugin_slug;
38
- private $options_page_slug;
39
- private $settingsLink;
40
- private $FAQLink;
41
-
42
- protected $pluginURLRoot;
43
- protected $pluginDIRRoot;
44
- private static $menu_data = array();
45
-
46
- function __construct($file, $pluginSlug) {
47
- $this->plugin_slug = $pluginSlug;
48
- $this->options_page_slug = $this->plugin_slug;
49
-
50
- $this->pluginURLRoot = plugins_url() . '/' . $this->plugin_slug . '/';
51
- $this->pluginDIRRoot = dirname($file) . '/../';
52
-
53
- add_action('init', array(&$this, 'init'));
54
- add_action('plugins_loaded', array(&$this, 'plugins_loaded_base'));
55
-
56
- //register actions
57
- if (is_admin()) {
58
- add_action('admin_init', array(&$this, 'admin_init'));
59
- add_action('admin_menu', array(&$this, 'admin_menu'));
60
- add_filter('plugin_action_links', array(&$this, 'action_links'), 10, 2);
61
- } else {
62
- add_action('wp_enqueue_scripts', array(&$this, 'enqueue_styles'));
63
- add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts'));
64
- }
65
- }
66
-
67
- protected function add_menu($title, $link) {
68
- self::$menu_data[] = array(
69
- 'title' => $title,
70
- 'link' => $link,
71
- 'this' => $this,
72
- 'slug' => $this->options_page_slug
73
- );
74
- }
75
-
76
- public function init() {
77
-
78
- }
79
-
80
- public function plugins_loaded_base() {
81
- //for localization
82
- //load_plugin_textdomain($this->plugin_slug, FALSE, $this->plugin_slug . '/languages/');
83
-
84
- $this->plugins_loaded();
85
- }
86
-
87
- public function plugins_loaded() {
88
-
89
- }
90
-
91
- public function admin_init() {
92
-
93
- }
94
-
95
- public function admin_menu() {
96
-
97
- }
98
-
99
- public static function submenu_compare($a, $b) {
100
- return strcmp($a[0], $b[0]);
101
- }
102
-
103
- public function action_links($links, $file) {
104
- if ($file == $this->plugin_slug . '/' . $this->plugin_slug . '.php') {
105
- $settings_link = '<a href="' . menu_page_url($this->options_page_slug, FALSE) . '">' . __('Settings', 'wpfront-scroll-top') . '</a>';
106
- array_unshift($links, $settings_link);
107
- }
108
- return $links;
109
- }
110
-
111
- public function enqueue_styles() {
112
-
113
- }
114
-
115
- public function enqueue_scripts() {
116
-
117
- }
118
-
119
- public function enqueue_options_styles() {
120
-
121
- }
122
-
123
- public function enqueue_options_scripts() {
124
-
125
- }
126
-
127
- //creates options page
128
- public function options_page() {
129
- if (!current_user_can('manage_options')) {
130
- wp_die(__('You do not have sufficient permissions to access this page.', 'wpfront-scroll-top'));
131
- return;
132
- }
133
-
134
- include($this->pluginDIRRoot . 'templates/options-template.php');
135
- }
136
-
137
- protected function options_page_header($title, $optionsGroupName) {
138
- echo '<div class="wrap">';
139
- @screen_icon($this->options_page_slug);
140
- echo '<h2>' . $title . '</h2>';
141
- echo '<div id="' . $this->options_page_slug . '-options" class="inside">';
142
- echo '<form method="post" action="options.php">';
143
- @settings_fields($optionsGroupName);
144
- @do_settings_sections($this->options_page_slug);
145
-
146
- if ((isset($_GET['settings-updated']) && $_GET['settings-updated'] == 'true') || (isset($_GET['updated']) && $_GET['updated'] == 'true')) {
147
- echo '
148
- <div class="updated">
149
- <p>
150
- <strong>' . __('If you have a caching plugin, clear the cache for the new settings to take effect.', 'wpfront-scroll-top') . '</strong>
151
- </p>
152
- </div>
153
- ';
154
- }
155
- }
156
-
157
- protected function options_page_footer($settingsLink, $FAQLink, $extraLinks = NULL) {
158
- @$this->submit_button();
159
-
160
- if ($extraLinks != NULL) {
161
- foreach ($extraLinks as $value) {
162
- echo '<a href="' . $value['href'] . '" target="' . $value['target'] . '">' . $value['text'] . '</a>';
163
- echo ' | ';
164
- }
165
- }
166
-
167
- echo '</form>';
168
- echo '</div>';
169
- echo '</div>';
170
-
171
- $this->settingsLink = $settingsLink;
172
- $this->FAQLink = $FAQLink;
173
-
174
- add_filter('admin_footer_text', array($this, 'admin_footer_text'));
175
- }
176
-
177
- public function admin_footer_text($text) {
178
- $settingsLink = sprintf('<a href="%s" target="_blank">%s</a>', 'https://wpfront.com/' . $this->settingsLink, __('Settings Description', 'wpfront-scroll-top'));
179
- $reviewLink = sprintf('<a href="%s" target="_blank">%s</a>', 'https://wordpress.org/support/plugin/' . $this->plugin_slug . '/reviews/', __('Write a Review', 'wpfront-scroll-top'));
180
- $donateLink = sprintf('<a href="%s" target="_blank">%s</a>', 'https://wpfront.com/donate/', __('Buy me a Beer or Coffee', 'wpfront-scroll-top'));
181
-
182
- return sprintf('%s | %s | %s | %s', $settingsLink, $reviewLink, $donateLink, $text);
183
- }
184
-
185
- //for compatibility
186
- public function submit_button() {
187
- if (function_exists('submit_button')) {
188
- submit_button();
189
- } else {
190
- echo '<p class="submit"><input type="submit" name="submit" id="submit" class="button button-primary" value="' . __('Save Changes', 'wpfront-scroll-top') . '" /></p>';
191
- }
192
- }
193
-
194
- public function pluginURL() {
195
- return $this->pluginURLRoot;
196
- }
197
-
198
- public function pluginDIR() {
199
- return $this->pluginDIRRoot;
200
- }
201
-
202
- }
203
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/base/class-wpfront-options-base.php CHANGED
@@ -73,18 +73,21 @@ class WPFront_Options_Base_ST {
73
  };
74
 
75
  $this->__data[$name . '_name'] = $this->__data[$name];
76
-
77
  //dynamic function returning option name for settings page
78
  $this->__data[$name . '_name']['func'] = function($self, $data) {
79
  return $self->__optionName . "[" . $data["name"] . "]";
80
  };
81
 
82
  $this->__data[$name . '_label'] = $this->__data[$name];
83
-
84
  //dynamic function returning option label for settings page
85
  $this->__data[$name . '_label']['func'] = function($self, $data) {
86
  return __($data["label"], $self->__localizeSlug);
87
  };
 
 
 
 
 
88
 
89
  $this->lastOptionName = $name;
90
  array_push($this->optionNames, $name);
73
  };
74
 
75
  $this->__data[$name . '_name'] = $this->__data[$name];
 
76
  //dynamic function returning option name for settings page
77
  $this->__data[$name . '_name']['func'] = function($self, $data) {
78
  return $self->__optionName . "[" . $data["name"] . "]";
79
  };
80
 
81
  $this->__data[$name . '_label'] = $this->__data[$name];
 
82
  //dynamic function returning option label for settings page
83
  $this->__data[$name . '_label']['func'] = function($self, $data) {
84
  return __($data["label"], $self->__localizeSlug);
85
  };
86
+
87
+ $this->__data['set_' . $name] = $this->__data[$name];
88
+ $this->__data['set_' . $name]['func'] = function($self, $data, $value) {
89
+ $self->__options[$data["name"]] = $value;
90
+ };
91
 
92
  $this->lastOptionName = $name;
93
  array_push($this->optionNames, $name);
classes/base/class-wpfront-static.php DELETED
@@ -1,66 +0,0 @@
1
- <?php
2
-
3
- /*
4
- WPFront Plugins Static Helpers
5
- Copyright (C) 2013, WPFront.com
6
- Website: wpfront.com
7
- Contact: syam@wpfront.com
8
-
9
- WPFront Plugins are 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
- namespace WPFront\Scroll_Top;
26
-
27
- /**
28
- * Plugin framework static helpers
29
- *
30
- * @author Syam Mohan <syam@wpfront.com>
31
- * @copyright 2013 WPFront.com
32
- */
33
- class WPFront_Static_ST {
34
-
35
- public static function is_admin_bar_showing() {
36
- if (function_exists('is_admin_bar_showing')) {
37
- return is_admin_bar_showing();
38
- }
39
-
40
- return FALSE;
41
- }
42
-
43
- public static function self_admin_url($path = '', $scheme = 'admin') {
44
- if (function_exists('self_admin_url'))
45
- return self_admin_url($path, $scheme);
46
-
47
- return admin_url($path, $scheme);
48
- }
49
-
50
- public static function doing_ajax() {
51
- if (defined('DOING_AJAX') && DOING_AJAX) {
52
- return TRUE;
53
- }
54
-
55
- if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
56
- return TRUE;
57
- }
58
-
59
- if (!empty($_SERVER['REQUEST_URI']) && strtolower($_SERVER['REQUEST_URI']) == '/wp-admin/async-upload.php') {
60
- return TRUE;
61
- }
62
-
63
- return FALSE;
64
- }
65
-
66
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/class-wpfront-scroll-top-options.php CHANGED
@@ -57,6 +57,12 @@ class WPFront_Scroll_Top_Options extends WPFront_Options_Base_ST {
57
  $this->addOption('hide_wpadmin', 'bit', FALSE)->label(__('Hide on WP-ADMIN', 'wpfront-scroll-top'));
58
  $this->addOption('hide_iframe', 'bit', FALSE)->label(__('Hide on iframes', 'wpfront-scroll-top'));
59
 
 
 
 
 
 
 
60
  $this->addOption('location', 'int', 1, array($this, 'validate_range_1_4'))->label(__('Location', 'wpfront-scroll-top'));
61
  $this->addOption('marginX', 'int', 20)->label(__('Margin X', 'wpfront-scroll-top'));
62
  $this->addOption('marginY', 'int', 20)->label(__('Margin Y', 'wpfront-scroll-top'));
@@ -147,6 +153,13 @@ class WPFront_Scroll_Top_Options extends WPFront_Options_Base_ST {
147
 
148
  return 'image';
149
  }
 
 
 
 
 
 
 
150
 
151
  protected function validate_color($arg) {
152
  if (strlen($arg) != 7)
@@ -169,5 +182,12 @@ class WPFront_Scroll_Top_Options extends WPFront_Options_Base_ST {
169
 
170
  return $arg;
171
  }
 
 
 
 
 
 
 
172
 
173
  }
57
  $this->addOption('hide_wpadmin', 'bit', FALSE)->label(__('Hide on WP-ADMIN', 'wpfront-scroll-top'));
58
  $this->addOption('hide_iframe', 'bit', FALSE)->label(__('Hide on iframes', 'wpfront-scroll-top'));
59
 
60
+ $this->addOption('button_action', 'string', 'top', array($this, 'validate_button_action'))->label(__('Button Action', 'wpfront-scroll-top'));
61
+ $this->addOption('button_action_page_url', 'string', '')->label(__('Page URL', 'wpfront-scroll-top'));
62
+ $this->addOption('button_action_element_selector', 'string', '')->label(__('Element CSS Selector', 'wpfront-scroll-top'));
63
+ $this->addOption('button_action_container_selector', 'string', 'html, body', array($this, 'button_action_container_selector'))->label(__('Scroll Container CSS Selector', 'wpfront-scroll-top'));
64
+ $this->addOption('button_action_element_offset', 'int', 0)->label(__('Offset', 'wpfront-scroll-top'));
65
+
66
  $this->addOption('location', 'int', 1, array($this, 'validate_range_1_4'))->label(__('Location', 'wpfront-scroll-top'));
67
  $this->addOption('marginX', 'int', 20)->label(__('Margin X', 'wpfront-scroll-top'));
68
  $this->addOption('marginY', 'int', 20)->label(__('Margin Y', 'wpfront-scroll-top'));
153
 
154
  return 'image';
155
  }
156
+
157
+ protected function validate_button_action($arg) {
158
+ if ($arg == 'element' || $arg == 'url')
159
+ return $arg;
160
+
161
+ return 'top';
162
+ }
163
 
164
  protected function validate_color($arg) {
165
  if (strlen($arg) != 7)
182
 
183
  return $arg;
184
  }
185
+
186
+ protected function button_action_container_selector($args) {
187
+ if(trim($args) === "")
188
+ return "html, body";
189
+
190
+ return $args;
191
+ }
192
 
193
  }
classes/class-wpfront-scroll-top.php CHANGED
@@ -1,295 +1,478 @@
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
- namespace WPFront\Scroll_Top;
26
-
27
- require_once("base/class-wpfront-base.php");
28
- require_once("class-wpfront-scroll-top-options.php");
29
-
30
- /**
31
- * Main class of WPFront Scroll Top plugin
32
- *
33
- * @author Syam Mohan <syam@wpfront.com>
34
- * @copyright 2013 WPFront.com
35
- */
36
- class WPFront_Scroll_Top extends WPFront_Base_ST {
37
-
38
- //Constants
39
- const VERSION = '1.6.2';
40
- const OPTIONS_GROUP_NAME = 'wpfront-scroll-top-options-group';
41
- const OPTION_NAME = 'wpfront-scroll-top-options';
42
- const PLUGIN_SLUG = 'wpfront-scroll-top';
43
-
44
- //Variables
45
- protected $iconsDIR;
46
- protected $iconsURL;
47
- protected $options;
48
- protected $markupLoaded;
49
- protected $scriptLoaded;
50
- protected $min_file_suffix;
51
-
52
- function __construct() {
53
- parent::__construct(__FILE__, self::PLUGIN_SLUG);
54
-
55
- $this->markupLoaded = FALSE;
56
- $this->min_file_suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
57
-
58
- //Root variables
59
- $this->iconsDIR = $this->pluginDIRRoot . 'images/icons/';
60
- $this->iconsURL = $this->pluginURLRoot . 'images/icons/';
61
-
62
- add_action('wp_footer', array(&$this, 'write_markup'));
63
- add_action('shutdown', array(&$this, 'shutdown_callback'));
64
- }
65
-
66
- //add scripts
67
- public function enqueue_scripts() {
68
- if ($this->enabled() == FALSE)
69
- return;
70
-
71
- $jsRoot = $this->pluginURLRoot . 'js/';
72
-
73
- wp_enqueue_script('jquery');
74
- wp_enqueue_script('wpfront-scroll-top', $jsRoot . 'wpfront-scroll-top' . $this->min_file_suffix . '.js', array('jquery'), self::VERSION, TRUE);
75
-
76
- $this->scriptLoaded = TRUE;
77
- }
78
-
79
- //add styles
80
- public function enqueue_styles() {
81
- if ($this->enabled() == FALSE)
82
- return;
83
-
84
- $cssRoot = $this->pluginURLRoot . 'css/';
85
-
86
- wp_enqueue_style('wpfront-scroll-top', $cssRoot . 'wpfront-scroll-top' . $this->min_file_suffix . '.css', array(), self::VERSION);
87
-
88
- if($this->options->button_style() == 'font-awesome') {
89
- if(!$this->options->fa_button_exclude_URL() || is_admin()) {
90
- $url = trim($this->options->fa_button_URL());
91
- $ver = FALSE;
92
- if(empty($url)) {
93
- $url = '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css';
94
- $ver = '4.7.0';
95
- }
96
- wp_enqueue_style('font-awesome', $url, array(), $ver);
97
- }
98
- }
99
- }
100
-
101
- public function admin_init() {
102
- register_setting(self::OPTIONS_GROUP_NAME, self::OPTION_NAME);
103
-
104
- $this->enqueue_styles();
105
- $this->enqueue_scripts();
106
- }
107
-
108
- public function admin_menu() {
109
- $page_hook_suffix = add_options_page(__('WPFront Scroll Top', 'wpfront-scroll-top'), __('Scroll Top', 'wpfront-scroll-top'), 'manage_options', self::PLUGIN_SLUG, array($this, 'options_page'));
110
-
111
- add_action('admin_print_scripts-' . $page_hook_suffix, array($this, 'enqueue_options_scripts'));
112
- add_action('admin_print_styles-' . $page_hook_suffix, array($this, 'enqueue_options_styles'));
113
- }
114
-
115
- public function enqueue_options_scripts() {
116
- $this->enqueue_scripts();
117
-
118
- $jsRoot = $this->pluginURLRoot . 'jquery-plugins/colorpicker/js/';
119
- wp_enqueue_script('jquery.eyecon.colorpicker', $jsRoot . 'colorpicker' . $this->min_file_suffix . '.js', array('jquery'), self::VERSION);
120
- }
121
-
122
- //options page styles
123
- public function enqueue_options_styles() {
124
- $styleRoot = $this->pluginURLRoot . 'jquery-plugins/colorpicker/css/';
125
- wp_enqueue_style('jquery.eyecon.colorpicker.colorpicker', $styleRoot . 'colorpicker' . $this->min_file_suffix . '.css', array(), self::VERSION);
126
-
127
- $styleRoot = $this->pluginURLRoot . 'css/';
128
- wp_enqueue_style('wpfront-scroll-top-options', $styleRoot . 'options' . $this->min_file_suffix . '.css', array(), self::VERSION);
129
- }
130
-
131
- public function plugins_loaded() {
132
- //load plugin options
133
- $this->options = new WPFront_Scroll_Top_Options(self::OPTION_NAME, self::PLUGIN_SLUG);
134
-
135
- if($this->options->javascript_async())
136
- add_filter('script_loader_tag', array($this, 'script_loader_tag'), 999999, 3);
137
- }
138
-
139
- public function script_loader_tag($tag, $handle, $src) {
140
- if($handle === 'wpfront-scroll-top')
141
- return '<script type="text/javascript" src="' . $src . '" async="async" defer="defer"></script>' . "\n";
142
-
143
- return $tag;
144
- }
145
-
146
- public function shutdown_callback() {
147
- if ($this->markupLoaded) {
148
- return;
149
- }
150
-
151
- $headers = headers_list();
152
- $flag = FALSE;
153
- foreach ($headers as $value) {
154
- $value = strtolower(str_replace(' ', '', $value));
155
- if (strpos($value, 'content-type:text/html') === 0) {
156
- $flag = TRUE;
157
- break;
158
- }
159
- }
160
-
161
- if ($flag)
162
- $this->write_markup();
163
- }
164
-
165
- //writes the html and script for the button
166
- public function write_markup() {
167
- if ($this->markupLoaded) {
168
- return;
169
- }
170
-
171
- if ($this->scriptLoaded != TRUE) {
172
- return;
173
- }
174
-
175
- if (WPFront_Static_ST::doing_ajax()) {
176
- return;
177
- }
178
-
179
- if ($this->enabled()) {
180
- include($this->pluginDIRRoot . 'templates/scroll-top-template.php');
181
-
182
- echo '<script type="text/javascript">';
183
- echo 'function wpfront_scroll_top_init() {';
184
- echo 'if(typeof wpfront_scroll_top == "function" && typeof jQuery !== "undefined") {';
185
- echo 'wpfront_scroll_top(' . json_encode(array(
186
- 'scroll_offset' => $this->options->scroll_offset(),
187
- 'button_width' => $this->options->button_width(),
188
- 'button_height' => $this->options->button_height(),
189
- 'button_opacity' => $this->options->button_opacity() / 100,
190
- 'button_fade_duration' => $this->options->button_fade_duration(),
191
- 'scroll_duration' => $this->options->scroll_duration(),
192
- 'location' => $this->options->location(),
193
- 'marginX' => $this->options->marginX(),
194
- 'marginY' => $this->options->marginY(),
195
- 'hide_iframe' => $this->options->hide_iframe(),
196
- 'auto_hide' => $this->options->auto_hide(),
197
- 'auto_hide_after' => $this->options->auto_hide_after(),
198
- )) . ');';
199
- echo '} else {';
200
- echo 'setTimeout(wpfront_scroll_top_init, 100);';
201
- echo '}';
202
- echo '}';
203
- echo 'wpfront_scroll_top_init();';
204
- echo '</script>';
205
- }
206
-
207
- $this->markupLoaded = TRUE;
208
- }
209
-
210
- private function enabled() {
211
- if (!$this->options->enabled())
212
- return FALSE;
213
-
214
- if ($this->options->hide_wpadmin() && is_admin())
215
- return FALSE;
216
-
217
- if (!$this->filter_pages())
218
- return FALSE;
219
-
220
- return TRUE;
221
- }
222
-
223
- private function filter_pages() {
224
- if (is_admin())
225
- return TRUE;
226
-
227
- switch ($this->options->display_pages()) {
228
- case 1:
229
- return TRUE;
230
- case 2:
231
- case 3:
232
- global $post;
233
- $ID = FALSE;
234
- if (is_home()) {
235
- $ID = 'home';
236
- } elseif(!empty($post)) {
237
- $ID = $post->ID;
238
- }
239
- if ($this->options->display_pages() == 2) {
240
- if ($ID !== FALSE) {
241
- if ($this->filter_pages_contains($this->options->include_pages(), $ID) === FALSE)
242
- return FALSE;
243
- else
244
- return TRUE;
245
- }
246
- return FALSE;
247
- }
248
- if ($this->options->display_pages() == 3) {
249
- if ($ID !== FALSE) {
250
- if ($this->filter_pages_contains($this->options->exclude_pages(), $ID) === FALSE)
251
- return TRUE;
252
- else
253
- return FALSE;
254
- }
255
- return TRUE;
256
- }
257
- }
258
-
259
- return TRUE;
260
- }
261
-
262
- public function filter_pages_contains($list, $key) {
263
- return strpos(',' . $list . ',', ',' . $key . ',');
264
- }
265
-
266
- private function image() {
267
- if ($this->options->image() == 'custom')
268
- return $this->options->custom_url();
269
- return $this->iconsURL . $this->options->image();
270
- }
271
-
272
- protected function get_filter_objects() {
273
- $objects = array();
274
-
275
- $objects['home'] = __('[Page]', 'wpfront-scroll-top') . ' ' . __('Home', 'wpfront-scroll-top');
276
-
277
- $pages = get_pages();
278
- foreach ($pages as $page) {
279
- $objects[$page->ID] = __('[Page]', 'wpfront-scroll-top') . ' ' . $page->post_title;
280
- }
281
-
282
- $posts = get_posts();
283
- foreach ($posts as $post) {
284
- $objects[$post->ID] = __('[Post]', 'wpfront-scroll-top') . ' ' . $post->post_title;
285
- }
286
-
287
- // $categories = get_categories();
288
- // foreach ($categories as $category) {
289
- // $objects['3.' . $category->cat_ID] = __('[Category]', 'wpfront-scroll-top') . ' ' . $category->cat_name;
290
- // }
291
-
292
- return $objects;
293
- }
294
-
295
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ namespace WPFront\Scroll_Top;
26
+
27
+ require_once("class-wpfront-scroll-top-options.php");
28
+
29
+ /**
30
+ * Main class of WPFront Scroll Top plugin
31
+ *
32
+ * @author Syam Mohan <syam@wpfront.com>
33
+ * @copyright 2013 WPFront.com
34
+ */
35
+ class WPFront_Scroll_Top {
36
+ //Constants
37
+ const VERSION = '2.0.1';
38
+ const OPTIONS_GROUP_NAME = 'wpfront-scroll-top-options-group';
39
+ const OPTION_NAME = 'wpfront-scroll-top-options';
40
+ const PLUGIN_SLUG = 'wpfront-scroll-top';
41
+ const PLUGIN_FILE = 'wpfront-scroll-top/wpfront-scroll-top.php';
42
+
43
+ //Variables
44
+ protected $iconsDIR = '/tmp/icons/';
45
+ protected $iconsURL = '//tmp/icons/';
46
+ protected $pluginDIRRoot = '/tmp/';
47
+ protected $pluginURLRoot = '//tmp/';
48
+ protected $options;
49
+ protected $markupLoaded;
50
+ protected $scriptLoaded;
51
+ protected $min_file_suffix;
52
+
53
+ private static $instance = null;
54
+
55
+ protected function __construct() {
56
+ $this->markupLoaded = FALSE;
57
+ $this->min_file_suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
58
+ }
59
+
60
+ public static function Instance() {
61
+ if(empty(self::$instance)) {
62
+ self::$instance = new WPFront_Scroll_Top();
63
+ }
64
+
65
+ return self::$instance;
66
+ }
67
+
68
+ public function init($pluginFile = null) {
69
+ //Root variables
70
+ $this->pluginURLRoot = plugins_url() . '/' . self::PLUGIN_SLUG . '/';
71
+ $this->iconsURL = $this->pluginURLRoot . 'images/icons/';
72
+ $this->pluginDIRRoot = plugin_dir_path($pluginFile);
73
+ $this->iconsDIR = $this->pluginDIRRoot . 'images/icons/';
74
+
75
+ add_action('plugins_loaded', array($this, 'plugins_loaded'));
76
+
77
+ add_action('wp_footer', array($this, 'write_markup'));
78
+ add_action('shutdown', array($this, 'shutdown_callback'));
79
+
80
+ $this->add_activation_redirect();
81
+
82
+ if (is_admin()) {
83
+ add_action('admin_init', array($this, 'admin_init'));
84
+ add_action('admin_menu', array($this, 'admin_menu'));
85
+ add_filter('plugin_action_links', array($this, 'action_links'), 10, 2);
86
+ } else {
87
+ add_action('wp_enqueue_scripts', array($this, 'enqueue_styles'));
88
+ add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'));
89
+ }
90
+ }
91
+
92
+ public function action_links($links, $file) {
93
+ if ($file == self::PLUGIN_FILE) {
94
+ $settings_link = '<a href="' . menu_page_url(self::PLUGIN_SLUG, FALSE) . '">' . __('Settings', 'wpfront-scroll-top') . '</a>';
95
+ array_unshift($links, $settings_link);
96
+ }
97
+ return $links;
98
+ }
99
+
100
+ protected function add_activation_redirect() {
101
+ add_action('activated_plugin', array($this, 'activated_plugin_callback'));
102
+ add_action('admin_init', array($this, 'admin_init_callback'), 999999);
103
+ }
104
+
105
+ public function activated_plugin_callback($plugin) {
106
+ if ($plugin !== self::PLUGIN_FILE) {
107
+ return;
108
+ }
109
+
110
+ if (is_network_admin() || isset($_GET['activate-multi'])) {
111
+ return;
112
+ }
113
+
114
+ $key = self::PLUGIN_SLUG . '-activation-redirect';
115
+ add_option($key, TRUE);
116
+ }
117
+
118
+ public function admin_init_callback() {
119
+ $key = self::PLUGIN_SLUG . '-activation-redirect';
120
+
121
+ if (get_option($key, FALSE)) {
122
+ delete_option($key);
123
+
124
+ if (is_network_admin() || isset($_GET['activate-multi'])) {
125
+ return;
126
+ }
127
+
128
+ wp_safe_redirect(menu_page_url(self::PLUGIN_SLUG, FALSE));
129
+ }
130
+ }
131
+
132
+ //add scripts
133
+ public function enqueue_scripts() {
134
+ if ($this->enabled() == FALSE) {
135
+ return;
136
+ }
137
+
138
+ $jsRoot = $this->pluginURLRoot . 'js/';
139
+
140
+ wp_enqueue_script('jquery');
141
+ wp_enqueue_script('wpfront-scroll-top', $jsRoot . 'wpfront-scroll-top' . $this->min_file_suffix . '.js', array('jquery'), self::VERSION, TRUE);
142
+
143
+ $this->scriptLoaded = TRUE;
144
+ }
145
+
146
+ //add styles
147
+ public function enqueue_styles() {
148
+ if ($this->enabled() == FALSE) {
149
+ return;
150
+ }
151
+
152
+ $cssRoot = $this->pluginURLRoot . 'css/';
153
+
154
+ wp_enqueue_style('wpfront-scroll-top', $cssRoot . 'wpfront-scroll-top' . $this->min_file_suffix . '.css', array(), self::VERSION);
155
+
156
+ if($this->options->button_style() == 'font-awesome') {
157
+ if(!$this->options->fa_button_exclude_URL() || is_admin()) {
158
+ $url = trim($this->options->fa_button_URL());
159
+ $ver = FALSE;
160
+ if(empty($url)) {
161
+ $url = '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css';
162
+ $ver = '4.7.0';
163
+ }
164
+ wp_enqueue_style('font-awesome', $url, array(), $ver);
165
+ }
166
+ }
167
+ }
168
+
169
+ public function admin_init() {
170
+ register_setting(self::OPTIONS_GROUP_NAME, self::OPTION_NAME);
171
+
172
+ $this->enqueue_styles();
173
+ $this->enqueue_scripts();
174
+ }
175
+
176
+ public function admin_menu() {
177
+ $page_hook_suffix = add_options_page(__('WPFront Scroll Top', 'wpfront-scroll-top'), __('Scroll Top', 'wpfront-scroll-top'), 'manage_options', self::PLUGIN_SLUG, array($this, 'options_page'));
178
+
179
+ add_action('admin_print_scripts-' . $page_hook_suffix, array($this, 'enqueue_options_scripts'));
180
+ add_action('admin_print_styles-' . $page_hook_suffix, array($this, 'enqueue_options_styles'));
181
+ }
182
+
183
+ public function enqueue_options_scripts() {
184
+ wp_enqueue_media();
185
+
186
+ $this->enqueue_scripts();
187
+
188
+ $jsRoot = $this->pluginURLRoot . 'jquery-plugins/colorpicker/js/';
189
+ wp_enqueue_script('jquery.eyecon.colorpicker', $jsRoot . 'colorpicker' . $this->min_file_suffix . '.js', array('jquery'), self::VERSION);
190
+
191
+ $jsRoot = $this->pluginURLRoot . 'js/';
192
+ wp_enqueue_script('wpfront-scroll-top-options', $jsRoot . 'options' . $this->min_file_suffix . '.js', array('jquery'), self::VERSION);
193
+ }
194
+
195
+ //options page styles
196
+ public function enqueue_options_styles() {
197
+ $styleRoot = $this->pluginURLRoot . 'jquery-plugins/colorpicker/css/';
198
+ wp_enqueue_style('jquery.eyecon.colorpicker', $styleRoot . 'colorpicker' . $this->min_file_suffix . '.css', array(), self::VERSION);
199
+
200
+ $styleRoot = $this->pluginURLRoot . 'css/';
201
+ wp_enqueue_style('wpfront-scroll-top-options', $styleRoot . 'options' . $this->min_file_suffix . '.css', array(), self::VERSION);
202
+ }
203
+
204
+ public function set_options($options) {
205
+ $this->options = $options;
206
+ }
207
+
208
+ public function plugins_loaded() {
209
+ //load plugin options
210
+ $this->set_options(new WPFront_Scroll_Top_Options(self::OPTION_NAME, self::PLUGIN_SLUG));
211
+
212
+ if($this->options->javascript_async()) {
213
+ add_filter('script_loader_tag', array($this, 'script_loader_tag'), 999999, 3);
214
+ }
215
+ }
216
+
217
+ public function script_loader_tag($tag, $handle, $src) {
218
+ if($handle === 'wpfront-scroll-top') {
219
+ return '<script type="text/javascript" src="' . $src . '" async="async" defer="defer"></script>' . "\n";
220
+ }
221
+
222
+ return $tag;
223
+ }
224
+
225
+ public function shutdown_callback() {
226
+ if ($this->markupLoaded) {
227
+ return;
228
+ }
229
+
230
+ $headers = headers_list();
231
+ $flag = FALSE;
232
+ foreach ($headers as $value) {
233
+ $value = strtolower(str_replace(' ', '', $value));
234
+ if (strpos($value, 'content-type:text/html') === 0) {
235
+ $flag = TRUE;
236
+ break;
237
+ }
238
+ }
239
+
240
+ if ($flag) {
241
+ $this->write_markup();
242
+ }
243
+ }
244
+
245
+ //writes the html and script for the button
246
+ public function write_markup() {
247
+ if ($this->markupLoaded) {
248
+ return;
249
+ }
250
+
251
+ if (!$this->scriptLoaded) {
252
+ return;
253
+ }
254
+
255
+ if ($this->doing_ajax()) {
256
+ return;
257
+ }
258
+
259
+ if ($this->enabled()) {
260
+ if(is_admin()) {
261
+ $this->options->set_button_action('top');
262
+ }
263
+
264
+ include($this->pluginDIRRoot . 'templates/scroll-top-template.php');
265
+
266
+ echo '<script type="text/javascript">';
267
+ echo 'function wpfront_scroll_top_init() {';
268
+ echo 'if(typeof wpfront_scroll_top == "function" && typeof jQuery !== "undefined") {';
269
+ echo 'wpfront_scroll_top(' . json_encode(array(
270
+ 'scroll_offset' => $this->options->scroll_offset(),
271
+ 'button_width' => $this->options->button_width(),
272
+ 'button_height' => $this->options->button_height(),
273
+ 'button_opacity' => $this->options->button_opacity() / 100,
274
+ 'button_fade_duration' => $this->options->button_fade_duration(),
275
+ 'scroll_duration' => $this->options->scroll_duration(),
276
+ 'location' => $this->options->location(),
277
+ 'marginX' => $this->options->marginX(),
278
+ 'marginY' => $this->options->marginY(),
279
+ 'hide_iframe' => $this->options->hide_iframe(),
280
+ 'auto_hide' => $this->options->auto_hide(),
281
+ 'auto_hide_after' => $this->options->auto_hide_after(),
282
+ 'button_action' => $this->options->button_action(),
283
+ 'button_action_element_selector' => $this->options->button_action_element_selector(),
284
+ 'button_action_container_selector' => $this->options->button_action_container_selector(),
285
+ 'button_action_element_offset' => $this->options->button_action_element_offset()
286
+ )) . ');';
287
+ echo '} else {';
288
+ echo 'setTimeout(wpfront_scroll_top_init, 100);';
289
+ echo '}';
290
+ echo '}';
291
+ echo 'wpfront_scroll_top_init();';
292
+ echo '</script>';
293
+ }
294
+
295
+ $this->markupLoaded = TRUE;
296
+ }
297
+
298
+ protected function doing_ajax() {
299
+ if (defined('DOING_AJAX') && DOING_AJAX) {
300
+ return TRUE;
301
+ }
302
+
303
+ if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
304
+ return TRUE;
305
+ }
306
+
307
+ if (!empty($_SERVER['REQUEST_URI']) && strtolower($_SERVER['REQUEST_URI']) == '/wp-admin/async-upload.php') {
308
+ return TRUE;
309
+ }
310
+
311
+ return FALSE;
312
+ }
313
+
314
+ protected function apply_button_action_html($html) {
315
+ if($this->options->button_action() == "url") {
316
+ return sprintf('<a href="%s">' . $html . '</a>', $this->options->button_action_page_url());
317
+ }
318
+
319
+ return $html;
320
+ }
321
+
322
+ protected function enabled() {
323
+ $enabled = TRUE;
324
+
325
+ if ($enabled && !$this->options->enabled()) {
326
+ $enabled = FALSE;
327
+ }
328
+
329
+ if ($enabled && $this->options->hide_wpadmin() && is_admin()) {
330
+ $enabled = FALSE;
331
+ }
332
+
333
+ if ($enabled && !$this->filter_pages()) {
334
+ $enabled = FALSE;
335
+ }
336
+
337
+ $enabled = apply_filters('wpfront_scroll_top_enabled', $enabled);
338
+
339
+ return $enabled;
340
+ }
341
+
342
+ protected function filter_pages() {
343
+ if (is_admin()) {
344
+ return TRUE;
345
+ }
346
+
347
+ switch ($this->options->display_pages()) {
348
+ case 1:
349
+ return TRUE;
350
+ case 2:
351
+ case 3:
352
+ global $post;
353
+ $ID = FALSE;
354
+ if (is_home()) {
355
+ $ID = 'home';
356
+ } elseif(!empty($post)) {
357
+ $ID = $post->ID;
358
+ }
359
+ if ($this->options->display_pages() == 2) {
360
+ if ($ID !== FALSE) {
361
+ if ($this->filter_pages_contains($this->options->include_pages(), $ID) === FALSE) {
362
+ return FALSE;
363
+ }
364
+ else {
365
+ return TRUE;
366
+ }
367
+ }
368
+ return FALSE;
369
+ }
370
+ if ($this->options->display_pages() == 3) {
371
+ if ($ID !== FALSE) {
372
+ if ($this->filter_pages_contains($this->options->exclude_pages(), $ID) === FALSE) {
373
+ return TRUE;
374
+ }
375
+ else {
376
+ return FALSE;
377
+ }
378
+ }
379
+ return TRUE;
380
+ }
381
+ }
382
+
383
+ return TRUE;
384
+ }
385
+
386
+ protected function filter_pages_contains($list, $key) {
387
+ return strpos(',' . $list . ',', ',' . $key . ',');
388
+ }
389
+
390
+ protected function image() {
391
+ if ($this->options->image() == 'custom') {
392
+ return $this->options->custom_url();
393
+ }
394
+ return $this->iconsURL . $this->options->image();
395
+ }
396
+
397
+ protected function get_filter_objects() {
398
+ $objects = array();
399
+
400
+ $objects['home'] = __('[Page]', 'wpfront-scroll-top') . ' ' . __('Home', 'wpfront-scroll-top');
401
+
402
+ $pages = get_pages();
403
+ foreach ($pages as $page) {
404
+ $objects[$page->ID] = __('[Page]', 'wpfront-scroll-top') . ' ' . $page->post_title;
405
+ }
406
+
407
+ $posts = get_posts();
408
+ foreach ($posts as $post) {
409
+ $objects[$post->ID] = __('[Post]', 'wpfront-scroll-top') . ' ' . $post->post_title;
410
+ }
411
+
412
+ // $categories = get_categories();
413
+ // foreach ($categories as $category) {
414
+ // $objects['3.' . $category->cat_ID] = __('[Category]', 'wpfront-scroll-top') . ' ' . $category->cat_name;
415
+ // }
416
+
417
+ return $objects;
418
+ }
419
+
420
+ public function options_page() {
421
+ if (!current_user_can('manage_options')) {
422
+ wp_die(__('You do not have sufficient permissions to access this page.', 'wpfront-scroll-top'));
423
+ return;
424
+ }
425
+
426
+ include($this->pluginDIRRoot . 'templates/options-template.php');
427
+ }
428
+
429
+ protected function options_page_header($title, $optionsGroupName) {
430
+ echo '<div class="wrap">';
431
+ echo '<h2>' . $title . '</h2>';
432
+ echo '<div id="' . self::PLUGIN_SLUG . '-options" class="inside">';
433
+ echo '<form method="post" action="options.php">';
434
+ @settings_fields($optionsGroupName);
435
+ @do_settings_sections(self::PLUGIN_SLUG);
436
+
437
+ if ((isset($_GET['settings-updated']) && $_GET['settings-updated'] == 'true') || (isset($_GET['updated']) && $_GET['updated'] == 'true')) {
438
+ echo '
439
+ <div class="updated">
440
+ <p>
441
+ <strong>' . __('If you have a caching plugin, clear the cache for the new settings to take effect.', 'wpfront-scroll-top') . '</strong>
442
+ </p>
443
+ </div>
444
+ ';
445
+ }
446
+ }
447
+
448
+ protected function options_page_footer($settingsLink, $FAQLink) {
449
+ @$this->submit_button();
450
+
451
+ echo '</form>';
452
+ echo '</div>';
453
+ echo '</div>';
454
+
455
+ $this->settingsLink = $settingsLink;
456
+ $this->FAQLink = $FAQLink;
457
+
458
+ add_filter('admin_footer_text', array($this, 'admin_footer_text'));
459
+ }
460
+
461
+ public function admin_footer_text($text) {
462
+ $settingsLink = sprintf('<a href="%s" target="_blank">%s</a>', 'https://wpfront.com/' . $this->settingsLink, __('Settings Description', 'wpfront-scroll-top'));
463
+ $reviewLink = sprintf('<a href="%s" target="_blank">%s</a>', 'https://wordpress.org/support/plugin/' . self::PLUGIN_SLUG . '/reviews/', __('Write a Review', 'wpfront-scroll-top'));
464
+ $donateLink = sprintf('<a href="%s" target="_blank">%s</a>', 'https://wpfront.com/donate/', __('Buy me a Beer or Coffee', 'wpfront-scroll-top'));
465
+
466
+ return sprintf('%s | %s | %s | %s', $settingsLink, $reviewLink, $donateLink, $text);
467
+ }
468
+
469
+ //for compatibility
470
+ public function submit_button() {
471
+ if (function_exists('submit_button')) {
472
+ submit_button();
473
+ } else {
474
+ echo '<p class="submit"><input type="submit" name="submit" id="submit" class="button button-primary" value="' . __('Save Changes', 'wpfront-scroll-top') . '" /></p>';
475
+ }
476
+ }
477
+ }
478
+
css/options.css CHANGED
@@ -79,4 +79,50 @@
79
  width: 70%;
80
  }
81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
 
79
  width: 70%;
80
  }
81
 
82
+ #wpfront-scroll-top-options div.button-action-container .alignment-holder
83
+ {
84
+ visibility: hidden;
85
+ }
86
+
87
+ #wpfront-scroll-top-options div.button-action-container div.fields-container
88
+ {
89
+ display: table;
90
+ }
91
+
92
+ #wpfront-scroll-top-options div.button-action-container div.fields-container.hidden
93
+ {
94
+ display: none;
95
+ }
96
+
97
+ #wpfront-scroll-top-options div.button-action-container div.fields-container div
98
+ {
99
+ display: table-row;
100
+ }
101
+
102
+ #wpfront-scroll-top-options div.button-action-container div.fields-container div span
103
+ {
104
+ display: table-cell;
105
+ }
106
+
107
+ #wpfront-scroll-top-options div.button-action-container div.fields-container div span.description
108
+ {
109
+ display:inline;
110
+ }
111
+
112
+ #wpfront-scroll-top-options div.button-action-container div.fields-container.url
113
+ {
114
+ width: 100%;
115
+ }
116
+
117
+ #wpfront-scroll-top-options div.button-action-container div.fields-container.url span.url
118
+ {
119
+ width: 90%;
120
+ }
121
+
122
+ #wpfront-scroll-top-options div.button-action-container div.fields-container.url span.url input.url
123
+ {
124
+ width: 100%;
125
+ max-width: 650px;
126
+ }
127
+
128
 
css/options.min.css CHANGED
@@ -1 +1,2 @@
1
- #icon-wpfront-scroll-top{background:url("../images/settings32x32.png") no-repeat scroll 0 0 rgba(0,0,0,0)}#wpfront-scroll-top-options input.pixels{width:40px}#wpfront-scroll-top-options input.seconds{width:40px}#wpfront-scroll-top-options div.icons-container{display:inline-block;width:80%}#wpfront-scroll-top-options div.icons-container div{float:left;margin-right:20px;margin-bottom:10px;min-width:100px;min-height:80px;zoom:80%}#wpfront-scroll-top-options div.icons-container div.selected{background-color:silver}#wpfront-scroll-top-options div.icons-container div:hover{background-color:silver}#wpfront-scroll-top-options div.icons-container div input{vertical-align:top}#wpfront-scroll-top-options input.url{width:50%}#wpfront-scroll-top-options table.form-table .color-selector-div{display:inline-block;width:100px}#wpfront-scroll-top-options table.form-table .color-selector{vertical-align:middle}#wpfront-scroll-top-options table.form-table div.pages-selection{width:70%;height:150px;background-color:#fff;overflow:auto;border:1px solid #dfdfdf;-moz-border-radius:4px;-khtml-border-radius:4px;-webkit-border-radius:4px;border-radius:4px}#wpfront-scroll-top-options table.form-table div.page-div{float:left;width:250px;padding:2px;white-space:nowrap;overflow:hidden}#wpfront-scroll-top-options input.post-id-list{width:70%}
 
1
+
2
+ #icon-wpfront-scroll-top{background:url("../images/settings32x32.png") no-repeat scroll 0 0 rgba(0,0,0,0)}#wpfront-scroll-top-options input.pixels{width:40px}#wpfront-scroll-top-options input.seconds{width:40px}#wpfront-scroll-top-options div.icons-container{display:inline-block;width:80%}#wpfront-scroll-top-options div.icons-container div{float:left;margin-right:20px;margin-bottom:10px;min-width:100px;min-height:80px;zoom:80%}#wpfront-scroll-top-options div.icons-container div.selected{background-color:silver}#wpfront-scroll-top-options div.icons-container div:hover{background-color:silver}#wpfront-scroll-top-options div.icons-container div input{vertical-align:top}#wpfront-scroll-top-options input.url{width:50%}#wpfront-scroll-top-options table.form-table .color-selector-div{display:inline-block;width:100px}#wpfront-scroll-top-options table.form-table .color-selector{vertical-align:middle}#wpfront-scroll-top-options table.form-table div.pages-selection{width:70%;height:150px;background-color:#fff;overflow:auto;border:1px solid #dfdfdf;-moz-border-radius:4px;-khtml-border-radius:4px;-webkit-border-radius:4px;border-radius:4px}#wpfront-scroll-top-options table.form-table div.page-div{float:left;width:250px;padding:2px;white-space:nowrap;overflow:hidden}#wpfront-scroll-top-options input.post-id-list{width:70%}#wpfront-scroll-top-options div.button-action-container .alignment-holder{visibility:hidden}#wpfront-scroll-top-options div.button-action-container div.fields-container{display:table}#wpfront-scroll-top-options div.button-action-container div.fields-container.hidden{display:none}#wpfront-scroll-top-options div.button-action-container div.fields-container div{display:table-row}#wpfront-scroll-top-options div.button-action-container div.fields-container div span{display:table-cell}#wpfront-scroll-top-options div.button-action-container div.fields-container div span.description{display:inline}#wpfront-scroll-top-options div.button-action-container div.fields-container.url{width:100%}#wpfront-scroll-top-options div.button-action-container div.fields-container.url span.url{width:90%}#wpfront-scroll-top-options div.button-action-container div.fields-container.url span.url input.url{width:100%;max-width:650px}
css/wpfront-scroll-top.css CHANGED
@@ -12,4 +12,10 @@
12
  -webkit-box-shadow: 4px 4px 5px 0px rgba(50, 50, 50, 0.5);
13
  -moz-box-shadow: 4px 4px 5px 0px rgba(50, 50, 50, 0.5);
14
  box-shadow: 4px 4px 5px 0px rgba(50, 50, 50, 0.5);
 
 
 
 
 
 
15
  }
12
  -webkit-box-shadow: 4px 4px 5px 0px rgba(50, 50, 50, 0.5);
13
  -moz-box-shadow: 4px 4px 5px 0px rgba(50, 50, 50, 0.5);
14
  box-shadow: 4px 4px 5px 0px rgba(50, 50, 50, 0.5);
15
+ }
16
+
17
+ #wpfront-scroll-top-container a {
18
+ outline-style: none;
19
+ box-shadow: none;
20
+ text-decoration: none;
21
  }
css/wpfront-scroll-top.min.css CHANGED
@@ -1 +1,2 @@
1
- #wpfront-scroll-top-container{display:none;position:fixed;cursor:pointer;z-index:9999}#wpfront-scroll-top-container div.text-holder{padding:3px 10px;border-radius:3px;-webkit-border-radius:3px;-webkit-box-shadow:4px 4px 5px 0 rgba(50,50,50,0.5);-moz-box-shadow:4px 4px 5px 0 rgba(50,50,50,0.5);box-shadow:4px 4px 5px 0 rgba(50,50,50,0.5)}
 
1
+
2
+ #wpfront-scroll-top-container{display:none;position:fixed;cursor:pointer;z-index:9999}#wpfront-scroll-top-container div.text-holder{padding:3px 10px;border-radius:3px;-webkit-border-radius:3px;-webkit-box-shadow:4px 4px 5px 0 rgba(50,50,50,0.5);-moz-box-shadow:4px 4px 5px 0 rgba(50,50,50,0.5);box-shadow:4px 4px 5px 0 rgba(50,50,50,0.5)}#wpfront-scroll-top-container a{outline-style:none;box-shadow:none;text-decoration:none}
js/options.js CHANGED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ WPFront Scroll Top Plugin
3
+ Copyright (C) 2013, WPFront.com
4
+ Website: wpfront.com
5
+ Contact: syam@wpfront.com
6
+
7
+ WPFront Scroll Top Plugin is distributed under the GNU General Public License, Version 3,
8
+ June 2007. Copyright (C) 2007 Free Software Foundation, Inc., 51 Franklin
9
+ St, Fifth Floor, Boston, MA 02110, USA
10
+
11
+ */
12
+
13
+ (function () {
14
+ window.init_wpfront_scroll_top_options = function (settings) {
15
+ var $ = jQuery;
16
+
17
+ function setColorPicker(div) {
18
+ div.ColorPicker({
19
+ color: div.attr('color'),
20
+ onShow: function(colpkr) {
21
+ $(colpkr).fadeIn(500);
22
+ return false;
23
+ }, onHide: function(colpkr) {
24
+ $(colpkr).fadeOut(500);
25
+ return false;
26
+ },
27
+ onChange: function(hsb, hex, rgb) {
28
+ div.css('backgroundColor', '#' + hex);
29
+ div.next().text('#' + hex).next().val('#' + hex);
30
+ }
31
+ }).css('backgroundColor', div.attr('color'));
32
+ }
33
+
34
+ $('#wpfront-scroll-top-options').find(".color-selector").each(function(i, e) {
35
+ setColorPicker($(e));
36
+ });
37
+
38
+ $('#wpfront-scroll-top-options .pages-selection input[type="checkbox"]').change(function() {
39
+ var $this = $(this);
40
+ var $input = $this.parent().parent().parent().prev();
41
+ var $text = $input.val();
42
+
43
+ if($this.prop('checked')) {
44
+ $text += ',' + $this.val();
45
+ } else {
46
+ $text = (',' + $text + ',').replace(',' + $this.val() + ',', ',');
47
+ }
48
+
49
+ $text = $text.replace(/(^[,\s]+)|([,\s]+$)/g, '');
50
+ $input.val($text);
51
+ });
52
+
53
+ $('#wpfront-scroll-top-options input.button-style').change(function() {
54
+ $('#wpfront-scroll-top-options .button-options').hide().filter('.' + $(this).val()).show();
55
+ });
56
+
57
+ $('#wpfront-scroll-top-options .button-options').hide().filter('.' + settings.button_style).show();
58
+
59
+ $('#wpfront-scroll-top-options input.button-action').change(function() {
60
+ $('#wpfront-scroll-top-options div.button-action-container div.fields-container').addClass('hidden').filter('.' + $(this).val()).removeClass('hidden');
61
+ });
62
+
63
+ $('#wpfront-scroll-top-options div.button-action-container div.fields-container').filter('.' + settings.button_action).removeClass('hidden');
64
+
65
+ (function() {
66
+ var mediaLibrary = null;
67
+
68
+ $('#media-library-button').click(function(e) {
69
+ e.preventDefault();
70
+
71
+ if(mediaLibrary === null) {
72
+ mediaLibrary = wp.media.frames.file_frame = wp.media({
73
+ title: settings.label_choose_image,
74
+ multiple: false,
75
+ button: {
76
+ text: settings.label_select_image
77
+ }
78
+ }).on('select', function() {
79
+ var obj = mediaLibrary.state().get('selection').first().toJSON();
80
+
81
+ $('#custom').prop('checked', true);
82
+ $('#custom-url-textbox').val(obj.url);
83
+
84
+ if(obj.alt !== "")
85
+ $('#alt-textbox').val(obj.alt);
86
+ });
87
+ }
88
+
89
+ mediaLibrary.open();
90
+ return false;
91
+ });
92
+ })();
93
+ };
94
+ })();
js/options.min.js ADDED
@@ -0,0 +1,2 @@
 
 
1
+
2
+ (function(){window.init_wpfront_scroll_top_options=function(a){var b=jQuery;function c(d){d.ColorPicker({color:d.attr("color"),onShow:function(e){b(e).fadeIn(500);return false},onHide:function(e){b(e).fadeOut(500);return false},onChange:function(e,g,f){d.css("backgroundColor","#"+g);d.next().text("#"+g).next().val("#"+g)}}).css("backgroundColor",d.attr("color"))}b("#wpfront-scroll-top-options").find(".color-selector").each(function(d,f){c(b(f))});b('#wpfront-scroll-top-options .pages-selection input[type="checkbox"]').change(function(){var e=b(this);var f=e.parent().parent().parent().prev();var d=f.val();if(e.prop("checked")){d+=","+e.val()}else{d=(","+d+",").replace(","+e.val()+",",",")}d=d.replace(/(^[,\s]+)|([,\s]+$)/g,"");f.val(d)});b("#wpfront-scroll-top-options input.button-style").change(function(){b("#wpfront-scroll-top-options .button-options").hide().filter("."+b(this).val()).show()});b("#wpfront-scroll-top-options .button-options").hide().filter("."+a.button_style).show();b("#wpfront-scroll-top-options input.button-action").change(function(){b("#wpfront-scroll-top-options div.button-action-container div.fields-container").addClass("hidden").filter("."+b(this).val()).removeClass("hidden")});b("#wpfront-scroll-top-options div.button-action-container div.fields-container").filter("."+a.button_action).removeClass("hidden");(function(){var d=null;b("#media-library-button").click(function(f){f.preventDefault();if(d===null){d=wp.media.frames.file_frame=wp.media({title:a.label_choose_image,multiple:false,button:{text:a.label_select_image}}).on("select",function(){var e=d.state().get("selection").first().toJSON();b("#custom").prop("checked",true);b("#custom-url-textbox").val(e.url);if(e.alt!==""){b("#alt-textbox").val(e.alt)}})}d.open();return false})})()}})();
js/wpfront-scroll-top.js CHANGED
@@ -107,7 +107,35 @@
107
  mouse_over = false;
108
  fnHideEvent();
109
  })
110
- .click(function () {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
111
  $("html, body").animate({scrollTop: 0}, data.scroll_duration);
112
  return false;
113
  });
107
  mouse_over = false;
108
  fnHideEvent();
109
  })
110
+ .click(function (e) {
111
+ if(data.button_action === "url") {
112
+ return true;
113
+ } else if(data.button_action === "element") {
114
+ e.preventDefault();
115
+
116
+ var element = $(data.button_action_element_selector).first();
117
+ var container = $(data.button_action_container_selector);
118
+
119
+ var offset = element.offset();
120
+ if(offset == null)
121
+ return false;
122
+
123
+ var contOffset = container.last().offset();
124
+ if(contOffset == null)
125
+ return false;
126
+
127
+ data.button_action_element_offset = parseInt(data.button_action_element_offset);
128
+ if(isNaN(data.button_action_element_offset))
129
+ data.button_action_element_offset = 0;
130
+
131
+ var top = offset.top - contOffset.top - data.button_action_element_offset;
132
+
133
+ container.animate({scrollTop: top}, data.scroll_duration);
134
+
135
+ return false;
136
+ }
137
+
138
+ e.preventDefault();
139
  $("html, body").animate({scrollTop: 0}, data.scroll_duration);
140
  return false;
141
  });
js/wpfront-scroll-top.min.js CHANGED
@@ -1,2 +1,2 @@
1
-
2
- (function(){window.wpfront_scroll_top=function(d){var e=jQuery;var a=e("#wpfront-scroll-top-container").css("opacity",0);var f={};switch(d.location){case 1:f.right=d.marginX+"px";f.bottom=d.marginY+"px";break;case 2:f.left=d.marginX+"px";f.bottom=d.marginY+"px";break;case 3:f.right=d.marginX+"px";f.top=d.marginY+"px";break;case 4:f.left=d.marginX+"px";f.top=d.marginY+"px";break}a.css(f);if(d.button_width==0){d.button_width="auto"}else{d.button_width+="px"}if(d.button_height==0){d.button_height="auto"}else{d.button_height+="px"}a.children("img").css({width:d.button_width,height:d.button_height});if(d.hide_iframe){if(e(window).attr("self")!==e(window).attr("top")){return}}var g=false;var b=0;var h=function(){clearTimeout(b);if(a.is(":visible")){a.stop().fadeTo(d.button_fade_duration,0,function(){a.hide();g=false})}};var j=function(){if(!d.auto_hide){return}clearTimeout(b);b=setTimeout(function(){h()},d.auto_hide_after*1000)};var i=false;var c=function(){if(i){return}i=true;if(e(window).scrollTop()>d.scroll_offset){a.stop().css("opacity",g?1:d.button_opacity).show();if(!g){j()}}else{h()}i=false};e(window).scroll(c);e(document).scroll(c);a.hover(function(){clearTimeout(b);g=true;e(this).css("opacity",1)},function(){e(this).css("opacity",d.button_opacity);g=false;j()}).click(function(){e("html, body").animate({scrollTop:0},d.scroll_duration);return false})}})();
1
+
2
+ (function(){window.wpfront_scroll_top=function(d){var e=jQuery;var a=e("#wpfront-scroll-top-container").css("opacity",0);var f={};switch(d.location){case 1:f.right=d.marginX+"px";f.bottom=d.marginY+"px";break;case 2:f.left=d.marginX+"px";f.bottom=d.marginY+"px";break;case 3:f.right=d.marginX+"px";f.top=d.marginY+"px";break;case 4:f.left=d.marginX+"px";f.top=d.marginY+"px";break}a.css(f);if(d.button_width==0){d.button_width="auto"}else{d.button_width+="px"}if(d.button_height==0){d.button_height="auto"}else{d.button_height+="px"}a.children("img").css({width:d.button_width,height:d.button_height});if(d.hide_iframe){if(e(window).attr("self")!==e(window).attr("top")){return}}var g=false;var b=0;var h=function(){clearTimeout(b);if(a.is(":visible")){a.stop().fadeTo(d.button_fade_duration,0,function(){a.hide();g=false})}};var j=function(){if(!d.auto_hide){return}clearTimeout(b);b=setTimeout(function(){h()},d.auto_hide_after*1000)};var i=false;var c=function(){if(i){return}i=true;if(e(window).scrollTop()>d.scroll_offset){a.stop().css("opacity",g?1:d.button_opacity).show();if(!g){j()}}else{h()}i=false};e(window).scroll(c);e(document).scroll(c);a.hover(function(){clearTimeout(b);g=true;e(this).css("opacity",1)},function(){e(this).css("opacity",d.button_opacity);g=false;j()}).click(function(o){if(d.button_action==="url"){return true}else{if(d.button_action==="element"){o.preventDefault();var m=e(d.button_action_element_selector).first();var l=e(d.button_action_container_selector);var p=m.offset();if(p==null){return false}var k=l.last().offset();if(k==null){return false}d.button_action_element_offset=parseInt(d.button_action_element_offset);if(isNaN(d.button_action_element_offset)){d.button_action_element_offset=0}var n=p.top-k.top-d.button_action_element_offset;l.animate({scrollTop:n},d.scroll_duration);return false}}o.preventDefault();e("html, body").animate({scrollTop:0},d.scroll_duration);return false})}})();
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: syammohanm
3
  Donate link: http://wpfront.com/donate/
4
  Tags: scroll to top, back to top, scroll top, scroll up, wordpress scroll top
5
  Requires at least: 4.1
6
- Tested up to: 4.9.4
7
- Stable tag: 1.6.2
8
  Requires PHP: 5.3
9
  License: GPLv3
10
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
@@ -17,6 +17,8 @@ WPFront Scroll Top plugin allows the visitor to easily scroll back to the top of
17
  ### Features
18
  * Displays a button when user scrolls down the page.
19
  * Scrolls the page back to top with animation.
 
 
20
  * Create text, image or Font Awesome button.
21
  * Set any image you want.
22
  * Hide on small devices.
@@ -31,30 +33,32 @@ Visit [WPFront Scroll Top Settings](http://wpfront.com/scroll-top-plugin-setting
31
 
32
  == Installation ==
33
 
34
- 1. Click Plugins/Add New from the WordPress admin panel
35
- 1. Search for "WPFront Scroll Top" and install
36
 
37
  -or-
38
 
39
- 1. Download the .zip package
40
- 1. Unzip into the subdirectory 'wpfront-scroll-top' within your local WordPress plugins directory
41
- 1. Refresh plugin page and activate plugin
42
- 1. Configure plugin using *settings* link under plugin name or by going to WPFront/Scroll Top
43
 
44
  == Frequently Asked Questions ==
45
 
46
  Visit [WPFront Scroll Top FAQ](http://wpfront.com/scroll-top-plugin-faq/) page for FAQ.
47
 
48
- = WPFront Scroll Top and GDPR compliance? =
49
-
50
- This plugin doesn’t collect any personal information. For more information please visit [GDPR compliance](https://wpfront.com/wpfront-and-gdpr-compliance/).
51
-
52
  == Screenshots ==
53
 
54
  1. Settings page.
55
 
56
  == Changelog ==
57
 
 
 
 
 
 
 
58
  = 1.6.2 =
59
  * Requires minimum PHP 5.3.
60
  * Bug fixes.
@@ -124,6 +128,9 @@ This plugin doesn’t collect any personal information. For more information ple
124
 
125
  == Upgrade Notice ==
126
 
 
 
 
127
  = 1.6.2 =
128
  * Bug and compatibility fixes.
129
 
3
  Donate link: http://wpfront.com/donate/
4
  Tags: scroll to top, back to top, scroll top, scroll up, wordpress scroll top
5
  Requires at least: 4.1
6
+ Tested up to: 4.9.6
7
+ Stable tag: 2.0.1
8
  Requires PHP: 5.3
9
  License: GPLv3
10
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
17
  ### Features
18
  * Displays a button when user scrolls down the page.
19
  * Scrolls the page back to top with animation.
20
+ * Link to an element within the page.
21
+ * Link to a different page using URL.
22
  * Create text, image or Font Awesome button.
23
  * Set any image you want.
24
  * Hide on small devices.
33
 
34
  == Installation ==
35
 
36
+ 1. Click Plugins/Add New from the WordPress admin panel.
37
+ 1. Search for "WPFront Scroll Top" and install.
38
 
39
  -or-
40
 
41
+ 1. Download the .zip package.
42
+ 1. Unzip into the subdirectory 'wpfront-scroll-top' within your local WordPress plugins directory.
43
+ 1. Refresh plugin page and activate plugin.
44
+ 1. Configure plugin using *Scroll Top* link under 'Settings' menu.
45
 
46
  == Frequently Asked Questions ==
47
 
48
  Visit [WPFront Scroll Top FAQ](http://wpfront.com/scroll-top-plugin-faq/) page for FAQ.
49
 
 
 
 
 
50
  == Screenshots ==
51
 
52
  1. Settings page.
53
 
54
  == Changelog ==
55
 
56
+ = 2.0.1 =
57
+ * Link to element.
58
+ * Link to page.
59
+ * Select image from media library easily.
60
+ * Performance improvements.
61
+
62
  = 1.6.2 =
63
  * Requires minimum PHP 5.3.
64
  * Bug fixes.
128
 
129
  == Upgrade Notice ==
130
 
131
+ = 2.0.1 =
132
+ * New features added.
133
+
134
  = 1.6.2 =
135
  * Bug and compatibility fixes.
136
 
templates/options-template.php CHANGED
@@ -183,6 +183,48 @@ namespace WPFront\Scroll_Top;
183
  </div>
184
  </td>
185
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
186
  </table>
187
 
188
  <h3><?php echo __('Location', 'wpfront-scroll-top'); ?></h3>
@@ -404,7 +446,8 @@ namespace WPFront\Scroll_Top;
404
  <div>
405
  <input id="custom" name="<?php echo $this->options->image_name(); ?>" type="radio" value="custom" <?php echo ($this->options->image() == 'custom' ? 'checked' : ''); ?> />
406
  <label for="custom"><?php echo __('Custom URL', 'wpfront-scroll-top'); ?>
407
- <input class="url" name="<?php echo $this->options->custom_url_name(); ?>" value="<?php echo $this->options->custom_url(); ?>"/>
 
408
  </label>
409
  </div>
410
  <table class="form-table">
@@ -413,7 +456,7 @@ namespace WPFront\Scroll_Top;
413
  <?php echo $this->options->image_alt_label(); ?>
414
  </th>
415
  <td>
416
- <input class="altText" name="<?php echo $this->options->image_alt_name(); ?>" value="<?php echo $this->options->image_alt(); ?>" />
417
  </td>
418
  </tr>
419
  </table>
@@ -422,48 +465,13 @@ namespace WPFront\Scroll_Top;
422
  <?php @$this->options_page_footer('scroll-top-plugin-settings/', 'scroll-top-plugin-faq/'); ?>
423
 
424
  <script type="text/javascript">
425
- (function($) {
426
- function setColorPicker(div) {
427
- div.ColorPicker({
428
- color: div.attr('color'),
429
- onShow: function(colpkr) {
430
- $(colpkr).fadeIn(500);
431
- return false;
432
- }, onHide: function(colpkr) {
433
- $(colpkr).fadeOut(500);
434
- return false;
435
- },
436
- onChange: function(hsb, hex, rgb) {
437
- div.css('backgroundColor', '#' + hex);
438
- div.next().text('#' + hex).next().val('#' + hex);
439
- }
440
- }).css('backgroundColor', div.attr('color'));
441
- }
442
-
443
- $('#wpfront-scroll-top-options').find(".color-selector").each(function(i, e) {
444
- setColorPicker($(e));
445
- });
446
-
447
- $('#wpfront-scroll-top-options .pages-selection input[type="checkbox"]').change(function() {
448
- var $this = $(this);
449
- var $input = $this.parent().parent().parent().prev();
450
- var $text = $input.val();
451
-
452
- if($this.prop('checked')) {
453
- $text += ',' + $this.val();
454
- } else {
455
- $text = (',' + $text + ',').replace(',' + $this.val() + ',', ',');
456
- }
457
-
458
- $text = $text.replace(/(^[,\s]+)|([,\s]+$)/g, '');
459
- $input.val($text);
460
- });
461
-
462
- $('#wpfront-scroll-top-options input.button-style').change(function() {
463
- $('#wpfront-scroll-top-options .button-options').hide().filter('.' + $(this).val()).show();
464
  });
465
-
466
- $('#wpfront-scroll-top-options .button-options').hide().filter('.<?php echo $this->options->button_style(); ?>').show();
467
- })(jQuery);
468
  </script>
469
 
183
  </div>
184
  </td>
185
  </tr>
186
+ <tr>
187
+ <th scope="row">
188
+ <?php echo $this->options->button_action_label(); ?>
189
+ </th>
190
+ <td>
191
+ <div class="button-action-container">
192
+ <label><input type="radio" class="button-action" name="<?php echo $this->options->button_action_name(); ?>" value="top" <?php echo $this->options->button_action() == 'top' ? 'checked' : ''; ?> /> <?php echo __('Scroll to Top', 'wpfront-scroll-top'); ?></label> <span class="description"><?php echo __('[Default action on WP-ADMIN pages.]', 'wpfront-scroll-top'); ?></span>
193
+ <br />
194
+ <label><input type="radio" class="button-action" name="<?php echo $this->options->button_action_name(); ?>" value="element" <?php echo $this->options->button_action() == 'element' ? 'checked' : ''; ?> /> <?php echo __('Scroll to Element', 'wpfront-scroll-top'); ?></label>
195
+ <div class="fields-container element hidden">
196
+ <div>
197
+ <span><input class="alignment-holder" type="radio"/></span>
198
+ <span class="sub-label"><?php echo $this->options->button_action_element_selector_label() . ':&nbsp;'; ?></span>
199
+ <span><input name="<?php echo $this->options->button_action_element_selector_name(); ?>" value="<?php echo $this->options->button_action_element_selector(); ?>" /> <span class="description"><?php echo __('[CSS selector of the element, you are trying to scroll to. Ex: #myDivID, .myDivClass]', 'wpfront-scroll-top'); ?></span></span>
200
+ </div>
201
+ <div>
202
+ <span><input class="alignment-holder" type="radio"/></span>
203
+ <span class="sub-label"><?php echo $this->options->button_action_container_selector_label() . ':&nbsp;'; ?></span>
204
+ <span><input name="<?php echo $this->options->button_action_container_selector_name(); ?>" value="<?php echo $this->options->button_action_container_selector(); ?>" /> <span class="description"><?php echo __('[CSS selector of the element, which has the scroll bar. "html, body" works in almost all cases.]', 'wpfront-scroll-top'); ?></span></span>
205
+ </div>
206
+ <div>
207
+ <span><input class="alignment-holder" type="radio"/></span>
208
+ <span class="sub-label"><?php echo $this->options->button_action_element_offset_label() . ':&nbsp;'; ?></span>
209
+ <span><input class="pixels" name="<?php echo $this->options->button_action_element_offset_name(); ?>" value="<?php echo $this->options->button_action_element_offset(); ?>" />px <span class="description"><?php echo __('[Negative value allowed. Use this filed to precisely set scroll position. Useful when you have overlapping elements.]', 'wpfront-scroll-top'); ?></span></span>
210
+ </div>
211
+ <div>
212
+ <span><input class="alignment-holder" type="radio"/></span>
213
+ <span class="sub-label"><a target="_blank" href="https://wpfront.com/wordpress-plugins/scroll-top-plugin/scroll-top-plugin-faq/"><?php echo __('How to find CSS selector?', 'wpfront-scroll-top'); ?></a></span>
214
+ </div>
215
+ </div>
216
+ <br />
217
+ <label><input type="radio" class="button-action" name="<?php echo $this->options->button_action_name(); ?>" value="url" <?php echo $this->options->button_action() == 'url' ? 'checked' : ''; ?> /> <?php echo __('Link to Page', 'wpfront-scroll-top'); ?></label>
218
+ <div class="fields-container url hidden">
219
+ <div>
220
+ <span><input class="alignment-holder" type="radio"/></span>
221
+ <span class="sub-label"><?php echo $this->options->button_action_page_url_label() . ':&nbsp;'; ?></span>
222
+ <span class="url"><input class="url" name="<?php echo $this->options->button_action_page_url_name(); ?>" value="<?php echo $this->options->button_action_page_url(); ?>" /></span>
223
+ </div>
224
+ </div>
225
+ </div>
226
+ </td>
227
+ </tr>
228
  </table>
229
 
230
  <h3><?php echo __('Location', 'wpfront-scroll-top'); ?></h3>
446
  <div>
447
  <input id="custom" name="<?php echo $this->options->image_name(); ?>" type="radio" value="custom" <?php echo ($this->options->image() == 'custom' ? 'checked' : ''); ?> />
448
  <label for="custom"><?php echo __('Custom URL', 'wpfront-scroll-top'); ?>
449
+ <input id="custom-url-textbox" class="url" name="<?php echo $this->options->custom_url_name(); ?>" value="<?php echo $this->options->custom_url(); ?>"/>
450
+ <input type="button" id="media-library-button" class="button" value="<?php echo __('Media Library', 'wpfront-scroll-top'); ?>" />
451
  </label>
452
  </div>
453
  <table class="form-table">
456
  <?php echo $this->options->image_alt_label(); ?>
457
  </th>
458
  <td>
459
+ <input id="alt-textbox" class="altText" name="<?php echo $this->options->image_alt_name(); ?>" value="<?php echo $this->options->image_alt(); ?>" />
460
  </td>
461
  </tr>
462
  </table>
465
  <?php @$this->options_page_footer('scroll-top-plugin-settings/', 'scroll-top-plugin-faq/'); ?>
466
 
467
  <script type="text/javascript">
468
+ (function() {
469
+ init_wpfront_scroll_top_options({
470
+ button_style: '<?php echo $this->options->button_style(); ?>',
471
+ button_action: '<?php echo $this->options->button_action(); ?>',
472
+ label_choose_image: '<?php echo __('Choose Image', 'wpfront-scroll-top'); ?>',
473
+ label_select_image: '<?php echo __('Select Image', 'wpfront-scroll-top'); ?>'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
474
  });
475
+ })();
 
 
476
  </script>
477
 
templates/scroll-top-template.php CHANGED
@@ -63,9 +63,11 @@ namespace WPFront\Scroll_Top;
63
  if ($this->options->button_style() == 'text') {
64
  ?>
65
  <div id="wpfront-scroll-top-container">
66
- <div class="text-holder">
67
- <?php echo $this->options->text_button_text(); ?>
68
- </div>
 
 
69
  </div>
70
 
71
  <style type="text/css">
@@ -85,7 +87,13 @@ if ($this->options->button_style() == 'text') {
85
  <?php
86
  } elseif($this->options->button_style() == 'font-awesome') {
87
  ?>
88
- <div id="wpfront-scroll-top-container"><i class="<?php echo $this->options->fa_button_class(); ?>"></i></div>
 
 
 
 
 
 
89
 
90
  <style type="text/css">
91
  #wpfront-scroll-top-container i {
@@ -97,7 +105,13 @@ if ($this->options->button_style() == 'text') {
97
  <?php
98
  } else {
99
  ?>
100
- <div id="wpfront-scroll-top-container"><img src="<?php echo $this->image(); ?>" alt="<?php echo $this->options->image_alt(); ?>" /></div>
 
 
 
 
 
 
101
  <?php
102
  }
103
  ?>
63
  if ($this->options->button_style() == 'text') {
64
  ?>
65
  <div id="wpfront-scroll-top-container">
66
+ <?php
67
+ $html = sprintf('<div class="text-holder">%s</div>', $this->options->text_button_text());
68
+ $html = $this->apply_button_action_html($html);
69
+ echo $html;
70
+ ?>
71
  </div>
72
 
73
  <style type="text/css">
87
  <?php
88
  } elseif($this->options->button_style() == 'font-awesome') {
89
  ?>
90
+ <div id="wpfront-scroll-top-container">
91
+ <?php
92
+ $html = sprintf('<i class="%s"></i>', $this->options->fa_button_class());
93
+ $html = $this->apply_button_action_html($html);
94
+ echo $html;
95
+ ?>
96
+ </div>
97
 
98
  <style type="text/css">
99
  #wpfront-scroll-top-container i {
105
  <?php
106
  } else {
107
  ?>
108
+ <div id="wpfront-scroll-top-container">
109
+ <?php
110
+ $html = sprintf('<img src="%s" alt="%s" />', $this->image(), $this->options->image_alt());
111
+ $html = $this->apply_button_action_html($html);
112
+ echo $html;
113
+ ?>
114
+ </div>
115
  <?php
116
  }
117
  ?>
wpfront-scroll-top.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: WPFront Scroll Top
4
  * Plugin URI: http://wpfront.com/scroll-top-plugin/
5
  * Description: Allows the visitor to easily scroll back to the top of the page.
6
- * Version: 1.6.2
7
  * Author: Syam Mohan
8
  * Author URI: http://wpfront.com
9
  * License: GPL v3
@@ -35,4 +35,4 @@ namespace WPFront\Scroll_Top;
35
 
36
  require_once("classes/class-wpfront-scroll-top.php");
37
 
38
- new WPFront_Scroll_Top();
3
  * Plugin Name: WPFront Scroll Top
4
  * Plugin URI: http://wpfront.com/scroll-top-plugin/
5
  * Description: Allows the visitor to easily scroll back to the top of the page.
6
+ * Version: 2.0.1
7
  * Author: Syam Mohan
8
  * Author URI: http://wpfront.com
9
  * License: GPL v3
35
 
36
  require_once("classes/class-wpfront-scroll-top.php");
37
 
38
+ WPFront_Scroll_Top::Instance()->init(__FILE__);