| 1 |
<?php |
| 2 |
/** |
| 3 |
* Module Name: Extra Sidebar Widgets |
| 4 |
* Module Description: Easily add images, Twitter updates, and your site's RSS links to your theme's sidebar. |
| 5 |
* Sort Order: 13 |
| 6 |
* First Introduced: 1.2 |
| 7 |
* Requires Connection: No |
| 8 |
* Auto Activate: Yes |
| 9 |
* Module Tags: Social, Appearance |
| 10 |
*/ |
| 11 |
|
| 12 |
function jetpack_load_widgets() { |
| 13 |
$widgets_include = array(); |
| 14 |
|
| 15 |
foreach ( Jetpack::glob_php( dirname( __FILE__ ) . '/widgets' ) as $file ) { |
| 16 |
$widgets_include[] = $file; |
| 17 |
} |
| 18 |
|
| 19 |
$widgets_include = apply_filters( 'jetpack_widgets_to_include', $widgets_include ); |
| 20 |
|
| 21 |
foreach( $widgets_include as $include ) { |
| 22 |
include $include; |
| 23 |
} |
| 24 |
} |
| 25 |
|
| 26 |
add_action( 'jetpack_modules_loaded', 'jetpack_widgets_loaded' ); |
| 27 |
|
| 28 |
function jetpack_widgets_loaded() { |
| 29 |
Jetpack::enable_module_configurable( __FILE__ ); |
| 30 |
Jetpack::module_configuration_load( __FILE__, 'jetpack_widgets_configuration_load' ); |
| 31 |
} |
| 32 |
|
| 33 |
function jetpack_widgets_configuration_load() { |
| 34 |
wp_safe_redirect( admin_url( 'widgets.php' ) ); |
| 35 |
exit; |
| 36 |
} |
| 37 |
|
| 38 |
/** |
| 39 |
* Loads file for front-end widget styles. |
| 40 |
*/ |
| 41 |
function jetpack_widgets_styles() { |
| 42 |
wp_enqueue_style( 'jetpack-widgets', plugins_url( 'widgets/widgets.css', __FILE__ ), array(), '20121003' ); |
| 43 |
} |
| 44 |
add_action( 'wp_enqueue_scripts', 'jetpack_widgets_styles' ); |
| 45 |
|
| 46 |
/** |
| 47 |
* Add the "(Jetpack)" suffix to the widget names |
| 48 |
*/ |
| 49 |
function jetpack_widgets_add_suffix( $widget_name ) { |
| 50 |
return sprintf( __( '%s (Jetpack)', 'jetpack' ), $widget_name ); |
| 51 |
} |
| 52 |
add_filter( 'jetpack_widget_name', 'jetpack_widgets_add_suffix' ); |
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
jetpack_load_widgets(); |
| 57 |
|