Skip to content

Commit

Permalink
Merge pull request #618 from live-composer/issue/573
Browse files Browse the repository at this point in the history
  • Loading branch information
Dima authored Feb 28, 2017
2 parents 8ac8dab + 77a7084 commit d71d50b
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 15 deletions.
18 changes: 17 additions & 1 deletion includes/other-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -484,4 +484,20 @@ function dslc_admin_int_on() {
return true;
}

add_filter( 'dslc_admin_interface_on', 'dslc_admin_int_on', 1 );
add_filter( 'dslc_admin_interface_on', 'dslc_admin_int_on', 1 );


/**
* Filter textarea
*
* @param string $content Get textarea.
*/
function dslc_filter_textarea( $content ) {

$content = str_replace( '<lctextarea', '<textarea', $content );
$content = str_replace( '</lctextarea', '</textarea', $content );

return $content;
}

add_filter( 'dslc_before_render', 'dslc_filter_textarea' );
22 changes: 22 additions & 0 deletions js/builder/builder.util.functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,26 @@ function dslc_editable_content_gen_code( dslcField ) {
jQuery('.dslca-module-option-front[data-id="' + dslcFieldID + '"]', dslcModule).val( dslcContent );
}

/**
* Filter Textarea
*/
function dslc_filter_textarea( dslcOptionValue ) {

if ( dslcDebug ) console.log( 'dslc_filter_textarea' );

// In some rare cases we have the next error:
// TypeError: undefined is not an object (evaluating 'dslcField.html().trim()...')
if ( undefined === dslcOptionValue ) {
return false;
}

var dslcContent;

dslcContent = dslcOptionValue.trim().replace(/<textarea/g, '<lctextarea').replace(/<\/textarea/g, '</lctextarea');

return dslcContent;
}

// Disable the prompt ( are you sure ) on refresh
window.onbeforeunload = function () { return; };

Expand Down Expand Up @@ -402,6 +422,8 @@ jQuery(document).ready(function($) {
* Change old value with new value
*/

dslcOptionValue = dslc_filter_textarea( dslcOptionValue );

jQuery( '.dslca-module-options-front textarea[data-id="' + dslcOptionID + '"]', dslcModule ).val(dslcOptionValue);

jQuery('.dslca-container-loader').show();
Expand Down
5 changes: 2 additions & 3 deletions modules/accordion/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -1245,9 +1245,8 @@ function output( $options ) {
<div class="dslca-editable-content"<?php if ( $dslc_is_admin ) echo ' data-exportable-content'; ?>>
<?php
$accordion_content_output = stripslashes( $accordion_content );
$accordion_content_output = str_replace( '<lctextarea', '<textarea', $accordion_content_output );
$accordion_content_output = str_replace( '</lctextarea', '</textarea', $accordion_content_output );
echo do_shortcode( $accordion_content_output );
$accordion_content_output = do_shortcode( $accordion_content_output );
echo apply_filters( 'dslc_before_render', $accordion_content_output );
?>
</div>
<?php if ( $dslc_is_admin ) : ?>
Expand Down
2 changes: 1 addition & 1 deletion modules/html/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -3503,7 +3503,7 @@ function output( $options ) {
$output_content = '<div class="dslc-notification dslc-green">' . __('Save and refresh the page to display the module safely.', 'live-composer-page-builder') . '</div>';
}

echo $output_content;
echo apply_filters( 'dslc_before_render', $output_content );

?></div><?php

Expand Down
12 changes: 10 additions & 2 deletions modules/image/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -853,9 +853,17 @@ function output( $options ) {
<div class="dslc-image-caption">

<?php if ( $dslc_is_admin ) : ?>
<div class="dslca-editable-content" data-id="custom_text" data-type="simple" <?php if ( $dslc_is_admin ) echo 'contenteditable'; ?>><?php echo stripslashes( $options['custom_text'] ); ?></div>
<div class="dslca-editable-content" data-id="custom_text" data-type="simple" <?php if ( $dslc_is_admin ) echo 'contenteditable'; ?>>
<?php
$output_content = stripslashes( $options['custom_text'] );
echo apply_filters( 'dslc_before_render', $output_content );
?>
</div>
<?php else : ?>
<?php echo stripslashes( $options['custom_text'] ); ?>
<?php
$output_content = stripslashes( $options['custom_text'] );
echo apply_filters( 'dslc_before_render', $output_content );
?>
<?php endif; ?>

</div>
Expand Down
10 changes: 8 additions & 2 deletions modules/infobox/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -2981,11 +2981,17 @@ function output( $options ) {
<div class="dslc-info-box-content">
<?php if ( $dslc_is_admin ) : ?>
<div class="dslca-editable-content inline-editor" data-type="simple" data-id="content">
<?php echo stripslashes( $options['content'] ); ?>
<?php
$output_content = stripslashes( $options['content'] );
echo apply_filters( 'dslc_before_render', $output_content );
?>
</div><!-- .dslca-editable-content -->
<div class="dslca-wysiwyg-actions-edit"><span class="dslca-wysiwyg-actions-edit-hook"><?php _e( 'Open in WP Editor', 'live-composer-page-builder' ); ?></span></div>
<?php else : ?>
<?php echo do_shortcode( stripslashes( $options['content'] ) ); ?>
<?php
$output_content = stripslashes( $options['content'] );
echo apply_filters( 'dslc_before_render', $output_content );
?>
<?php endif; ?>
</div><!-- .dslc-info-box-content -->
<?php endif; ?>
Expand Down
5 changes: 2 additions & 3 deletions modules/tabs/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -3580,9 +3580,8 @@ function output( $options ) {
<div class="dslca-editable-content"<?php if ( $dslc_is_admin ) echo ' data-exportable-content'; ?>>
<?php
$tab_content_output = stripslashes( $tab_content );
$tab_content_output = str_replace( '<lctextarea', '<textarea', $tab_content_output );
$tab_content_output = str_replace( '</lctextarea', '</textarea', $tab_content_output );
echo do_shortcode( $tab_content_output );
$tab_content_output = do_shortcode( $tab_content_output );
echo apply_filters( 'dslc_before_render', $tab_content_output );
?>
</div>
<?php if ( $dslc_is_admin ) : ?>
Expand Down
4 changes: 1 addition & 3 deletions modules/text-simple/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -4964,10 +4964,8 @@ function output( $options ) {
}

$output_content = stripslashes( $options['content'] );
$output_content = str_replace( '<lctextarea', '<textarea', $output_content );
$output_content = str_replace( '</lctextarea', '</textarea', $output_content );
$output_content = do_shortcode( $output_content );
echo $output_content;
echo apply_filters( 'dslc_before_render', $output_content );

if ( $dslc_active ) {
?></div><!-- .dslca-editable-content --><?php
Expand Down

0 comments on commit d71d50b

Please sign in to comment.