Code Duplication    Length = 20-21 lines in 2 locations

modules/widgets/authors.php 1 location

@@ 20-39 (lines=20) @@
17
 * @since 4.5.0
18
 */
19
class Jetpack_Widget_Authors extends WP_Widget {
20
	public function __construct() {
21
		parent::__construct(
22
			'authors',
23
			/** This filter is documented in modules/widgets/facebook-likebox.php */
24
			apply_filters( 'jetpack_widget_name', __( 'Authors', 'jetpack' ) ),
25
			array(
26
				'classname'                   => 'widget_authors',
27
				'description'                 => __( 'Display blogs authors with avatars and recent posts.', 'jetpack' ),
28
				'customize_selective_refresh' => true,
29
			)
30
		);
31
32
		if ( is_active_widget( false, false, $this->id_base ) || is_active_widget( false, false, 'monster' ) || is_customize_preview() ) {
33
			add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ) );
34
		}
35
36
		add_action( 'publish_post', array( __CLASS__, 'flush_cache' ) );
37
		add_action( 'deleted_post', array( __CLASS__, 'flush_cache' ) );
38
		add_action( 'switch_theme', array( __CLASS__, 'flush_cache' ) );
39
	}
40
41
	/**
42
	 * Enqueue stylesheet to adapt the widget to various themes.

modules/widgets/milestone/class-milestone-widget.php 1 location

@@ 38-58 (lines=21) @@
35
	/**
36
	 * Milestone_Widget constructor.
37
	 */
38
	public function __construct() {
39
		$widget = array(
40
			'classname'   => 'milestone-widget',
41
			'description' => __( 'Display a countdown to a certain date.', 'jetpack' ),
42
		);
43
44
		parent::__construct(
45
			'Milestone_Widget',
46
			/** This filter is documented in modules/widgets/facebook-likebox.php */
47
			apply_filters( 'jetpack_widget_name', __( 'Milestone', 'jetpack' ) ),
48
			$widget
49
		);
50
51
		add_action( 'wp_enqueue_scripts', array( __class__, 'enqueue_template' ) );
52
		add_action( 'admin_enqueue_scripts', array( __class__, 'enqueue_admin' ) );
53
		add_action( 'wp_footer', array( $this, 'localize_script' ) );
54
55
		if ( is_active_widget( false, false, $this->id_base, true ) || is_active_widget( false, false, 'monster', true ) || is_customize_preview() ) {
56
			add_action( 'wp_head', array( __class__, 'styles_template' ) );
57
		}
58
	}
59
60
	/**
61
	 * Enqueue admin assets.