$responsive_name = $name . ( 'default' == $device ? '' : '_' . $device ); if ( is_array( $responsive ) && isset( $responsive['default'] ) && isset( $responsive['default'][ $device ] ) ) { $defaults->{ $responsive_name } = $responsive['default'][ $device ]; } else if( 'default' == $device ) { $defaults->$name = $default; } else { $defaults->{ $responsive_name } = ''; } } } else { $defaults->$name = $default; } } // Cache the defaults. self::$settings_form_defaults[ $type ] = apply_filters( 'fl_builder_settings_form_defaults', $defaults, $form_type ); return self::$settings_form_defaults[ $type ]; } /** * Save the settings for a node. * * @since 1.0 * @param string $node_id The node ID. * @param object $settings The settings to save. * @return void */ static public function save_settings($node_id = null, $settings = null) { $node = self::get_node($node_id); $new_settings = (object)array_merge((array)$node->settings, (array)$settings); $template_post_id = self::is_node_global( $node ); // Process the settings. $new_settings = self::process_node_settings($node, $new_settings); // Save the settings to the node. $data = self::get_layout_data(); $data[$node_id]->settings = $new_settings; // Update the layout data. self::update_layout_data($data); // Save settings for a global node template? if ( $template_post_id && ! self::is_post_node_template() ) { // Get the template data. $template_data = self::get_layout_data( 'published', $template_post_id ); // Update the template node settings. $template_data[ $node->template_node_id ]->settings = $new_settings; // Save the template data. self::update_layout_data( $template_data, 'published', $template_post_id ); self::update_layout_data( $template_data, 'draft', $template_post_id ); // Delete the template asset cache. self::delete_all_asset_cache( $template_post_id ); self::delete_node_template_asset_cache( $template_post_id ); } // Return the new layout. return FLBuilderAJAXLayout::render(); } /** * Adds slashes to settings going into the database as WordPress * removes them when we save using update_metadata. This is done * to ensure slashes in user input aren't removed. * * @since 1.5.6 * @param mixed $data The data to slash. * @return mixed The slashed data. */ static public function slash_settings( $data ) { if ( is_array( $data ) ) { foreach ( $data as $key => $val ) { $data[ $key ] = self::slash_settings( $val ); } } else if ( is_object( $data ) ) { foreach ( $data as $key => $val ) { $data->$key = self::slash_settings( $val ); } } else if ( is_string( $data ) ) { $data = wp_slash( $data ); } return $data; } /** * Merge defaults into a settings object. * * @since 1.0 * @param object $settings Reference to a settings object. * @param array $defaults The defaults to merge in. * @return void */ static public function default_settings(&$settings, $defaults) { foreach($defaults as $name => $value) { if(!isset($settings->$name)) { $settings->$name = $value; } } } /** * Get the global builder settings. * * @since 1.0 * @return object */ static public function get_global_settings() { if ( null === self::$global_settings ) { $settings = get_option('_fl_builder_settings'); $defaults = self::get_settings_form_defaults( 'global' ); if ( !$settings ) { $settings = new StdClass(); } // Merge in defaults and cache settings self::$global_settings = (object) array_merge((array) $defaults, (array) $settings); } return self::$global_settings; } /** * Save the global builder settings. * * @since 1.0 * @param array $settings The new global settings. * @return object */ static public function save_global_settings($settings = array()) { $old_settings = self::get_global_settings(); $new_settings = (object)array_merge((array)$old_settings, (array)$settings); self::delete_asset_cache_for_all_posts(); self::$global_settings = null; update_option('_fl_builder_settings', $settings); return self::get_global_settings(); } /** * Duplicate the current post. * * @since 1.0 * @return int The new post ID. */ static public function duplicate_post() { global $wpdb; $post_id = self::get_post_id(); $post = get_post($post_id); $current_user = wp_get_current_user(); // Duplicate the post. $data = array( 'comment_status' => $post->comment_status, 'ping_status' => $post->ping_status, 'post_author' => $current_user->ID, 'post_content' => $post->post_content, 'post_excerpt' => $post->post_excerpt, 'post_name' => $post->post_name, 'post_parent' => $post->post_parent, 'post_password' => $post->post_password, 'post_status' => 'draft', 'post_title' => sprintf( _x( 'Copy of %s', '%s stands for post/page title.', 'fl-builder' ), $post->post_title ), 'post_type' => $post->post_type, 'to_ping' => $post->to_ping, 'menu_order' => $post->menu_order ); // Get the new post id. $new_post_id = wp_insert_post($data); // Duplicate post meta. $post_meta = $wpdb->get_results("SELECT meta_key, meta_value FROM {$wpdb->postmeta} WHERE post_id= {$post_id}"); if(count($post_meta) !== 0) { $sql = "INSERT INTO {$wpdb->postmeta} (post_id, meta_key, meta_value) "; foreach($post_meta as $meta_info) { $meta_key = $meta_info->meta_key; $meta_value = addslashes($meta_info->meta_value); $sql_select[] = "SELECT {$new_post_id}, '{$meta_key}', '{$meta_value}'"; } $sql .= implode(" UNION ALL ", $sql_select); $wpdb->query($sql); } // Duplicate post terms. $taxonomies = get_object_taxonomies($post->post_type); foreach($taxonomies as $taxonomy) { $post_terms = wp_get_object_terms($post_id, $taxonomy); for($i = 0; $i < count($post_terms); $i++) { wp_set_object_terms($new_post_id, $post_terms[$i]->slug, $taxonomy, true); } } // Get the duplicated layout data. $data = self::get_layout_data('published', $new_post_id); // Generate new node ids. $data = self::generate_new_node_ids($data); // Save the duplicated layout data. self::update_layout_data($data, 'published', $new_post_id); // Return the new post id. return $new_post_id; } /** * Deletes all layout data and asset cache for a post. * * @since 1.0 * @param int $post_id The post ID to delete data and cache for. * @return void */ static public function delete_post( $post_id ) { // If this is a global template, unlink it from other posts. self::unlink_global_node_template_from_all_posts( $post_id ); // Delete all published and draft data. self::delete_layout_data( 'published', $post_id ); self::delete_layout_data( 'draft', $post_id ); // Delete all css and js. self::delete_all_asset_cache( $post_id ); } /** * Save a revision of a builder layout. * * @since 1.0 * @param int $post_id * @return void */ static public function save_revision($post_id) { $parent_id = wp_is_post_revision($post_id); if($parent_id) { $parent = get_post($parent_id); $data = self::get_layout_data('published', $parent->ID); $settings = self::get_layout_settings('published', $parent->ID); if(!empty($data)) { self::update_layout_data($data, 'published', $post_id); self::update_layout_settings($settings, 'published', $post_id); } } } /** * Restore a revision of a builder layout. * * @since 1.0 * @param int $post_id * @param int $revision_id * @return void */ static public function restore_revision($post_id, $revision_id) { $post = get_post($post_id); $revision = get_post($revision_id); if($revision) { $data = self::get_layout_data('published', $revision->ID); $settings = self::get_layout_settings('published', $revision->ID); if(!empty($data)) { self::update_layout_data($data, 'published', $post_id); self::update_layout_data($data, 'draft', $post_id); self::update_layout_settings(i – Làm Khô Tai Với Không Khí Ấm Áp Êm Ái Giúp Giảm Nhiễm Trùng Ống Tai Cho Người Bơi Lội Tai">
Máy Sấy Tai – Làm Khô Tai Với Không Khí Ấm Mịn Giúp Giảm ...
  • Dòng phản lực ba động cơ di động mới xuất hiện với khả năng phát hiện nhiệt độ và bộ tưới tai khử trùng bằng tia cực tím
    Dòng máy bay phản lực ba động cơ có động cơ mới đến với...
  • Dryears – Máy Sấy Tai Giúp Giảm Nhiễm Trùng Ống Tai Cho Người Bơi Lội
    Dryears – Máy Sấy Tai Giúp Giảm Nhiễm Trùng Ống Tai...
  • Máy làm sạch răng Máy cạo vôi răng siêu âm cho răng Loại bỏ vết bẩn cao răng
    Máy làm sạch răng siêu âm Máy cạo vôi răng để làm sạch răng...
  • Thiết bị rửa ráy tai bằng điện Dụng cụ tháo ráy tai Thiết bị làm sạch máy giặt
    Dụng cụ rửa ráy tai bằng điện Dụng cụ loại bỏ ráy tai ...
  • Máy mát xa giảm áp lực tai Đau tai giảm thính lực
    Giảm áp lực tai Giảm đau tai Giảm thính lực...
  • Dụng cụ làm sạch ráy tai kèm bộ máy ảnh
    Dụng cụ làm sạch ráy tai kèm bộ máy ảnh