diff --git a/fx-builder.php b/fx-builder.php index 361ac4e..d35b922 100644 --- a/fx-builder.php +++ b/fx-builder.php @@ -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 @@ -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 diff --git a/includes/builder/assets/custom-css.css b/includes/builder/assets/custom-css.css index ecf4cc1..063d662 100644 --- a/includes/builder/assets/custom-css.css +++ b/includes/builder/assets/custom-css.css @@ -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; diff --git a/includes/builder/assets/switcher.css b/includes/builder/assets/switcher.css index e725a7d..1cc238b 100644 --- a/includes/builder/assets/switcher.css +++ b/includes/builder/assets/switcher.css @@ -6,4 +6,7 @@ } .fx_builder_active #fxb-wrapper{ display: block !important; +} +.fx_builder_active #post-preview{ + display: none !important; } \ No newline at end of file diff --git a/includes/builder/builder.php b/includes/builder/builder.php index 7399489..5ab68fa 100644 --- a/includes/builder/builder.php +++ b/includes/builder/builder.php @@ -157,22 +157,31 @@ 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' ); @@ -180,6 +189,7 @@ public function save( $post_id, $post ){ return false; } + /* Page Builder Datas ------------------------------------------ */ @@ -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 diff --git a/includes/builder/front.php b/includes/builder/front.php index d522a16..60c507e 100644 --- a/includes/builder/front.php +++ b/includes/builder/front.php @@ -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{ diff --git a/includes/builder/revisions.php b/includes/builder/revisions.php index 3c0912b..c45adb6 100644 --- a/includes/builder/revisions.php +++ b/includes/builder/revisions.php @@ -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 ); } @@ -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 ); } diff --git a/includes/builder/switcher.php b/includes/builder/switcher.php index d94dbdc..1821b33 100644 --- a/includes/builder/switcher.php +++ b/includes/builder/switcher.php @@ -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{ @@ -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 ); } @@ -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 diff --git a/readme.txt b/readme.txt index 12afacc..0bfa80f 100644 --- a/readme.txt +++ b/readme.txt @@ -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 @@ -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.