QNimate

  • CoursesVideos
  • WP PremiumPlugins
  • DemosLab
  • Home
  • QIdea
  • QTrack
Home Carbon Ads Attaching Icons to WordPress Theme Menu Items

Attaching Icons to WordPress Theme Menu Items

This post is a part 10 of Creating a WordPress Admin Theme post series.

Attaching icons to menu items has become a trend. WordPress theme developers need to build a functionality write into WordPress theme to provide users to choose icons for menu items. For themes which don’t support menu icons, users usually used plugins like Menu Icons to achieve this functionality.


Menu Icons in WordPress Themes

We can actually pack this plugin in our theme and install it automatically when the theme is installed by the user. Its completely legal to pack third party plugins into your theme if these plugins are open source plugins.

You can install Menu icons plugin automatically using TGM Plugin Activation Library.

First download class-tgm-plugin-activation.php file and put it inside the theme folder. And then put this code in your functions.php file

<?php
 
require_once dirname( __FILE__ ) . '/class-tgm-plugin-activation.php';
 
add_action( 'tgmpa_register', 'mytheme_require_plugins' );
 
function mytheme_require_plugins() {
 
    $plugins = array( array(
        'name'      => 'Menu Icons',
        'slug'      => 'menu-icons',
        'required'  => true, // this plugin is recommended
        'force_activation' => true, // this plugin is going to stay activated unless the user switches to another theme
        'force_deactivation' => true, // deactivate this plugin when the user switches to another theme
    ) );
   
    $config = array(
        'id'           => 'qnimate-tgmpa', // your unique TGMPA ID
        'default_path' => get_stylesheet_directory() . '/lib/plugins/', // default absolute path
        'menu'         => 'qnimate-install-required-plugins', // menu slug
        'has_notices'  => true, // Show admin notices
        'dismissable'  => false, // the notices are NOT dismissable
        'dismiss_msg'  => 'I really, really need you to install these plugins, okay?', // this message will be output at top of nag
        'is_automatic' => true, // automatically activate plugins after installation
        'message'      => '<!--Hey there.-->', // message to output right before the plugins table
        'strings'      => array() // The array of message strings that TGM Plugin Activation uses
    );
 
    tgmpa( $plugins, $config );
 
}
 
?>

Now whoever installs your theme will have the plugin installed and it will seem like the theme has this built in functionality.

Sep 11, 2014Narayan Prusty
How To Avoid Killing Of Terminal Attached Processes When SSH Connection DropsSecret Blogging Tools And Methods That Will Help You To Succeed
Comments: 1
  1. julie ranawat
    6 years ago

    Great work..keep it up…thanks..

    ReplyCancel

Leave a Reply Cancel reply

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax

Narayan Prusty

I am a software engineer specialising in Blockchain, DevOps and Go/JavaScript. This is my personal blog where I write about things that I learn and feel interesting to share.

8 years ago 1 Comment WordPress
Share this
0
GooglePlus
0
Facebook
0
Twitter
0
Linkedin
Related Articles
  • Multi-language WordPress Theme and Site
  • WordPress “Buy me a Beer” Plugin
  • Changing WordPress Admin Footer Text
  • WordPress Enable or Disable Auto Update
  • WordPress Frontend Twitter OAuth Login
Our Sponsor
My Books

2014 - 2015 © QNimate
All tutorials MIT license