function bb_get_topic_sticky_link($args = '') { $defaults = array('id' => 0, 'before' => '[', 'after' => ']'); extract(wp_parse_args($args, $defaults), EXTR_SKIP); $id = (int) $id; $topic = get_topic(get_topic_id($id)); if (!$topic || !bb_current_user_can('stick_topic', $topic->topic_id)) { return; } $uri_stick = bb_get_uri('bb-admin/sticky.php', array('id' => $topic->topic_id), BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN); $uri_stick = esc_url(bb_nonce_url($uri_stick, 'stick-topic_' . $topic->topic_id)); $uri_super = bb_get_uri('bb-admin/sticky.php', array('id' => $topic->topic_id, 'super' => 1), BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN); $uri_super = esc_url(bb_nonce_url($uri_super, 'stick-topic_' . $topic->topic_id)); if (topic_is_sticky($topic->topic_id)) { return "{$before}<a href='" . $uri_stick . "'>" . __('Unstick topic') . "</a>{$after}"; } else { return "{$before}<a href='" . $uri_stick . "'>" . __('Stick topic') . "</a> (<a href='" . $uri_super . "'>" . __('to front') . "</a>){$after}"; } }
<?php require 'admin-action.php'; $topic_id = (int) $_GET['id']; $topic = get_topic($topic_id); $super = isset($_GET['super']) && 1 == (int) $_GET['super'] ? 1 : 0; if (!$topic) { bb_die(__('There is a problem with that topic, pardner.')); } if (!bb_current_user_can('stick_topic', $topic_id)) { wp_redirect(bb_get_uri(null, null, BB_URI_CONTEXT_HEADER)); exit; } bb_check_admin_referer('stick-topic_' . $topic_id); if (topic_is_sticky($topic_id)) { bb_unstick_topic($topic_id); } else { bb_stick_topic($topic_id, $super); } if (!($redirect = wp_get_referer())) { $redirect = get_topic_link($topic_id); } bb_safe_redirect($redirect); exit;