| 1 |
<?php |
| 2 |
/** |
| 3 |
* Module Name: Extra Sidebar Widgets |
| 4 |
* Module Description: Add images, Twitter streams, your site’s RSS links, and more to your sidebar. |
| 5 |
* Sort Order: 4 |
| 6 |
* First Introduced: 1.2 |
| 7 |
* Requires Connection: No |
| 8 |
* Auto Activate: Yes |
| 9 |
* Module Tags: Social, Appearance |
| 10 |
* Additional Search Queries: widget, widgets, facebook, gallery, twitter, gravatar, image, rss |
| 11 |
*/ |
| 12 |
|
| 13 |
function jetpack_load_widgets() { |
| 14 |
$widgets_include = array(); |
| 15 |
|
| 16 |
foreach ( Jetpack::glob_php( dirname( __FILE__ ) . '/widgets' ) as $file ) { |
| 17 |
$widgets_include[] = $file; |
| 18 |
} |
| 19 |
/** |
| 20 |
* Modify which Jetpack Widgets to register. |
| 21 |
* |
| 22 |
* @module widgets |
| 23 |
* |
| 24 |
* @since 2.2.1 |
| 25 |
* |
| 26 |
* @param array $widgets_include An array of widgets to be registered. |
| 27 |
*/ |
| 28 |
$widgets_include = apply_filters( 'jetpack_widgets_to_include', $widgets_include ); |
| 29 |
|
| 30 |
foreach( $widgets_include as $include ) { |
| 31 |
include $include; |
| 32 |
} |
| 33 |
} |
| 34 |
|
| 35 |
add_action( 'jetpack_modules_loaded', 'jetpack_widgets_loaded' ); |
| 36 |
|
| 37 |
function jetpack_widgets_loaded() { |
| 38 |
Jetpack::enable_module_configurable( __FILE__ ); |
| 39 |
Jetpack::module_configuration_load( __FILE__, 'jetpack_widgets_configuration_load' ); |
| 40 |
} |
| 41 |
|
| 42 |
function jetpack_widgets_configuration_load() { |
| 43 |
wp_safe_redirect( admin_url( 'widgets.php' ) ); |
| 44 |
exit; |
| 45 |
} |
| 46 |
|
| 47 |
/** |
| 48 |
* Add the "(Jetpack)" suffix to the widget names |
| 49 |
*/ |
| 50 |
function jetpack_widgets_add_suffix( $widget_name ) { |
| 51 |
return sprintf( __( '%s (Jetpack)', 'jetpack' ), $widget_name ); |
| 52 |
} |
| 53 |
add_filter( 'jetpack_widget_name', 'jetpack_widgets_add_suffix' ); |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
jetpack_load_widgets(); |
| 58 |
|
| 59 |
/** |
| 60 |
* Enqueue utilities to work with widgets in Customizer. |
| 61 |
* |
| 62 |
* @since 4.0.0 |
| 63 |
*/ |
| 64 |
function jetpack_widgets_customizer_assets() { |
| 65 |
wp_enqueue_script( 'jetpack-customizer-widget-utils', plugins_url( '/widgets/customizer-utils.js', __FILE__ ), array( 'customize-base' ) ); |
| 66 |
} |
| 67 |
add_action( 'customize_preview_init', 'jetpack_widgets_customizer_assets' ); |