/** * Applies a user defined template instead * of a core template. * * @since 1.5.7 * @param int $template_id The post ID of the template to apply. * @param bool $append Whether to append the new template or replacing the existing layout. * @return bool */ public static function apply($template_id = null, $append = false) { $site_id = self::get_source_site_id(); $template = new StdClass(); if ($site_id) { if (is_multisite()) { switch_to_blog($site_id); } $template->data = FLBuilderModel::get_layout_data('published', $template_id); $template->settings = FLBuilderModel::get_layout_settings('published', $template_id); if (is_multisite()) { restore_current_blog(); } FLBuilderModel::apply_user_template($template, $append); return true; } return false; }