Skip to content

Commit

Permalink
Post by Email: corrected paths to JS and CSS files, adjusted style at…
Browse files Browse the repository at this point in the history
…tribute.

- Files `post-by-email.js` and `post-by-email.css` were enqueued incorrectly. Since the class was moved into the module directory, they got additional `post-by-email/` in the path, fixed now.
- Escaping `style` attributes in the "User Profile" form leads to quotes being converted to HTML entities. I refactored this tiny piece of code to make the attribute escaping work.
  • Loading branch information
sergeymitr committed Apr 2, 2020
1 parent acb25a9 commit 867af1b
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions modules/post-by-email/class-jetpack-post-by-email.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ public function action_init() {
* Enqueues scripts for user profile page.
*/
public function profile_scripts() {
wp_enqueue_script( 'post-by-email', plugins_url( 'post-by-email/post-by-email.js', __FILE__ ), array( 'jquery' ), JETPACK__VERSION, true );
wp_enqueue_script( 'post-by-email', plugins_url( 'post-by-email.js', __FILE__ ), array( 'jquery' ), JETPACK__VERSION, true );
wp_localize_script(
'post-by-email',
'pbeVars',
array(
'rest_nonce' => wp_create_nonce( 'wp_rest' ),
)
);
wp_enqueue_style( 'post-by-email', plugins_url( 'post-by-email/post-by-email.css', __FILE__ ), array(), JETPACK__VERSION );
wp_enqueue_style( 'post-by-email', plugins_url( 'post-by-email.css', __FILE__ ), array(), JETPACK__VERSION );
wp_style_add_data( 'post-by-email', 'jetpack-inline', true );
}

Expand Down Expand Up @@ -105,17 +105,12 @@ public function user_profile() {
if ( $this->check_user_connection() ) {
$email = $this->get_post_by_email_address();

if ( empty( $email ) ) {
$enable_hidden = '';
$info_hidden = ' style="display: none;"';
} else {
$enable_hidden = ' style="display: none;"';
$info_hidden = '';
}
$enable_button_style = empty( $email ) ? '' : 'display: none;';
$info_style = empty( $email ) ? 'display: none;' : '';
?>

<input type="button" name="jp-pbe-enable" id="jp-pbe-enable" class="button" value="<?php esc_attr_e( 'Enable Post By Email', 'jetpack' ); ?> "<?php echo esc_attr( $enable_hidden ); ?> />
<div id="jp-pbe-info"<?php echo esc_attr( $info_hidden ); ?>>
<input type="button" name="jp-pbe-enable" id="jp-pbe-enable" class="button" value="<?php esc_attr_e( 'Enable Post By Email', 'jetpack' ); ?>" style="<?php echo esc_attr( $enable_button_style ); ?>" />
<div id="jp-pbe-info" style="<?php echo esc_attr( $info_style ); ?>">
<p id="jp-pbe-email-wrapper">
<input type="text" id="jp-pbe-email" value="<?php echo esc_attr( $email ); ?>" readonly="readonly" class="regular-text" />
<span class="description"><a target="_blank" href="https://jetpack.com/support/post-by-email/"><?php esc_html_e( 'More information', 'jetpack' ); ?></a></span>
Expand Down

0 comments on commit 867af1b

Please sign in to comment.