PluginProbe
Automatic YouTube Gallery – Embed Auto-Updating YouTube Video Galleries, Feeds, Playlists & Channels / 2.3.2
Automatic YouTube Gallery – Embed Auto-Updating YouTube Video Galleries, Feeds, Playlists & Channels v2.3.2
2.9.1 2.9.0 trunk 1.0.0 1.1.0 1.2.0 1.3.0 1.4.0 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 2.0.0 2.1.0 2.2.0 2.3.2 2.3.3 2.3.5 2.3.6 2.3.8 2.3.9 2.4.3 All 37 releases
← All changes | widget/widget.php +16 -22 trunk2.3.2 View file →
@@ -53,19 +53,11 @@
53 53 if ( ! empty( $instance['title'] ) ) {
54 54 echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ) . $args['after_title'];
55 55 }
56 56
57 - // Deprecated since v2.5.8. Retained for backward compatibility.
58 57 if ( isset( $args['widget_id'] ) ) {
59 - $instance['deprecated_uid'] = md5( $args['widget_id'] );
58 + $instance['uid'] = md5( $args['widget_id'] );
60 59 }
61 -
62 - // If popup is enabled and type is video, force theme to popup
63 - if ( isset( $instance['popup'] ) && ! empty( $instance['popup'] ) ) {
64 - if ( isset( $instance['type'] ) && 'video' == $instance['type'] ) {
65 - $instance['theme'] = 'popup';
66 - }
67 - }
68 60
69 61 echo ayg_build_gallery( $instance );
70 62
71 63 echo $args['after_widget'];
@@ -79,30 +71,32 @@
79 71 * @param array $old_instance The previous instance of values before the update.
80 72 */
81 73 public function update( $new_instance, $old_instance ) {
82 74 $instance = array();
75 +
83 76 $instance['title'] = isset( $new_instance['title'] ) ? strip_tags( $new_instance['title'] ) : '';
84 77
85 78 $fields = ayg_get_editor_fields();
86 79
87 - foreach ( $fields as $section ) {
88 - foreach ( $section['fields'] as $field ) {
89 - $name = $field['name'];
80 + foreach ( $fields as $key => $value ) {
81 + foreach ( $value['fields'] as $field ) {
82 + $field_name = $field['name'];
83 + $field_type = $field['type'];
90 84
91 - if ( 'checkbox' === $field['type'] ) {
92 - $instance[ $name ] = ! empty( $new_instance[ $name ] ) ? 1 : 0;
93 - } elseif ( ! isset( $new_instance[ $name ] ) ) {
94 - continue;
95 - } elseif ( 'select' === $field['type'] && isset( $field['options'] ) ) {
96 - $raw = sanitize_text_field( $new_instance[ $name ] );
97 - $instance[ $name ] = array_key_exists( $raw, $field['options'] ) ? $raw : sanitize_text_field( $field['value'] );
85 + if ( 'number' == $field_type ) {
86 + if ( ! empty( $new_instance[ $field_name ] ) ) {
87 + $instance[ $field_name ] = false === strpos( $new_instance[ $field_name ], '.' ) ? (int) $new_instance[ $field_name ] : (float) $new_instance[ $field_name ];
88 + } else {
89 + $instance[ $field_name ] = 0;
90 + }
91 + } elseif ( 'checkbox' == $field_type ) {
92 + $instance[ $field_name ] = isset( $new_instance[ $field_name ] ) ? (int) $new_instance[ $field_name ] : 0;
98 93 } else {
99 - $sanitize_callback = ! empty( $field['sanitize_callback'] ) ? $field['sanitize_callback'] : 'sanitize_text_field';
100 - $instance[ $name ] = call_user_func( $sanitize_callback, $new_instance[ $name ] );
94 + $instance[ $field_name ] = ! empty( $new_instance[ $field_name ] ) ? sanitize_text_field( $new_instance[ $field_name ] ) : '';
101 95 }
102 96 }
103 97 }
104 -
98 +
105 99 return $instance;
106 100 }
107 101
108 102 /**