| 1 |
<?php |
| 2 |
/** |
| 3 |
* New/Edit Topic |
| 4 |
* |
| 5 |
* @package bbPress |
| 6 |
* @subpackage Theme |
| 7 |
*/ |
| 8 |
|
| 9 |
// Exit if accessed directly |
| 10 |
defined( 'ABSPATH' ) || exit; |
| 11 |
|
| 12 |
wp_enqueue_style('nice-select'); |
| 13 |
wp_enqueue_script('nice-select'); |
| 14 |
|
| 15 |
if ( ! bbp_is_single_forum() ) : ?> |
| 16 |
|
| 17 |
<div id="bbpress-forums" class="bbpress-wrapper"> |
| 18 |
|
| 19 |
<?php endif; ?> |
| 20 |
|
| 21 |
<?php if ( bbp_is_topic_edit() ) : ?> |
| 22 |
|
| 23 |
<?php bbp_get_template_part( 'alert', 'topic-lock' ); ?> |
| 24 |
|
| 25 |
<?php endif; ?> |
| 26 |
|
| 27 |
<?php if ( bbp_current_user_can_access_create_topic_form() ) : ?> |
| 28 |
|
| 29 |
<div id="new-topic-<?php bbp_topic_id(); ?>" class="bbp-topic-form"> |
| 30 |
|
| 31 |
<form id="new-post" name="new-post" method="post"> |
| 32 |
|
| 33 |
<?php do_action( 'bbp_theme_before_topic_form' ); ?> |
| 34 |
|
| 35 |
<fieldset class="bbp-form"> |
| 36 |
<legend> |
| 37 |
|
| 38 |
<?php |
| 39 |
if ( bbp_is_topic_edit() ) : |
| 40 |
printf( esc_html__( 'Now Editing “%s”', 'forumax' ), bbp_get_topic_title() ); |
| 41 |
else : |
| 42 |
( bbp_is_single_forum() && bbp_get_forum_title() ) |
| 43 |
? printf( esc_html__( 'Create New Topic in “%s”', 'forumax' ), bbp_get_forum_title() ) |
| 44 |
: esc_html_e( 'Create New Topic', 'forumax' ); |
| 45 |
endif; |
| 46 |
?> |
| 47 |
|
| 48 |
</legend> |
| 49 |
|
| 50 |
<?php do_action( 'bbp_theme_before_topic_form_notices' ); ?> |
| 51 |
|
| 52 |
<?php if ( ! bbp_is_topic_edit() && bbp_is_forum_closed() ) : ?> |
| 53 |
|
| 54 |
<div class="bbp-template-notice"> |
| 55 |
<ul> |
| 56 |
<li><?php esc_html_e( 'This forum is marked as closed to new topics, however your posting capabilities still allow you to create a topic.', |
| 57 |
'forumax' ); ?></li> |
| 58 |
</ul> |
| 59 |
</div> |
| 60 |
|
| 61 |
<?php endif; ?> |
| 62 |
|
| 63 |
<?php if ( current_user_can( 'unfiltered_html' ) ) : ?> |
| 64 |
|
| 65 |
<div class="bbp-template-notice"> |
| 66 |
<ul> |
| 67 |
<li><?php esc_html_e( 'Your account has the ability to post unrestricted HTML content.', 'forumax' ); ?></li> |
| 68 |
</ul> |
| 69 |
</div> |
| 70 |
|
| 71 |
<?php endif; ?> |
| 72 |
|
| 73 |
<?php do_action( 'bbp_template_notices' ); ?> |
| 74 |
|
| 75 |
<div class="row aq-form-wrapper"> |
| 76 |
|
| 77 |
<?php bbp_get_template_part( 'form', 'anonymous' ); ?> |
| 78 |
|
| 79 |
<?php do_action( 'bbp_theme_before_topic_form_title' ); ?> |
| 80 |
|
| 81 |
<div class="form-item column-md-12"> |
| 82 |
<label for="bbp_topic_title"><?php printf( esc_html__( 'Topic Title (Maximum Length: %d):', 'forumax' ), |
| 83 |
bbp_get_title_max_length() ); ?></label><br/> |
| 84 |
<input type="text" id="bbp_topic_title" value="<?php bbp_form_topic_title(); ?>" size="40" name="bbp_topic_title" |
| 85 |
maxlength="<?php bbp_title_max_length(); ?>"/> |
| 86 |
</div> |
| 87 |
|
| 88 |
<?php do_action( 'bbp_theme_after_topic_form_title' ); ?> |
| 89 |
|
| 90 |
<?php do_action( 'bbp_theme_before_topic_form_content' ); ?> |
| 91 |
|
| 92 |
<?php bbp_the_content( array( 'context' => 'topic' ) ); ?> |
| 93 |
|
| 94 |
<?php do_action( 'bbp_theme_after_topic_form_content' ); ?> |
| 95 |
|
| 96 |
<?php if ( ! ( bbp_use_wp_editor() || current_user_can( 'unfiltered_html' ) ) ) : ?> |
| 97 |
|
| 98 |
<p class="form-allowed-tags"> |
| 99 |
<label><?php printf( esc_html__( 'You may use these %s tags and attributes:', 'forumax' ), |
| 100 |
'<abbr title="HyperText Markup Language">HTML</abbr>' ); ?></label><br/> |
| 101 |
<code><?php bbp_allowed_tags(); ?></code> |
| 102 |
</p> |
| 103 |
|
| 104 |
<?php endif; ?> |
| 105 |
|
| 106 |
<?php if ( bbp_allow_topic_tags() && current_user_can( 'assign_topic_tags', bbp_get_topic_id() ) ) : ?> |
| 107 |
|
| 108 |
<?php do_action( 'bbp_theme_before_topic_form_tags' ); ?> |
| 109 |
|
| 110 |
<div class="form-item column-md-12"> |
| 111 |
<label for="bbp_topic_tags"><?php esc_html_e( 'Topic Tags:', 'forumax' ); ?></label><br/> |
| 112 |
<input type="text" value="<?php bbp_form_topic_tags(); ?>" size="40" name="bbp_topic_tags" |
| 113 |
id="bbp_topic_tags" <?php disabled( bbp_is_topic_spam() ); ?> /> |
| 114 |
</div> |
| 115 |
|
| 116 |
<?php do_action( 'bbp_theme_after_topic_form_tags' ); ?> |
| 117 |
|
| 118 |
<?php endif; ?> |
| 119 |
|
| 120 |
<?php if ( ! bbp_is_single_forum() ) : ?> |
| 121 |
|
| 122 |
<?php do_action( 'bbp_theme_before_topic_form_forum' ); ?> |
| 123 |
|
| 124 |
<div class="form-item column-md-4"> |
| 125 |
<label for="bbp_forum_id"><?php esc_html_e( 'Forum:', 'forumax' ); ?></label><br/> |
| 126 |
<?php |
| 127 |
bbp_dropdown( array( |
| 128 |
'show_none' => esc_html__( '— No forum —', 'forumax' ), |
| 129 |
'selected' => bbp_get_form_topic_forum() |
| 130 |
) ); |
| 131 |
?> |
| 132 |
</div> |
| 133 |
|
| 134 |
<?php do_action( 'bbp_theme_after_topic_form_forum' ); ?> |
| 135 |
|
| 136 |
<?php endif; ?> |
| 137 |
|
| 138 |
<?php if ( current_user_can( 'moderate', bbp_get_topic_id() ) ) : ?> |
| 139 |
|
| 140 |
<?php do_action( 'bbp_theme_before_topic_form_type' ); ?> |
| 141 |
|
| 142 |
<div class="form-item col-md-<?php echo bbp_is_single_forum() ? '6' : '4'; ?>"> |
| 143 |
|
| 144 |
<label for="bbp_stick_topic"><?php esc_html_e( 'Topic Type:', 'forumax' ); ?></label><br/> |
| 145 |
|
| 146 |
<?php bbp_form_topic_type_dropdown(); ?> |
| 147 |
|
| 148 |
</div> |
| 149 |
|
| 150 |
<?php do_action( 'bbp_theme_after_topic_form_type' ); ?> |
| 151 |
|
| 152 |
<?php do_action( 'bbp_theme_before_topic_form_status' ); ?> |
| 153 |
|
| 154 |
<div class="form-item col-md-<?php echo bbp_is_single_forum() ? '6' : '4'; ?>"> |
| 155 |
|
| 156 |
<label for="bbp_topic_status"><?php esc_html_e( 'Topic Status:', 'forumax' ); ?></label><br/> |
| 157 |
|
| 158 |
<?php bbp_form_topic_status_dropdown(); ?> |
| 159 |
|
| 160 |
</div> |
| 161 |
|
| 162 |
<?php do_action( 'bbp_theme_after_topic_form_status' ); ?> |
| 163 |
|
| 164 |
<?php endif; ?> |
| 165 |
|
| 166 |
<?php if ( bbp_allow_revisions() && bbp_is_topic_edit() ) : ?> |
| 167 |
|
| 168 |
<?php do_action( 'bbp_theme_before_topic_form_revisions' ); ?> |
| 169 |
|
| 170 |
<fieldset class="bbp-form"> |
| 171 |
<legend> |
| 172 |
<input name="bbp_log_topic_edit" id="bbp_log_topic_edit" type="checkbox" value="1" <?php bbp_form_topic_log_edit(); ?> /> |
| 173 |
<label for="bbp_log_topic_edit"><?php esc_html_e( 'Keep a log of this edit:', 'forumax' ); ?></label><br/> |
| 174 |
</legend> |
| 175 |
|
| 176 |
<div> |
| 177 |
<label for="bbp_topic_edit_reason"><?php printf( esc_html__( 'Optional reason for editing:', 'forumax' ), |
| 178 |
bbp_get_current_user_name() ); ?></label><br/> |
| 179 |
<input type="text" value="<?php bbp_form_topic_edit_reason(); ?>" size="40" name="bbp_topic_edit_reason" |
| 180 |
id="bbp_topic_edit_reason"/> |
| 181 |
</div> |
| 182 |
</fieldset> |
| 183 |
|
| 184 |
<?php do_action( 'bbp_theme_after_topic_form_revisions' ); ?> |
| 185 |
|
| 186 |
<?php endif; ?> |
| 187 |
|
| 188 |
<?php do_action( 'bbp_theme_before_topic_form_submit_wrapper' ); ?> |
| 189 |
|
| 190 |
<div class="form-item column-md-12 bbp-submit-wrapper"> |
| 191 |
|
| 192 |
<?php if ( bbp_is_subscriptions_active() && ! bbp_is_anonymous() |
| 193 |
&& ( ! bbp_is_topic_edit() |
| 194 |
|| ( bbp_is_topic_edit() |
| 195 |
&& ! bbp_is_topic_anonymous() ) ) |
| 196 |
) : ?> |
| 197 |
|
| 198 |
<div class="aq-notify-check"> |
| 199 |
<?php do_action( 'bbp_theme_before_topic_form_subscriptions' ); ?> |
| 200 |
|
| 201 |
<input class="checkbox-tik" name="bbp_topic_subscription" id="bbp_topic_subscription" type="checkbox" |
| 202 |
value="bbp_subscribe" <?php bbp_form_topic_subscribed(); ?> /> |
| 203 |
|
| 204 |
<?php if ( bbp_is_topic_edit() && ( bbp_get_topic_author_id() !== bbp_get_current_user_id() ) ) : ?> |
| 205 |
|
| 206 |
<label for="bbp_topic_subscription"><?php esc_html_e( 'Notify the author of follow-up replies via email', |
| 207 |
'forumax' ); ?></label> |
| 208 |
|
| 209 |
<?php else : ?> |
| 210 |
|
| 211 |
<label for="bbp_topic_subscription"><?php esc_html_e( 'Notify me of follow-up replies via email', 'forumax' ); ?></label> |
| 212 |
|
| 213 |
<?php endif; ?> |
| 214 |
|
| 215 |
<?php do_action( 'bbp_theme_after_topic_form_subscriptions' ); ?> |
| 216 |
</div> |
| 217 |
|
| 218 |
<?php endif; ?> |
| 219 |
|
| 220 |
<?php do_action( 'bbp_theme_before_topic_form_submit_button' ); ?> |
| 221 |
|
| 222 |
<button type="submit" id="bbp_topic_submit" name="bbp_topic_submit" class="button submit fill-brand"> |
| 223 |
<?php esc_html_e( 'Submit', 'forumax' ); ?> |
| 224 |
</button> |
| 225 |
|
| 226 |
<?php do_action( 'bbp_theme_after_topic_form_submit_button' ); ?> |
| 227 |
|
| 228 |
</div> |
| 229 |
|
| 230 |
<?php do_action( 'bbp_theme_after_topic_form_submit_wrapper' ); ?> |
| 231 |
|
| 232 |
</div> |
| 233 |
|
| 234 |
<?php bbp_topic_form_fields(); ?> |
| 235 |
|
| 236 |
</fieldset> |
| 237 |
|
| 238 |
<?php do_action( 'bbp_theme_after_topic_form' ); ?> |
| 239 |
|
| 240 |
</form> |
| 241 |
</div> |
| 242 |
|
| 243 |
<?php elseif ( bbp_is_forum_closed() ) : ?> |
| 244 |
|
| 245 |
<div id="forum-closed-<?php bbp_forum_id(); ?>" class="bbp-forum-closed"> |
| 246 |
<div class="bbp-template-notice"> |
| 247 |
<ul> |
| 248 |
<li><?php printf( esc_html__( 'The forum ‘%s’ is closed to new topics and replies.', 'forumax' ), bbp_get_forum_title() ); ?></li> |
| 249 |
</ul> |
| 250 |
</div> |
| 251 |
</div> |
| 252 |
|
| 253 |
<?php else : ?> |
| 254 |
|
| 255 |
<div id="no-topic-<?php bbp_forum_id(); ?>" class="bbp-no-topic"> |
| 256 |
<div class="bbp-template-notice"> |
| 257 |
<ul> |
| 258 |
<li> |
| 259 |
<?php |
| 260 |
is_user_logged_in() |
| 261 |
? esc_html_e( 'You cannot create new topics.', 'forumax' ) |
| 262 |
: esc_html_e( 'You must be logged in to create new topics.', 'forumax' ); |
| 263 |
?> |
| 264 |
</li> |
| 265 |
</ul> |
| 266 |
</div> |
| 267 |
|
| 268 |
<?php if ( ! is_user_logged_in() ) : ?> |
| 269 |
|
| 270 |
<?php |
| 271 |
if ( forumax_get_opt('topic_login_shortcode') ) { |
| 272 |
echo do_shortcode(forumax_get_opt('topic_login_shortcode')); |
| 273 |
} else { |
| 274 |
bbp_get_template_part('form', 'user-login'); |
| 275 |
} |
| 276 |
?> |
| 277 |
|
| 278 |
<?php endif; ?> |
| 279 |
|
| 280 |
</div> |
| 281 |
|
| 282 |
<?php endif; ?> |
| 283 |
|
| 284 |
<?php if ( ! bbp_is_single_forum() ) : ?> |
| 285 |
|
| 286 |
</div> |
| 287 |
|
| 288 |
<?php endif; |
| 289 |
|