Skip to content
Open
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
10 changes: 6 additions & 4 deletions classes/controllers/FrmStylesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -630,10 +630,12 @@ private static function render_style_page( $active_style, $form, $default_style
break;

case 'duplicate':
$style = clone $active_style;
$new_style = $frm_style->get_new();
$style->ID = $new_style->ID;
$style->post_name = $new_style->post_name;
$style = clone $active_style;
$new_style = $frm_style->get_new();
$style->ID = $new_style->ID;

$style->post_content['old_name_before_duplicate'] = $active_style->post_name;
$style->post_name = $new_style->post_name;
unset( $new_style );
break;

Expand Down
12 changes: 6 additions & 6 deletions classes/models/FrmStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,16 @@ public function update( $id = 'default' ) {
$new_instance['post_content']['custom_css'] = $custom_css;
unset( $custom_css );

if ( ! empty( $new_instance['post_content']['single_style_custom_css'] ) ) {
$css_scope = 'frm_style_' . $new_instance['post_name'];
$new_instance['post_content']['single_style_custom_css'] = $css_scope_helper->nest( $new_instance['post_content']['single_style_custom_css'], $css_scope );
}

$new_instance['post_type'] = FrmStylesController::$post_type;
$new_instance['post_status'] = 'publish';

if ( ! $id ) {
$new_instance['post_name'] = $new_instance['post_title'];
$new_instance['post_name'] = sanitize_title( $new_instance['post_title'] );
}

if ( ! empty( $new_instance['post_content']['single_style_custom_css'] ) ) {
$css_scope = 'frm_style_' . $new_instance['post_name'];
$new_instance['post_content']['single_style_custom_css'] = $css_scope_helper->nest( $new_instance['post_content']['single_style_custom_css'], $css_scope );
}

$default_settings = $this->get_defaults();
Expand Down
7 changes: 4 additions & 3 deletions classes/views/styles/_quick-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,12 @@ class="frm-style-item-heading">

<div id="frm_single_style_custom_css_editor" class="frm12 frm_form_field frm-style-component <?php echo empty( $style->post_content['enable_style_custom_css'] ) ? 'frm_hidden' : ''; ?>">
<?php
$css_scope_helper = new FrmCssScopeHelper();
$custom_css = $style->post_content['single_style_custom_css'] ?? '';
$css_scope_helper = new FrmCssScopeHelper();
$custom_css = $style->post_content['single_style_custom_css'] ?? '';
$scoped_style_name = ! empty( $style->post_content['old_name_before_duplicate'] ) ? $style->post_content['old_name_before_duplicate'] : $style->post_name;

if ( ! empty( $custom_css ) ) {
$custom_css = $css_scope_helper->unnest( $custom_css, 'frm_style_' . $style->post_name );
$custom_css = $css_scope_helper->unnest( $custom_css, 'frm_style_' . $scoped_style_name );
Copy link
Contributor

@Crabcyborg Crabcyborg Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Liviu-p It seems that old_name_before_duplicate is never unset, but wouldn't this mean that the custom CSS is still set to the original style, and not the duplicate?

I feel like we should be fixing this during the duplication. We could unnest with the original name, then immediately nest with the new name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Crabcyborg, I agree that It makes sense to have this handled in the duplicate action( it's an initial approach that I took, but changes weren't reflected in the style settings section ). So I noticed that style creation on duplicate is made for preview section only and the style settings is keeping the original one Basically changing some style options on duplicate isn't getting reflected in the settings area. It requires a "Save"/"Update" action for duplicated style to be created an saved into db.

}

FrmStylesController::custom_css(
Expand Down
2 changes: 1 addition & 1 deletion js/formidable-web-components.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/formidable_admin.js

Large diffs are not rendered by default.