/** * Enqueue the styles and scripts for a single layout. * * @since 1.0 * @param int $post_id The post ID for this layout. * @return void */ public static function enqueue_layout_styles_scripts($post_id) { if (FLBuilderModel::is_builder_enabled()) { $nodes = FLBuilderModel::get_categorized_nodes(); $asset_info = FLBuilderModel::get_asset_info(); $asset_ver = FLBuilderModel::get_asset_version(); // Enqueue required row CSS and JS foreach ($nodes['rows'] as $row) { if ($row->settings->bg_type == 'slideshow') { wp_enqueue_script('yui3'); wp_enqueue_script('fl-slideshow'); wp_enqueue_style('fl-slideshow'); } else { if ($row->settings->bg_type == 'video') { wp_enqueue_script('jquery-imagesloaded'); } } } // Enqueue required module CSS and JS foreach ($nodes['modules'] as $module) { $module->enqueue_icon_styles(); $module->enqueue_font_styles(); $module->enqueue_scripts(); foreach ($module->css as $handle => $props) { wp_enqueue_style($handle, $props[0], $props[1], $props[2], $props[3]); } foreach ($module->js as $handle => $props) { wp_enqueue_script($handle, $props[0], $props[1], $props[2], $props[3]); } if (!empty($module->settings->animation)) { wp_enqueue_script('jquery-waypoints'); } } // Enqueue main CSS if (!file_exists($asset_info['css'])) { FLBuilder::render_css(); } $deps = apply_filters('fl_builder_layout_style_dependencies', array()); $media = apply_filters('fl_builder_layout_style_media', 'all'); wp_enqueue_style('fl-builder-layout-' . $post_id, $asset_info['css_url'], $deps, $asset_ver, $media); // Enqueue Google Fonts FLBuilderFonts::enqueue_styles(); // Enqueue main JS if (!file_exists($asset_info['js'])) { FLBuilder::render_js(); } wp_enqueue_script('fl-builder-layout-' . $post_id, $asset_info['js_url'], array('jquery'), $asset_ver, true); } }
/** * 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 */ public static function save_settings($node_id = null, $settings = null) { $post_data = self::get_post_data(); $node_id = isset($post_data['node_id']) ? $post_data['node_id'] : $node_id; $settings = isset($post_data['settings']) ? $post_data['settings'] : $settings; $node = self::get_node($node_id); $new_settings = (object) array_merge((array) $node->settings, (array) $settings); // 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); // Return the new layout. if (defined('DOING_AJAX')) { FLBuilder::render_css(); FLBuilder::render_js(); FLBuilder::render_layout(); } }