Skip to content

Commit

Permalink
AeriaSection json save field
Browse files Browse the repository at this point in the history
  • Loading branch information
vincio87 committed Nov 10, 2015
1 parent 76bdd66 commit 0f145dc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
12 changes: 6 additions & 6 deletions classes/AeriaSection.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function($post) use ($args){
$s++;
}

if(!empty($sections)) update_post_meta( $post_id, 'post_sections', addslashes(serialize($sections)) );
if(!empty($sections)) update_post_meta( $post_id, 'post_sections', wp_slash(json_encode($sections,JSON_UNESCAPED_UNICODE)) );

});

Expand Down Expand Up @@ -101,7 +101,7 @@ function($post) use ($args){
}

public static function sort_section($order, $post_id) {
$sections = unserialize(get_post_meta( $post_id, 'post_sections', true ));
$sections = json_decode(get_post_meta( $post_id, 'post_sections', true ),true);

$new_sections = [];
$s = 0;
Expand All @@ -111,7 +111,7 @@ public static function sort_section($order, $post_id) {
$s++;
}

update_post_meta( $post_id, 'post_sections', addslashes(serialize($new_sections)) );
update_post_meta( $post_id, 'post_sections', wp_slash(json_encode($new_sections,JSON_UNESCAPED_UNICODE)) );

die(json_encode([
'success' => 1
Expand All @@ -136,9 +136,10 @@ public static function render_controls(){
}

public static function render_sections($post_id, $args){
$sections = unserialize(get_post_meta( $post_id, 'post_sections', true ));
$sections = json_decode(get_post_meta( $post_id, 'post_sections', true ),true);
wp_nonce_field( 'section_metabox', 'section_metabox_nonce' );


?>
<div class="box-reorder">
<p>Prima di utilizzare questa funzionalità assicurati di aver <b>salvato</b> tutto il lavoro.</p>
Expand Down Expand Up @@ -255,7 +256,6 @@ public static function render_section($section_passed = [], $key = 0, $ncol = 1,
AeriaSection::render_field($field,$key,$value);
}
}

for ($i=1; $i <= $section['columns']; $i++) {
if($section['columns'] > 1) echo '<h2>Column '.$i.'</h2>';
wp_editor( stripslashes($section['content']['column_'.$i]) , 'post_section_'.$key.'_'.$i );
Expand All @@ -266,4 +266,4 @@ public static function render_section($section_passed = [], $key = 0, $ncol = 1,
<?php
}

}
}
8 changes: 0 additions & 8 deletions resources/js/section.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,6 @@ jQuery(function($){

$.post(window.ajaxurl, { action: 'sort_section', order : order, post_id : post_id }, function(response) {
location.reload();
/*
var $button_save_draft = $('#save-post');
if($button_save_draft.length){
$button_save_draft.trigger('click');
}else{
$('#publish').trigger('click');
}
*/
});
});

Expand Down

0 comments on commit 0f145dc

Please sign in to comment.