PluginProbe
Block Animations, Motion & Scroll Effects – Ghost Kit / 3.7.2
Block Animations, Motion & Scroll Effects – Ghost Kit v3.7.2
3.7.2 3.7.1 3.7.0 3.6.1 trunk 1.6.3 2.25.0 3.3.0 3.3.1 3.3.2 3.3.3 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.5.0 3.5.1 3.6.0
← All changes | classes/class-reusable-widget.php +96 -96 2.25.03.7.2 View file →
@@ -8,34 +8,34 @@
8 8 /**
9 9 * GhostKit_Reusable_Widget
10 10 */
11 11 class GhostKit_Reusable_Widget extends WP_Widget {
12 - /**
13 - * Sets up the widgets name etc
14 - */
15 - public function __construct() {
16 - parent::__construct(
17 - 'ghostkit_reusable_widget',
18 - esc_html__( 'Reusable Block', 'ghostkit' ),
19 - array(
20 - 'classname' => 'ghostkit-reusable-widget',
21 - 'description' => esc_html__( 'Display Gutenberg Reusable Blocks.', 'ghostkit' ),
22 - )
23 - );
24 - }
12 + /**
13 + * Sets up the widgets name etc
14 + */
15 + public function __construct() {
16 + parent::__construct(
17 + 'ghostkit_reusable_widget',
18 + esc_html__( 'Reusable Block', 'ghostkit' ),
19 + array(
20 + 'classname' => 'ghostkit-reusable-widget',
21 + 'description' => esc_html__( 'Display Gutenberg Reusable Blocks.', 'ghostkit' ),
22 + )
23 + );
24 + }
25 25
26 - /**
27 - * Outputs the content of the widget
28 - *
29 - * @param array $args args.
30 - * @param array $instance instance.
31 - */
32 - public function widget( $args, $instance ) {
33 - $title = ! empty( $instance['title'] ) ? apply_filters( 'widget_title', $instance['title'] ) : '';
34 - $block_id = isset( $instance['block'] ) && ! empty( $instance['block'] ) ? $instance['block'] : '';
35 - $post = $block_id ? get_post( $block_id ) : false;
26 + /**
27 + * Outputs the content of the widget
28 + *
29 + * @param array $args args.
30 + * @param array $instance instance.
31 + */
32 + public function widget( $args, $instance ) {
33 + $title = ! empty( $instance['title'] ) ? apply_filters( 'widget_title', $instance['title'] ) : '';
34 + $block_id = isset( $instance['block'] ) && ! empty( $instance['block'] ) ? $instance['block'] : '';
35 + $post = $block_id ? get_post( $block_id ) : false;
36 36
37 - if ( $block_id && isset( $post->post_content ) && $post->post_content && function_exists( 'has_blocks' ) && function_exists( 'parse_blocks' ) ) {
37 + if ( $block_id && isset( $post->post_content ) && $post->post_content && function_exists( 'has_blocks' ) && function_exists( 'parse_blocks' ) ) {
38 38 // phpcs:disable
39 39 echo $args['before_widget'];
40 40
41 41 if ( ! empty( $title ) ) {
@@ -57,84 +57,84 @@
57 57 }
58 58
59 59 echo $args['after_widget'];
60 60 // phpcs:enable
61 - }
62 - }
63 - /**
64 - * Outputs the options form on admin
65 - *
66 - * @param array $instance The widget options.
67 - */
68 - public function form( $instance ) {
69 - $title = ! empty( $instance['title'] ) ? $instance['title'] : '';
70 - $selected_block = ! empty( $instance['block'] ) ? $instance['block'] : '';
71 - $blocks = get_posts(
72 - array(
73 - 'post_type' => 'wp_block',
74 - 'numberposts' => -1,
75 - )
76 - );
61 + }
62 + }
63 + /**
64 + * Outputs the options form on admin
65 + *
66 + * @param array $instance The widget options.
67 + */
68 + public function form( $instance ) {
69 + $title = ! empty( $instance['title'] ) ? $instance['title'] : '';
70 + $selected_block = ! empty( $instance['block'] ) ? $instance['block'] : '';
71 + $blocks = get_posts(
72 + array(
73 + 'post_type' => 'wp_block',
74 + 'numberposts' => -1,
75 + )
76 + );
77 77
78 - wp_enqueue_script( 'ghostkit-admin-reusable-widget', ghostkit()->plugin_url . 'assets/admin/js/reusable-widget.min.js', array( 'jquery' ), '2.25.0', false );
79 - ?>
78 + GhostKit_Assets::enqueue_script( 'ghostkit-admin-reusable-widget', 'build/assets/admin/js/reusable-widget', array(), null, false );
79 + ?>
80 80
81 - <p>
82 - <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_attr_e( 'Title:', 'ghostkit' ); ?></label>
83 - <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>">
84 - </p>
81 + <p>
82 + <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_attr_e( 'Title:', 'ghostkit' ); ?></label>
83 + <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>">
84 + </p>
85 85
86 - <?php
87 - if ( ! empty( $blocks ) ) {
88 - ?>
89 - <p>
90 - <label for="<?php echo esc_attr( $this->get_field_id( 'block' ) ); ?>"><?php echo esc_attr__( 'Select Block:', 'ghostkit' ); ?></label>
91 - <select class="widefat gkt-reusable-block-select" id="<?php echo esc_attr( $this->get_field_id( 'block' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'block' ) ); ?>">
92 - <option value="" disabled <?php selected( '', $selected_block ); ?>><?php echo esc_html__( '--- Select block ---', 'ghostkit' ); ?></option>
93 - <?php
94 - foreach ( $blocks as $block ) {
95 - ?>
96 - <option value="<?php echo esc_attr( $block->ID ); ?>" <?php selected( $selected_block, $block->ID ); ?>>
97 - <?php echo esc_html( $block->post_title ); ?>
98 - </option>
99 - <?php
100 - }
101 - ?>
102 - </select>
103 - </p>
104 - <?php
105 - } else {
106 - ?>
107 - <p><?php echo esc_attr__( 'No reusable blocks found.', 'ghostkit' ); ?></p>
108 - <?php
109 - }
110 - ?>
111 - <p class="gkt-reusable-block-edit-button" style="display: none" data-admin-url="<?php echo esc_url( get_admin_url() ); ?>">
112 - <label for="<?php echo esc_attr( $this->get_field_id( 'edit_button' ) ); ?>"><?php esc_attr_e( 'Edit:', 'ghostkit' ); ?></label>
113 - <br>
114 - <a class="button" id="<?php echo esc_attr( $this->get_field_id( 'edit_button' ) ); ?>" href="" target="_blank">
115 - <?php esc_attr_e( 'Edit Reusable Block', 'ghostkit' ); ?>
116 - </a>
117 - </p>
118 - <?php
119 - }
86 + <?php
87 + if ( ! empty( $blocks ) ) {
88 + ?>
89 + <p>
90 + <label for="<?php echo esc_attr( $this->get_field_id( 'block' ) ); ?>"><?php echo esc_attr__( 'Select Block:', 'ghostkit' ); ?></label>
91 + <select class="widefat gkt-reusable-block-select" id="<?php echo esc_attr( $this->get_field_id( 'block' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'block' ) ); ?>">
92 + <option value="" disabled <?php selected( '', $selected_block ); ?>><?php echo esc_html__( '--- Select block ---', 'ghostkit' ); ?></option>
93 + <?php
94 + foreach ( $blocks as $block ) {
95 + ?>
96 + <option value="<?php echo esc_attr( $block->ID ); ?>" <?php selected( $selected_block, $block->ID ); ?>>
97 + <?php echo esc_html( $block->post_title ); ?>
98 + </option>
99 + <?php
100 + }
101 + ?>
102 + </select>
103 + </p>
104 + <?php
105 + } else {
106 + ?>
107 + <p><?php echo esc_attr__( 'No reusable blocks found.', 'ghostkit' ); ?></p>
108 + <?php
109 + }
110 + ?>
111 + <p class="gkt-reusable-block-edit-button" style="display: none" data-admin-url="<?php echo esc_url( get_admin_url() ); ?>">
112 + <label for="<?php echo esc_attr( $this->get_field_id( 'edit_button' ) ); ?>"><?php esc_attr_e( 'Edit:', 'ghostkit' ); ?></label>
113 + <br>
114 + <a class="button" id="<?php echo esc_attr( $this->get_field_id( 'edit_button' ) ); ?>" href="" target="_blank">
115 + <?php esc_attr_e( 'Edit Reusable Block', 'ghostkit' ); ?>
116 + </a>
117 + </p>
118 + <?php
119 + }
120 120
121 - /**
122 - * Processing widget options on save
123 - *
124 - * @param array $new_instance new options.
125 - * @param array $old_instance previous options.
126 - *
127 - * @return array
128 - */
129 - public function update( $new_instance, $old_instance ) {
130 - $instance = array(
131 - 'title' => ! empty( $new_instance['title'] ) ? sanitize_text_field( $new_instance['title'] ) : '',
132 - 'block' => ! empty( $new_instance['block'] ) ? sanitize_text_field( $new_instance['block'] ) : '',
133 - );
121 + /**
122 + * Processing widget options on save
123 + *
124 + * @param array $new_instance new options.
125 + * @param array $old_instance previous options.
126 + *
127 + * @return array
128 + */
129 + public function update( $new_instance, $old_instance ) {
130 + $instance = array(
131 + 'title' => ! empty( $new_instance['title'] ) ? sanitize_text_field( $new_instance['title'] ) : '',
132 + 'block' => ! empty( $new_instance['block'] ) ? sanitize_text_field( $new_instance['block'] ) : '',
133 + );
134 134
135 - return $instance;
136 - }
135 + return $instance;
136 + }
137 137 }
138 138
139 139 /**
140 140 * Register Widget
@@ -139,7 +139,7 @@
139 139 /**
140 140 * Register Widget
141 141 */
142 142 function ghostkit_register_reusable_widget() {
143 - register_widget( 'GhostKit_Reusable_Widget' );
143 + register_widget( 'GhostKit_Reusable_Widget' );
144 144 }
145 145 add_action( 'widgets_init', 'ghostkit_register_reusable_widget' );