How to add a shortcode for custom menu item in WordPress


Hi Guys,

Today i will explain how to use short code for custom menu item in navigation.

I have tried and got the result for it. Here i explained how i did it.

First you have to install the this plugin for url short-code -> http://wordpress.org/extend/plugins/peters-blog-url-shortcodes/

Add this code to your functions.php file with your theme.


class description_walker extends Walker_Nav_Menu{
function start_el(&$output, $item, $depth, $args)
{
global $wp_query;
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';

$class_names = $value = '';

$classes = empty( $item->classes ) ? array() : (array) $item->classes;

$class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );
$class_names = ' class="'. esc_attr( $class_names ) . '"';

$output .= $indent . '

  • ID . '"' . $value . $class_names .'>';

    $attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) .'"' : '';
    $attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : '';
    $attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : '';

    //echo $item->url;
    $string = explode('::', $item->url, 3);
    if($string[1]){
    $string[1] = str_replace('-',' ', $string[1] );
    $item->url = do_shortcode("[$string[1]]");
    }

    $attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : '';

    $prepend = '';
    $append = '
    ';
    $description = ! empty( $item->description ) ? ''.esc_attr( $item->description ).'' : '';

    if($depth != 0)
    {
    $description = $append = $prepend = "";
    }

    $item_output = $args->before;
    $item_output .= '';
    $item_output .= $args->link_before .$prepend.apply_filters( 'the_title', $item->title, $item->ID ).$append;
    $item_output .= $description.$args->link_after;
    $item_output .= '
    ';
    $item_output .= $args->after;

    $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
    }
    }

    Then you have to call this function from wp_nav_menu from the templates files.


    $arg = array( 'menu' => "main-menu", 'echo' => true, 'fallback_cb' => 'wp_page_menu', 'depth' => 0, 'walker' => new description_walker() );

    wp_nav_menu( $arg );

    Thats it. Then go to the back-end with menu section.

    For example i want to give the page URL to custom link.

    I will add like this —–> http://::blogurl-id=’1302′::

    That’s All.

    Now you can go to the front-end and check the shortcode will work.

    Thanks.

    Advertisements
  • Joomla password check for wordpress


    Hi to All,

    Today we will see about joomla password check method for wordpress side.

    Normally most of joomla website owners moving to wordpress. Joomla Users Migrating to wordpress users. I think most of the developers did joomla users to wordpress users. Like Firstname, Lastname, username and all information. But when we login from wordpress site, it does not work. So we have to use joomla MD5 password with SALT method. After you migrating the joomla users and wordpress users table. You need to put these code to wordpress includes directory.

    Step 1: You have to open this file – /wp-includes/class-phpass.php. Check the end of the code with function. You have to replace this.

    function CheckPassword($password, $stored_hash)
    {
    $hash = $this->crypt_private($password, $stored_hash);
    if ($hash[0] == '*')
    $hash = crypt($password, $stored_hash);

    return $hash == $stored_hash;
    }

    to replace this code.

    function CheckPassword($password, $stored_hash)
    {
    $password_for_check = $password;
    if( @count( $pass_array = @explode(':',$stored_hash) ) == 2 ){
    $joomla_pass = $pass_array[0];
    $joomla_salt = $pass_array[1];
    if($joomla_pass == md5($password_for_check.$joomla_salt))
    return 1;
    }

    $hash = $this->crypt_private($password, $stored_hash);
    if ($hash[0] == '*')
    $hash = crypt($password, $stored_hash);

    return $hash == $stored_hash;
    }

    Thats it. Now you can login with joomla username and password.

    Before you migrating the joomla users to wordpress users, you have check the wp_users table column password. Because joomla MD5 password length is little high. but wordpress table column password length is too short. You have to increase it.

    Note:
    If we upgrade wordpress, password length again changed to too short. You have to increase the password column limit to 256 varchar.

    That’s ALL. If anything you want to know, please comment here.

    Thank you.

    CS CART Vendor user creation via custom code – Multi Vendor Version


    Hi there,

    Today we will take a look about the user creation via code.

    create a php file what ever you wants from the root of the cs cart folder.


    define('AREA', 'A');
    define('AREA_NAME', 'admin');
    define('ACCOUNT_TYPE', 'admin');
    require dirname(__FILE__) . '/prepare.php';
    require dirname(__FILE__) . '/init.php';
    $user_data['company'] = "Test";
    $user_data['status'] = "D";
    $user_data['company'] = "Test";
    $user_data['lang_code'] = "EN";
    $user_data['commission'] = "";
    $user_data['commission_type'] = "";
    $user_data['email'] = "manisanjai@gmail.com";
    $user_data['phone'] = "9944509663";
    $user_data['url'] = "";
    $user_data['fax'] = "";
    $user_data['address'] = "test, Test street";
    $user_data['country'] = "IN";
    $user_data['state'] = "Tamilnadu";
    $user_data['zipcode'] = "6000028";
    $user_data['company_description'] = "Test Company";
    $user_data['categories'] = "";
    $user_data['shippings'] = '';
    $result = fn_update_company($user_data);
    echo $result; // You can get the results.
    }

    Just copy and paste this code to your php file. Then execute the file from the browser. You can get the result as an array with user id and profile id.

    That’s All.

    I hope it helps some one.

    Thanks.

    CS CART user creation via custom code – Multi Vendor Version


    Hi there,

    Today we will take a look about the user creation via code.

    create a php file what ever you wants from the root of the cs cart folder.


    define('AREA', 'C');
    define('AREA_NAME', 'customer');
    require dirname(__FILE__) . '/prepare.php';
    require dirname(__FILE__) . '/init.php';
    $user_id = $notify_user = $ship_to_another = '';
    $user_data = array( 'email' => 'manisanjai@gmail.com',
    'password1' => '123456',
    'password2' => '123456',
    'birthday' => '14/01/1988',
    'b_firstname' => 'Manimaran',
    'b_lastname' => 'Kalimuthu',
    'b_address' => '25, 2nd street',
    'b_address_2' => 'test',
    'b_city' => 'test',
    'b_country' => 'IN',
    'b_state' => 'Tamilnadu',
    'b_zipcode' => '620008',
    'b_phone' => '12345678',
    'user_type' => 'C'
    );
    $_result = fn_update_user($user_id, $user_data, $auth, $ship_to_another,$notify_user);
    print_r($_result); // You can get an array with profile id and user id.
    }

    Just copy and paste this code to your php file. Then execute the file from the browser. You can get the result as an array with user id and profile id.

    That’s All.

    I hope it helps some one.

    Thanks.

    Get Reviews for a product in magento


    Hi Guys,
    Here i have added some Magento Code for Get reviews collection or Reviews Summary collection data of a Product in Magento CMS. I hope it helps lot for beginners.

    $_reviews = Mage::getModel('review/review')->getCollection()
    ->addStoreFilter(Mage::app()->getStore()->getId())
    ->addStatusFilter('approved')
    ->addEntityFilter('product', $_product->getId())
    ->setDateOrder(); // You can filter the results

    foreach($_reviews as $re){
    print_r($re->getData()); // You can get the results here
    }