PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 12.9.3
Jetpack – WP Security, Backup, Speed, & Growth v12.9.3
16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 13.9.2 14.0.1 14.1.1 14.2.2 14.3.1 All 501 releases
jetpack / modules / widgets.php

widgets.php in Jetpack – WP Security, Backup, Speed, & Growth 12.9.3, at modules/widgets.php

113 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Module Name: Extra Sidebar Widgets
4 * Module Description: Provides additional widgets for use on your site.
5 * Sort Order: 4
6 * First Introduced: 1.2
7 * Requires Connection: No
8 * Auto Activate: No
9 * Module Tags: Social, Appearance
10 * Feature: Appearance
11 * Additional Search Queries: widget, widgets, facebook, gallery, twitter, gravatar, image, rss
12 *
13 * @package automattic/jetpack
14 */
15
16 /**
17 * Load Jetpack widget files.
18 */
19 function jetpack_load_widgets() {
20 $widgets_include = array();
21
22 foreach ( Jetpack::glob_php( __DIR__ . '/widgets' ) as $file ) {
23 $widgets_include[] = $file;
24 }
25 /**
26 * Modify which Jetpack Widgets to register.
27 *
28 * @module widgets
29 *
30 * @since 2.2.1
31 *
32 * @param array $widgets_include An array of widgets to be registered.
33 */
34 $widgets_include = apply_filters( 'jetpack_widgets_to_include', $widgets_include );
35
36 foreach ( $widgets_include as $include ) {
37 include_once $include;
38 }
39
40 include_once __DIR__ . '/widgets/migrate-to-core/image-widget.php';
41 include_once __DIR__ . '/widgets/migrate-to-core/gallery-widget.php';
42 }
43
44 add_action( 'jetpack_modules_loaded', 'jetpack_widgets_loaded' );
45 /**
46 * Actions to perform after Jetpack widgets are loaded.
47 */
48 function jetpack_widgets_loaded() {
49 Jetpack::enable_module_configurable( __FILE__ );
50 add_filter( 'jetpack_module_configuration_url_widgets', 'jetpack_widgets_configuration_url' );
51 }
52
53 /**
54 * Overrides default configuration url
55 *
56 * @uses admin_url
57 * @return string module settings URL
58 */
59 function jetpack_widgets_configuration_url() {
60 return admin_url( 'customize.php?autofocus[panel]=widgets' );
61 }
62
63 jetpack_load_widgets();
64
65 /**
66 * Enqueue utilities to work with widgets in Customizer.
67 *
68 * @since 4.4.0
69 */
70 function jetpack_widgets_customizer_assets_preview() {
71 wp_enqueue_script(
72 'jetpack-customizer-widget-utils',
73 plugins_url( '/widgets/customizer-utils.js', __FILE__ ),
74 array( 'jquery', 'customize-base' ),
75 JETPACK__VERSION,
76 false
77 );
78 }
79 add_action( 'customize_preview_init', 'jetpack_widgets_customizer_assets_preview' );
80
81 /**
82 * Enqueue styles to stylize widgets in Customizer.
83 *
84 * @since 4.4.0
85 */
86 function jetpack_widgets_customizer_assets_controls() {
87 wp_enqueue_style(
88 'jetpack-customizer-widget-controls',
89 plugins_url( '/widgets/customizer-controls.css', __FILE__ ),
90 array( 'customize-widgets' ),
91 JETPACK__VERSION
92 );
93 }
94 add_action( 'customize_controls_enqueue_scripts', 'jetpack_widgets_customizer_assets_controls' );
95
96 /**
97 * Cleanup old Jetpack widgets data.
98 */
99 function jetpack_widgets_remove_old_widgets() {
100 $old_widgets = array(
101 'googleplus-badge',
102 );
103
104 // Don't bother cleaning up the sidebars_widgets data.
105 // That will get cleaned up the next time a widget is
106 // added, removed, moved, etc.
107 foreach ( $old_widgets as $old_widget ) {
108 delete_option( "widget_{$old_widget}" );
109 }
110 }
111
112 add_action( 'updating_jetpack_version', 'jetpack_widgets_remove_old_widgets' );
113