当前位置: 首页>>代码示例>>PHP>>正文


PHP dwqa_current_user_can函数代码示例

本文整理汇总了PHP中dwqa_current_user_can函数的典型用法代码示例。如果您正苦于以下问题:PHP dwqa_current_user_can函数的具体用法?PHP dwqa_current_user_can怎么用?PHP dwqa_current_user_can使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了dwqa_current_user_can函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: dwqa_read_comment_permission_apply

function dwqa_read_comment_permission_apply($comments, $post_id)
{
    if (('dwqa-question' == get_post_type($post_id) || 'dwqa-answer' == get_post_type($post_id)) && !dwqa_current_user_can('read_comment')) {
        return array();
    }
    return $comments;
}
开发者ID:christianlee13,项目名称:dw-question-answer,代码行数:7,代码来源:roles.php

示例2: submit_question_form_shortcode

 public function submit_question_form_shortcode()
 {
     global $dwqa_sript_vars, $script_version, $dwqa_template_compat;
     ob_start();
     $dwqa_template_compat->remove_all_filters('the_content');
     echo '<div class="dwqa-container" >';
     if (dwqa_current_user_can('post_question')) {
         dwqa_load_template('question', 'submit-form');
     } else {
         echo '<p class="alert alert-error">' . __('You do not have permission to submit question.', 'dwqa') . '</p>';
     }
     echo '</div>';
     $html = ob_get_contents();
     $dwqa_template_compat->restore_all_filters('the_content');
     ob_end_clean();
     wp_enqueue_script('dwqa-submit-question', DWQA_URI . 'inc/templates/default/assets/js/dwqa-submit-question.js', array('jquery'), $script_version, true);
     wp_localize_script('dwqa-submit-question', 'dwqa', $dwqa_sript_vars);
     return $this->sanitize_output($html);
 }
开发者ID:douglaswebdesigns,项目名称:ask-bio-expert,代码行数:19,代码来源:shortcodes.php

示例3: dwqa_question_answers_count

/**
 * Return number of answer for a question
 * @param  int $question_id Question ID ( if null get ID of current post )
 * @return int      Number of answer
 */
function dwqa_question_answers_count($question_id = null)
{
    global $wpdb;
    if (!$question_id) {
        global $post;
        $question_id = $post->ID;
    }
    $answer_count = get_transient('dwqa_answer_count_for_' . $question_id);
    if (false === $answer_count) {
        $sql = "SELECT COUNT( DISTINCT `P`.ID ) FROM {$wpdb->postmeta} PM JOIN {$wpdb->posts} P ON `PM`.post_id = `P`.ID WHERE `PM`.meta_key = '_question' AND meta_value = {$question_id} AND `P`.post_type = 'dwqa-answer' AND `P`.post_status = 'publish'";
        $sql .= " AND ( `P`.post_status = 'publish' ";
        if (dwqa_current_user_can('edit_question', $question_id)) {
            $sql .= " OR `P`.post_status = 'private'";
        }
        $sql .= " )";
        $answer_count = $wpdb->get_var($sql);
        set_transient('dwqa_answer_count_for_' . $question_id, $answer_count, 15 * 60);
    }
    return $answer_count;
}
开发者ID:layoutzweb,项目名称:dw-question-answer,代码行数:25,代码来源:Answer.php

示例4: ajax_create_update_question_editor

    public function ajax_create_update_question_editor()
    {
        if (!isset($_POST['question'])) {
            return false;
        }
        extract($_POST);
        ob_start();
        ?>
		<form action="<?php 
        echo admin_url('admin-ajax.php?action=dwqa-update-question');
        ?>
" method="post">
			<?php 
        wp_nonce_field('_dwqa_update_question');
        ?>

			<?php 
        if ('draft' == get_post_status($question) && dwqa_current_user_can('edit_question')) {
            ?>
			<input type="hidden" name="dwqa-action-draft" value="true" >
			<?php 
        }
        ?>
 
			<input type="hidden" name="dwqa-action" value="update-question" >
			<input type="hidden" name="question" value="<?php 
        echo $question;
        ?>
">
			<?php 
        $question = get_post($question);
        ?>
			<input type="text" style="width:100%" name="dwqa-question-title" id="dwqa-question-title" value="<?php 
        echo $question->post_title;
        ?>
">
			<?php 
        $question_content = apply_filters('dwqa_prepare_edit_question_content', $question->post_content);
        add_filter('dwqa_prepare_edit_question_content', 'wpautop');
        dwqa_init_tinymce_editor(array('content' => $question_content, 'textarea_name' => 'dwqa-question-content', 'wpautop' => false));
        ?>
			<p class="dwqa-question-form-btn">
				<input type="submit" name="submit-question" class="dwqa-btn dwqa-btn-default" value="<?php 
        _e('Update', 'dwqa');
        ?>
">
				<a type="button" class="question-edit-cancel dwqa-btn dwqa-btn-link" ><?php 
        _e('Cancel', 'dwqa');
        ?>
</a>
				<?php 
        if ('draft' == get_post_status($question) && current_user_can('manage_options')) {
            ?>
				<input type="submit" name="submit-question" class="btn btn-primary btn-small" value="<?php 
            _e('Publish', 'dwqa');
            ?>
">
				<?php 
        }
        ?>
			</p>
		</form>
		<?php 
        $editor = ob_get_contents();
        ob_end_clean();
        wp_send_json_success(array('editor' => $editor));
    }
开发者ID:blogfor,项目名称:king,代码行数:67,代码来源:Editor.php

示例5: posts_where_filter_default

 public function posts_where_filter_default($where)
 {
     global $current_user;
     $manager = 0;
     if (dwqa_current_user_can('edit_question')) {
         $manager = 1;
     }
     $where .= " AND if ( post_status = 'private', if ( {$manager} = 1, 1, if ( post_author = {$current_user->ID}, 1, 0 ) ), 1 ) = 1";
     $where .= " AND if ( post_status = 'pending', if ( {$manager} = 1, 1, if ( post_author = {$current_user->ID}, 1, 0 ) ), 1 ) = 1";
     return $where;
 }
开发者ID:layoutzweb,项目名称:dw-question-answer,代码行数:11,代码来源:Filter.php

示例6: dwqa_siteinfo_guest_fields

function dwqa_siteinfo_guest_fields()
{
    if (!is_user_logged_in() && dwqa_current_user_can('post_question')) {
        ?>
	<div class="user-name">
		<label for="user-email" title="<?php 
        _e('Enter your name.', 'dwqa_site_info');
        ?>
"><?php 
        _e('Your name *', 'dwqa');
        ?>
</label> 
		<input type="text" name="_dwqa_anonymous_name" id="_dwqa_anonymous_name" class="large-text" placeholder="<?php 
        _e('Your name', 'dwqa_site_info');
        ?>
" required> 
	</div>
	<?php 
    }
}
开发者ID:jomsocial,项目名称:dwqaSiteInfo,代码行数:20,代码来源:dwqa_site_info.php

示例7: wp_create_nonce

        ?>
						<li class="dwqa-comment-edit-link" data-edit="0" data-comment-edit-nonce="<?php 
        echo wp_create_nonce('_dwqa_action_comment_edit_nonce');
        ?>
" data-comment-id="<?php 
        echo $comment->comment_ID;
        ?>
" ><a href="#"><i class="fa fa-pencil"></i> <?php 
        _e('Edit', 'dwqa');
        ?>
</a></li>
						<?php 
    }
    ?>
						<?php 
    if (dwqa_current_user_can('delete_comment') || $current_user->ID == $comment->user_id) {
        ?>
						<li class="comment-delete-link" data-comment-type="<?php 
        echo $post->post_type == 'dwqa-question' ? 'question' : 'answer';
        ?>
" data-comment-id="<?php 
        echo $comment->comment_ID;
        ?>
" data-comment-delete-nonce="<?php 
        echo wp_create_nonce('_dwqa_action_comment_delete_nonce');
        ?>
" ><a href="#"><i class="fa fa-trash-o"></i> <?php 
        _e('Delete', 'dwqa');
        ?>
</a></li>
						<?php 
开发者ID:hacklabr,项目名称:portal-timtec,代码行数:31,代码来源:content-comment.php

示例8: ajax_create_update_question_editor

    public function ajax_create_update_question_editor()
    {
        if (!isset($_POST['question'])) {
            return false;
        }
        extract($_POST);
        ob_start();
        ?>
		<form action="<?php 
        echo admin_url('admin-ajax.php?action=dwqa-update-question');
        ?>
" method="post">
			<?php 
        wp_nonce_field('_dwqa_update_question');
        ?>

			<?php 
        if ('draft' == get_post_status($question) && dwqa_current_user_can('edit_question')) {
            ?>
			<input type="hidden" name="dwqa-action-draft" value="true" >
			<?php 
        }
        ?>
 
			<input type="hidden" name="dwqa-action" value="update-question" >
			<input type="hidden" name="question" value="<?php 
        echo $question;
        ?>
">
			<?php 
        $question = get_post($question);
        ?>
			<input type="text" style="width:100%" name="dwqa-question-title" id="dwqa-question-title" value="<?php 
        echo $question->post_title;
        ?>
">
			<?php 
        $question_content = apply_filters('dwqa_prepare_edit_question_content', $question->post_content);
        dwqa_init_tinymce_editor(array('content' => $question_content, 'textarea_name' => 'dwqa-question-content', 'wpautop' => false));
        ?>
			<script type="text/javascript">
				var id = 'dwqa-custom-content-editor';
				var settings = tinyMCEPreInit.mceInit['dwqa-answer-question-editor'];

                    settings.elements = id;
                    settings.body_class = id + ' post-type-dwqa-question';
                    settings.editor_selector = id; // deprecated in TinyMCE 4.x
                    settings.selector = '#' + id;
                    //init tinymce
                    if( tinyMCE.get(id) ) {
                        tinymce.remove('#'+id);   
                    }
                    tinyMCE.init(settings);
			</script>
			<p class="dwqa-question-form-btn">
				<input type="submit" name="submit-question" class="dwqa-btn dwqa-btn-default" value="<?php 
        _e('Update', 'dwqa');
        ?>
">
				<a type="button" class="question-edit-cancel dwqa-btn dwqa-btn-link" ><?php 
        _e('Cancel', 'dwqa');
        ?>
</a>
				<?php 
        if ('draft' == get_post_status($question) && current_user_can('manage_options')) {
            ?>
				<input type="submit" name="submit-question" class="btn btn-primary btn-small" value="<?php 
            _e('Publish', 'dwqa');
            ?>
">
				<?php 
        }
        ?>
			</p>
		</form>
		<?php 
        $editor = apply_filters('dwqa_question_edit_content_editor', ob_get_contents(), $_POST);
        ob_end_clean();
        wp_send_json_success(array('editor' => $editor));
    }
开发者ID:yisrael1981,项目名称:dw-question-answer,代码行数:80,代码来源:Editor.php

示例9: _e

	</p>
	<p>
		<label for="question-tag"><?php 
_e('Tag', 'dwqa');
?>
</label>
		<?php 
$tags = isset($_POST['question-tag']) ? $_POST['question-tag'] : '';
?>
		<input type="text" class="" name="question-tag" value="<?php 
echo $tags;
?>
" >
	</p>
	<?php 
if (dwqa_current_user_can('post_question') && !is_user_logged_in()) {
    ?>
	<p>
		<label for="_dwqa_anonymous_email"><?php 
    _e('Your Email', 'dwqa');
    ?>
</label>
		<?php 
    $email = isset($_POST['_dwqa_anonymous_email']) ? $_POST['_dwqa_anonymous_email'] : '';
    ?>
		<input type="email" class="" name="_dwqa_anonymous_email" value="<?php 
    echo $email;
    ?>
" >
	</p>
	<p>
开发者ID:hamdouni,项目名称:dw-question-answer,代码行数:31,代码来源:question-submit-form.php

示例10: wp_list_comments

    ?>
</span>
	</div>
	<?php 
}
?>

	<?php 
if (have_comments()) {
    ?>
	<ol class="dwqa-comment-list">
	<?php 
    wp_list_comments(array('style' => 'ol', 'callback' => 'dwqa_question_comment_callback'));
    ?>
	</ol>
	<?php 
}
?>

	<?php 
if (!dwqa_is_closed(get_the_ID()) && dwqa_current_user_can('post_comment')) {
    ?>
		<?php 
    global $current_user;
    $args = array('comment_field' => (is_user_logged_in() ? get_avatar($current_user->ID, 32) : '') . '<textarea id="comment" name="comment" aria-required="true" placeholder="' . __('Write a reply...', 'dwqa') . '"></textarea>', 'comment_notes_before' => '', 'logged_in_as' => '', 'comment_notes_after' => '', 'id_form' => 'comment_form_' . get_the_ID());
    ?>
		<?php 
    dwqa_comment_form($args);
    ?>
	<?php 
}
开发者ID:blogfor,项目名称:king,代码行数:31,代码来源:comments.php

示例11: dwqa_question_button_action

		<span class="dwqa-question-actions"><?php 
dwqa_question_button_action();
?>
</span>
	</div>
	<div class="dwqa-question-content"><?php 
the_content();
?>
</div>
	<footer class="dwqa-question-footer">
		<div class="dwqa-question-meta">
			<?php 
echo get_the_term_list(get_the_ID(), 'dwqa-question_tag', '<span class="dwqa-question-tag">' . __('Question Tags: ', 'dwqa'), ', ', '</span>');
?>
			<?php 
if (dwqa_current_user_can('edit_question', get_the_ID())) {
    ?>
			<span class="dwqa-question-status">
				<?php 
    _e('This question is:', 'dwqa');
    ?>
				<select id="dwqa-question-status" data-nonce="<?php 
    echo wp_create_nonce('_dwqa_update_privacy_nonce');
    ?>
" data-post="<?php 
    the_ID();
    ?>
">
					<optgroup label="Status">
						<option <?php 
    selected(dwqa_question_status(), 'open');
开发者ID:layoutzweb,项目名称:dw-question-answer,代码行数:31,代码来源:content-single-question.php

示例12: load_template

 public function load_template($name, $extend = false, $include = true)
 {
     $check = true;
     if ($extend) {
         $name .= '-' . $extend;
     }
     if ($name == 'submit-question-form' && is_user_logged_in() && !dwqa_current_user_can('post_question')) {
         echo '<div class="alert">' . __('You do not have permission to submit a question', 'dwqa') . '</div>';
         return false;
     }
     $template = get_stylesheet_directory() . '/dwqa-templates/' . $name . '.php';
     if (!file_exists($template)) {
         $template = DWQA_DIR . 'templates/' . $this->active . '/' . $name . '.php';
     }
     $template = apply_filters('dwqa-load-template', $template, $name);
     if (!$template) {
         return false;
     }
     if (!$include) {
         return $template;
     }
     include $template;
 }
开发者ID:Trideon,项目名称:gigolo,代码行数:23,代码来源:Template.php

示例13: single_question


//.........这里部分代码省略.........
                <footer class="dwqa-footer">
                    <div class="dwqa-author">
                        <?php 
            echo get_avatar($post->post_author, 32, false);
            ?>
                        <span class="author">
                            <?php 
            printf('<a href="%1$s" title="%2$s %3$s">%3$s</a>', get_author_posts_url(get_the_author_meta('ID')), __('Posts by', 'dwqa'), get_the_author_meta('display_name'));
            ?>
                        </span><!-- Author Info -->
                        <span class="dwqa-date">
                            <?php 
            printf('<a href="%s" title="%s #%d">%s %s</a>', get_permalink(), __('Link to', 'dwqa'), $post_id, __('asked', 'dwqa'), get_the_date());
            ?>
                        </span> <!-- Question Date -->
                        
                        
                        <div data-post="<?php 
            echo $post_id;
            ?>
" data-nonce="<?php 
            echo wp_create_nonce('_dwqa_update_privacy_nonce');
            ?>
" data-type="question" class="dwqa-privacy">
                            <input type="hidden" name="privacy" value="<?php 
            get_post_status();
            ?>
">
                            <span class="dwqa-current-privacy"> <?php 
            echo 'private' == get_post_status() ? '<i class="fa fa-lock"></i> ' . __('Private', 'dwqa') : '<i class="fa fa-globe"></i> ' . __('Public', 'dwqa');
            ?>
</span>
                            <?php 
            if (dwqa_current_user_can('edit_question') || dwqa_current_user_can('edit_answer') || $post->post_author == $current_user->ID) {
                ?>
                            <span class="dwqa-change-privacy">
                                <div class="dwqa-btn-group">
                                    <button type="button" class="dropdown-toggle" ><i class="fa fa-caret-down"></i></button>
                                    <div class="dwqa-dropdown-menu">
                                        <div class="dwqa-dropdown-caret">
                                            <span class="dwqa-caret-outer"></span>
                                            <span class="dwqa-caret-inner"></span>
                                        </div>
                                        <ul role="menu">
                                            <li title="<?php 
                _e('Everyone can see', 'dwqa');
                ?>
" data-privacy="publish" <?php 
                echo 'publish' == get_post_status() ? 'class="current"' : '';
                ?>
><a href="#"><i class="fa fa-globe"></i> <?php 
                _e('Public', 'dwqa');
                ?>
</a></li>
                                            <li title="<?php 
                _e('Only Author and Administrator can see', 'dwqa');
                ?>
" data-privacy="private" <?php 
                echo 'private' == get_post_status() ? 'class="current"' : '';
                ?>
><a href="#" ><i class="fa fa-lock"></i> <?php 
                _e('Private', 'dwqa');
                ?>
</a></li>
                                        </ul>
                                    </div>
开发者ID:christianlee13,项目名称:dw-question-answer,代码行数:67,代码来源:box.php

示例14: dwqa_print_notices

	<form name="dwqa-answer-form" id="dwqa-answer-form" method="post">
		<?php 
dwqa_print_notices();
?>
		<?php 
$content = isset($_POST['answer-content']) ? $_POST['answer-content'] : '';
?>
		<?php 
dwqa_init_tinymce_editor(array('content' => $content, 'textarea_name' => 'answer-content', 'id' => 'dwqa-answer-content'));
?>
		<?php 
dwqa_load_template('captcha', 'form');
?>

		<?php 
if (dwqa_current_user_can('post_answer') && !is_user_logged_in()) {
    ?>
		<p>
			<label for="user-email"><?php 
    _e('Your Email', 'dwqa');
    ?>
</label>
			<?php 
    $email = isset($_POST['user-email']) ? $_POST['user-email'] : '';
    ?>
			<input type="email" class="" name="user-email" value="<?php 
    echo $email;
    ?>
" >
		</p>
		<?php 
开发者ID:layoutzweb,项目名称:dw-question-answer,代码行数:31,代码来源:answer-submit-form.php

示例15: remove_answer

 function remove_answer()
 {
     if (!isset($_POST['wpnonce']) || !wp_verify_nonce(esc_html($_POST['wpnonce']), '_dwqa_action_remove_answer_nonce') || !is_user_logged_in()) {
         wp_send_json_error(array('message' => __('Are you cheating huh?', 'dwqa')));
     }
     if (isset($_POST['answer_id'])) {
         $answer_id = intval($_POST['answer_id']);
     } else {
         wp_send_json_error(array('message' => __('Missing answer ID', 'dwqa')));
     }
     global $current_user;
     $answer_author = get_post_field('post_author', $answer_id);
     if (!(dwqa_current_user_can('delete_answer') || is_user_logged_in() && $answer_author == $current_user->ID)) {
         wp_send_json_error(array('message' => __('You do not have permission to edit this post', 'dwqa')));
     }
     if (get_post_type($answer_id) != 'dwqa-answer') {
         wp_send_json_error(array('message' => __('This post is not an answer', 'dwqa')));
     }
     $question_id = get_post_meta($answer_id, '_question', true);
     do_action('dwqa_delete_answer', $answer_id, $question_id);
     wp_delete_post($answer_id);
     wp_send_json_success(array('question' => $question_id, 'answer' => $answer_id));
 }
开发者ID:Trideon,项目名称:gigolo,代码行数:23,代码来源:Answer.php


注:本文中的dwqa_current_user_can函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。