示例#1
0
function build_page_object($dic)
{
    $childobject = array();
    $childobject["title"] = $dic->post_title;
    $childobject["link"] = get_permalink($dic->ID);
    $childobject["ml_link"] = plugins_url("get_page.php?page_ID=" . $dic->ID, __FILE__);
    $childobject["ml_render"] = ml_page_get_render($dic->ID);
    $childobject["id"] = "{$dic->ID}";
    $comments_count = wp_count_comments($dic->ID);
    $childobject["comments-count"] = 0;
    if ($comments_count) {
        $childobject["comments-count"] = intval($comments_count->approved);
    }
    //$my_wp_query = new WP_Query();
    //$all_wp_pages = $my_wp_query->query(array('post_type' => 'page'));
    //$children = get_page_children($dic->ID,$all_wp_pages);
    $children = get_pages(array('parent' => $dic->ID));
    $childarray = array();
    foreach ($children as $child) {
        if ($child->post_title != NULL && $child->ID != NULL && $child->post_parent == $dic->ID) {
            array_push($childarray, build_page_object($child));
        }
    }
    //wp_reset_postdata();
    $childobject["children"] = $childarray;
    return $childobject;
}
function build_page_object($dic)
{
    $childobject = array();
    $childobject[base64_decode('dGl0bGU=')] = $dic->post_title;
    $childobject[base64_decode('bGluaw==')] = get_permalink($dic->ID);
    $childobject[base64_decode('bWxfbGluaw==')] = plugins_url(base64_decode('Z2V0X3BhZ2UucGhwP3BhZ2VfSUQ9') . $dic->ID, __FILE__);
    $childobject[base64_decode('bWxfcmVuZGVy')] = ml_page_get_render($dic->ID);
    $childobject[base64_decode('aWQ=')] = "{$dic->ID}";
    $comments_count = wp_count_comments($dic->ID);
    $childobject[base64_decode('Y29tbWVudHMtY291bnQ=')] = 0;
    if ($comments_count) {
        $childobject[base64_decode('Y29tbWVudHMtY291bnQ=')] = intval($comments_count->approved);
    }
    $children = get_pages(array(base64_decode('cGFyZW50') => $dic->ID));
    $childarray = array();
    foreach ($children as $child) {
        if ($child->post_title != NULL && $child->ID != NULL && $child->post_parent == $dic->ID) {
            array_push($childarray, build_page_object($child));
        }
    }
    $childobject[base64_decode('Y2hpbGRyZW4=')] = $childarray;
    return $childobject;
}