Ejemplo n.º 1
0
function clearbase_ajax_get_folder_tree()
{
    $tree = clearbase_get_folder_tree();
    echo '<ul>';
    for ($i = 0, $count = count($tree); $i < $count; $i++) {
        __clearbase_ajax_print_folder($tree[$i]);
    }
    echo '</ul>';
    wp_die();
}
Ejemplo n.º 2
0
function clearbase_is_child_of($parent_folder_id, $post_id)
{
    //a post id of zero will never be a child of anything
    if (0 == $post_id) {
        return false;
    }
    //find out if the $post_id is a folder
    $post = get_post($post_id);
    if (is_wp_error($post)) {
        return $post;
    }
    $is_child = $post->post_parent === $parent_folder_id;
    //search deeper into the tree
    if (!$is_child) {
        $folder_id = 'clearbase_folder' === $post->post_type ? $post_id : $post->post_parent;
        //get a copy of the master tree
        $tree = clearbase_get_folder_tree();
        //search the master tree for the parent_folder_id
        $parent_tree = clearbase_folder_tree_find($parent_folder_id, $tree);
        //if we have found the parent folder tree
        if ($parent_tree) {
            //look in the parent_tree for the folder_id.  If the return is false
            //then the folder_id is not a child of parent_folder tree
            $is_child = false !== clearbase_folder_tree_find($folder_id, $parent_tree);
        }
    }
    //nope. its not
    return $is_child;
}