custom-sidebars
Last commit date
assets
4 years ago
inc
1 year ago
languages
5 years ago
views
1 year ago
customsidebars.php
1 year ago
license.txt
5 years ago
readme.txt
1 year ago
customsidebars.php
152 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Plugin Name: Custom Sidebars |
| 4 | * Plugin URI: https://wordpress.org/plugins/custom-sidebars/ |
| 5 | * Description: Allows you to create widgetized areas and custom sidebars. Replace whole sidebars or single widgets for specific posts and pages. |
| 6 | * Version: 3.37 |
| 7 | * Author: WebFactory Ltd |
| 8 | * Author URI: https://www.webfactoryltd.com/ |
| 9 | * Textdomain: custom-sidebars |
| 10 | * License: GPLv2 or later |
| 11 | * Tested up to: 6.7 |
| 12 | */ |
| 13 | |
| 14 | /* |
| 15 | Copyright Incsub 2017 - 2020 (https://incsub.com) |
| 16 | Copyright WebFactory Ltd 2020 - 2025 (https://www.webfactoryltd.com/) |
| 17 | |
| 18 | This program is free software; you can redistribute it and/or modify |
| 19 | it under the terms of the GNU General Public License (Version 2 - GPLv2) as published by |
| 20 | the Free Software Foundation. |
| 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, write to the Free Software |
| 29 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 30 | |
| 31 | This plugin was originally developed by Javier Marquez. http://arqex.com/ |
| 32 | */ |
| 33 | |
| 34 | function inc_sidebars_init() { |
| 35 | if ( class_exists( 'CustomSidebars' ) ) { |
| 36 | return; |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * Do not load plugin when saving file in WP Editor |
| 41 | */ |
| 42 | if ( isset( $_REQUEST['action'] ) && 'edit-theme-plugin-file' == $_REQUEST['action'] ) { |
| 43 | return; |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * if admin, load only on proper pages |
| 48 | */ |
| 49 | if ( is_admin() && isset( $_SERVER['SCRIPT_FILENAME'] ) ) { |
| 50 | $file = basename( $_SERVER['SCRIPT_FILENAME'] ); |
| 51 | $allowed = array( |
| 52 | 'edit.php', |
| 53 | 'admin-ajax.php', |
| 54 | 'post.php', |
| 55 | 'plugins.php', |
| 56 | 'post-new.php', |
| 57 | 'widgets.php', |
| 58 | ); |
| 59 | /** |
| 60 | * Allowed pages array. |
| 61 | * |
| 62 | * To change where Custom Sidebars is loaded, use this filter. |
| 63 | * |
| 64 | * @since 3.2.3 |
| 65 | * |
| 66 | * @param array $allowed Allowed pages list. |
| 67 | */ |
| 68 | $allowed = apply_filters( 'custom_sidebars_allowed_pages_array', $allowed ); |
| 69 | if ( ! in_array( $file, $allowed ) ) { |
| 70 | return; |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | $plugin_dir = dirname( __FILE__ ); |
| 75 | $plugin_dir_rel = dirname( plugin_basename( __FILE__ ) ); |
| 76 | $plugin_url = plugin_dir_url( __FILE__ ); |
| 77 | |
| 78 | define( 'CSB_PLUGIN', __FILE__ ); |
| 79 | define( 'CSB_IS_PRO', false ); |
| 80 | define( 'CSB_VIEWS_DIR', $plugin_dir . '/views/' ); |
| 81 | define( 'CSB_INC_DIR', $plugin_dir . '/inc/' ); |
| 82 | define( 'CSB_JS_URL', $plugin_url . 'assets/js/' ); |
| 83 | define( 'CSB_CSS_URL', $plugin_url . 'assets/css/' ); |
| 84 | define( 'CSB_IMG_URL', $plugin_url . 'assets/img/' ); |
| 85 | |
| 86 | // Include function library. |
| 87 | $modules[] = CSB_INC_DIR . 'external/wpmu-lib/core.php'; |
| 88 | $modules[] = CSB_INC_DIR . 'class-custom-sidebars.php'; |
| 89 | |
| 90 | |
| 91 | // Free-version configuration - no drip campaign yet... |
| 92 | $cta_label = false; |
| 93 | $drip_param = false; |
| 94 | |
| 95 | |
| 96 | |
| 97 | |
| 98 | foreach ( $modules as $path ) { |
| 99 | if ( file_exists( $path ) ) { require_once $path; } |
| 100 | } |
| 101 | |
| 102 | // Register the current plugin, for pro and free plugins! |
| 103 | do_action( |
| 104 | 'wdev-register-plugin', |
| 105 | /* Plugin ID */ plugin_basename( __FILE__ ), |
| 106 | /* Plugin Title */ 'CustomSidebars', |
| 107 | /* https://wordpress.org */ '/plugins/custom-sidebars/', |
| 108 | /* Email Button CTA */ $cta_label, |
| 109 | /* getdrip Plugin param */ $drip_param |
| 110 | ); |
| 111 | |
| 112 | // Initialize the plugin |
| 113 | CustomSidebars::instance(); |
| 114 | } |
| 115 | |
| 116 | inc_sidebars_init(); |
| 117 | |
| 118 | if ( ! class_exists( 'CustomSidebarsEmptyPlugin' ) ) { |
| 119 | class CustomSidebarsEmptyPlugin extends WP_Widget { |
| 120 | public function __construct() { |
| 121 | parent::__construct( false, $name = 'CustomSidebarsEmptyPlugin' ); |
| 122 | } |
| 123 | public function form( $instance ) { |
| 124 | //Nothing, just a dummy plugin to display nothing |
| 125 | } |
| 126 | public function update( $new_instance, $old_instance ) { |
| 127 | //Nothing, just a dummy plugin to display nothing |
| 128 | } |
| 129 | public function widget( $args, $instance ) { |
| 130 | echo ''; |
| 131 | } |
| 132 | } //end class |
| 133 | } //end if class exists |
| 134 | |
| 135 | |
| 136 | // Translation. |
| 137 | function inc_sidebars_init_translation() { |
| 138 | load_plugin_textdomain( 'custom-sidebars', false, basename( dirname( __FILE__ ) ) . '/languages' ); |
| 139 | } |
| 140 | add_action( 'plugins_loaded', 'inc_sidebars_init_translation' ); |
| 141 | |
| 142 | // since the notification needs to be global and show everywhere we'll add it outside the plugin's class |
| 143 | add_action('init', function() { |
| 144 | add_action('admin_notices', function() { |
| 145 | global $wp_version; |
| 146 | |
| 147 | if ((false == is_plugin_active('classic-widgets/classic-widgets.php') && apply_filters('use_widgets_block_editor', true)) && version_compare($wp_version, '5.8', '>=') == true) { |
| 148 | CustomSidebars::wp_kses_wf('<div class="error notice" style="max-width: 700px;"><p><b>🔥 IMPORTANT 🔥</b><br><br>Custom Sidebars plugin is NOT compatible with the new widgets edit screen (powered by Gutenberg).<br>Install the official <a href="' . admin_url('plugin-install.php?s=classic%20widgets&tab=search&type=term') . '">Classic Widgets</a> plugin if you want to continue using it.</p></div>'); |
| 149 | } |
| 150 | }); |
| 151 | }, 1000, 0); |
| 152 |