Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blocks: allow multi-line submit buttons #11223

Merged
merged 3 commits into from
Feb 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions modules/contact-form/grunion-contact-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ function __construct() {
) {
add_filter( 'widget_text', array( $this, 'widget_shortcode_hack' ), 5 );
}

add_filter( 'jetpack_contact_form_is_spam', array( $this, 'is_spam_blacklist' ), 10, 2 );

// Akismet to the rescue
Expand Down Expand Up @@ -631,7 +631,7 @@ function widget_shortcode_hack( $text ) {

return $text;
}

/**
* Check if a submission matches the Comment Blacklist.
* The Comment Blacklist is a means to moderate discussion, and contact
Expand All @@ -647,11 +647,11 @@ function is_spam_blacklist( $is_spam, $form = array() ) {
if ( $is_spam ) {
return $is_spam;
}

if ( wp_blacklist_check( $form['comment_author'], $form['comment_author_email'], $form['comment_author_url'], $form['comment_content'], $form['user_ip'], $form['user_agent'] ) ) {
return true;
}

return false;
}

Expand Down Expand Up @@ -1799,6 +1799,11 @@ class Grunion_Contact_Form extends Crunion_Contact_Form_Shortcode {
*/
static $style = false;

/**
* @var array When printing the submit button, what tags are allowed
*/
static $allowed_html_tags_for_submit_button = array( 'br' => array() );

function __construct( $attributes, $content = null ) {
global $post;

Expand Down Expand Up @@ -2057,12 +2062,16 @@ static function parse( $attributes, $content ) {
$submit_button_text = $form->get_attribute( 'submit_button_text' );
}

$r .= "\t\t<input type='submit' value='" . esc_attr( $submit_button_text ) . "' class='" . esc_attr( $submit_button_class ) . "'";
$r .= "\t\t<button type='submit' class='" . esc_attr( $submit_button_class ) . "'";
if ( ! empty( $submit_button_styles ) ) {
$r .= " style='" . esc_attr( $submit_button_styles ) . "'";
}
$r .= "/>\n";

$r .= ">";
$r .= wp_kses(
$submit_button_text,
self::$allowed_html_tags_for_submit_button
) . "</button>";

if ( is_user_logged_in() ) {
$r .= "\t\t" . wp_nonce_field( 'contact-form_' . $id, '_wpnonce', true, false ) . "\n"; // nonce and referer
}
Expand Down
25 changes: 21 additions & 4 deletions modules/subscriptions/views.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

class Jetpack_Subscriptions_Widget extends WP_Widget {
static $instance_count = 0;
/**
* @var array When printing the submit button, what tags are allowed
*/
static $allowed_html_tags_for_submit_button = array( 'br' => array() );

function __construct() {
$widget_ops = array(
Expand Down Expand Up @@ -289,14 +293,21 @@ static function render_widget_subscription_form( $args, $instance, $subscribe_em
<input type="hidden" name="sub-type" value="<?php echo esc_attr( $source ); ?>"/>
<input type="hidden" name="redirect_fragment" value="<?php echo esc_attr( $widget_id ); ?>"/>
<?php wp_nonce_field( 'blogsub_subscribe_' . $current_blog->blog_id, '_wpnonce', false ); ?>
<input type="submit" value="<?php echo esc_attr( $subscribe_button ); ?>"
<button type="submit"
<?php if ( ! empty( $submit_button_classes ) ) { ?>
class="<?php echo esc_attr( $submit_button_classes ); ?>"
<?php }; ?>
<?php if ( ! empty( $submit_button_styles ) ) { ?>
style="<?php echo esc_attr( $submit_button_styles ); ?>"
<?php }; ?>
/>
>
<?php
echo wp_kses(
$subscribe_button,
self::$allowed_html_tags_for_submit_button
);
?>
</button>
</p>
</form>
<?php
Expand Down Expand Up @@ -349,15 +360,21 @@ class="screen-reader-text"
wp_nonce_field( 'blogsub_subscribe_' . get_current_blog_id(), '_wpnonce', false );
}
?>
<input type="submit" value="<?php echo esc_attr( $subscribe_button ); ?>"
<button type="submit"
<?php if ( ! empty( $submit_button_classes ) ) { ?>
class="<?php echo esc_attr( $submit_button_classes ); ?>"
<?php }; ?>
<?php if ( ! empty( $submit_button_styles ) ) { ?>
style="<?php echo esc_attr( $submit_button_styles ); ?>"
<?php }; ?>
name="jetpack_subscriptions_widget"
/>
>
<?php
echo wp_kses(
$subscribe_button,
self::$allowed_html_tags_for_submit_button
); ?>
</button>
</p>
<?php } ?>
</form>
Expand Down