Making WordPress.org

Ticket #5233: 5233.diff

File 5233.diff, 4.3 KB (added by audrasjb, 5 years ago)

HelpHub: Add a basic Customizer setting to hide forums sections from localized helphub sites that don’t use forum feature

  • wordpress.org/public_html/wp-content/themes/pub/wporg-support/front-page.php

    diff --git a/wordpress.org/public_html/wp-content/themes/pub/wporg-support/front-page.php b/wordpress.org/public_html/wp-content/themes/pub/wporg-support/front-page.php
    index d81109cd1..cf729eb1b 100644
    a b get_header(); ?> 
    1717                                <?php dynamic_sidebar( 'front-page-blocks' ); ?>
    1818                        </div>
    1919
    20                         <hr>
    21 
    22                         <div id="helphub-forum-link" class="text-center">
    23                                 <h3><?php esc_html_e( 'Support Forums', 'wporg-forums' ); ?></h3>
    24 
    25                                 <p>
    26                                         <span>
    27                                                 <?php esc_html_e( 'Can\'t find what you\'re looking for? Find out if others share your experience.', 'wporg-forums' ); ?>
    28                                         </span>
    29 
    30                                         <br>
    31 
    32                                         <a href="<?php echo esc_url( site_url( '/forums/' ) ); ?>"><?php esc_html_e( 'Check out our support forums', 'wporg-forums' ); ?></a>
    33                                 </p>
    34                         </div>
     20                        <?php if ( get_theme_mod( 'wporg_hide_forum', false ) ) : ?>
     21                                <hr>
     22       
     23                                <div id="helphub-forum-link" class="text-center">
     24                                        <h3><?php esc_html_e( 'Support Forums', 'wporg-forums' ); ?></h3>
     25       
     26                                        <p>
     27                                                <span>
     28                                                        <?php esc_html_e( 'Can\'t find what you\'re looking for? Find out if others share your experience.', 'wporg-forums' ); ?>
     29                                                </span>
     30       
     31                                                <br>
     32       
     33                                                <a href="<?php echo esc_url( site_url( '/forums/' ) ); ?>"><?php esc_html_e( 'Check out our support forums', 'wporg-forums' ); ?></a>
     34                                        </p>
     35                                </div>
     36                        <?php endif; ?>
    3537                <?php endif; ?>
    3638
    3739        </main>
  • wordpress.org/public_html/wp-content/themes/pub/wporg-support/functions.php

    diff --git a/wordpress.org/public_html/wp-content/themes/pub/wporg-support/functions.php b/wordpress.org/public_html/wp-content/themes/pub/wporg-support/functions.php
    index a00fb2cf2..d28be2557 100644
    a b function bb_is_intl_forum() { 
    888888 * Include the Strings for the supporg/update-php page.
    889889 */
    890890include_once __DIR__ . '/helphub-update-php-strings.php';
     891
     892/**
     893 * Add wporg_hide_forum Customizer setting.
     894 */
     895if ( ! class_exists( 'WPORG_Support_Customize' ) ) {
     896        /**
     897         * CUSTOMIZER SETTINGS
     898         */
     899        class WPORG_Support_Customize {
     900
     901                /**
     902                 * Register customizer options.
     903                 *
     904                 * @param WP_Customize_Manager $wp_customize Theme Customizer object.
     905                 */
     906                public static function register( $wp_customize ) {
     907                        /**
     908                         * Theme Options
     909                         */
     910                        $wp_customize->add_section(
     911                                'options',
     912                                array(
     913                                        'title'      => __( 'Theme options', 'wporg-support' ),
     914                                        'priority'   => 40,
     915                                        'capability' => 'edit_theme_options',
     916                                )
     917                        );
     918
     919                        $wp_customize->add_setting(
     920                                'wporg_hide_forum',
     921                                array(
     922                                        'capability'        => 'edit_theme_options',
     923                                        'default'           => false,
     924                                        'sanitize_callback' => array( __CLASS__, 'sanitize_checkbox' ),
     925                                )
     926                        );
     927
     928                        $wp_customize->add_control(
     929                                'wporg_hide_forum',
     930                                array(
     931                                        'type'     => 'checkbox',
     932                                        'section'  => 'options',
     933                                        'priority' => 10,
     934                                        'label'    => __( 'Hide support forum infos', 'wporg-support' ),
     935                                )
     936                        );
     937                }
     938
     939                /**
     940                 * Sanitize boolean for checkbox.
     941                 *
     942                 * @param bool $checked Whether or not a box is checked.
     943                 *
     944                 * @return bool
     945                 */
     946                public static function sanitize_checkbox( $checked ) {
     947                        return ( ( isset( $checked ) && true === $checked ) ? true : false );
     948                }
     949        }
     950
     951        // Setup the Theme Customizer settings and controls.
     952        add_action( 'customize_register', array( 'WPORG_Support_Customize', 'register' ) );
     953}
  • wordpress.org/public_html/wp-content/themes/pub/wporg-support/searchform.php

    diff --git a/wordpress.org/public_html/wp-content/themes/pub/wporg-support/searchform.php b/wordpress.org/public_html/wp-content/themes/pub/wporg-support/searchform.php
    index 3ceb1fcee..ddab73a56 100644
    a b  
    22namespace WordPressdotorg\Forums;
    33?>
    44
    5 <?php if ( bb_is_intl_forum() ) : ?>
     5<?php if ( bb_is_intl_forum() && ! get_theme_mod( 'wporg_hide_forum', false ) ) : ?>
    66
    77<form role="search" method="get" class="search-form" action="<?php bbp_search_url(); ?>">
    88        <label for="s" class="screen-reader-text"><?php _ex( 'Search for:', 'label', 'wporg-forums' ); ?></label>