Hello Readers!

So today i want to share with you some useful Snippets to use with your KLEO theme.

Snippets are an easy and cool way of customizing your website and adding extra features to make it stand out!

PHP Snippets for KLEO

  • Change side menu font icon with an image.
function kleo_side_menu_button ( $items, $args )
{
if ($args->theme_location == 'primary')
{
$items .= '<li id="nav-menu-item-side" class="menu-item">' .
'<a href="#" rel="nofollow">' .
'*** add your image markup here ***' .
'</a>' .
'';
}
return $items;
}

How to use it:

Copy the code into your childs function.php file

Upload an image to your media folder in dashboard. Then get the url and use standard img tag markup.http://www.w3schools.com/tags/tag_img.asp

Snippet credit: sharmstr

 

  • Stop Registering of Certain Notifications in Activity
//Block certain activity types from being added
function bp_activity_dont_save( $activity_object ) {
$exclude = array(
        'updated_profile',
        'new_member',
        'new_avatar',
        'friendship_created',
        'joined_group'
    );

How to use it:

Copy the code into your childs function.php file
This doesnt hide them, it STOPS them from being saved to the db.

Snippet credit: sharmstr

  • Hide “Upgrade Account” for Certain Memberships
function kleo_membership_info()
{
    global $membership_levels, $current_user;
    if (!$membership_levels) {
        return;
    }

    $levels_arr = array('2','3','4');
    if (bp_is_my_profile()) {
        if ( isset($current_user->membership_level) && in_array($current_user->membership_level->ID, $levels_arr) ) {
            echo '' . $current_user->membership_level->name . '';
        } else {
            echo '' . __("Upgrade account", 'kleo_framework') . '';
        }
    }
}

How to use:
Add the code to your child theme functions.php
Change the level IDs with yours at:

 $levels_arr = array('2','3','4');

This is all for now, have fun!

http://laura-solanes.com/
Do you like Laura Solanes's articles? Follow on social!