WordPress add active class to Menu item – Plugin

Hello friends,

I have developed a simple WordPress plugin to add active class to menu item li tag. Currently it is current-menu-item or current_page_parent. You can even set custom class to li tag if your need is other than active class. Hope you will like it.

Download it from: https://wordpress.org/plugins/wp-add-active-class-to-menu-item/

Note: For any customization or help please do contact me on my mail or at plugins support page.

indian rupee symbol not showing

Indian Rupee Symbol For Woocommerce – Plugin

I was facing a issue in displaying new Indian Rupee Symbol in Woocommerce. In my shopping page, cart, filters etc. the rupee symbol was not showing. It was display a square box (error). So with the help of google and other means I have developed new plugin as a solution to this problem. Hope you will like and it will be really helpful.

Check it out on: https://wordpress.org/plugins/indian-rupee-symbol-for-woocommerce/

Note: For any type of customization or help please do contact me or at plugins support page.

Session based flash messages

Quite a while ago, I grew tired of trying to come up with new and creative ways to display simple, one-time messages to users without crazy amounts of code for something that was frequently as trivial as “Saved!”.

Sessions are the obvious solution, however, without a single function that could both generate, AND display the messages, it still wasn’t any better.  And as usual, where there’s a will, and some code- there’s a way!

Before we get started, make sure that a session is started, otherwise a) no message will be displayed, and b) super fun headers already sent messages.

//Ensure that a session exists (just in case)
if( !session_id() )
{
    session_start();
}

//Actual function

/**
 * Function to create and display error and success messages
 * @access public
 * @param string session name
 * @param string message
 * @param string display class
 * @return string message
 */
function flash( $name = '', $message = '', $class = 'success fadeout-message' )
{
    //We can only do something if the name isn't empty
    if( !empty( $name ) )
    {
        //No message, create it
        if( !empty( $message ) && empty( $_SESSION[$name] ) )
        {
            if( !empty( $_SESSION[$name] ) )
            {
                unset( $_SESSION[$name] );
            }
            if( !empty( $_SESSION[$name.'_class'] ) )
            {
                unset( $_SESSION[$name.'_class'] );
            }

            $_SESSION[$name] = $message;
            $_SESSION[$name.'_class'] = $class;
        }
        //Message exists, display it
        elseif( !empty( $_SESSION[$name] ) && empty( $message ) )
        {
            $class = !empty( $_SESSION[$name.'_class'] ) ? $_SESSION[$name.'_class'] : 'success';
            echo '
.$class.'" id="msg-flash">'.$_SESSION[$name].'
'
; unset($_SESSION[$name]); unset($_SESSION[$name.'_class']); } } }
//Set the first flash message with default class
flash( 'example_message', 'This content will show up on example2.php' );

//Set the second flash with an error class
flash( 'example_class', 'This content will show up on example2.php with the error class', 'error' );
//Displaying the messages
<?php flash( 'example_message' ); ?>
<?php flash( 'example_class' ); ?>

You can download the source from here

From: http://www.phpdevtips.com/

Add Extra Charges In Woocommerce Cart

If you want to apply extra fee in the cart then Woocommerce provide an action for applying a fee on the cart.

The fee can be used as shipping fee, installation fee or whatever as per your requirement.

add_action( ‘woocommerce_cart_calculate_fees’, ‘add_extra_cart_fee’ ,10,1 );
This action calculates the total fee and adds into the cart amount.

This Woocommerce function is used to add the fee to Woocommerce cart.

How to use it ?

<?php
add_action( ‘woocommerce_cart_calculate_fees’, ‘add_extra_cart_fee’ ,10,1 );
function add_extra_cart_fee( $cart_object ) {

global $woocommerce;
$spfee = 14.00; // initialize special fee
$woocommerce-&gt;cart-&gt;add_fee( ‘Extra Tax Fee’, $spfee, true, ‘standard’ );

}
?>

From: https://www.linkedin.com/pulse/add-fee-woocommerce-cart-vishal-patel

Browser and Operating System Finder

Capture

My first ever wordpress plugin to find Browser and Operating System on which website is running. It will add those particular names in body tag class attributes as shown below:

<body class=”…. browser-firefox os-windows”>
<body class=”…. browser-chrome os-apple”>
<body class=”…. browser-safari os-iphone”>
<body class=”…. browser-chrome os-android”>

You can configure names as per your need.

You can get this plugin at https://wordpress.org/plugins/browser-and-operating-system-finder/

OR

you can just search for “Browser and Operating System Finder” in search plugins box.