__('Asgaros Forum', 'asgaros-forum'), 'description' => __('Awards %_plural% for Asgaros Forum actions.', 'asgaros-forum'), 'callback' => array('MyCRED_AsgarosForum') ); return $installed; } function mycred_load_asgarosforum_hook() { class MyCRED_AsgarosForum extends myCRED_Hook { private $asgarosforum = null; public function __construct($hook_prefs, $type = MYCRED_DEFAULT_TYPE_KEY) { global $asgarosforum; $this->asgarosforum = $asgarosforum; parent::__construct(array( 'id' => 'hook_asgarosforum', 'defaults' => array( 'new_topic' => array( 'creds' => 1, 'log' => __('%plural% for new forum topic', 'asgaros-forum'), 'limit' => '0/x' ), 'delete_topic' => array( 'creds' => -1, /* translators: singular label of point-type for deduction when deleting forum topic */ 'log' => __('%singular% deduction for deleted forum topic', 'asgaros-forum') ), 'new_post' => array( 'creds' => 1, 'log' => __('%plural% for new forum post', 'asgaros-forum'), 'author' => 0, 'limit' => '0/x' ), 'delete_post' => array( 'creds' => -1, /* translators: singular label of point-type for deduction when deleting forum post */ 'log' => __('%singular% deduction for deleted forum post', 'asgaros-forum') ), 'received_like' => array( 'creds' => 1, 'log' => __('%plural% for received forum post like', 'asgaros-forum'), 'limit' => '0/x' ), 'received_dislike' => array( 'creds' => -1, /* translators: singular label of point-type for deduction when receiving forum post dislike */ 'log' => __('%singular% deduction for received forum post dislike', 'asgaros-forum') ), 'show_points' => 0, 'show_badges' => 0, 'show_ranks' => 0 ) ), $hook_prefs, $type); } public function run() { if ($this->prefs['new_topic']['creds'] != 0) { add_action('asgarosforum_after_add_topic_submit', array($this, 'new_topic'), 20, 6); } if ($this->prefs['delete_topic']['creds'] != 0) { add_action('asgarosforum_before_delete_topic', array($this, 'delete_topic'), 20, 1); } if ($this->prefs['new_post']['creds'] != 0) { add_action('asgarosforum_after_add_post_submit', array($this, 'new_post'), 20, 6); } if ($this->prefs['delete_post']['creds'] != 0) { add_action('asgarosforum_before_delete_post', array($this, 'delete_post'), 20, 1); } if ($this->prefs['received_like']['creds'] != 0) { add_action('asgarosforum_after_add_reaction', array($this, 'received_like'), 20, 3); add_action('asgarosforum_after_update_reaction', array($this, 'received_like'), 20, 3); } if ($this->prefs['received_dislike']['creds'] != 0) { add_action('asgarosforum_after_add_reaction', array($this, 'received_dislike'), 20, 3); add_action('asgarosforum_after_update_reaction', array($this, 'received_dislike'), 20, 3); } if (isset($this->prefs['show_points']) && $this->prefs['show_points'] == 1) { add_action('asgarosforum_after_post_author', array($this, 'show_points'), 100, 2); add_action('asgarosforum_profile_row', array($this, 'show_points_profile'), 100, 1); } if (isset($this->prefs['show_badges']) && $this->prefs['show_badges'] == 1) { add_action('asgarosforum_after_post_author', array($this, 'show_badges'), 200, 2); add_action('asgarosforum_profile_row', array($this, 'show_badges_profile'), 200, 1); } if (isset($this->prefs['show_ranks']) && $this->prefs['show_ranks'] == 1) { add_action('asgarosforum_after_post_author', array($this, 'show_ranks'), 300, 2); add_action('asgarosforum_profile_row', array($this, 'show_ranks_profile'), 300, 1); } } public function show_points($user_id, $number_of_posts) { if (!$user_id) { return; } $balance = $this->core->get_users_balance($user_id, $this->mycred_type); $layout = $this->core->plural().': '.$this->core->format_creds($balance); echo ''.$layout.''; } public function show_points_profile($user_data) { $balance = $this->core->get_users_balance($user_data->ID, $this->mycred_type); $this->asgarosforum->profile->renderProfileRow($this->core->plural().':', $this->core->format_creds($balance)); } public function show_badges($user_id, $number_of_posts) { if (!$user_id) { return; } mycred_display_users_badges($user_id); } public function show_badges_profile($user_data) { echo '
'; echo '
'.esc_html__('Badges:', 'asgaros-forum').'
'; echo '
'; mycred_display_users_badges($user_data->ID); echo '
'; echo '
'; } public function show_ranks($user_id, $number_of_posts) { if (!$user_id) { return; } $rank_id = mycred_get_users_rank_id($user_id); echo mycred_get_rank_logo($rank_id); } public function show_ranks_profile($user_data) { $rank_id = mycred_get_users_rank_id($user_data->ID); $this->asgarosforum->profile->renderProfileRow(__('Rank:', 'asgaros-forum'), mycred_get_rank_logo($rank_id)); } public function new_topic($post_id, $topic_id, $subject, $content, $link, $author_id) { if (!$author_id) { return; } if ($this->core->exclude_user($author_id)) { return; } if ($this->over_hook_limit('new_topic', 'new_forum_topic', $author_id)) { return; } if ($this->has_entry('new_forum_topic', $topic_id, $author_id)) { return; } $this->core->add_creds( 'new_forum_topic', $author_id, $this->prefs['new_topic']['creds'], $this->prefs['new_topic']['log'], $topic_id, '', $this->mycred_type ); } public function delete_topic($topic_id) { $author_id = $this->asgarosforum->get_topic_starter($topic_id); if ($this->has_entry('new_forum_topic', $topic_id, $author_id)) { $this->core->add_creds( 'deleted_topic', $author_id, $this->prefs['delete_topic']['creds'], $this->prefs['delete_topic']['log'], $topic_id, '', $this->mycred_type ); } } public function new_post($post_id, $topic_id, $subject, $content, $link, $author_id) { if (!$author_id) { return; } if ($this->core->exclude_user($author_id)) { return; } if ((bool)$this->prefs['new_post']['author'] === false && $this->asgarosforum->get_topic_starter($topic_id) == $author_id) { return; } if ($this->over_hook_limit('new_post', 'new_forum_post', $author_id)) { return; } if ($this->has_entry('new_forum_post', $post_id, $author_id)) { return; } $this->core->add_creds( 'new_forum_post', $author_id, $this->prefs['new_post']['creds'], $this->prefs['new_post']['log'], $post_id, '', $this->mycred_type ); } public function delete_post($post_id) { $author_id = $this->asgarosforum->get_post_author($post_id); if ($this->has_entry('new_forum_post', $post_id, $author_id)) { $this->core->add_creds( 'deleted_post', $author_id, $this->prefs['delete_post']['creds'], $this->prefs['delete_post']['log'], $post_id, '', $this->mycred_type ); } } public function received_like($post_id, $user_id, $reaction) { if ($reaction !== 'up') { return; } $user_id = $this->asgarosforum->get_post_author($post_id); if (!$user_id) { return; } if ($this->core->exclude_user($user_id)) { return; } if ($this->has_entry('received_like', $post_id, $user_id)) { return; } if ($this->over_hook_limit('received_like', 'received_like', $user_id)) { return; } $this->core->add_creds( 'received_like', $user_id, $this->prefs['received_like']['creds'], $this->prefs['received_like']['log'], $post_id, '', $this->mycred_type ); } public function received_dislike($post_id, $user_id, $reaction) { if ($reaction !== 'down') { return; } $user_id = $this->asgarosforum->get_post_author($post_id); if (!$user_id) { return; } if ($this->core->exclude_user($user_id)) { return; } if ($this->has_entry('received_dislike', $post_id, $user_id)) { return; } $this->core->add_creds( 'received_dislike', $user_id, $this->prefs['received_dislike']['creds'], $this->prefs['received_dislike']['log'], $post_id, '', $this->mycred_type ); } public function preferences() { $prefs = $this->prefs; if (!isset($prefs['new_topic']['limit'])) { $prefs['new_topic']['limit'] = '0/x'; } if (!isset($prefs['new_post']['limit'])) { $prefs['new_post']['limit'] = '0/x'; } if (!isset($prefs['received_like']['limit'])) { $prefs['received_like']['limit'] = '0/x'; } ?>

hook_limit_setting($this->field_name(array('new_topic', 'limit')), $this->field_id(array('new_topic', 'limit')), $prefs['new_topic']['limit']); ?>
available_template_tags(array('general')); ?>

available_template_tags(array('general')); ?>

hook_limit_setting($this->field_name(array('new_post', 'limit')), $this->field_id(array('new_post', 'limit')), $prefs['new_post']['limit']); ?>
available_template_tags(array('general')); ?>

available_template_tags(array('general')); ?>

available_template_tags(array('general')); ?>
hook_limit_setting($this->field_name(array('received_like', 'limit')), $this->field_id(array('received_like', 'limit')), $prefs['received_like']['limit']); ?>

available_template_tags(array('general')); ?>