Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
08/26/2024 11:10:35 PM (16 months ago)
Author:
espellcaste
Message:

WPCS: Part I: miscellaneous fixes for some of the files of the blogs component.

See #9174
See #9173

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-blogs/classes/class-bp-blogs-theme-compat.php

    r10517 r14010  
    3838
    3939        // Bail if not looking at a group.
    40         if ( ! bp_is_blogs_component() )
     40        if ( ! bp_is_blogs_component() ) {
    4141            return;
     42        }
    4243
    4344        // Bail if looking at a users sites.
    44         if ( bp_is_user() )
     45        if ( bp_is_user() ) {
    4546            return;
     47        }
    4648
    4749        // Blog Directory.
     
    5759            do_action( 'bp_blogs_screen_index' );
    5860
    59             add_filter( 'bp_get_buddypress_template',                array( $this, 'directory_template_hierarchy' ) );
     61            add_filter( 'bp_get_buddypress_template', array( $this, 'directory_template_hierarchy' ) );
    6062            add_action( 'bp_template_include_reset_dummy_post_data', array( $this, 'directory_dummy_post' ) );
    61             add_filter( 'bp_replace_the_content',                    array( $this, 'directory_content'    ) );
    62 
    63         // Create blog.
     63            add_filter( 'bp_replace_the_content', array( $this, 'directory_content' ) );
     64
     65            // Create blog.
    6466        } elseif ( is_user_logged_in() && bp_blog_signup_enabled() ) {
    65             add_filter( 'bp_get_buddypress_template',                array( $this, 'create_template_hierarchy' ) );
     67            add_filter( 'bp_get_buddypress_template', array( $this, 'create_template_hierarchy' ) );
    6668            add_action( 'bp_template_include_reset_dummy_post_data', array( $this, 'create_dummy_post' ) );
    67             add_filter( 'bp_replace_the_content',                    array( $this, 'create_content'    ) );
     69            add_filter( 'bp_replace_the_content', array( $this, 'create_content' ) );
    6870        }
    6971    }
     
    7981     * @since 1.8.0
    8082     *
    81      * @param string $templates The templates from bp_get_theme_compat_templates().
     83     * @param array $templates The templates from bp_get_theme_compat_templates().
    8284     * @return array $templates Array of custom templates to look for.
    8385     */
    8486    public function directory_template_hierarchy( $templates ) {
     87
     88        if ( empty( $templates ) || ! is_array( $templates ) ) {
     89            $templates = array();
     90        }
    8591
    8692        /**
     
    8995         * @since 1.8.0
    9096         *
    91          * @param array $value Array of template paths to add to template list to look for.
     97         * @param array $template_paths Array of template paths to add to template list to look for.
    9298         */
    93         $new_templates = apply_filters( 'bp_template_hierarchy_blogs_create', array(
    94             'blogs/index-directory.php'
    95         ) );
     99        $new_templates = apply_filters(
     100            'bp_template_hierarchy_blogs_create',
     101            array(
     102                'blogs/index-directory.php',
     103            )
     104        );
    96105
    97106        // Merge new templates with existing stack
    98107        // @see bp_get_theme_compat_templates().
    99         $templates = array_merge( (array) $new_templates, $templates );
    100 
    101         return $templates;
     108        return array_merge( $new_templates, $templates );
    102109    }
    103110
     
    108115     */
    109116    public function directory_dummy_post() {
    110 
    111         bp_theme_compat_reset_post( array(
    112             'ID'             => 0,
    113             'post_title'     => __( 'Sites', 'buddypress' ),
    114             'post_author'    => 0,
    115             'post_date'      => 0,
    116             'post_content'   => '',
    117             'post_type'      => 'page',
    118             'post_status'    => 'publish',
    119             'is_page'        => true,
    120             'comment_status' => 'closed'
    121         ) );
     117        bp_theme_compat_reset_post(
     118            array(
     119                'ID'             => 0,
     120                'post_title'     => __( 'Sites', 'buddypress' ),
     121                'post_author'    => 0,
     122                'post_date'      => 0,
     123                'post_content'   => '',
     124                'post_type'      => 'page',
     125                'post_status'    => 'publish',
     126                'is_page'        => true,
     127                'comment_status' => 'closed',
     128            )
     129        );
    122130    }
    123131
     
    126134     *
    127135     * @since 1.7.0
     136     *
     137     * @return string|null
    128138     */
    129139    public function directory_content() {
     
    141151     * @since 1.8.0
    142152     *
    143      * @param string $templates The templates from bp_get_theme_compat_templates().
     153     * @param array $templates The templates from bp_get_theme_compat_templates().
    144154     * @return array $templates Array of custom templates to look for.
    145155     */
    146156    public function create_template_hierarchy( $templates ) {
     157
     158        if ( empty( $templates ) || ! is_array( $templates ) ) {
     159            $templates = array();
     160        }
    147161
    148162        /**
     
    151165         * @since 1.8.0
    152166         *
    153          * @param array $value Array of template paths to add to template list to look for.
     167         * @param array $template_paths Array of template paths to add to template list to look for.
    154168         */
    155         $new_templates = apply_filters( 'bp_template_hierarchy_blogs_create', array(
    156             'blogs/index-create.php'
    157         ) );
     169        $new_templates = apply_filters(
     170            'bp_template_hierarchy_blogs_create',
     171            array(
     172                'blogs/index-create.php',
     173            )
     174        );
    158175
    159176        // Merge new templates with existing stack
    160177        // @see bp_get_theme_compat_templates().
    161         $templates = array_merge( (array) $new_templates, $templates );
    162 
    163         return $templates;
     178        return array_merge( $new_templates, $templates );
    164179    }
    165180
     
    178193        }
    179194
    180         bp_theme_compat_reset_post( array(
    181             'ID'             => 0,
    182             'post_title'     => $title,
    183             'post_author'    => 0,
    184             'post_date'      => 0,
    185             'post_content'   => '',
    186             'post_type'      => 'page',
    187             'post_status'    => 'publish',
    188             'is_page'        => true,
    189             'comment_status' => 'closed'
    190         ) );
     195        bp_theme_compat_reset_post(
     196            array(
     197                'ID'             => 0,
     198                'post_title'     => $title,
     199                'post_author'    => 0,
     200                'post_date'      => 0,
     201                'post_content'   => '',
     202                'post_type'      => 'page',
     203                'post_status'    => 'publish',
     204                'is_page'        => true,
     205                'comment_status' => 'closed',
     206            )
     207        );
    191208    }
    192209
     
    195212     *
    196213     * @since 1.7.0
     214     *
     215     * @return string|null
    197216     */
    198217    public function create_content() {
Note: See TracChangeset for help on using the changeset viewer.