Skip to content

Commit

Permalink
Merge pull request #46 from turtlepod/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
turtlepod authored Jan 6, 2017
2 parents 9562c93 + 303a689 commit 9ca1ded
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 52 deletions.
4 changes: 2 additions & 2 deletions fx-builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: f(x) Builder
* Plugin URI: http://genbumedia.com/plugins/fx-builder/
* Description: A simple page builder plugin. The one you can actually use. (Alpha Version)
* Version: 1.0.0
* Version: 1.0.2
* Author: David Chandra Purnama
* Author URI: http://shellcreeper.com/
* License: GPLv2 or later
Expand All @@ -24,7 +24,7 @@
define( 'FX_BUILDER_PATH', trailingslashit( plugin_dir_path( __FILE__ ) ) );
define( 'FX_BUILDER_FILE', __FILE__ );
define( 'FX_BUILDER_PLUGIN', plugin_basename( __FILE__ ) );
define( 'FX_BUILDER_VERSION', '1.0.0' );
define( 'FX_BUILDER_VERSION', '1.0.2' );


/* Init
Expand Down
2 changes: 0 additions & 2 deletions includes/builder/assets/custom-css.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@
border: 1px solid #ccc;
color: #555;
font-weight: 400;
margin-right: -14px;
display: none;
}
.rtl .fxb-nav-css{
float: left;
margin-right: 0;
margin-left: -14px;
}
.fx_builder_active .fxb-nav-css{
display: block;
Expand Down
3 changes: 3 additions & 0 deletions includes/builder/assets/switcher.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@
}
.fx_builder_active #fxb-wrapper{
display: block !important;
}
.fx_builder_active #post-preview{
display: none !important;
}
25 changes: 18 additions & 7 deletions includes/builder/builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,29 +157,39 @@ public function save( $post_id, $post ){
------------------------------------------ */
$request = stripslashes_deep( $_POST );
if ( ! isset( $request['fxb_nonce'] ) || ! wp_verify_nonce( $request['fxb_nonce'], __FILE__ ) ){
return false;
return $post_id;
}
if( defined('DOING_AUTOSAVE' ) && DOING_AUTOSAVE ){
return false;
if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ){
return $post_id;
}
$post_type = get_post_type_object( $post->post_type );
if ( !current_user_can( $post_type->cap->edit_post, $post_id ) ){
return false;
return $post_id;
}
$wp_preview = isset( $request['wp-preview'] ) ? esc_attr( $request['wp-preview'] ) : false;
if( $wp_preview ){
return $post_id;
}

/* Check Swicther
------------------------------------------ */
$active = get_post_meta( $post_id, '_fxb_active', true );
$active = isset( $request['_fxb_active'] ) ? $request['_fxb_active'] : false;

/* Page Builder Active */
if( $active ){
update_post_meta( $post_id, '_fxb_active', 1 );
}
/* Page Builder Not Selected: Delete Data and Bail. */
if( !$active ){
else{
delete_post_meta( $post_id, '_fxb_active' );
delete_post_meta( $post_id, '_fxb_db_version' );
delete_post_meta( $post_id, '_fxb_row_ids' );
delete_post_meta( $post_id, '_fxb_rows' );
delete_post_meta( $post_id, '_fxb_items' );
return false;
}


/* Page Builder Datas
------------------------------------------ */

Expand Down Expand Up @@ -253,9 +263,10 @@ public function save( $post_id, $post ){
*/
remove_action( 'save_post', array( $this, __FUNCTION__ ) );
wp_update_post( $this_post );
add_action( 'save_post', array( $this, __FUNCTION__ ) );
add_action( 'save_post', array( $this, __FUNCTION__ ), 10, 2 );
}


/**
* Admin Scripts
* @since 1.0.0
Expand Down
15 changes: 11 additions & 4 deletions includes/builder/front.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,18 @@ public function __construct() {
* This will format content with page builder data.
*/
public function content_filter( $content ){
$post_id = get_the_ID();
$post_type = get_post_type( $post_id );
$active = get_post_meta( $post_id, '_fxb_active', true );

/* Check Post Support */
$post_id = get_the_ID();
$post_type = get_post_type( $post_id );
if( ! post_type_supports( $post_type, 'fx_builder' ) ){
return $content;
}

$active = get_post_meta( $post_id, '_fxb_active', true );

remove_filter( 'the_content', 'wpautop' );
if( post_type_supports( $post_type, 'fx_builder' ) && $active ){
if( $active ){
$content = Functions::content( $post_id ); // autop added in this function.
}
else{
Expand Down
12 changes: 12 additions & 0 deletions includes/builder/revisions.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,16 @@ public function save_revision( $post_id, $post ){

$parent = get_post( $parent_id );

$active = get_post_meta( $parent->ID, '_fxb_active', true );
$db_version = get_post_meta( $parent->ID, '_fxb_db_version', true );
$row_ids = get_post_meta( $parent->ID, '_fxb_row_ids', true );
$rows = get_post_meta( $parent->ID, '_fxb_rows', true );
$items = get_post_meta( $parent->ID, '_fxb_items', true );
$css = get_post_meta( $parent->ID, '_fxb_custom_css', true );

if ( $active ){
add_metadata( 'post', $post_id, '_fxb_active', $active );
}
if ( false !== $db_version ){
add_metadata( 'post', $post_id, '_fxb_db_version', $db_version );
}
Expand Down Expand Up @@ -76,12 +80,20 @@ public function restore_revision( $post_id, $revision_id ) {

$revision = get_post( $revision_id );

$active = get_metadata( 'post', $revision->ID, '_fxb_active', true );
$db_version = get_metadata( 'post', $revision->ID, '_fxb_db_version', true );
$row_ids = get_metadata( 'post', $revision->ID, '_fxb_row_ids', true );
$rows = get_metadata( 'post', $revision->ID, '_fxb_rows', true );
$items = get_metadata( 'post', $revision->ID, '_fxb_items', true );
$css = get_metadata( 'post', $revision->ID, '_fxb_custom_css', true );

if ( $active ){
update_post_meta( $post_id, '_fxb_active', $active );
}
else{
delete_post_meta( $post_id, '_fxb_active' );
}

if ( false !== $db_version ){
update_post_meta( $post_id, '_fxb_db_version', $db_version );
}
Expand Down
37 changes: 1 addition & 36 deletions includes/builder/switcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

/**
* Switcher: Toggle between page builder / wp editor.
* Since v.1.0.1 Switcher save method is added in builder.php
* @since 1.0.0
*/
class Switcher{
Expand All @@ -30,9 +31,6 @@ public function __construct() {
/* Add Editor/Page Builder Tab */
add_action( 'edit_form_after_title', array( $this, 'editor_toggle' ) );

/* Save Switcher Preference */
add_action( 'save_post', array( $this, 'save' ), 9, 2 );

/* Scripts */
add_action( 'admin_enqueue_scripts', array( $this, 'scripts' ), 99 );
}
Expand Down Expand Up @@ -87,39 +85,6 @@ public function editor_toggle( $post ){
}


/**
* Save Switcher Pref
* @since 1.0.0
*/
public function save( $post_id, $post ){
$request = stripslashes_deep( $_POST );
if ( ! isset( $request['fxb_switcher_nonce'] ) || ! wp_verify_nonce( $request['fxb_switcher_nonce'], __FILE__ ) ){
return false;
}
if( defined('DOING_AUTOSAVE' ) && DOING_AUTOSAVE ){
return false;
}
$post_type = get_post_type_object( $post->post_type );
if ( !current_user_can( $post_type->cap->edit_post, $post_id ) ){
return false;
}

/* Save Builder Tab */
if( isset( $request['_fxb_active'] ) ){
$new_data = $request['_fxb_active'] ? 1 : 0;
if( $new_data ){
update_post_meta( $post_id, '_fxb_active', 1 );
}
else{
delete_post_meta( $post_id, '_fxb_active' );
}
}
else{
delete_post_meta( $post_id, '_fxb_active' );
}
}


/**
* Admin Scripts
* @since 1.0.0
Expand Down
9 changes: 8 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
Tags: Page Builder, Drag and Drop, Beta
Requires at least: 4.5
Tested up to: 4.7
Stable tag: 1.0.0
Stable tag: 1.0.1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -50,6 +50,13 @@ You can contribute to development at GitHub https://github.com/turtlepod/fx-buil

== Changelog ==

= 1.0.1 - 03 Jan 2017 =
* Fix bug: wp preview remove page builder data https://github.com/turtlepod/fx-builder/issues/45
* Fix CSS Bug: Tools & CSS button position.
* Store _fxb_active in revisions.
* Hide "Preview Changes" button in "Publish" meta box when page builder active.
* Fix "save_post" hook to fix fatal error bug.

= 1.0.0 - 09 Dec 2016 =
* First Stable Release.

Expand Down

0 comments on commit 9ca1ded

Please sign in to comment.