| 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 https://catchplugins.com |
| 12 |
* @since 1.0.0 |
| 13 |
* @package Essential_Widgets |
| 14 |
* |
| 15 |
* @wordpress-plugin |
| 16 |
* Plugin Name: Essential Widgets |
| 17 |
* Plugin URI: https://catchplugins.com/plugins/essential-widgets/ |
| 18 |
* Description: Essential Widgets is a WordPress plugin for widgets that allows you to create and add amazing widgets with high customization option on your website without affecting your wallet. |
| 19 |
* Version: 3.1 |
| 20 |
* Author: Catch Plugins |
| 21 |
* Author URI: https://catchplugins.com/ |
| 22 |
* License: GPL-2.0+ |
| 23 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt |
| 24 |
* Text Domain: essential-widgets |
| 25 |
* Domain Path: /languages |
| 26 |
*/ |
| 27 |
|
| 28 |
// If this file is called directly, abort. |
| 29 |
if ( ! defined( 'WPINC' ) ) { |
| 30 |
die; |
| 31 |
} |
| 32 |
|
| 33 |
// Define Version |
| 34 |
define( 'ESSENTIAL_WIDGETS_VERSION', '3.1' ); |
| 35 |
|
| 36 |
/** |
| 37 |
* The code that runs during plugin activation. |
| 38 |
* This action is documented in includes/class-essential-widgets-activator.php |
| 39 |
*/ |
| 40 |
if ( ! defined( 'ESSENTIAL_WIDGETS_URL' ) ) { |
| 41 |
define( 'ESSENTIAL_WIDGETS_URL', plugin_dir_url( __FILE__ ) ); |
| 42 |
} |
| 43 |
|
| 44 |
|
| 45 |
// The absolute path of the directory that contains the file |
| 46 |
if ( ! defined( 'ESSENTIAL_WIDGETS_PATH' ) ) { |
| 47 |
define( 'ESSENTIAL_WIDGETS_PATH', plugin_dir_path( __FILE__ ) ); |
| 48 |
} |
| 49 |
|
| 50 |
|
| 51 |
// Gets the path to a plugin file or directory, relative to the plugins directory, without the leading and trailing slashes. |
| 52 |
if ( ! defined( 'ESSENTIAL_WIDGETS_BASENAME' ) ) { |
| 53 |
define( 'ESSENTIAL_WIDGETS_BASENAME', plugin_basename( __FILE__ ) ); |
| 54 |
} |
| 55 |
|
| 56 |
function essential_widgets_activate() { |
| 57 |
$required = 'essential-widgets-pro/essential-widgets-pro.php'; |
| 58 |
if ( is_plugin_active( $required ) ) { |
| 59 |
// Translators: %1$s and %2$s wrap the "Return to Plugins" link. The message informs the user that the Pro version is active. |
| 60 |
$message = __( 'Sorry, Pro version is already active. No need to activate Free version. If you still want to activate the Free version, please deactivate the Pro version first. %1$s« Return to Plugins%2$s.', 'essential-widgets' ); |
| 61 |
|
| 62 |
$message = sprintf( |
| 63 |
$message, |
| 64 |
'<br><a href="' . esc_url( admin_url( 'plugins.php' ) ) . '">', |
| 65 |
'</a>' |
| 66 |
); |
| 67 |
|
| 68 |
// Escape all HTML output before printing |
| 69 |
wp_die( wp_kses_post( $message ) ); |
| 70 |
} |
| 71 |
|
| 72 |
require_once plugin_dir_path( __FILE__ ) . 'includes/class-essential-widgets-activator.php'; |
| 73 |
Essential_Widgets_Activator::activate(); |
| 74 |
} |
| 75 |
|
| 76 |
/** |
| 77 |
* The code that runs during plugin deactivation. |
| 78 |
* This action is documented in includes/class-essential-widgets-deactivator.php |
| 79 |
*/ |
| 80 |
function essential_widgets_deactivate() { |
| 81 |
require_once plugin_dir_path( __FILE__ ) . 'includes/class-essential-widgets-deactivator.php'; |
| 82 |
Essential_Widgets_Deactivator::deactivate(); |
| 83 |
} |
| 84 |
|
| 85 |
register_activation_hook( __FILE__, 'essential_widgets_activate' ); |
| 86 |
register_deactivation_hook( __FILE__, 'essential_widgets_deactivate' ); |
| 87 |
|
| 88 |
/** |
| 89 |
* The core plugin class that is used to define internationalization, |
| 90 |
* admin-specific hooks, and public-facing site hooks. |
| 91 |
*/ |
| 92 |
require plugin_dir_path( __FILE__ ) . 'includes/class-essential-widgets.php'; |
| 93 |
|
| 94 |
|
| 95 |
function essential_widgets_sanitize_checkbox( $checked ) { |
| 96 |
// Boolean check. |
| 97 |
return ( ( isset( $checked ) && true === $checked ) ? true : false ); |
| 98 |
} |
| 99 |
|
| 100 |
if ( ! function_exists( 'essential_widgets_get_options' ) ) : |
| 101 |
function essential_widgets_get_options() { |
| 102 |
$defaults = essential_widgets_default_options(); |
| 103 |
$options = get_option( 'essential_widgets_options', $defaults ); |
| 104 |
|
| 105 |
return wp_parse_args( $options, $defaults ); |
| 106 |
} |
| 107 |
endif; // essential_widgets_get_options |
| 108 |
|
| 109 |
|
| 110 |
if ( ! function_exists( 'essential_widgets_default_options' ) ) : |
| 111 |
/** |
| 112 |
* Return array of default options |
| 113 |
* |
| 114 |
* @since 1.0 |
| 115 |
* @return array default options. |
| 116 |
*/ |
| 117 |
function essential_widgets_default_options( $option = null ) { |
| 118 |
$widget_list = essential_widgets_list(); |
| 119 |
$default_options = array(); |
| 120 |
|
| 121 |
foreach ( $widget_list as $key => $value ) { |
| 122 |
$default_options[ $key ] = 1; |
| 123 |
} |
| 124 |
|
| 125 |
if ( null === $option ) { |
| 126 |
return apply_filters( 'essential_widgets_options', $default_options ); |
| 127 |
} else { |
| 128 |
return $default_options[ $option ]; |
| 129 |
} |
| 130 |
} |
| 131 |
endif; // essential_widgets_default_options |
| 132 |
|
| 133 |
|
| 134 |
if ( ! function_exists( 'essential_widgets_list' ) ) : |
| 135 |
function essential_widgets_list() { |
| 136 |
$widget_list = array( |
| 137 |
'ew_authors' => 'EW: Authors', |
| 138 |
'ew_categories' => 'EW: Category', |
| 139 |
'ew_menus' => 'EW: Menu', |
| 140 |
'ew_pages' => 'EW: Pages', |
| 141 |
'ew_posts' => 'EW: Post', |
| 142 |
'ew_archives' => 'EW: Recent Posts', |
| 143 |
'ew_tags' => 'EW: Tags', |
| 144 |
); |
| 145 |
return $widget_list; |
| 146 |
} |
| 147 |
endif; |
| 148 |
|
| 149 |
/** |
| 150 |
* Begins execution of the plugin. |
| 151 |
* |
| 152 |
* Since everything within the plugin is registered via hooks, |
| 153 |
* then kicking off the plugin from this point in the file does |
| 154 |
* not affect the page life cycle. |
| 155 |
* |
| 156 |
* @since 1.0.0 |
| 157 |
*/ |
| 158 |
function essential_widgets_run() { |
| 159 |
|
| 160 |
$plugin = new Essential_Widgets(); |
| 161 |
$plugin->run(); |
| 162 |
|
| 163 |
} |
| 164 |
essential_widgets_run(); |
| 165 |
|
| 166 |
/* CTP tabs removal options */ |
| 167 |
require plugin_dir_path( __FILE__ ) . 'includes/ctp-tabs-removal.php'; |
| 168 |
|
| 169 |
$ctp_options = ctp_get_options(); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Used immediately on the next line; ctp_ prefix kept for cross-plugin compatibility. |
| 170 |
if ( 1 === (int) $ctp_options['theme_plugin_tabs'] ) { |
| 171 |
/* Adds Catch Themes tab in Add theme page and Themes by Catch Themes in Customizer's change theme option. */ |
| 172 |
if ( ! class_exists( 'CatchThemesThemePlugin' ) && ! function_exists( 'add_our_plugins_tab' ) ) { |
| 173 |
require plugin_dir_path( __FILE__ ) . 'includes/CatchThemesThemePlugin.php'; |
| 174 |
} |
| 175 |
} |
| 176 |
|
| 177 |
/** Add EW Blocks */ |
| 178 |
require plugin_dir_path( __FILE__ ) . 'includes/ew-block/index.php'; |
| 179 |
|