本文整理汇总了PHP中ap_opt函数的典型用法代码示例。如果您正苦于以下问题:PHP ap_opt函数的具体用法?PHP ap_opt怎么用?PHP ap_opt使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ap_opt函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: anspress_activate
/**
* Create base pages, add roles, add caps and create tables
* @param $network_wide
*/
function anspress_activate($network_wide)
{
// add roles
$ap_roles = new AP_Roles();
$ap_roles->add_roles();
$ap_roles->add_capabilities();
ap_create_base_page();
if (ap_opt('ap_version') != AP_VERSION) {
ap_opt('ap_installed', 'false');
ap_opt('ap_version', AP_VERSION);
}
global $wpdb;
/**
* Run DB quries only if AP_DB_VERSION does not match
*/
if (ap_opt('ap_db_version') != AP_DB_VERSION) {
$charset_collate = !empty($wpdb->charset) ? "DEFAULT CHARACTER SET " . $wpdb->charset : '';
$meta_table = "CREATE TABLE IF NOT EXISTS `" . $wpdb->prefix . "ap_meta` (\n\t\t\t\t `apmeta_id` bigint(20) NOT NULL AUTO_INCREMENT,\n\t\t\t\t `apmeta_userid` bigint(20) DEFAULT NULL,\n\t\t\t\t `apmeta_type` varchar(256) DEFAULT NULL,\n\t\t\t\t `apmeta_actionid` bigint(20) DEFAULT NULL,\n\t\t\t\t `apmeta_value` text,\n\t\t\t\t `apmeta_param` LONGTEXT DEFAULT NULL,\n\t\t\t\t `apmeta_date` timestamp NULL DEFAULT NULL,\n\t\t\t\t PRIMARY KEY (`apmeta_id`)\n\t\t\t\t)" . $charset_collate . ";";
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
dbDelta($meta_table);
ap_opt('ap_db_version', AP_DB_VERSION);
}
if (!get_option('anspress_opt')) {
update_option('anspress_opt', ap_default_options());
} else {
update_option('anspress_opt', get_option('anspress_opt') + ap_default_options());
}
ap_opt('ap_flush', 'true');
flush_rewrite_rules(false);
}
示例2: init
public function init()
{
// return if reputation is disabled
if (ap_opt('disable_reputation')) {
return;
}
ap_register_user_page('reputation', __('Reputation', 'ap'), array($this, 'reputation_page'));
add_filter('ap_user_menu', array($this, 'sort_reputation_page'));
add_action('ap_after_new_question', array($this, 'new_question'));
add_action('ap_untrash_question', array($this, 'new_question'));
add_action('ap_trash_question', array($this, 'trash_question'), 10, 2);
add_action('ap_after_new_answer', array($this, 'new_answer'));
add_action('ap_untrash_answer', array($this, 'new_answer'));
add_action('ap_trash_answer', array($this, 'delete_answer'), 10, 2);
add_action('ap_select_answer', array($this, 'select_answer'), 10, 3);
add_action('ap_unselect_answer', array($this, 'unselect_answer'), 10, 3);
add_action('ap_vote_up', array($this, 'vote_up'), 10, 2);
add_action('ap_vote_down', array($this, 'vote_down'), 10, 2);
add_action('ap_undo_vote_up', array($this, 'undo_vote_up'), 10, 2);
add_action('ap_undo_vote_down', array($this, 'undo_vote_down'), 10, 2);
add_action('ap_publish_comment', array($this, 'new_comment'));
add_action('ap_unpublish_comment', array($this, 'delete_comment'));
add_filter('ap_user_display_meta_array', array($this, 'display_meta'), 10, 2);
add_filter('user_register', array($this, 'user_register'));
}
示例3: ap_scripts_front
function ap_scripts_front()
{
wp_enqueue_script('jquery');
wp_enqueue_script('jquery-form', array('jquery'), false);
wp_enqueue_script('ap-functions-js', ANSPRESS_URL . 'assets/prod/ap-functions.min.js', array('jquery', 'jquery-form'));
wp_enqueue_script('ap-anspress_script', ANSPRESS_URL . 'assets/prod/anspress_site.min.js', array('jquery', 'jquery-form'), AP_VERSION);
wp_enqueue_script('peity-js', ap_get_theme_url('js/jquery.peity.min.js'), 'jquery', AP_VERSION);
wp_enqueue_script('ap-initial.js', ap_get_theme_url('js/initial.min.js'), 'jquery', AP_VERSION);
wp_enqueue_script('ap-scrollbar.js', ap_get_theme_url('js/jquery.scrollbar.min.js'), 'jquery', AP_VERSION);
wp_enqueue_script('ap-js', ap_get_theme_url('prod/ap.min.js'), array('jquery', 'jquery-form'), AP_VERSION);
wp_enqueue_style('ap-style', ap_get_theme_url('css/main.css'), array(), AP_VERSION);
$custom_css = '
#anspress .ap-q-cells{
margin-left: ' . (ap_opt('avatar_size_qquestion') + 10) . 'px;
}
#anspress .ap-a-cells{
margin-left: ' . (ap_opt('avatar_size_qanswer') + 10) . 'px;
}#anspress .ap-comment-content{
margin-left: ' . (ap_opt('avatar_size_qcomment') + 15) . 'px;
}';
wp_add_inline_style('ap-style', $custom_css);
wp_enqueue_style('ap-fonts', ap_get_theme_url('fonts/style.css'), array(), AP_VERSION);
do_action('ap_enqueue');
wp_enqueue_style('ap-responsive', ap_get_theme_url('css/responsive.css'), array(), AP_VERSION);
wp_enqueue_style('ap-overrides', ap_get_theme_url('css/overrides.css'), array(), AP_VERSION);
echo '<script type="text/javascript">';
echo 'var ajaxurl = "' . admin_url('admin-ajax.php') . '",';
echo 'ap_nonce = "' . wp_create_nonce('ap_ajax_nonce') . '",';
echo 'ap_max_tags = "' . ap_opt('max_tags') . '",';
echo 'disable_hover_card = "' . (ap_opt('disable_hover_card') ? true : false) . '"';
echo '</script>';
wp_localize_script('ap-anspress_script', 'aplang', array('password_field_not_macthing' => __('Password not matching', 'ap'), 'password_length_less' => __('Password length must be 6 or higher', 'ap'), 'not_valid_email' => __('Not a valid email', 'ap'), 'username_less' => __('Username length must be 4 or higher', 'ap'), 'username_not_avilable' => __('Username not available', 'ap'), 'email_already_in_use' => sprintf(__('Email already in use. %sDo you want to reset your password?%s', 'ap'), '<a href="' . wp_lostpassword_url() . '">', '</a>'), 'loading' => __('Loading', 'ap'), 'sending' => __('Sending request', 'ap'), 'adding_to_fav' => __('Adding question to your favorites', 'ap'), 'voting_on_post' => __('Sending your vote', 'ap'), 'requesting_for_closing' => __('Requesting for closing this question', 'ap'), 'sending_request' => __('Submitting request', 'ap'), 'loading_comment_form' => __('Loading comment form', 'ap'), 'submitting_your_question' => __('Sending your question', 'ap'), 'submitting_your_answer' => __('Sending your answer', 'ap'), 'submitting_your_comment' => __('Sending your comment', 'ap'), 'deleting_comment' => __('Deleting comment', 'ap'), 'updating_comment' => __('Updating comment', 'ap'), 'loading_form' => __('Loading form', 'ap'), 'saving_labels' => __('Saving labels', 'ap'), 'loading_suggestions' => __('Loading suggestions', 'ap'), 'uploading_cover' => __('Uploading cover', 'ap'), 'saving_profile' => __('Saving profile', 'ap'), 'sending_message' => __('Sending message', 'ap'), 'loading_conversation' => __('Loading conversation', 'ap'), 'loading_new_message_form' => __('Loading new message form', 'ap'), 'loading_more_conversations' => __('Loading more conversations', 'ap'), 'searching_conversations' => __('Searching conversations', 'ap'), 'loading_message_edit_form' => __('Loading message form', 'ap'), 'updating_message' => __('Updating message', 'ap'), 'deleting_message' => __('Deleting message', 'ap'), 'uploading' => __('Uploading', 'ap'), 'error' => ap_icon('error'), 'warning' => ap_icon('warning'), 'success' => ap_icon('success'), 'not_valid_response' => __('Something went wrong in server side, not a valid response.', 'ap')));
wp_localize_script('ap-site-js', 'apoptions', array('ajaxlogin' => ap_opt('ajax_login')));
}
示例4: rewrites
/**
* Rewrite rules
* @return array
*/
public function rewrites()
{
global $wp_rewrite;
global $ap_rules;
unset($wp_rewrite->extra_permastructs['question']);
unset($wp_rewrite->extra_permastructs['answer']);
$base_page_id = ap_opt('base_page');
$slug = ap_base_page_slug() . '/';
$question_slug = ap_opt('question_page_slug');
if (empty($question_slug)) {
$question_slug = 'question';
}
$user_page = ap_opt('base_before_user_perma') ? $slug . ap_get_user_page_slug() . '/' : ap_get_user_page_slug() . '/';
$new_rules = array($slug . 'parent/([^/]+)/?' => 'index.php?page_id=' . $base_page_id . '&parent=' . $wp_rewrite->preg_index(1), $slug . 'tag/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?page_id=' . $base_page_id . '&ap_page=tag&q_tag=' . $wp_rewrite->preg_index(1) . '&paged=' . $wp_rewrite->preg_index(2), $slug . 'tag/([^/]+)/?' => 'index.php?page_id=' . $base_page_id . '&ap_page=tag&q_tag=' . $wp_rewrite->preg_index(1), $slug . 'page/?([0-9]{1,})/?$' => 'index.php?page_id=' . $base_page_id . '&paged=' . $wp_rewrite->preg_index(1), $slug . '([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?page_id=' . $base_page_id . '&ap_page=' . $wp_rewrite->preg_index(1) . '&paged=' . $wp_rewrite->preg_index(2));
if (!ap_opt('question_permalink_follow')) {
$new_rules[$question_slug . '/([^/]+)/page/?([0-9]{1,})/?$'] = 'index.php?page_id=' . $base_page_id . '&question_name=' . $wp_rewrite->preg_index(1) . '&paged=' . $wp_rewrite->preg_index(2);
$new_rules[$question_slug . '/([^/]+)/?$'] = 'index.php?page_id=' . $base_page_id . '&question_name=' . $wp_rewrite->preg_index(1);
} else {
$new_rules[$slug . $question_slug . '/([^/]+)/page/?([0-9]{1,})/?$'] = 'index.php?page_id=' . $base_page_id . '&question_name=' . $wp_rewrite->preg_index(1) . '&paged=' . $wp_rewrite->preg_index(2);
$new_rules[$slug . $question_slug . '/([^/]+)/?$'] = 'index.php?page_id=' . $base_page_id . '&question_name=' . $wp_rewrite->preg_index(1);
}
$new_rules[$slug . $question_slug . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $base_page_id . '&question_id=' . $wp_rewrite->preg_index(1) . '&question_name=' . $wp_rewrite->preg_index(2);
$new_rules[$user_page . '([^/]+)/([^/]+)/page/?([0-9]{1,})/?$'] = 'index.php?page_id=' . $base_page_id . '&ap_page=' . ap_get_user_page_slug() . '&ap_user=' . $wp_rewrite->preg_index(1) . '&user_page=' . $wp_rewrite->preg_index(2) . '&paged=' . $wp_rewrite->preg_index(3);
$new_rules[$user_page . '([^/]+)/([^/]+)/?'] = 'index.php?page_id=' . $base_page_id . '&ap_page=' . ap_get_user_page_slug() . '&ap_user=' . $wp_rewrite->preg_index(1) . '&user_page=' . $wp_rewrite->preg_index(2);
$new_rules[$user_page . '([^/]+)/?$'] = 'index.php?page_id=' . $base_page_id . '&ap_page=' . ap_get_user_page_slug() . '&ap_user=' . $wp_rewrite->preg_index(1);
$new_rules[$user_page . '?$'] = 'index.php?page_id=' . $base_page_id . '&ap_page=' . ap_get_user_page_slug();
$new_rules[$slug . 'search/([^/]+)/?'] = 'index.php?page_id=' . $base_page_id . '&ap_page=search&ap_s=' . $wp_rewrite->preg_index(1);
$new_rules[$slug . 'ask/([^/]+)/?'] = 'index.php?page_id=' . $base_page_id . '&ap_page=ask&parent=' . $wp_rewrite->preg_index(1);
$new_rules[$slug . '([^/]+)/?'] = 'index.php?page_id=' . $base_page_id . '&ap_page=' . $wp_rewrite->preg_index(1);
$ap_rules = apply_filters('ap_rewrite_rules', $new_rules, $slug, $base_page_id);
return $wp_rewrite->rules = $ap_rules + $wp_rewrite->rules;
}
示例5: rewrites
/**
* Rewrite rules
* @return array
*/
public function rewrites()
{
global $wp_rewrite;
global $ap_rules;
unset($wp_rewrite->extra_permastructs['question']);
unset($wp_rewrite->extra_permastructs['answer']);
$base_page_id = ap_opt('base_page');
$slug = ap_base_page_slug() . '/';
$question_slug = ap_opt('question_page_slug');
$user_page = ap_opt('base_before_user_perma') ? $slug . 'user/' : ap_opt('user_page_slug') . '/';
$new_rules = array($slug . "parent/([^/]+)/?" => "index.php?page_id=" . $base_page_id . "&parent=" . $wp_rewrite->preg_index(1), $slug . "category/([^/]+)/page/?([0-9]{1,})/?\$" => "index.php?page_id=" . $base_page_id . "&ap_page=category&q_cat=" . $wp_rewrite->preg_index(1) . "&paged=" . $wp_rewrite->preg_index(2), $slug . "tag/([^/]+)/page/?([0-9]{1,})/?\$" => "index.php?page_id=" . $base_page_id . "&ap_page=tag&q_tag=" . $wp_rewrite->preg_index(1) . "&paged=" . $wp_rewrite->preg_index(2), $slug . "category/([^/]+)/?" => "index.php?page_id=" . $base_page_id . "&ap_page=category&q_cat=" . $wp_rewrite->preg_index(1), $slug . "tag/([^/]+)/?" => "index.php?page_id=" . $base_page_id . "&ap_page=tag&q_tag=" . $wp_rewrite->preg_index(1), $slug . "page/?([0-9]{1,})/?\$" => "index.php?page_id=" . $base_page_id . "&paged=" . $wp_rewrite->preg_index(1), $slug . "([^/]+)/page/?([0-9]{1,})/?\$" => "index.php?page_id=" . $base_page_id . "&ap_page=" . $wp_rewrite->preg_index(1) . "&paged=" . $wp_rewrite->preg_index(2));
if (!ap_opt('question_permalink_follow')) {
$new_rules[$question_slug . "/([^/]+)/page/?([0-9]{1,})/?\$"] = "index.php?page_id=" . $base_page_id . "&question_name=" . $wp_rewrite->preg_index(1) . "&paged=" . $wp_rewrite->preg_index(2);
$new_rules[$question_slug . "/([^/]+)/?\$"] = "index.php?page_id=" . $base_page_id . "&question_name=" . $wp_rewrite->preg_index(1);
} else {
$new_rules[$slug . $question_slug . "/([^/]+)/page/?([0-9]{1,})/?\$"] = "index.php?page_id=" . $base_page_id . "&question_name=" . $wp_rewrite->preg_index(1) . "&paged=" . $wp_rewrite->preg_index(2);
$new_rules[$slug . $question_slug . "/([^/]+)/?\$"] = "index.php?page_id=" . $base_page_id . "&question_name=" . $wp_rewrite->preg_index(1);
}
$new_rules[$slug . $question_slug . "/([^/]+)/([^/]+)/?\$"] = "index.php?page_id=" . $base_page_id . "&question_id=" . $wp_rewrite->preg_index(1) . "&question_name=" . $wp_rewrite->preg_index(2);
$new_rules[$user_page . "([^/]+)/([^/]+)/page/?([0-9]{1,})/?\$"] = "index.php?page_id=" . $base_page_id . "&ap_page=user&ap_user=" . $wp_rewrite->preg_index(1) . "&user_page=" . $wp_rewrite->preg_index(2) . "&paged=" . $wp_rewrite->preg_index(3);
$new_rules[$user_page . "([^/]+)/([^/]+)/?"] = "index.php?page_id=" . $base_page_id . "&ap_page=user&ap_user=" . $wp_rewrite->preg_index(1) . "&user_page=" . $wp_rewrite->preg_index(2);
$new_rules[$user_page . "([^/]+)/?\$"] = "index.php?page_id=" . $base_page_id . "&ap_page=user&ap_user=" . $wp_rewrite->preg_index(1);
$new_rules[$user_page . "?\$"] = "index.php?page_id=" . $base_page_id . "&ap_page=user";
$new_rules[$slug . "search/([^/]+)/?"] = "index.php?page_id=" . $base_page_id . "&ap_page=search&ap_s=" . $wp_rewrite->preg_index(1);
$new_rules[$slug . "ask/([^/]+)/?"] = "index.php?page_id=" . $base_page_id . "&ap_page=ask&parent=" . $wp_rewrite->preg_index(1);
$new_rules[$slug . "([^/]+)/?"] = "index.php?page_id=" . $base_page_id . "&ap_page=" . $wp_rewrite->preg_index(1);
$ap_rules = apply_filters('ap_rewrite_rules', $new_rules);
return $wp_rewrite->rules = $ap_rules + $wp_rewrite->rules;
}
示例6: ask_form_name_field
public function ask_form_name_field($args)
{
if (!is_user_logged_in() && ap_opt('allow_anonymous')) {
$args['fields'][] = array('name' => 'name', 'label' => __('Name', 'ap'), 'type' => 'text', 'placeholder' => __('Enter your name to display', 'ap'), 'value' => sanitize_text_field(@$_POST['name']), 'order' => 12);
}
return $args;
}
示例7: activate
/**
* Fired when the plugin is activated.
*
* @since 1.0.0
*
* @param boolean $network_wide True if WPMU superadmin uses
* "Network Activate" action, false if
* WPMU is disabled or plugin is
* activated on an individual blog.
*/
public static function activate($network_wide)
{
global $wpdb;
anspress_activate::add_roles();
// create base page
if (!get_option('ap_base_page_created') || !get_post(get_option('ap_base_page_created'))) {
global $user_ID;
$post = array();
$post['post_type'] = 'page';
$post['post_content'] = '[anspress]';
$post['post_author'] = null;
$post['post_status'] = 'publish';
$post['post_title'] = '[anspress]';
$postid = wp_insert_post($post);
if ($postid) {
update_option('ap_base_page_created', $postid);
$post = get_post($postid);
ap_opt('base_page_slug', $post->post_name);
ap_opt('base_page', $postid);
}
}
if (get_option('ap_version') != AP_VERSION) {
update_option('ap_installed', false);
update_option('ap_version', AP_VERSION);
}
// create table
if (get_option('ap_db_version') != AP_DB_VERSION) {
if (!empty($wpdb->charset)) {
$charset_collate = "DEFAULT CHARACTER SET " . $wpdb->charset;
}
$meta_table = "CREATE TABLE IF NOT EXISTS `" . $wpdb->base_prefix . "ap_meta` (\n\t\t\t\t\t `apmeta_id` bigint(20) NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t `apmeta_userid` bigint(20) DEFAULT NULL,\n\t\t\t\t\t `apmeta_type` varchar(256) DEFAULT NULL,\n\t\t\t\t\t `apmeta_actionid` bigint(20) DEFAULT NULL,\n\t\t\t\t\t `apmeta_value` text,\n\t\t\t\t\t `apmeta_param` LONGTEXT DEFAULT NULL,\n\t\t\t\t\t `apmeta_date` timestamp NULL DEFAULT NULL,\n\t\t\t\t\t PRIMARY KEY (`apmeta_id`)\n\t\t\t\t\t)" . $charset_collate . ";";
$message_table = "CREATE TABLE IF NOT EXISTS " . $wpdb->prefix . "ap_messages (\n\t\t\t\t\t`message_id` bigint(20) NOT NULL auto_increment,\n\t\t\t\t\t`message_content` text NOT NULL,\n\t\t\t\t\t`message_sender` bigint(20) NOT NULL,\n\t\t\t\t\t`message_conversation` bigint(20) NOT NULL,\n\t\t\t\t\t`message_date` datetime NOT NULL,\n\t\t\t\t\t`message_read` tinyint(1) NOT NULL,\n\t\t\t\t\tPRIMARY KEY (`message_id`)\n\t\t\t\t )" . $charset_collate . ";";
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
dbDelta($meta_table);
dbDelta($message_table);
update_option('ap_db_version', AP_DB_VERSION);
}
if (!get_option('anspress_opt')) {
update_option('anspress_opt', ap_default_options());
} else {
update_option('anspress_opt', get_option('anspress_opt') + ap_default_options());
}
if (function_exists('is_multisite') && is_multisite()) {
if ($network_wide) {
// Get all blog ids
$blog_ids = self::get_blog_ids();
foreach ($blog_ids as $blog_id) {
switch_to_blog($blog_id);
self::single_activate();
}
restore_current_blog();
} else {
self::single_activate();
}
} else {
self::single_activate();
}
add_option('ap_flush', true);
flush_rewrite_rules(false);
}
示例8: __construct
/**
* Initialize class
* @param array $args
* @access public
* @since 2.0
*/
public function __construct($args = array())
{
$paged = get_query_var('paged') ? get_query_var('paged') : 1;
if (isset($args['post_parent'])) {
$post_parent = $args['post_parent'];
} else {
$post_parent = get_query_var('parent') ? get_query_var('parent') : false;
}
$defaults = array('showposts' => ap_opt('question_per_page'), 'paged' => $paged);
$args['post_status'][] = 'publish';
$args['post_status'][] = 'closed';
if ($post_parent) {
$this->args['post_parent'] = $post_parent;
}
$this->args = wp_parse_args($args, $defaults);
if (get_query_var('ap_s') != '') {
$this->args['s'] = sanitize_text_field(get_query_var('ap_s'));
}
if (isset($this->args['sortby'])) {
$this->orderby_questions();
}
$this->args['post_type'] = 'question';
$args = $this->args;
/**
* Initialize parent class
*/
parent::__construct($args);
}
示例9: __construct
/**
* Initialize class
* @param array $args Query arguments.
* @access public
* @since 2.0
*/
public function __construct($args = array())
{
global $answers;
$paged = get_query_var('paged') ? get_query_var('paged') : 1;
$defaults = array('question_id' => get_question_id(), 'ap_answers_query' => true, 'showposts' => ap_opt('answers_per_page'), 'paged' => $paged, 'only_best_answer' => false, 'include_best_answer' => false);
$args['post_status'][] = 'publish';
$args['post_status'][] = 'closed';
$this->args = wp_parse_args($args, $defaults);
if (isset($this->args['question_id'])) {
$question_id = $this->args['question_id'];
}
if (!empty($question_id)) {
$this->args['post_parent'] = $question_id;
}
if (isset($this->args['sortby'])) {
$this->orderby_answers();
}
// Check if requesting only for best Answer
if (isset($this->args['only_best_answer']) && $this->args['only_best_answer']) {
$this->args['meta_query'] = array(array('key' => ANSPRESS_BEST_META, 'type' => 'BOOLEAN', 'compare' => '=', 'value' => '1'));
}
$this->args['post_type'] = 'answer';
$args = $this->args;
/**
* Initialize parent class
*/
parent::__construct($args);
}
示例10: ap_comment
function ap_comment($comment)
{
$GLOBALS['comment'] = $comment;
?>
<li <?php
comment_class();
?>
id="li-comment-<?php
comment_ID();
?>
">
<article id="comment-<?php
comment_ID();
?>
" class="comment">
<div class="ap-avatar">
<a href="<?php
echo ap_user_link($comment->user_id);
?>
">
<?php
echo get_avatar($comment, ap_opt('avatar_size_qcomment'));
?>
</a>
</div>
<div class="comment-content">
<?php
if ('0' == $comment->comment_approved) {
?>
<p class="comment-awaiting-moderation"><?php
_e('Your comment is awaiting moderation.', 'ap');
?>
</p>
<?php
}
?>
<p class="ap-comment-texts">
<?php
echo get_comment_text();
?>
<?php
printf(' - <time datetime="%1$s">%2$s %3$s</time>', get_comment_time('c'), ap_human_time(get_comment_time('U')), __('ago', 'ap'));
?>
</p>
<div class="comment-meta">
<?php
if (ap_user_can_edit_comment(get_comment_ID())) {
echo '<a class="comment-edit-btn" href="#" data-button="ap-edit-comment" data-args="' . get_comment_ID() . '-' . wp_create_nonce('comment-' . get_comment_ID()) . '"><i class="aicon-pencil"></i> ' . __('Edit', 'ap') . '</a>';
}
if (ap_user_can_delete_comment(get_comment_ID())) {
echo '<a class="comment-delete-btn" href="#" data-button="ap-delete-comment" data-confirm="' . __('Are you sure? It cannot be undone!', 'ap') . '" data-args="' . get_comment_ID() . '-' . wp_create_nonce('delete-comment-' . get_comment_ID()) . '"><i class="aicon-close"></i> ' . __('Delete', 'ap') . '</a>';
}
?>
</div>
</div>
</article>
<?php
}
示例11: __construct
public function __construct($args = '')
{
$this->per_page = ap_opt('users_per_page');
// grab the current page number and set to 1 if no page number is set
$this->paged = get_query_var('paged') ? get_query_var('paged') : 1;
$this->offset = $this->per_page * ($this->paged - 1);
$args = wp_parse_args($args, array('number' => $this->per_page, 'offset' => $this->offset, 'sortby' => 'reputtaion'));
if (isset($args['ID'])) {
$this->users = array(get_user_by('id', $args['ID']));
$this->total_user_count = 1;
$this->total_pages = 1;
$this->user_count = 1;
} else {
if (isset($args['sortby'])) {
switch ($args['sortby']) {
case 'newest':
$args['orderby'] = 'registered';
$args['order'] = 'DESC';
break;
case 'active':
$args['ap_query'] = 'user_sort_by_active';
$args['orderby'] = 'meta_value date';
$args['order'] = 'ASC';
$args['meta_query'] = array(array('key' => '__last_active'));
break;
case 'best_answer':
$args['ap_query'] = 'user_sort_by_best_answer';
$args['orderby'] = 'meta_value date';
$args['order'] = 'ASC';
$args['meta_query'] = array(array('key' => '__best_answers'));
break;
case 'answer':
$args['ap_query'] = 'user_sort_by_answer';
$args['orderby'] = 'meta_value date';
$args['order'] = 'ASC';
$args['meta_query'] = array(array('key' => '__total_answers'));
break;
case 'followers':
$args['ap_query'] = 'user_sort_by_followers';
break;
case 'following':
$args['ap_query'] = 'user_sort_by_following';
break;
default:
$args['ap_query'] = 'user_sort_by_reputation';
$args['orderby'] = 'meta_value';
$args['order'] = 'DESC';
$args['meta_query'] = array('relation' => 'OR', array('key' => 'ap_reputation'), array('key' => 'ap_reputation', 'compare' => 'NOT EXISTS'));
break;
}
}
$ap_user_query = new WP_User_Query($args);
$this->users = $ap_user_query->results;
// count the number of users found in the query
$this->total_user_count = $ap_user_query->get_total();
$this->total_pages = ceil($this->total_user_count / $this->per_page);
$this->user_count = count($this->users);
}
}
示例12: anspress_activate
/**
* Create base pages, add roles, add caps and create tables
* @param $network_wide
*/
function anspress_activate($network_wide)
{
// add roles
$ap_roles = new AP_Roles();
$ap_roles->add_roles();
$ap_roles->add_capabilities();
ap_create_base_page();
if (ap_opt('ap_version') != AP_VERSION) {
ap_opt('ap_installed', 'false');
ap_opt('ap_version', AP_VERSION);
}
global $wpdb;
/**
* Run DB quries only if AP_DB_VERSION does not match
*/
if (ap_opt('ap_db_version') != AP_DB_VERSION) {
$charset_collate = !empty($wpdb->charset) ? 'DEFAULT CHARACTER SET ' . $wpdb->charset : '';
$meta_table = 'CREATE TABLE IF NOT EXISTS `' . $wpdb->prefix . 'ap_meta` (
`apmeta_id` bigint(20) NOT NULL AUTO_INCREMENT,
`apmeta_userid` bigint(20) DEFAULT NULL,
`apmeta_type` varchar(256) DEFAULT NULL,
`apmeta_actionid` bigint(20) DEFAULT NULL,
`apmeta_value` text,
`apmeta_param` LONGTEXT DEFAULT NULL,
`apmeta_date` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`apmeta_id`)
)' . $charset_collate . ';';
$activity_table = 'CREATE TABLE IF NOT EXISTS `' . $wpdb->prefix . 'ap_activity` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`user_id` bigint(20) DEFAULT NULL,
`secondary_user` bigint(20) DEFAULT NULL,
`type` varchar(256) DEFAULT NULL,
`parent_type` varchar(256) DEFAULT NULL,
`status` varchar(256) DEFAULT NULL,
`content` LONGTEXT DEFAULT NULL,
`permalink` text DEFAULT NULL,
`question_id` bigint(20) DEFAULT NULL,
`answer_id` bigint(20) DEFAULT NULL,
`item_id` bigint(20) DEFAULT NULL,
`created` timestamp NULL DEFAULT NULL,
`updated` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`)
)' . $charset_collate . ';';
$activity_meta = "CREATE TABLE IF NOT EXISTS `" . $wpdb->base_prefix . "ap_activitymeta` (\n\t\t\t `meta_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t `ap_activity_id` bigint(20) unsigned NOT NULL DEFAULT '0',\n\t\t\t `meta_key` varchar(255) DEFAULT NULL,\n\t\t\t `meta_value` longtext,\n\t\t\t PRIMARY KEY (`meta_id`)\n\t\t\t)" . $charset_collate . ";";
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
dbDelta($meta_table);
dbDelta($activity_table);
dbDelta($activity_meta);
ap_opt('ap_db_version', AP_DB_VERSION);
}
if (!get_option('anspress_opt')) {
update_option('anspress_opt', ap_default_options());
} else {
update_option('anspress_opt', get_option('anspress_opt') + ap_default_options());
}
ap_opt('ap_flush', 'true');
flush_rewrite_rules(false);
}
示例13: ap_linkyfy_mentions
/**
* Surround mentions with anchor tag.
* @param string $content Post content.
* @return string
*/
function ap_linkyfy_mentions($content)
{
if (!ap_opt('base_before_user_perma')) {
$base = home_url('/' . ap_get_user_page_slug() . '/');
} else {
$base = ap_get_link_to(ap_get_user_page_slug());
}
// Find mentions and wrap with anchor.
return preg_replace('/(?:[\\s.]|^)@(\\w+)/', '<a class="ap-mention-link" href="' . $base . '$1">@$1</a> ', $content);
}
示例14: custom_category_link
public function custom_category_link($url, $term, $taxonomy)
{
if (ap_opt('enable_categories')) {
/* change category link if permalink not enabled */
if ('question_category' == $term->taxonomy && !get_option('permalink_structure')) {
return add_query_arg(array('question_category' => false, 'page_id' => ap_opt('base_page'), 'qcat_id' => $term->term_id), $url);
} elseif ('question_category' == $term->taxonomy && get_option('permalink_structure')) {
return ap_get_link_to('category/' . $term->slug);
}
}
return $url;
}
示例15: ap_check_for_bad_words
/**
* Check if checking for bad word is enabled.
* @return boolean
* @since 2.4.5
*/
function ap_check_for_bad_words()
{
$bad_word_file = ap_get_theme_location('badwords.txt');
// Return if badwords.txt file does not exists.
if (!file_exists($bad_word_file)) {
return false;
}
if (ap_opt('check_bad_words')) {
return true;
}
return false;
}