public function get_groups($args = array()) { global $wpddlayout; foreach ($this->layouts as $item) { $layout = WPDD_Layouts::get_layout_settings($item->ID, true); if ($layout) { if (property_exists($layout, 'has_child') === false) { $layout->has_child = false; } $item = $this->_filter_layout_item($item); $item->show_posts = $this->set_number_of_items_for_posts($item, $args); $item->kind = 'Item'; $item->post_name = urldecode($item->post_name); $item->id = $item->ID; $item->is_parent = $layout->has_child; $item->date_formatted = get_the_time(get_option('date_format'), $item->ID); $item->post_title = str_replace('\\\\"', '\\"', $item->post_title); $item->has_loop = property_exists($layout, 'has_loop') ? $layout->has_loop : false; $item->has_post_content_cell = property_exists($layout, 'has_post_content_cell') ? $layout->has_post_content_cell : false; if ($item->is_parent) { $item->children = self::get_children($layout, $this->layouts); } if (property_exists($layout, 'parent') && $layout->parent) { $parent = get_post(WPDD_Layouts::get_layout_parent($item->ID, $layout)); $item->is_child = true; if (is_object($parent) && $parent->post_status == $item->post_status) { $item->parent = $parent->ID; } } else { $item->is_child = false; } $types = $wpddlayout->post_types_manager->get_layout_post_types_object($item->ID); if ($types && !$item->is_parent) { $item->types = $types; //$item->group = 3; $this->post_types[] = (array) $item; } $loops = $this->loop_manager->get_layout_loops_labels($item->ID); if ($loops && !$item->is_parent) { $item->loops = $loops; $this->to_loops[] = (array) $item; } $posts_ids = $this->get_posts_where_used($item, $types, $args); if ($posts_ids && count($posts_ids) > 0 && !$item->is_parent) { $yes = $this->show_in_single($types, $posts_ids); $item->posts = $yes; // $item_posts_count = count( $item->posts ); $total_count = $wpddlayout->get_where_used_count(); if ($total_count > self::NUMBER_OF_ITEMS) { $item->show_more_button = true; } if (sizeof($item->posts) > 0) { $this->to_single[] = (array) $item; } } elseif ($item->is_parent || !$posts_ids && !$types && !$loops) { //$item->group = 1; $this->not_assigned[] = (array) $item; } } } $ret = array(array('id' => 1, 'name' => __("Layouts not being used anywhere", 'ddl-layouts'), 'kind' => 'Group', 'items' => $this->not_assigned), array('id' => 2, 'name' => __('Layouts being used to display single posts or pages', 'ddl-layouts'), 'kind' => 'Group', 'items' => $this->to_single), array('id' => 3, 'name' => __('Layouts being used as templates for post types', 'ddl-layouts'), 'kind' => 'Group', 'items' => $this->post_types), array('id' => 4, 'name' => __('Layouts being used to customize archives', 'ddl-layouts'), 'kind' => 'Group', 'items' => $this->to_loops)); return apply_filters('ddl_get_layouts_listing_groups', $ret, $this); }