示例#1
0
function rcl_get_postlist_page()
{
    global $wpdb;
    $type = sanitize_text_field($_POST['type']);
    $start = intval($_POST['start']);
    $author_lk = intval($_POST['id_user']);
    $start .= ',';
    //$edit_url = rcl_format_url(get_permalink($rcl_options['public_form_page_rcl']));
    $posts = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "posts WHERE post_author='%d' AND post_type='%s' AND post_status NOT IN ('draft','auto-draft') ORDER BY post_date DESC LIMIT {$start} 20", $author_lk, $type));
    $rayting = false;
    if (function_exists('rcl_get_rating_block')) {
        $b = 0;
        foreach ((array) $posts as $p) {
            if (++$b > 1) {
                $p_list .= ',';
            }
            $p_list .= $p->ID;
        }
        $rayt_p = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . RCL_PREF . "total_rayting_posts WHERE post_id IN ({$p_list})", $p_list));
        foreach ((array) $rayt_p as $r) {
            $rayt[$r->post_id] = $r->total;
        }
        $rayting = true;
    }
    $posts_block .= '<table class="publics-table-rcl">
		<tr>
			<td>' . __('Date', 'wp-recall') . '</td><td>' . __('Title', 'wp-recall') . '</td><td>' . __('Status', 'wp-recall') . '</td>';
    //if($user_ID==$author_lk) $posts_block .= '<td>Ред.</td>';
    $posts_block .= '</tr>';
    foreach ((array) $posts as $post) {
        if ($post->post_status == 'pending') {
            $status = '<span class="pending">' . __('on approval', 'wp-recall') . '</span>';
        } elseif ($post->post_status == 'trash') {
            $status = '<span class="pending">' . __('deleted', 'wp-recall') . '</span>';
        } else {
            $status = '<span class="publish">' . __('publish', 'wp-recall') . '</span>';
        }
        $posts_block .= '<tr>
			<td>' . mysql2date('d-m-Y', $post->post_date) . '</td><td><a target="_blank" href="' . $post->guid . '">' . $post->post_title . '</a>';
        if ($rayting) {
            $posts_block .= ' ' . rcl_get_rating_block($rayt[$post->ID]);
        }
        $posts_block .= '</td><td>' . $status . '</td>';
        //if($user_ID==$author_lk) $posts_block .= '<td><a target="_blank" href="'.$edit_url.'rcl-post-edit='.$post->ID.'">Ред.</a></td>';
        $posts_block .= '</tr>';
    }
    $posts_block .= '</table>';
    $log['post_content'] = $posts_block;
    $log['recall'] = 100;
    echo json_encode($log);
    exit;
}
示例#2
0
function rcl_add_rating_block($content, $args)
{
    $content .= rcl_get_rating_block($args);
    return $content;
}