-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Widgets: Fix creating and editing non-multi widgets (#32978)
* Widgets: Fix creating and editing non-multi widgets * Add regression e2e tests * Lint * Lint * Deactivate gutenberg-test-marquee-widget after test runs Co-authored-by: Adam Zieliński <[email protected]>
- Loading branch information
1 parent
1c0dad4
commit a74c99e
Showing
5 changed files
with
183 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
/** | ||
* Plugin Name: Gutenberg Test Marquee Widget | ||
* Plugin URI: https://github.com/WordPress/gutenberg | ||
* Author: Gutenberg Team | ||
* | ||
* @package gutenberg-test-marquee-widget | ||
*/ | ||
|
||
/** | ||
* Add a non-WP_Widget marquee widget. | ||
*/ | ||
function marquee_greeting_init() { | ||
wp_register_sidebar_widget( | ||
'marquee_greeting', | ||
'Marquee Greeting', | ||
function() { | ||
$greeting = get_option( 'marquee_greeting', 'Hello!' ); | ||
printf( '<marquee>%s</marquee>', esc_html( $greeting ) ); | ||
} | ||
); | ||
|
||
wp_register_widget_control( | ||
'marquee_greeting', | ||
'Marquee Greeting', | ||
function() { | ||
if ( isset( $_POST['marquee-greeting'] ) ) { | ||
update_option( | ||
'marquee_greeting', | ||
sanitize_text_field( $_POST['marquee-greeting'] ) | ||
); | ||
} | ||
|
||
$greeting = get_option( 'marquee_greeting' ); | ||
?> | ||
<p> | ||
<label for="marquee-greeting">Greeting:</label> | ||
<input | ||
id="marquee-greeting" | ||
class="widefat" | ||
name="marquee-greeting" | ||
type="text" | ||
value="<?php echo esc_attr( $greeting ); ?>" | ||
placeholder="Hello!" | ||
/> | ||
</p> | ||
<?php | ||
} | ||
); | ||
} | ||
add_action( 'init', 'marquee_greeting_init' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters