Skip to:
Content

BuddyPress.org

Changeset 11900


Ignore:
Timestamp:
03/18/2018 10:51:34 PM (8 years ago)
Author:
djpaul
Message:

Templates, Nouveau: general code review/tweaks.

Location:
trunk/src/bp-templates/bp-nouveau
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-templates/bp-nouveau/buddypress-functions.php

    r11899 r11900  
    3838    protected static $instance = null;
    3939
    40     /** Functions *************************************************************/
    41 
    4240    /**
    4341     * Return the instance of this class.
     
    4644     */
    4745    public static function get_instance() {
    48 
    49         // If the single instance hasn't been set, set it now.
    5046        if ( null === self::$instance ) {
    5147            self::$instance = new self;
     
    6359        parent::start();
    6460
    65         // Include needed files
    6661        $this->includes();
    67 
    68         // Setup features support
    6962        $this->setup_support();
    7063    }
     
    8376
    8477        $this->includes_dir  = trailingslashit( $this->dir ) . 'includes/';
    85         $this->lang_dir      = trailingslashit( $this->dir ) . 'languages';
    86         $this->domain        = 'bp-nouveau';
    8778        $this->directory_nav = new BP_Core_Nav();
    8879    }
     
    175166        add_action( 'bp_actions', array( $this, 'neutralize_core_template_notices' ), 6 );
    176167
    177         /** Scripts ***********************************************************/
    178 
     168        // Scripts
    179169        add_action( 'bp_enqueue_scripts', array( $this, 'register_scripts' ), 2 ); // Register theme JS
    180 
    181         // We won't use this.
    182170        remove_action( 'bp_enqueue_scripts', 'bp_core_confirmation_js' );
    183 
    184171        add_action( 'bp_enqueue_scripts', array( $this, 'enqueue_styles' ) ); // Enqueue theme CSS
    185172        add_action( 'bp_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); // Enqueue theme JS
    186173        add_filter( 'bp_enqueue_scripts', array( $this, 'localize_scripts' ) ); // Enqueue theme script localization
    187174
    188         /** Body no-js Class **************************************************/
    189 
     175        // Body no-js class
    190176        add_filter( 'body_class', array( $this, 'add_nojs_body_class' ), 20, 1 );
    191177
     
    367353     *
    368354     * @param array $classes Array of classes to append to body tag.
     355     *
    369356     * @return array $classes
    370357     */
     
    549536     * @see bp_buffer_template_part()
    550537     *
    551      * @param  string $retval Current template part contents.
     538     * @param string $retval Current template part contents.
     539     *
    552540     * @return string
    553541     */
  • trunk/src/bp-templates/bp-nouveau/includes/activity/functions.php

    r11899 r11900  
    280280     * @since 3.0.0
    281281     *
    282      * @param  array $nav_items The list of the activity directory nav items.
     282     * @param array $nav_items The list of the activity directory nav items.
    283283     */
    284284    return apply_filters( 'bp_nouveau_get_activity_directory_nav_items', $nav_items );
     
    291291 * @since 3.0.0
    292292 *
    293  * @param string $output string HTML output
    294  * @param 'directory' see comment below
     293 * @param string $output  HTML output
     294 * @param array  $filters Optional.
     295 * @param string $context
    295296 *
    296297 * @return array
     
    430431 * @since 3.0.0
    431432 */
    432 
    433433function bp_nouveau_activity_time_since( $time_since, $activity = null ) {
    434434    if ( ! isset( $activity->date_recorded ) ) {
  • trunk/src/bp-templates/bp-nouveau/includes/activity/widgets.php

    r11899 r11900  
    4646     * @since 3.0.0
    4747     *
    48      * @param  array $args     Widget arguments.
    49      * @param  array $instance Widget settings, as saved by the user.
     48     * @param array $args     Widget arguments.
     49     * @param array $instance Widget settings, as saved by the user.
    5050     */
    5151    public function widget( $args, $instance ) {
  • trunk/src/bp-templates/bp-nouveau/includes/classes.php

    r11899 r11900  
    9595     * @since 3.0.0
    9696     *
    97      * @param  array the list of buttons to sort.
     97     * @param array the list of buttons to sort.
     98     *
    9899     * @return array the list of buttons sorted.
    99100     */
     
    114115                do {
    115116                    $position += 1;
    116                 } while ( in_array( $position, $sorted_keys ) );
     117                } while ( in_array( $position, $sorted_keys, true ) );
    117118            }
    118119
     
    129130     * @since 3.0.0
    130131     *
    131      * @param  bool $sort whether to sort the buttons or not.
     132     * @param bool $sort whether to sort the buttons or not.
     133     *
    132134     * @return array An array of HTML links.
    133135     */
     
    161163     * @since 3.0.0
    162164     *
    163      * @param array $args See the __constructor for a description of this argument.
     165     * @param array $args Optional. See the __constructor for a description of this argument.
    164166     */
    165167    public function update( $args = array() ) {
    166         if ( empty( $args ) ) {
    167             return false;
    168         }
    169 
    170168        foreach ( $args as $id => $params ) {
    171169            if ( isset( $this->group[ $id ] ) ) {
  • trunk/src/bp-templates/bp-nouveau/includes/functions.php

    r11899 r11900  
    607607 * @since 3.0.0
    608608 *
    609  * @param  string $hook      The hook to fire.
    610  * @param  string $component The component nav belongs to.
    611  * @param  int    $position  The position of the nav item.
     609 * @param string $hook      The hook to fire.
     610 * @param string $component The component nav belongs to.
     611 * @param int    $position  The position of the nav item.
    612612 *
    613613 * @return array A list of component's dir nav items
     
    771771 * @since 3.0.0
    772772 *
    773  * @param  string $option the index of the setting to get.
    774  * @param  mixed  $retval the value to use as default.
    775  * @return mixed          the value for the requested option.
     773 * @param string $option the index of the setting to get.
     774 * @param mixed  $retval the value to use as default.
     775 *
     776 * @return mixed The value for the requested option.
    776777 */
    777778function bp_nouveau_get_temporary_setting( $option = '', $retval = false ) {
     
    942943
    943944    $cover_image = isset( $params['cover_image'] ) ? 'background-image: url( ' . $params['cover_image'] . ' );' : '';
    944 
    945945    $hide_avatar_style = '';
    946946
  • trunk/src/bp-templates/bp-nouveau/includes/groups/functions.php

    r11899 r11900  
    1212 * Provide a convenience function to add markup wrapper for message strings
    1313 *
    14  * @param  $message: The message text string
    15  *         $type: the message type - 'error, 'info', 'warning', success'
     14 * @param string $message The message text string
     15 * @param string $type    The message type - 'error, 'info', 'warning', success'
     16 *
    1617 * @return string
    1718 *
     
    1920 */
    2021function bp_nouveau_message_markup_wrapper( $message, $type ) {
    21 
    2222    if ( ! $message ) {
    2323        return false;
     
    3434 * @since 3.0.0
    3535 *
    36  * @param  array  $scripts  The array of scripts to register
    37  * @return array  The same array with the specific groups scripts.
     36 * @param array $scripts Optional. The array of scripts to register.
     37 *
     38 * @return array The same array with the specific groups scripts.
    3839 */
    3940function bp_nouveau_groups_register_scripts( $scripts = array() ) {
     
    674675 * @since 3.0.0
    675676 *
    676  * @param array $settings the settings to add.
     677 * @param array $settings Optional. The settings to add.
    677678 *
    678679 * @return array the settings to add.
     
    751752 * @since 3.0.0
    752753 *
    753  * @param array $controls the controls to add.
     754 * @param array $controls Optional. The controls to add.
    754755 *
    755756 * @return array the controls to add.
     
    821822 * @since 3.0.0
    822823 *
    823  * @param array           $templates The list of templates for the front.php template part.
    824  * @param BP_Groups_Group The group object.
     824 * @param array           $templates Optional. The list of templates for the front.php template part.
     825 * @param BP_Groups_Group $group Optional. The group object.
    825826 *
    826827 * @return array The same list with the default front template if needed.
     
    850851 * @since 3.0.0
    851852 *
    852  * @param string $template The template part to get (eg: activity, members...).
     853 * @param string $template Optional. The template part to get (eg: activity, members...).
    853854 *
    854855 * @return string The located template.
     
    903904 * @since 3.0.0
    904905 *
    905  * @param string $template The template part to get (eg: activity, members...).
     906 * @param string $template Optional. The template part to get (eg: activity, members...).
    906907 *
    907908 * @return string HTML output.
     
    944945 * @since 3.0.0
    945946 *
    946  * @param array $args The Activities Template arguments.
     947 * @param array $args Optional. The Activities Template arguments.
    947948 *
    948949 * @return array The Activities Template arguments.
     
    960961 * @since 3.0.0
    961962 *
    962  * @param array $args The Groups Template arguments.
     963 * @param array $args Optional. The Groups Template arguments.
    963964 *
    964965 * @return array The Groups Template arguments.
     
    975976 * @since 3.0.0
    976977 *
    977  * @param array $args The Members Template arguments.
     978 * @param array $args Optional. The Members Template arguments.
    978979 *
    979980 * @return array The Members Template arguments.
     
    10221023 * @since 3.0.0
    10231024 *
    1024  * @param string $id The screen id
     1025 * @param string $id Optional. The screen id
    10251026 *
    10261027 * @return mixed An array containing the hook dynamic part, the nonce, and eventually a specific template.
     
    10491050 * @since 3.0.0
    10501051 *
    1051  * @param string $id The screen id
     1052 * @param string $id Optional. The screen id
    10521053 *
    10531054 * @return mixed An array containing the hook dynamic part and the nonce.
  • trunk/src/bp-templates/bp-nouveau/includes/groups/template-tags.php

    r11899 r11900  
    12881288 * @since 3.0.0
    12891289 *
    1290  * @param object $group  Optional. The group being referenced.
    1291  *                       Defaults to the group currently being
    1292  *                       iterated on in the groups loop.
    1293  * @param int $length    Optional. Length of returned string, including ellipsis.
    1294  *                       Default: 100.
     1290 * @param object $group Optional. The group being referenced.
     1291 *                      Defaults to the group currently being iterated on in the groups loop.
     1292 * @param int $length   Optional. Length of returned string, including ellipsis. Default: 100.
    12951293 *
    12961294 * @return string Excerpt.
     
    13011299
    13021300/**
    1303  * Filters the excerpt  of a group description.
     1301 * Filters the excerpt of a group description.
    13041302 *
    13051303 * Checks if the group loop is set as a 'Grid' layout and returns a reduced excerpt.
     
    13071305 * @since 3.0.0
    13081306 *
    1309  * @param object $group  Optional. The group being referenced.
    1310  *                       Defaults to the group currently being
    1311  *                       iterated on in the groups loop.
    1312  * @param int $length    Optional. Length of returned string, including ellipsis.
    1313  *                       Default: 100.
     1307 * @param object $group Optional. The group being referenced. Defaults to the group currently being
     1308 *                      iterated on in the groups loop.
     1309 * @param int $length   Optional. Length of returned string, including ellipsis. Default: 100.
    13141310 *
    13151311 * @return string Excerpt.
     
    13231319
    13241320    /**
    1325     * If this is a grid layout but no length is passed in set a shorter
    1326     * default value otherwise use the passed in value.
    1327     * If not a grid then the BP core default is used or passed in value.
    1328     */
     1321     * If this is a grid layout but no length is passed in set a shorter
     1322     * default value otherwise use the passed in value.
     1323     * If not a grid then the BP core default is used or passed in value.
     1324     */
    13291325    if ( bp_nouveau_loop_is_grid() && 'groups' === bp_current_component() ) {
    13301326        if ( ! $length ) {
  • trunk/src/bp-templates/bp-nouveau/includes/members/functions.php

    r11899 r11900  
    423423 * @since 3.0.0
    424424 *
    425  * @param  WP_User $user The user object. Optional.
    426  * @return array         The list of WP Profile fields
     425 * @param WP_User $user The user object. Optional.
     426 *
     427 * @return array The list of WP Profile fields
    427428 */
    428429function bp_nouveau_get_wp_profile_fields( $user = null ) {
  • trunk/src/bp-templates/bp-nouveau/includes/notifications/functions.php

    r11899 r11900  
    122122        return $bp_nouveau->notifications->filters[ $id ];
    123123
    124     // Oops nothing found!
    125124    } else {
    126125        return false;
     
    144143
    145144    foreach ( $filters as $filter ) {
    146         // Default position
    147145        $position = 99;
    148146
     
    157155            do {
    158156                $position += 1;
    159             } while ( in_array( $position, $sorted_keys ) );
     157            } while ( in_array( $position, $sorted_keys, true ) );
    160158        }
    161159
  • trunk/src/bp-templates/bp-nouveau/includes/template-tags.php

    r11899 r11900  
    132132 * Checks if the template notice/feedback message needs a dismiss button
    133133 *
    134  *
    135134 * @todo Dismiss button re-worked to try and prevent buttons on general
    136  * BP template notices - Nouveau user_feedback key needs review.
    137     *
     135 *       BP template notices - Nouveau user_feedback key needs review.
    138136 *
    139137 * @since 3.0.0
     
    149147    }
    150148
    151     // Test for isset as value may be bool or string i.e 'clear'
     149    // Test for isset as value can be falsey.
    152150    if ( isset( $bp_nouveau->user_feedback['dismiss'] ) ) {
    153151        return true;
     
    159157/**
    160158 * Ouptut the dismiss type.
     159 *
    161160 * $type is used to set the data-attr for the button.
    162161 * 'clear' is tested for & used to remove cookies, if set, in buddypress-nouveau.js.
     
    237236
    238237        // Adds a 'dimiss' (button) key to array - set true/false.
    239         // defaulting to false.
    240238        $template_message['dismiss'] = false;
    241239
     
    359357 */
    360358function bp_nouveau_pagination( $position ) {
    361     $component = bp_current_component();
    362 
    363     // @TODO: How is this ever going to occur?
    364     if ( ! bp_is_active( $component ) ) {
    365         return;
    366     }
    367 
    368359    $screen          = 'dir';
    369     $pagination_type = $component;
     360    $pagination_type = bp_current_component();
    370361
    371362    if ( bp_is_user() ) {
     
    616607/**
    617608 * Return a bool check for component directory layout.
    618  * Checks if activity, members, groups, blogs has the vert nav layout selected
    619  *
    620  * @since 3.0.0
    621  *
    622  * @return bool.
     609 *
     610 * Checks if activity, members, groups, blogs has the vert nav layout selected.
     611 *
     612 * @since 3.0.0
     613 *
     614 * @return bool
    623615 */
    624616function bp_dir_is_vert_layout() {
    625         $bp_nouveau = bp_nouveau();
    626         $component  = sanitize_key( bp_current_component() );
    627 
    628         return (bool) $bp_nouveau->{$component}->directory_vertical_layout;
     617    $bp_nouveau = bp_nouveau();
     618    $component  = sanitize_key( bp_current_component() );
     619
     620    return (bool) $bp_nouveau->{$component}->directory_vertical_layout;
    629621}
    630622
     
    748740            $nav = $user_nav->get_primary( $args );
    749741        }
     742
    750743    } elseif ( ! empty( $bp_nouveau->object_nav ) ) {
    751 
    752744        $bp_nouveau->displayed_nav = $bp_nouveau->object_nav;
    753745
     
    13021294     *
    13031295     * @since 3.0.0
     1296     *
     1297     * @return string
    13041298     */
    13051299    function bp_nouveau_get_directory_list_class() {
     
    13401334
    13411335
    1342 /** Template tags for the single item navs ***********************************/
     1336// Template tags for the single item navs.
    13431337
    13441338/**
     
    15261520     */
    15271521    function bp_nouveau_get_single_item_subnav_classes() {
    1528         $classes  = array( 'bp-navs', 'bp-subnavs', 'no-ajax' );
     1522        $classes = array( 'bp-navs', 'bp-subnavs', 'no-ajax' );
    15291523
    15301524        // Set user or group class string
     
    17771771
    17781772
    1779 /** Template tags for the directory & user/group screen filters **********************************/
     1773// Template tags for the directory & user/group screen filters.
    17801774
    17811775/**
  • trunk/src/bp-templates/bp-nouveau/includes/xprofile/functions.php

    r11899 r11900  
    1414 * @since 3.0.0
    1515 *
    16  * @param  array $scripts The array of scripts to register
     16 * @param array $scripts The array of scripts to register
    1717 *
    1818 * @return array The same array with the specific groups scripts.
  • trunk/src/bp-templates/bp-nouveau/includes/xprofile/loader.php

    r11899 r11900  
    5252     */
    5353    protected function setup_actions() {
    54         // Enqueue the scripts
    5554        add_action( 'bp_nouveau_enqueue_scripts', 'bp_nouveau_xprofile_enqueue_scripts' );
    5655    }
     
    6261     */
    6362    protected function setup_filters() {
    64         // Register xprofile scripts
    6563        add_filter( 'bp_nouveau_register_scripts', 'bp_nouveau_xprofile_register_scripts', 10, 1 );
    6664    }
  • trunk/src/bp-templates/bp-nouveau/includes/xprofile/template-tags.php

    r11899 r11900  
    3333    bp_nouveau_hook( $hook );
    3434}
    35 
    3635
    3736/**
  • trunk/src/bp-templates/bp-nouveau/js/buddypress-messages.js

    r11686 r11900  
    401401                return bp.ajax.send( options );
    402402            }
    403 
    404             /*if ( 'delete' === method ) {
    405                 options.data = _.extend( options.data, {
    406                     action     : 'groups_delete_group_invite',
    407                     '_wpnonce' : BP_Nouveau.group_invites.nonces.uninvite
    408                 } );
    409 
    410                 if ( model ) {
    411                     options.data.user = model;
    412                 }
    413 
    414                 return bp.ajax.send( options );
    415             }*/
    416403        },
    417404
Note: See TracChangeset for help on using the changeset viewer.