Skip to content

Commit

Permalink
New: email input callback function for settings
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmigf committed Jan 16, 2025
1 parent 8fb16ad commit 9070a45
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions assets/css/settings-styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ body.woocommerce_page_wpo_wcpdf_options_page {

#wpo-wcpdf-preview-wrapper .sidebar .form-table > tbody > tr > td > input[type="text"],
#wpo-wcpdf-preview-wrapper .sidebar .form-table > tbody > tr > td > input[type="url"],
#wpo-wcpdf-preview-wrapper .sidebar .form-table > tbody > tr > td > input[type="email"],
#wpo-wcpdf-preview-wrapper .sidebar .form-table > tbody > tr > td > select,
#wpo-wcpdf-preview-wrapper .sidebar .form-table > tbody > tr > td > textarea {
max-width: none;
Expand Down
29 changes: 29 additions & 0 deletions includes/Settings/SettingsCallbacks.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,35 @@ public function url_input( $args ) {
}
}

/**
* Email input callback.
*
* args:
* option_name - name of the main option
* id - key of the setting
* size - size of the text input (em)
* default - default setting (optional)
* description - description (optional)
* type - type (optional)
*
* @return void.
*/
public function email_input( $args ) {
extract( $this->normalize_settings_args( $args ) );

if ( empty( $type ) ) {
$type = 'email';
}

$size = ! empty( $size ) ? sprintf( 'size="%s"', esc_attr( $size ) ) : '';
printf( '<input type="%1$s" id="%2$s" name="%3$s" value="%4$s" %5$s placeholder="%6$s" %7$s/>', esc_attr( $type ), esc_attr( $id ), esc_attr( $setting_name ), sanitize_email( $current ), $size, esc_attr( $placeholder ), ! empty( $disabled ) ? 'disabled="disabled"' : '' );

// output description.
if ( ! empty( $description ) ) {
printf( '<p class="description">%s</p>', wp_kses_post( $description ) );
}
}

/**
* Combined checkbox & text input callback.
*
Expand Down

0 comments on commit 9070a45

Please # to comment.