Changeset 813
- Timestamp:
- 08/26/2014 08:04:21 AM (10 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/functions.php
r806 r813 30 30 require __DIR__ . '/inc/breadcrumb-trail.php'; 31 31 } 32 33 /** 34 * User-submitted content (comments, examples, etc). 35 */ 36 require __DIR__ . '/inc/user-content.php'; 32 37 33 38 /** … … 58 63 add_filter( 'the_excerpt', __NAMESPACE__ . '\\lowercase_P_dangit_just_once' ); 59 64 add_filter( 'the_content', __NAMESPACE__ . '\\make_doclink_clickable', 10, 5 ); 60 add_filter( 'comments_open', __NAMESPACE__ . '\\can_user_post_example', 10, 2 );61 65 62 66 // Add the handbook's 'Watch' action link. … … 65 69 } 66 70 67 // Temporarily disable comments68 //add_filter( 'comments_open', '__return_false' );69 70 71 add_filter( 'breadcrumb_trail_items', __NAMESPACE__ . '\\breadcrumb_trail_items', 10, 2 ); 71 72 72 treat_comments_as_examples();73 73 } 74 74 … … 356 356 wp_enqueue_script( 'wporg-developer-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20120206', true ); 357 357 wp_enqueue_script( 'wporg-developer-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20130115', true ); 358 359 if ( is_singular() && ( '0' != get_comments_number() || post_type_has_source_code() ) ) {360 wp_enqueue_script( 'wporg-developer-function-reference', get_template_directory_uri() . '/js/function-reference.js', array( 'jquery', 'syntaxhighlighter-core', 'syntaxhighlighter-brush-php' ), '20140515', true );361 wp_enqueue_style( 'syntaxhighlighter-core' );362 wp_enqueue_style( 'syntaxhighlighter-theme-default' );363 364 wp_enqueue_script( 'wporg-developer-code-examples', get_template_directory_uri() . '/js/code-example.js', array(), '20140423', true );365 if ( get_option( 'thread_comments' ) ) {366 wp_enqueue_script( 'comment-reply' );367 }368 }369 }370 371 /**372 * Handles adding/removing hooks to enable comments as examples.373 *374 * Mostly gives users greater permissions in terms of comment content.375 *376 * In order to submit code examples, users must be able to post with less restrictions.377 */378 function treat_comments_as_examples() {379 // Restricts commenting to logged in users.380 add_filter( 'comments_open', __NAMESPACE__ . '\\prevent_invalid_comment_submissions', 10, 2 );381 382 if ( ! current_user_can( 'unfiltered_html' ) ) {383 remove_filter( 'pre_comment_content', 'wp_filter_kses' );384 add_filter( 'pre_comment_content', 'wp_filter_post_kses' );385 }386 387 // Force comment registration to be true388 add_filter( 'pre_option_comment_registration', '__return_true' );389 390 // Force comment moderation to be true391 add_filter( 'pre_option_comment_moderation', '__return_true' );392 393 // Remove reply to link394 add_filter( 'comment_reply_link', '__return_empty_string' );395 396 /* foreach ( array( 'comment_save_pre', 'pre_comment_content' ) as $filter ) {397 add_filter( $filter, 'balanceTags', 50 );398 }*/399 400 remove_filter( 'comment_text', 'capital_P_dangit', 31 );401 402 remove_filter( 'comment_text', 'wptexturize' );403 remove_filter( 'comment_text', 'convert_chars' );404 remove_filter( 'comment_text', 'make_clickable', 9 );405 remove_filter( 'comment_text', 'force_balance_tags', 25 );406 remove_filter( 'comment_text', 'convert_smilies', 20 );407 remove_filter( 'comment_text', 'wpautop', 30 );408 409 remove_filter( 'pre_comment_content', 'wp_rel_nofollow', 15 );410 411 // Be more permissive with content of examples.412 // Note: the content gets fully escaped via 'get_comment_text'.413 if ( post_type_supports_examples() ) {414 if ( current_user_can( 'unfiltered_html' ) ) {415 remove_filter( 'pre_comment_content', 'wp_filter_post_kses' );416 } else {417 remove_filter( 'pre_comment_content', 'wp_filter_kses' );418 }419 }420 421 add_filter( 'get_comment_text', __NAMESPACE__ . '\\escape_example_content' );422 }423 424 /**425 * Escapes the entirety of the content for examples.426 *427 * @param string $text The comment/example content.428 * @return string429 */430 function escape_example_content( $text ) {431 // Only proceed if the post type is one that has examples.432 if ( ! post_type_supports_examples() ) {433 return $text;434 }435 436 return htmlentities( $text );437 }438 439 /**440 * Disables commenting to invalid or non-users.441 *442 * @param bool $status Default commenting status for post.443 * @return bool False if commenter isn't a user, otherwise the passed in status.444 */445 function prevent_invalid_comment_submissions( $status, $post_id ) {446 if ( $_POST && ( ! is_user_logged_in() || ! is_user_member_of_blog() ) ) {447 return false;448 }449 450 return $status;451 358 } 452 359 -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/template-tags.php
r785 r813 93 93 <li id="comment-<?php comment_ID(); ?>" <?php comment_class( empty( $args['has_children'] ) ? '' : 'parent' ); ?>> 94 94 <article id="div-comment-<?php comment_ID(); ?>" class="comment-body"> 95 <div class="comment-content code-example-container">96 < pre class="brush: php; toolbar: false;"><?php comment_text(); /* Fully escaped via filter */ ?></pre>95 <div class="comment-content"> 96 <?php comment_text(); ?> 97 97 </div> 98 98 <!-- .comment-content --> -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/scss/main.scss
r803 r813 973 973 974 974 .comment-list li { 975 padding: 24px 24px 0 24px; 976 padding: 1.5rem 1.5rem 0 1.5rem; 975 padding: 2rem 1.5rem 1rem; 977 976 border: 0 solid #eee; 978 977 border-bottom-width: 1px; 979 978 background: #fff; 980 } 981 982 .comment-list li:first-child {983 padding-top: 0;979 980 &:first-child { 981 padding-top: 1rem; 982 } 984 983 } 985 984 -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/stylesheets/main.css
r803 r813 1162 1162 } 1163 1163 .devhub-wrap .comment-list li { 1164 padding: 24px 24px 0 24px; 1165 padding: 1.5rem 1.5rem 0 1.5rem; 1164 padding: 2rem 1.5rem 1rem; 1166 1165 border: 0 solid #eee; 1167 1166 border-bottom-width: 1px; 1168 1167 background: #fff; 1169 1168 } 1170 .devhub-wrap .comment-list li {1171 padding-top: 0;1169 .devhub-wrap .comment-list li:first-child { 1170 padding-top: 1rem; 1172 1171 } 1173 1172 .devhub-wrap .comment-list .avatar {
Note: See TracChangeset
for help on using the changeset viewer.