예제 #1
0
파일: admin.php 프로젝트: guysyml/software
/**
 * Get custom POST vars on edit/create page pages and update options accordingly
 */
function pr_meta_save()
{
    if (isset($_POST['pr']) && $_POST['pr'] == 'update') {
        $post_ID = $_POST['post_ID'];
        $post = get_post($post_ID);
        if ($post->post_type == 'page') {
            $restrict_type = 'pages';
        } else {
            $restrict_type = 'posts';
        }
        $pr_options['pages'] = pr_get_opt('pages');
        $pr_options['posts'] = pr_get_opt('posts');
        $restricted = $pr_options[$restrict_type];
        if (!is_array($restricted)) {
            $restricted = array();
        }
        if (!empty($_POST['restriction_status']) && $_POST['restriction_status'] == 'on') {
            $restricted[] = $post_ID;
            $pr_options[$restrict_type] = $restricted;
        } else {
            $pr_options[$restrict_type] = array_filter($restricted, 'pr_array_delete');
        }
        $pr_options['loginform'] = pr_get_opt('loginform');
        $pr_options['method'] = pr_get_opt('method');
        $pr_options['message'] = pr_get_opt('message');
        $pr_options['version'] = pr_get_opt('version');
        update_option('pr_options', $pr_options);
    }
}
예제 #2
0
function pr_comment_restrict($pr_comment_array)
{
    global $post;
    if (!is_user_logged_in() && is_array(pr_get_opt('pages'))) {
        $is_restricted = (in_array($post->ID, pr_get_opt('pages')) || in_array($post->ID, pr_get_opt('posts'))) && pr_get_opt('method') != 'none';
        if ($is_restricted || pr_get_opt('method') == 'all') {
            $pr_comment_array = array();
        }
    }
    return $pr_comment_array;
}