Skip to content

Commit

Permalink
Merge pull request #1490 from sapayth/fix/distorted_post_description_…
Browse files Browse the repository at this point in the history
…image_for_block_theme

fix: post description image for block theme
  • Loading branch information
sapayth authored Nov 11, 2024
2 parents d02f506 + 689e03b commit 5611f13
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 7 deletions.
21 changes: 21 additions & 0 deletions includes/Fields/Form_Field_Post_Content.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,27 @@ public function __construct() {
$this->name = __( 'Post Content', 'wp-user-frontend' );
$this->input_type = 'post_content';
$this->icon = 'text-width';

// check if block theme is active
if ( function_exists( 'wp_is_block_theme' ) && wp_is_block_theme() ) {
add_filter( 'format_for_editor', [ $this, 'format_for_editor' ], 10, 2 );
}
}

/**
* Format the content for editor. Need to do this for block theme support
*
* @param string $content
* @param string $default_editor
*
* @return string
*/
public function format_for_editor( $content, $default_editor ) {
if ( 'tinymce' !== $default_editor ) {
return $content;
}

return htmlspecialchars_decode( $content, ENT_NOQUOTES );
}

/**
Expand Down
13 changes: 9 additions & 4 deletions includes/Frontend/Frontend_Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public function __construct() {
*
* @param array $atts
*
* @return
**/
* @return false|string
*/
public function edit_post_shortcode( $atts ) {
add_filter( 'wpuf_form_fields', [ $this, 'add_field_settings' ] );
// @codingStandardsIgnoreStart
Expand All @@ -52,7 +52,13 @@ public function edit_post_shortcode( $atts ) {

wp_login_form();

return;
return '';
}

$nonce = isset( $_GET['_wpnonce'] ) ? sanitize_key( wp_unslash( $_GET['_wpnonce'] ) ) : '';

if ( ! wp_verify_nonce( $nonce, 'wpuf_edit' ) ) {
return '<div class="wpuf-info">' . __( 'Please re-open the post', 'wp-user-frontend' ) . '</div>';
}

$post_id = isset( $_GET['pid'] ) ? intval( wp_unslash( $_GET['pid'] ) ) : 0;
Expand Down Expand Up @@ -110,7 +116,6 @@ public function edit_post_shortcode( $atts ) {
$form = new Form( $form_id );

$this->form_fields = $form->get_fields();
// $form_settings = wpuf_get_form_settings( $form_id );
$this->form_settings = $form->get_settings();

$disable_pending_edit = wpuf_get_option( 'disable_pending_edit', 'wpuf_dashboard', 'on' );
Expand Down
6 changes: 3 additions & 3 deletions includes/Frontend_Render_Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public function render_form( $form_id, $post_id = null, $atts = [], $form = null
return;
}

if ( $form_status != 'publish' ) {
if ( 'publish' !== $form_status ) {
echo wp_kses_post( '<div class="wpuf-message">' . __( "Please make sure you've published your form.", 'wp-user-frontend' ) . '</div>' );

return;
Expand Down Expand Up @@ -222,9 +222,9 @@ public function render_form( $form_id, $post_id = null, $atts = [], $form = null
if ( $this->form_fields ) {
?>

<form class="wpuf-form-add wpuf-form-<?php echo esc_attr( $layout ); ?> <?php echo ( $layout == 'layout1' ) ? esc_html( $theme_css ) : 'wpuf-style'; ?>" action="" method="post">
<form class="wpuf-form-add wpuf-form-<?php echo esc_attr( $layout ); ?> <?php echo ( 'layout1' === $layout ) ? esc_html( $theme_css ) : 'wpuf-style'; ?>" action="" method="post">

<script type="text/javascript">
<script type="text/javascript">
if ( typeof wpuf_conditional_items === 'undefined' ) {
wpuf_conditional_items = [];
}
Expand Down

0 comments on commit 5611f13

Please sign in to comment.