-
Notifications
You must be signed in to change notification settings - Fork 0
/
custom-featured-page-widget.php
69 lines (63 loc) · 2.15 KB
/
custom-featured-page-widget.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
/**
* Custom Featured Page Widget
*
* @package Custom_Featured_Page_Widget
* @author Sridhar Katakam
* @license GPL-2.0+
* @link https://sridharkatakam.com/
* @copyright 2017 Sridhar Katakam
*
* @wordpress-plugin
* Plugin Name: Custom Featured Page Widget
* Plugin URI: https://sridharkatakam.com/...
* Description: Provides a canvas for modifying Genesis Featured Page Widget.
* Version: 1.0.1
* Author: Sridhar Katakam
* Author URI: https://sridharkatakam.com/
* Text Domain: custom-featured-page-widget
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Domain Path: /languages
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
register_activation_hook( __FILE__, 'custom_activation_check' );
/**
* Check if Genesis is the parent theme.
*/
function custom_activation_check() {
$theme_info = wp_get_theme();
$genesis_flavors = array(
'genesis',
'genesis-trunk',
);
if ( ! in_array( $theme_info->Template, $genesis_flavors, true ) ) {
deactivate_plugins( plugin_basename( __FILE__ ) ); // Deactivate ourself.
$message = sprintf(
/* translators: %s: URL to Genesis Framework. */
__( 'Sorry, you can\'t activate this plugin unless you have installed <a href="%s">Genesis</a>.', 'genesis-simple-hook-guide' ),
esc_url( 'https://my.studiopress.com/themes/genesis/' )
);
wp_die( $message );
}
}
add_action( 'widgets_init', 'custom_featured_page_widget', 15 );
/**
* Register widgets for use in a Genesis child theme.
*
* @since 1.0.0
*/
function custom_featured_page_widget() {
require plugin_dir_path( __FILE__ ) . 'class-custom-featured-page.php';
unregister_widget( 'Genesis_Featured_Page' );
register_widget( 'Custom_Featured_Page' );
}
/* Note: If the require is happening too late, then move into a new function, hooked to genesis_setup, 15 instead:
add_action( 'genesis_setup', 'custom_featured_page_load_class', 15 );
function custom_featured_page_load_class() {
require plugin_dir_path( __FILE__ ) . 'class-custom-featured-page.php';
}
*/