A Simple Way to Create “Special Words” Plugin on WordPress

With this WordPress plugin you can add functionality and expand the features of website. “Special Words” is created to facilitate your work. It’s user-friendly plugin and has an easy installation process. The plugin allows to emphasize the preferred words in a page or post allowing users to focus on the appropriate words. For becoming more noticeable, the words will be highlighted in red. Let’s build a plugin to do just that!

Building WordPress Plugin

Download the Plugin here

How to create the plugin

These steps below will show you how to create this “Special Words” plugin:

Step #1.

Open WordPress CMS folder > WP Content > Plugins

Step #2.

Make a folder named “Special words” and create special-words.php file

Step #3.

The file must contain:

  • Standard plugin information header
    This header allows WordPress know that the Plugin exists. Your Plugin will be activated only with the
    header.
    <?php
    
    /*
    
    Plugin Name: Special Words
    
    Plugin URI:
    
    Description: //
    
    Version: 0.1
    
    Author:
    
    Author URI:
    
    License:
    
    */
    
  • Hook for creating menu, here.
  • Function for creating menu
    add_action('admin_menu', 'reg_my_spec_word');
    
    functionreg_my_spec_word() {
    
    add_menu_page('Special Word', 'Special Word', 'manage_options', 'Special_word', 'spec_word_select_word');
    
    }
    
  • The code which is responsible for the plugin’s admin panel interface
    functionspec_word_select_word(){
    if($_GET['task']=='save')
    update_option('spider_special_word',$_POST['sp_word']);
    ?>
    <form method="post" action="/articles_and_tutorials/build_special_words_plugin_on_wordpress/admin_page_Special_word_amptask_save.html">
    <input type="text" name="sp_word" value="<?php echo get_option('spider_special_word') ?
    >"><input type="submit" value="save">
    
    </form>
    <?php
    }
    
  • The code which works when the plugin is being activated
    register_activation_hook( __FILE__, activat_special_words);
    
    functionactivat_special_words(){
    
    add_option("spider_special_word", 'special');
    
    }
    
  • The code in the content which is responsible for emphasizing the words
    add_action('the_content','special_word_front_end');
    
    functionspecial_word_front_end($content){
    
    returnstr_replace(get_option('spider_special_word'),'<span style="background-color:
    red;">'.get_option('spider_special_word').'</span>',$content);
    
    }
    

That’s all, that was surprisingly easy, right? For more information, please visit: http://codex.wordpress.org/Writing_a_Plugin#Administration_Panels

How to use the plugin

  1. The first step is you must install then activate the plugin.
  2. After you activated the plugin, on the left menu will appears the “Special Word” plugin.

    Building WordPress Plugin

  3. Please click it then add a word which will be emphasized.

    Building WordPress Plugin

  4. This is the view of the emphasized words.

    Building WordPress Plugin

Conclusion

Simple Words Plugin will help the users to focus on the appropriate words in your article. And of course you could definitely do more in terms of styling and functionality, but I believe this tutorial should be a good starting point. Feel free to use this code as a canvas for your own custom plugins. Please let us know about your ideas in comments below.

Download the Plugin here

- About the Author -

My full name is John Devise. I was born on May 25,1987 in ТХЕUSA. I’m a Web developer with five years experience. I specialize in creating plugins and extensions for websites, focusing primarily on Joomla and WordPress content management systems. Check out my site – http://web-dorado.com/ to download my other plugins.

Leave a Reply

 

Amazingly Beautiful WordPress Themes