function get_items($request) { $templates = array(); $user_templates = get_posts(array('post_type' => 'fl-builder-template', 'orderby' => 'menu_order title', 'order' => 'ASC', 'posts_per_page' => -1, 'fl-builder-template-type' => 'layout')); //$user_templates = FLBuilderModel::get_user_templates(); if (!empty($user_templates)) { foreach ($user_templates as $post) { $layout = get_post_meta($post->ID, '_fl_builder_data', true); if ($layout) { $categories = get_post_meta($post->ID, 'template_categories', true); if (empty($categories)) { $categories = array('saved'); } $templates[] = array('handle' => $post->ID, 'label' => $post->post_title, 'description' => $post->post_excerpt, 'author' => $post->post_author, 'modified' => $post->post_modified, 'edit_link' => FLBuilderModel::get_edit_url($post->ID), 'categories' => $categories, 'type' => 'user', 'is_global' => get_post_meta($post->ID, '_fl_builder_template_global', true), 'is_editable' => true); } } } $template_data = FLBuilderModel::get_templates(); if (!empty($template_data)) { foreach ($template_data as $data) { $templates[] = array('handle' => $data->index, 'label' => $data->name, 'screenshot' => array('thumbnail' => FL_BUILDER_URL . 'img/templates/' . $data->image), 'author' => array('name' => 'Beaver Builder Team'), 'categories' => array($data->category), 'is_premium' => $data->premium, 'is_builtin' => true, 'type' => 'core'); } } $response = rest_ensure_response($templates); return $response; }
function get_templates() { /* $user_templates = get_posts( array( 'post_type' => 'fl-builder-template', 'orderby' => 'menu_order title', 'order' => 'ASC', 'posts_per_page' => -1, 'fl-builder-template-type' => 'layout' )); */ // Temp $template_data = FLBuilderModel::get_templates(); return $template_data; }