PluginProbe
Essential Widgets / 1.3
Essential Widgets v1.3
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 1.3, at essential-widgets.php

158 lines 5.3 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: 1.3
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 /**
34 * The code that runs during plugin activation.
35 * This action is documented in includes/class-essential-widgets-activator.php
36 */
37 if ( !defined( 'ESSENTIAL_WIDGETS_URL' ) ) {
38 define( 'ESSENTIAL_WIDGETS_URL', plugin_dir_url( __FILE__ ) );
39 }
40
41
42 // The absolute path of the directory that contains the file
43 if ( !defined( 'ESSENTIAL_WIDGETS_PATH' ) ) {
44 define( 'ESSENTIAL_WIDGETS_PATH', plugin_dir_path( __FILE__ ) );
45 }
46
47
48 // Gets the path to a plugin file or directory, relative to the plugins directory, without the leading and trailing slashes.
49 if ( !defined( 'ESSENTIAL_WIDGETS_BASENAME' ) ) {
50 define( 'ESSENTIAL_WIDGETS_BASENAME', plugin_basename( __FILE__ ) );
51 }
52 function activate_essential_widgets() {
53 $required = 'essential-widgets-pro/essential-widgets-pro.php';
54 if ( is_plugin_active( $required ) ) {
55 $message = esc_html__( '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' );
56 $message = sprintf( $message, '<br><a href="' . esc_url( admin_url( 'plugins.php' ) ) . '">', '</a>' );
57 wp_die( $message );
58 }
59 require_once plugin_dir_path( __FILE__ ) . 'includes/class-essential-widgets-activator.php';
60 Essential_Widgets_Activator::activate();
61 }
62
63 /**
64 * The code that runs during plugin deactivation.
65 * This action is documented in includes/class-essential-widgets-deactivator.php
66 */
67 function deactivate_essential_widgets() {
68 require_once plugin_dir_path( __FILE__ ) . 'includes/class-essential-widgets-deactivator.php';
69 Essential_Widgets_Deactivator::deactivate();
70 }
71
72 register_activation_hook( __FILE__, 'activate_essential_widgets' );
73 register_deactivation_hook( __FILE__, 'deactivate_essential_widgets' );
74
75 /**
76 * The core plugin class that is used to define internationalization,
77 * admin-specific hooks, and public-facing site hooks.
78 */
79 require plugin_dir_path( __FILE__ ) . 'includes/class-essential-widgets.php';
80
81
82 function essential_widgets_sanitize_checkbox( $checked ) {
83 // Boolean check.
84 return ( ( isset( $checked ) && true == $checked ) ? true : false );
85 }
86
87 if ( ! function_exists( 'essential_widgets_get_options' ) ) :
88 function essential_widgets_get_options() {
89 $defaults = essential_widgets_default_options();
90 $options = get_option( 'essential_widgets_options', $defaults );
91
92 return wp_parse_args( $options, $defaults ) ;
93 }
94 endif; // essential_widgets_get_options
95
96
97 if ( ! function_exists( 'essential_widgets_default_options' ) ) :
98 /**
99 * Return array of default options
100 *
101 * @since 1.0
102 * @return array default options.
103 */
104 function essential_widgets_default_options( $option = null ) {
105 $widget_list = essential_widgets_list();
106 foreach( $widget_list as $key => $value ) {
107 $default_options[$key] = 1;
108 }
109
110 if ( null == $option ) {
111 return apply_filters( 'essential_widgets_options', $default_options );
112 }
113 else {
114 return $default_options[ $option ];
115 }
116 }
117 endif; // essential_widgets_default_options
118
119
120 if ( ! function_exists( 'essential_widgets_list' ) ) :
121 function essential_widgets_list(){
122 $widget_list = array(
123 'ew_authors' => esc_html__( 'EW: Authors', 'essential-widgets' ),
124 'ew_categories' => esc_html__( 'EW: Category', 'essential-widgets' ),
125 'ew_menus' => esc_html__( 'EW: Menu', 'essential-widgets' ),
126 'ew_pages' => esc_html__( 'EW: Pages', 'essential-widgets' ),
127 'ew_posts' => esc_html__( 'EW: Post', 'essential-widgets' ),
128 'ew_archives' => esc_html__( 'EW: Recent Posts', 'essential-widgets' ),
129 'ew_tags' => esc_html__( 'EW: Tags', 'essential-widgets' ),
130 );
131 return $widget_list;
132 }
133 endif;
134
135 /**
136 * Begins execution of the plugin.
137 *
138 * Since everything within the plugin is registered via hooks,
139 * then kicking off the plugin from this point in the file does
140 * not affect the page life cycle.
141 *
142 * @since 1.0.0
143 */
144 function run_essential_widgets() {
145
146 $plugin = new Essential_Widgets();
147 $plugin->run();
148
149 }
150 run_essential_widgets();
151 /* Adds Catch Themes tab in Add theme page and Themes by Catch Themes in Customizer's change theme option. */
152 require plugin_dir_path( __FILE__ ) . 'includes/our-themes.php';
153
154 /* Adds Catch Plugins tab in Add theme page. */
155 require plugin_dir_path( __FILE__ ) . 'includes/our-plugins.php';
156
157
158