catch-scroll-progress-bar
Last commit date
admin
6 years ago
includes
6 years ago
languages
6 years ago
public
6 years ago
LICENSE.txt
6 years ago
README.txt
6 years ago
catch-scroll-progress-bar.php
6 years ago
index.php
6 years ago
uninstall.php
6 years ago
catch-scroll-progress-bar.php
165 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * The plugin bootstrap file |
| 5 | * |
| 6 | * This file is read by WordPress to generate the plugin information in the plugin |
| 7 | * admin area. This file also includes all of the dependencies used by the plugin, |
| 8 | * registers the activation and deactivation functions, and defines a function |
| 9 | * that starts the plugin. |
| 10 | * |
| 11 | * @link www.catchplugins.com |
| 12 | * @since 1.0.0 |
| 13 | * @package Catch_Scroll_Progress_Bar |
| 14 | * |
| 15 | * @wordpress-plugin |
| 16 | * Plugin Name: Catch Scroll Progress Bar |
| 17 | * Plugin URI: wordpress.org/plugins/catch-scroll-progress-bar |
| 18 | * Description: This is a simple, super-light WordPress progress bar plugin that has the most essential features to show the users how far they’ve scrolled through the current page or post |
| 19 | * Version: 1.1 |
| 20 | * Author: Catch Plugins |
| 21 | * Author URI: www.catchplugins.com |
| 22 | * License: GPL-2.0+ |
| 23 | * License URI: http://www.gnu.org/licenses/gpl-2.0.txt |
| 24 | * Text Domain: catch-scroll-progress-bar |
| 25 | * Domain Path: /languages |
| 26 | */ |
| 27 | |
| 28 | // If this file is called directly, abort. |
| 29 | if ( ! defined( 'WPINC' ) ) { |
| 30 | die; |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * Currently plugin version. |
| 35 | * Start at version 1.0.0 and use SemVer - https://semver.org |
| 36 | * Rename this for your plugin and update it as you release new versions. |
| 37 | */ |
| 38 | define( 'CATCH_SCROLL_PROGRESS_BAR_VERSION', '1.1' ); |
| 39 | |
| 40 | /** |
| 41 | * The code that runs during plugin activation. |
| 42 | * This action is documented in includes/class-catch-scroll-progress-bar-activator.php |
| 43 | */ |
| 44 | // The URL of the directory that contains the plugin |
| 45 | if ( !defined( 'CATCH_SCROLL_PROGRESS_BAR_URL' ) ) { |
| 46 | define( 'CATCH_SCROLL_PROGRESS_BAR_URL', plugin_dir_url( __FILE__ ) ); |
| 47 | } |
| 48 | |
| 49 | |
| 50 | // The absolute path of the directory that contains the file |
| 51 | if ( !defined( 'CATCH_SCROLL_PROGRESS_BAR_PATH' ) ) { |
| 52 | define( 'CATCH_SCROLL_PROGRESS_BAR_PATH', plugin_dir_path( __FILE__ ) ); |
| 53 | } |
| 54 | |
| 55 | |
| 56 | // Gets the path to a plugin file or directory, relative to the plugins directory, without the leading and trailing slashes. |
| 57 | if ( !defined( 'CATCH_SCROLL_PROGRESS_BAR_BASENAME' ) ) { |
| 58 | define( 'CATCH_SCROLL_PROGRESS_BAR_BASENAME', plugin_basename( __FILE__ ) ); |
| 59 | } |
| 60 | |
| 61 | function activate_catch_scroll_progress_bar() { |
| 62 | require_once plugin_dir_path( __FILE__ ) . 'includes/class-catch-scroll-progress-bar-activator.php'; |
| 63 | Catch_Scroll_Progress_Bar_Activator::activate(); |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * The code that runs during plugin deactivation. |
| 68 | * This action is documented in includes/class-catch-scroll-progress-bar-deactivator.php |
| 69 | */ |
| 70 | function deactivate_catch_scroll_progress_bar() { |
| 71 | require_once plugin_dir_path( __FILE__ ) . 'includes/class-catch-scroll-progress-bar-deactivator.php'; |
| 72 | Catch_Scroll_Progress_Bar_Deactivator::deactivate(); |
| 73 | } |
| 74 | |
| 75 | register_activation_hook( __FILE__, 'activate_catch_scroll_progress_bar' ); |
| 76 | register_deactivation_hook( __FILE__, 'deactivate_catch_scroll_progress_bar' ); |
| 77 | |
| 78 | /** |
| 79 | * The core plugin class that is used to define internationalization, |
| 80 | * admin-specific hooks, and public-facing site hooks. |
| 81 | */ |
| 82 | require plugin_dir_path( __FILE__ ) . 'includes/class-catch-scroll-progress-bar.php'; |
| 83 | |
| 84 | /** |
| 85 | * Begins execution of the plugin. |
| 86 | * |
| 87 | * Since everything within the plugin is registered via hooks, |
| 88 | * then kicking off the plugin from this point in the file does |
| 89 | * not affect the page life cycle. |
| 90 | * |
| 91 | * @since 1.0.0 |
| 92 | */ |
| 93 | if ( ! function_exists( 'catch_progress_bar_get_options' ) ) : |
| 94 | function catch_progress_bar_get_options() { |
| 95 | $defaults = catch_progress_bar_default_options(); |
| 96 | $options = get_option( 'catch_progress_bar_options', $defaults ); |
| 97 | return wp_parse_args( $options, $defaults ) ; |
| 98 | } |
| 99 | endif; |
| 100 | |
| 101 | |
| 102 | if ( ! function_exists( 'catch_progress_bar_default_options' ) ) : |
| 103 | /** |
| 104 | * Return array of default options |
| 105 | * |
| 106 | * @since 1.0 |
| 107 | * @return array default options. |
| 108 | */ |
| 109 | function catch_progress_bar_default_options( $option = null ) { |
| 110 | $default_options = array( |
| 111 | |
| 112 | 'status' => 1, |
| 113 | 'background_color' => '#32dbd5', |
| 114 | 'foreground_opacity' => 1, |
| 115 | 'background_opacity' => 1, |
| 116 | 'foreground_color' => '#dd0f0f', |
| 117 | 'progress_bar_height' => '', |
| 118 | 'progress_bar_position' => '', |
| 119 | 'home' => 1, |
| 120 | 'blog' => 0, |
| 121 | 'archive' => 0, |
| 122 | 'single' => 0, |
| 123 | 'field_posttypes' => array(), |
| 124 | 'bar_height' =>'7', |
| 125 | 'radius' =>'8' |
| 126 | ); |
| 127 | |
| 128 | |
| 129 | |
| 130 | if ( null == $option ) { |
| 131 | return apply_filters( 'catch_progress_bar_deafault_options', $default_options ); |
| 132 | } |
| 133 | else { |
| 134 | return $default_options[ $option ]; |
| 135 | } |
| 136 | } |
| 137 | endif; // catch_progress_bar_default_options |
| 138 | function catch_progress_bar_position(){ |
| 139 | $options = array( |
| 140 | 'top'=> esc_html__( 'Top', 'catch-scroll-progress-bar' ), |
| 141 | 'bottom' => esc_html__( 'Bottom', 'catch-scroll-progress-bar' ), |
| 142 | |
| 143 | ); |
| 144 | return $options; |
| 145 | } |
| 146 | |
| 147 | function run_catch_scroll_progress_bar() { |
| 148 | |
| 149 | $plugin = new Catch_Scroll_Progress_Bar(); |
| 150 | $plugin->run(); |
| 151 | |
| 152 | } |
| 153 | run_catch_scroll_progress_bar(); |
| 154 | |
| 155 | /* CTP tabs removal options */ |
| 156 | require plugin_dir_path( __FILE__ ) . '/includes/ctp-tabs-removal.php'; |
| 157 | |
| 158 | $ctp_options = ctp_get_options(); |
| 159 | if( 1 == $ctp_options['theme_plugin_tabs'] ) { |
| 160 | /* Adds Catch Themes tab in Add theme page and Themes by Catch Themes in Customizer's change theme option. */ |
| 161 | if( ! class_exists( 'CatchThemesThemePlugin' ) && ! function_exists( 'add_our_plugins_tab' ) ) { |
| 162 | require plugin_dir_path( __FILE__ ) . '/includes/CatchThemesThemePlugin.php'; |
| 163 | } |
| 164 | } |
| 165 |