| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Plugin Name: To Top |
| 5 |
* Plugin URI: https://catchplugins.com/plugins/to-top/ |
| 6 |
* Description: To Top plugin allows the visitor as well as admin to easily scroll back to the top of the page, with fully customizable options and ability to use image. |
| 7 |
* Author: Catch Plugins |
| 8 |
* Author URI: https://catchplugins.com/ |
| 9 |
* Version: 3.0 |
| 10 |
* License: GPL-3.0+ |
| 11 |
* License URI: http://www.gnu.org/licenses/gpl-3.0.txt |
| 12 |
* Text Domain: to-top |
| 13 |
* Domain Path: languages |
| 14 |
* |
| 15 |
* Copyright (C) 2012-2018 Catch Plugins, (info@catchplugins.com) |
| 16 |
* |
| 17 |
* To Top Plugin is free software; you can redistribute it and/or modify |
| 18 |
* it under the terms of the GNU General Public License as published by |
| 19 |
* the Free Software Foundation; either version 3 of the License, or |
| 20 |
* (at your option) any later version. |
| 21 |
* |
| 22 |
* This program is distributed in the hope that it will be useful, |
| 23 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 24 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 25 |
* GNU General Public License for more details. |
| 26 |
* |
| 27 |
* You should have received a copy of the GNU General Public License |
| 28 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 29 |
* |
| 30 |
* @package To_Top |
| 31 |
* @link catchplugins.com |
| 32 |
* @author Catch Plugins |
| 33 |
* @version 2.5.4 |
| 34 |
*/ |
| 35 |
|
| 36 |
// If this file is called directly, abort. |
| 37 |
if (! defined('WPINC')) { |
| 38 |
die; |
| 39 |
} |
| 40 |
|
| 41 |
// Define Version |
| 42 |
if (! defined('TOTOP_VERSION')) { |
| 43 |
define('TOTOP_VERSION', '3.0'); |
| 44 |
} |
| 45 |
|
| 46 |
// The URL of the directory that contains the plugin |
| 47 |
if (! defined('TOTOP_URL')) { |
| 48 |
define('TOTOP_URL', plugin_dir_url(__FILE__)); |
| 49 |
} |
| 50 |
|
| 51 |
|
| 52 |
// The absolute path of the directory that contains the file |
| 53 |
if (! defined('TOTOP_PATH')) { |
| 54 |
define('TOTOP_PATH', plugin_dir_path(__FILE__)); |
| 55 |
} |
| 56 |
|
| 57 |
// Gets the path to a plugin file or directory, relative to the plugins directory, without the leading and trailing slashes. |
| 58 |
if (! defined('TOTOP_BASENAME')) { |
| 59 |
define('TOTOP_BASENAME', plugin_basename(__FILE__)); |
| 60 |
} |
| 61 |
|
| 62 |
function activate_to_top() |
| 63 |
{ |
| 64 |
require_once plugin_dir_path(__FILE__) . 'includes/class-to-top-activator.php'; |
| 65 |
To_Top_Activator::activate(); |
| 66 |
} |
| 67 |
|
| 68 |
/** |
| 69 |
* The code that runs during plugin deactivation. |
| 70 |
* This action is documented in includes/class-to-top-deactivator.php |
| 71 |
*/ |
| 72 |
function deactivate_to_top() |
| 73 |
{ |
| 74 |
require_once plugin_dir_path(__FILE__) . 'includes/class-to-top-deactivator.php'; |
| 75 |
To_Top_Deactivator::deactivate(); |
| 76 |
} |
| 77 |
|
| 78 |
register_activation_hook(__FILE__, 'activate_to_top'); |
| 79 |
register_deactivation_hook(__FILE__, 'deactivate_to_top'); |
| 80 |
|
| 81 |
/** |
| 82 |
* The core plugin class that is used to define internationalization, |
| 83 |
* admin-specific hooks, and public-facing site hooks. |
| 84 |
*/ |
| 85 |
require plugin_dir_path(__FILE__) . 'includes/class-to-top.php'; |
| 86 |
|
| 87 |
/** |
| 88 |
* Begins execution of the plugin. |
| 89 |
* |
| 90 |
* Since everything within the plugin is registered via hooks, |
| 91 |
* then kicking off the plugin from this point in the file does |
| 92 |
* not affect the page life cycle. |
| 93 |
* |
| 94 |
* @since 1.0 |
| 95 |
*/ |
| 96 |
function run_to_top() |
| 97 |
{ |
| 98 |
|
| 99 |
$plugin = new To_Top(); |
| 100 |
$plugin->run(); |
| 101 |
} |
| 102 |
run_to_top(); |
| 103 |
|
| 104 |
/** |
| 105 |
* Returns the options array for Top options |
| 106 |
* |
| 107 |
* @since 1.0 |
| 108 |
*/ |
| 109 |
function to_top_get_options() |
| 110 |
{ |
| 111 |
$defaults = to_top_default_options(); |
| 112 |
$options = get_option('to_top_options', $defaults); |
| 113 |
|
| 114 |
return wp_parse_args($options, $defaults); |
| 115 |
} |
| 116 |
|
| 117 |
/** |
| 118 |
* Return array of default options |
| 119 |
* |
| 120 |
* @since 1.0 |
| 121 |
* @return array default options. |
| 122 |
*/ |
| 123 |
function to_top_default_options($option = null) |
| 124 |
{ |
| 125 |
$default_options = array( |
| 126 |
//Basic Settings |
| 127 |
'scroll_offset' => '100', |
| 128 |
'icon_opacity' => '50', |
| 129 |
'style' => 'icon', |
| 130 |
|
| 131 |
//Icon Settings |
| 132 |
'icon_type' => 'dashicons-arrow-up-alt2', |
| 133 |
'icon_color' => '#ffffff', |
| 134 |
'icon_bg_color' => '#000000', |
| 135 |
'icon_size' => '32', |
| 136 |
'border_radius' => '5', |
| 137 |
|
| 138 |
//Image Settings |
| 139 |
'image' => plugin_dir_url(__FILE__) . 'admin/images/default.png', |
| 140 |
'image_width' => '65', |
| 141 |
'image_alt' => '', |
| 142 |
|
| 143 |
//Advanced Settings |
| 144 |
'location' => 'bottom-right', |
| 145 |
'margin_x' => '20', |
| 146 |
'margin_y' => '20', |
| 147 |
'show_on_admin' => 0, |
| 148 |
'enable_autohide' => 0, |
| 149 |
'autohide_time' => '2', |
| 150 |
'enable_hide_small_device' => 0, |
| 151 |
'small_device_max_width' => '640', |
| 152 |
|
| 153 |
//Reset Settings |
| 154 |
'reset' => 0, |
| 155 |
); |
| 156 |
|
| 157 |
if (null == $option) { |
| 158 |
return apply_filters('to_top_options', $default_options); |
| 159 |
} else { |
| 160 |
return $default_options[$option]; |
| 161 |
} |
| 162 |
} |
| 163 |
|
| 164 |
/* CTP tabs removal options */ |
| 165 |
require plugin_dir_path(__FILE__) . 'admin/inc/ctp-tabs-removal.php'; |
| 166 |
|
| 167 |
$ctp_options = ctp_get_options(); |
| 168 |
if (1 == $ctp_options['theme_plugin_tabs']) { |
| 169 |
/* Adds Catch Themes tab in Add theme page and Themes by Catch Themes in Customizer's change theme option. */ |
| 170 |
if (! class_exists('CatchThemesThemePlugin') && ! function_exists('add_our_plugins_tab')) { |
| 171 |
require plugin_dir_path(__FILE__) . 'admin/inc/CatchThemesThemePlugin.php'; |
| 172 |
} |
| 173 |
} |
| 174 |
|