To add a custom tab with an icon in the LearnPress profile menu, follow these steps:

Step 1: Add the Custom Tab with an Icon

Add this code to your theme’s functions.php file:

function custom_learnpress_profile_tab( $tabs ) {
    $tabs['custom-tab'] = array(
        'title'    => __( 'Custom Tab', 'learnpress' ),
        'slug'     => 'custom-tab',
        'icon'     => 'dashicons-admin-generic', // WordPress Dashicons
        'callback' => 'custom_learnpress_profile_content'
    );
    return $tabs;
}
add_filter( 'learn-press/profile-tabs', 'custom_learnpress_profile_tab' );

function custom_learnpress_profile_content() {
    echo '<h2>Custom Tab Content</h2>';
    echo '<p>This is the content of the custom tab.</p>';
}

// Add Icons to LearnPress Profile Tabs
function custom_learnpress_profile_tab_icon( $tab_slug, $tab ) {
    if ( isset( $tab['icon'] ) ) {
        echo '<span class="dashicons ' . esc_attr( $tab['icon'] ) . '"></span>';
    }
}
add_action( 'learn-press/before-profile-nav', 'custom_learnpress_profile_tab_icon', 10, 2 );

Step 2: Choose an Icon

Replace 'dashicons-admin-generic' with any Dashicon from WordPress Dashicons, like:

  • dashicons-welcome-learn-more
  • dashicons-book
  • dashicons-smiley

Step 3: Style the Icon (Optional)

Add this CSS to your theme’s style.css file for better icon visibility:

.learn-press-profile-tabs li a .dashicons {
    font-size: 18px;
    margin-right: 5px;
    vertical-align: middle;
}

Step 4: Refresh Permalinks

  1. Go to Settings → Permalinks in WordPress.
  2. Click Save Changes to refresh the structure.

Now, your custom tab will appear with an icon in the LearnPress profile menu! 🎉

Let me know if you need further customizations. 🚀

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x