Completed
Push — add/connect-splash-content ( ec1611...3bc2bd )
by
unknown
22:10 queued 11:17
created

widgets.php ➔ jetpack_widgets_add_suffix()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Module Name: Extra Sidebar Widgets
4
 * Module Description: Add images, Twitter streams, 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
 * Feature: Appearance
11
 * Additional Search Queries: widget, widgets, facebook, gallery, twitter, gravatar, image, rss
12
 */
13
14
function jetpack_load_widgets() {
15
	$widgets_include = array();
16
17
	foreach ( Jetpack::glob_php( dirname( __FILE__ ) . '/widgets' ) as $file ) {
18
		$widgets_include[] = $file;
19
	}
20
	/**
21
	 * Modify which Jetpack Widgets to register.
22
	 *
23
	 * @module widgets
24
	 *
25
	 * @since 2.2.1
26
	 *
27
	 * @param array $widgets_include An array of widgets to be registered.
28
	 */
29
	$widgets_include = apply_filters( 'jetpack_widgets_to_include', $widgets_include );
30
31
	foreach( $widgets_include as $include ) {
32
		include $include;
33
	}
34
35
	include_once dirname( __FILE__ ) . '/widgets/migrate-to-core/image-widget.php';
36
	include_once dirname( __FILE__ ) . '/widgets/migrate-to-core/gallery-widget.php';
37
}
38
39
add_action( 'jetpack_modules_loaded', 'jetpack_widgets_loaded' );
40
41
function jetpack_widgets_loaded() {
42
	Jetpack::enable_module_configurable( __FILE__ );
43
	Jetpack::module_configuration_load( __FILE__, 'jetpack_widgets_configuration_load' );
44
}
45
46
function jetpack_widgets_configuration_load() {
47
	wp_safe_redirect( admin_url( 'widgets.php' ) );
48
	exit;
0 ignored issues
show
Coding Style Compatibility introduced by
The function jetpack_widgets_configuration_load() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
49
}
50
51
/**
52
 * Add the "(Jetpack)" suffix to the widget names
53
 */
54
function jetpack_widgets_add_suffix( $widget_name ) {
55
	return sprintf( __( '%s (Jetpack)', 'jetpack' ), $widget_name );
56
}
57
add_filter( 'jetpack_widget_name', 'jetpack_widgets_add_suffix' );
58
59
60
61
jetpack_load_widgets();
62
63
/**
64
 * Enqueue utilities to work with widgets in Customizer.
65
 *
66
 * @since 4.4.0
67
 */
68
function jetpack_widgets_customizer_assets_preview() {
69
	wp_enqueue_script( 'jetpack-customizer-widget-utils', plugins_url( '/widgets/customizer-utils.js', __FILE__ ), array( 'customize-base' ) );
70
}
71
add_action( 'customize_preview_init', 'jetpack_widgets_customizer_assets_preview' );
72
73
/**
74
 * Enqueue styles to stylize widgets in Customizer.
75
 *
76
 * @since 4.4.0
77
 */
78
function jetpack_widgets_customizer_assets_controls() {
79
	wp_enqueue_style( 'jetpack-customizer-widget-controls', plugins_url( '/widgets/customizer-controls.css', __FILE__ ), array( 'customize-widgets' ) );
80
}
81
add_action( 'customize_controls_enqueue_scripts', 'jetpack_widgets_customizer_assets_controls' );
82