PluginProbe
Essential Widgets / trunk
Essential Widgets vtrunk
3.2.1 3.3 3.2 trunk 1.0.0 1.0.1 1.1 1.2 1.2.1 1.2.2 1.3 1.4 1.4.1 1.5 1.6 1.7 1.7.1 1.7.2 1.7.3 1.7.4 1.8 1.9 2.0 2.1 2.2 All 31 releases
essential-widgets / essential-widgets.php

essential-widgets.php in Essential Widgets trunk, at essential-widgets.php

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