Changeset 10412 for sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-support/functions.php
- Timestamp:
- 10/27/2020 11:05:32 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-support/functions.php
r10411 r10412 13 13 14 14 /** 15 * Add theme support for some features. 16 */ 17 function wporg_support_theme_support() { 18 add_theme_support( 'html5', array( 'comment-form' ) ); 19 } 20 add_action( 'after_setup_theme', 'wporg_support_theme_support' ); 21 22 /** 15 23 * Enqueue scripts and styles. 16 24 * … … 20 28 function wporg_support_scripts() { 21 29 22 wp_enqueue_style( 'forum-wp4-style', get_stylesheet_uri(), [], '2020 0723' );30 wp_enqueue_style( 'forum-wp4-style', get_stylesheet_uri(), [], '20201023' ); 23 31 wp_style_add_data( 'forum-wp4-style', 'rtl', 'replace' ); 24 32 … … 50 58 } 51 59 add_action( 'widgets_init', 'wporg_support_register_widget_areas' ); 60 61 /** 62 * Don't include comments on HelpHub articles in REST responses. 63 * 64 * These comments are not intended to be public, and only read by HelpHub editors. 65 * 66 * @param array $args 67 * 68 * @return array 69 */ 70 function wporg_support_rest_comment_query( $args ) { 71 $post_types = get_post_types( array( 'name' => 'helphub_article' ), 'names', 'NOT' ); 72 $args['post_type'] = $post_types; 73 74 return $args; 75 } 76 add_filter( 'rest_comment_query', 'wporg_support_rest_comment_query' ); 77 78 /** 79 * Prevent viewing of individual comments on HelpHub articles via the REST API. 80 * 81 * These comments are not intended to be public, and only read by HelpHub editors. 82 * 83 * @param WP_REST_Response $response 84 * @param WP_Comment $comment 85 * 86 * @return WP_REST_Response|WP_Error 87 */ 88 function wporg_support_rest_prepare_comment( $response, $comment ) { 89 $post_type = get_post_type( $comment->comment_post_ID ); 90 91 if ( 'helphub_article' === $post_type ) { 92 return new WP_Error( 93 'rest_cannot_read', 94 __( 'Sorry, you are not allowed to read this comment.' ), 95 array( 'status' => rest_authorization_required_code() ) 96 ); 97 } 98 99 return $response; 100 } 101 add_filter( 'rest_prepare_comment', 'wporg_support_rest_prepare_comment', 10, 2 ); 102 103 /** 104 * Modify the redirect after a feedback comment is submitted on an Article. 105 * 106 * @param string $location 107 * @param WP_Comment $comment 108 * 109 * @return string 110 */ 111 function wporg_support_comment_post_redirect( $location, $comment ) { 112 if ( 'helphub_article' === get_post_type( $comment->comment_post_ID ) ) { 113 $location = substr( $location, 0, strpos( $location, '#' ) ); 114 $location = add_query_arg( 'feedback_submitted', 1, $location ); 115 $location .= '#reply-title'; 116 } 117 118 return $location; 119 } 120 add_filter( 'comment_post_redirect', 'wporg_support_comment_post_redirect', 10, 2 ); 52 121 53 122 /**
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)