asgarosforum = $object; add_action('asgarosforum_editor_custom_content_bottom', array($this, 'editor_poll_form'), 10, 1); add_action('asgarosforum_after_add_topic_submit', array($this, 'editor_poll_process'), 10, 6); add_action('asgarosforum_after_edit_post_submit', array($this, 'editor_poll_process'), 10, 6); add_action('asgarosforum_prepare_topic', array($this, 'save_vote')); add_action('asgarosforum_after_delete_topic', array($this, 'delete_poll'), 10, 1); } public function editor_poll_form($editor_view) { // Cancel if poll-functionality is disabled. if (!$this->asgarosforum->options['enable_polls']) { return; } // Cancel if user is not logged-in. if (!is_user_logged_in()) { return; } // Cancel if user has no permissions to create a poll. if ($this->asgarosforum->options['polls_permission'] == 'moderator' && !$this->asgarosforum->permissions->isModerator('current')) { return; } // Set IDs. $post_id = $this->asgarosforum->current_post; $topic_id = $this->asgarosforum->current_topic; if ($editor_view === 'addtopic') { $this->poll_form_add(); } if ($editor_view === 'editpost') { // Cancel if this is not the first post. if (!$this->asgarosforum->is_first_post($post_id)) { return; } // Try to get a poll. $poll = $this->get_poll($topic_id); if ($poll === false) { $this->poll_form_add(); } else { $this->poll_form_edit($poll); } } } public function poll_form_add() { echo '