Skip to content

Commit

Permalink
#1831 added an option for add script/html and styles in page builder …
Browse files Browse the repository at this point in the history
…for specific pages
  • Loading branch information
ajeetku committed Mar 12, 2018
1 parent af2d1d3 commit 0b054ac
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 6 deletions.
18 changes: 14 additions & 4 deletions pagebuilder/components/pbSettingTemplates.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
'layout'=>'Layout Directory',
'save_layout'=>'Save layout',
'export'=>'Import / Export',
'advance'=>'Advance',
),
);
global $layoutTemplate;
Expand Down Expand Up @@ -37,9 +38,18 @@ class="link"
<h3>Layout Directory</h3>
</div>
<div class="modal-body">
<div v-if="modalCrrentTab=='customize'">

</div><!-- customize closed -->
<div v-if="modalCrrentTab=='advance'" class="modal-settings">
<div class="amp-form-control" id="ampb_script_handler" data-type='textarea' >
<div class="form-label">Enter HTML in Head</div>
<div class="form-field"><textarea class="full textarea" id="ampb_script_textarea" name="ampb_script_handler" v-model="ampb_script_textarea"></textarea></div>
<div class="clearfix"></div>
</div>
<div class="amp-form-control" id="ampb_style_handler" data-type='textarea' >
<div class="form-label">Enter Style in Head</div>
<div class="form-field"><textarea class="full textarea" id="ampb_style_textarea" name="ampb_style_handler" v-model="ampb_style_textarea"></textarea></div>
<div class="clearfix"></div>
</div>
</div><!-- Advance closed -->

<div v-else-if="modalCrrentTab=='save_layout'">
<div class="amppb-layout-library-wrapper" style="margin: 40px 15px 10px 20px;">
Expand Down Expand Up @@ -183,7 +193,7 @@ class="link"
<span class="button button-primary button-large del-btn-modal" @click="loadLayOutFolder()" v-if="innerLayouts!=''">
Back
</span>
<button type="button" class="button modal-default-button" v-if="modalCrrentTab=='customize'" @click="savePagebuilderSettings(currentLayoutData)">
<button type="button" class="button modal-default-button" v-if="modalCrrentTab=='advance'" @click="savePagebuilderSettings(currentLayoutData)">
Save
</button>
<button type="button" class="button modal-default-button preview button" @click="hidePageBuilderPopUp()">
Expand Down
6 changes: 5 additions & 1 deletion pagebuilder/inc/admin-amp-page-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Vue.component('amp-pagebuilder-modal', {
importLayoutfromFile: '',
innerLayouts: '',
innerLayoutsHeading: '',
ampb_script_textarea: (app.mainContent.settingdata['scripts_data']? app.mainContent.settingdata['scripts_data']: ''),
ampb_style_textarea: (app.mainContent.settingdata['style_data']? app.mainContent.settingdata['style_data']:'')
}
},
methods:{
Expand All @@ -30,7 +32,9 @@ Vue.component('amp-pagebuilder-modal', {
this.modalCrrentTab=key;
},
savePagebuilderSettings:function(currentLayoutData){
app.mainContent = currentLayoutData;
//app.mainContent = currentLayoutData;
app.mainContent.settingdata['scripts_data'] = this.ampb_script_textarea;
app.mainContent.settingdata['style_data'] = this.ampb_style_textarea;
this.hidePageBuilderPopUp();
},
savePagebuildercustomLayout: function(event){
Expand Down
24 changes: 23 additions & 1 deletion pagebuilder/inc/viewShowFrontData.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,25 @@ function ampforwp_insert_pb_content( $content ){
return $content;
}


add_action('amp_post_template_head','ampforwp_pagebuilder_header_html_output',11);
function ampforwp_pagebuilder_header_html_output(){
//To load css of modules which are in use
global $redux_builder_amp, $moduleTemplate, $post, $containerCommonSettings;
$postId = $post->ID;
if( ampforwp_is_front_page() && isset($redux_builder_amp['amp-frontpage-select-option-pages']) ){
$postId = $redux_builder_amp['amp-frontpage-select-option-pages'];
}
$previousData = get_post_meta($postId,'amp-page-builder');
$previousData = isset($previousData[0])? $previousData[0]: null;
$ampforwp_pagebuilder_enable = get_post_meta($postId,'ampforwp_page_builder_enable', true);
if($previousData!="" && $ampforwp_pagebuilder_enable=='yes'){
$previousData = (str_replace("'", "", $previousData));
$previousData = json_decode($previousData,true);
if(isset($previousData['settingdata']['scripts_data']) && $previousData['settingdata']['scripts_data']!=""){
echo $previousData['settingdata']['scripts_data'];
}
}
}
add_action('amp_post_template_data','amp_pagebuilder_script_loader',100);
function amp_pagebuilder_script_loader($scriptData){
//To load css of modules which are in use
Expand Down Expand Up @@ -351,6 +369,10 @@ function amp_pagebuilder_content_styles(){

}//foreach closed complete data
}//if closed count($previousData['rows'])>0

if(isset($previousData['settingdata']['style_data']) && $previousData['settingdata']['style_data']!=""){
echo amppb_validateCss($previousData['settingdata']['style_data']);
}
}//If Closed $previousData!="" && $ampforwp_pagebuilder_enable=='yes'
}
function amppb_validateCss($css){
Expand Down

0 comments on commit 0b054ac

Please sign in to comment.