echo format_to_edit(mb_code_trick_reverse(mb_get_topic_content(mb_get_topic_id(), 'raw'))); ?> </textarea> </p> <p> <input type="submit" value="<?php esc_attr_e('Submit', 'message-board'); ?> " /> </p> <p> <label> <input type="checkbox" name="mb_topic_subscribe" value="<?php echo mb_is_user_subscribed_topic(mb_get_topic_author_id(), mb_get_topic_id()) ? 1 : 0; ?> " /> <?php _e('Notify me of follow-up posts via email', 'message-board'); ?> </label> </p> <input type="hidden" name="mb_topic_id" value="<?php echo absint(mb_get_topic_id()); ?> " /> <?php wp_nonce_field('mb_edit_topic_action', 'mb_edit_topic_nonce', false);
/** * Returns the topic un/subscribe link. * * @since 1.0.0 * @access public * @param int $topic_id * @return string */ function mb_get_topic_subscribe_link($topic_id = 0) { if (!mb_is_subscriptions_active()) { return ''; } $topic_id = mb_get_topic_id($topic_id); $link = ''; if (is_user_logged_in()) { $user_id = get_current_user_id(); $url = mb_get_topic_subscribe_url($topic_id); $text = mb_is_user_subscribed_topic($user_id, $topic_id) ? __('Unsubscribe', 'message-board') : __('Subscribe', 'message-board'); if (!empty($url)) { $link = sprintf('<a class="mb-subscribe-link" href="%s">%s</a>', $url, $text); } } return apply_filters('mb_get_topic_subscribe_link', $link, $topic_id); }
function mb_handler_topic_subscribe() { /* Is this a topic subscription request? */ if (!mb_is_board_action('toggle_subscribe') || !isset($_GET['topic_id'])) { return; } /* Make sure the user is logged in and subscriptions are active. */ if (!is_user_logged_in() || !mb_is_subscriptions_active()) { return; } /* Get the topic ID. */ $topic_id = mb_get_topic_id($_GET['topic_id']); /* Verify nonce. */ if (!isset($_GET['mb_nonce']) || !wp_verify_nonce($_GET['mb_nonce'], "subscribe_topic_{$topic_id}")) { return; } /* Get the current user ID. */ $user_id = get_current_user_id(); /* If the current user can't read the topic, make sure they are not subscribed and bail. */ if (!current_user_can('read_topic', $topic_id)) { mb_remove_user_topic_subscription($user_id, $topic_id); return; } /* If the user is already subscribed, unsubscribe them. */ if (mb_is_user_subscribed_topic($user_id, $topic_id)) { mb_remove_user_topic_subscription($user_id, $topic_id); /* Else, subscribe them. */ } else { mb_add_user_topic_subscription($user_id, $topic_id); } /* Redirect the user. */ wp_safe_redirect(esc_url(remove_query_arg(array('mb_action', 'topic_id', 'mb_nonce')))); }
?> </label> <?php mb_reply_editor(); ?> </div><!-- .mb-form-content --> <p> <input type="submit" value="<?php esc_attr_e('Post Reply', 'message-board'); ?> " /> </p> <?php if (mb_is_subscriptions_active() && !mb_is_user_subscribed_topic(mb_get_topic_id())) { ?> <p> <label> <input type="checkbox" name="mb_reply_subscribe" value="1" /> <?php _e('Notify me of follow-up posts via email', 'message-board'); ?> </label> </p> <?php } // End check if subscriptions enabled. ?>