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.

  • 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
    }

    Magento – a foreign key constraint fails when reindex


    Just execute the query in the database.
    SET FOREIGN_KEY_CHECKS = 0;
    TRUNCATE TABLE `catalog_product_bundle_option`;
    TRUNCATE TABLE `catalog_product_bundle_option_value`;
    TRUNCATE TABLE `catalog_product_bundle_selection`;
    TRUNCATE TABLE `catalog_product_entity_datetime`;
    TRUNCATE TABLE `catalog_product_entity_decimal`;
    TRUNCATE TABLE `catalog_product_entity_gallery`;
    TRUNCATE TABLE `catalog_product_entity_int`;
    TRUNCATE TABLE `catalog_product_entity_media_gallery`;
    TRUNCATE TABLE `catalog_product_entity_media_gallery_value`;
    TRUNCATE TABLE `catalog_product_entity_text`;
    TRUNCATE TABLE `catalog_product_entity_tier_price`;
    TRUNCATE TABLE `catalog_product_entity_varchar`;
    TRUNCATE TABLE `catalog_product_link`;
    TRUNCATE TABLE `catalog_product_link_attribute`;
    TRUNCATE TABLE `catalog_product_link_attribute_decimal`;
    TRUNCATE TABLE `catalog_product_link_attribute_int`;
    TRUNCATE TABLE `catalog_product_link_attribute_varchar`;
    TRUNCATE TABLE `catalog_product_link_type`;
    TRUNCATE TABLE `catalog_product_option`;
    TRUNCATE TABLE `catalog_product_option_price`;
    TRUNCATE TABLE `catalog_product_option_title`;
    TRUNCATE TABLE `catalog_product_option_type_price`;
    TRUNCATE TABLE `catalog_product_option_type_title`;
    TRUNCATE TABLE `catalog_product_option_type_value`;
    TRUNCATE TABLE `catalog_product_super_attribute_label`;
    TRUNCATE TABLE `catalog_product_super_attribute_pricing`;
    TRUNCATE TABLE `catalog_product_super_attribute`;
    TRUNCATE TABLE `catalog_product_super_link`;
    TRUNCATE TABLE `catalog_product_enabled_index`;
    TRUNCATE TABLE `catalog_product_website`;
    TRUNCATE TABLE `catalog_category_product_index`;
    TRUNCATE TABLE `catalog_category_product`;
    TRUNCATE TABLE `cataloginventory_stock_item`;
    TRUNCATE TABLE `cataloginventory_stock_status`;
    TRUNCATE TABLE `cataloginventory_stock`;
    INSERT INTO `catalog_product_link_type`(`link_type_id`,`code`) VALUES (1,'relation'),(2,'bundle'),(3,'super'),(4,'up_sell'),(5,'cross_sell');
    INSERT INTO `catalog_product_link_attribute`(`product_link_attribute_id`,`link_type_id`,`product_link_attribute_code`,`data_type`) VALUES (1,2,'qty','decimal'),(2,1,'position','int'),(3,4,'position','int'),(4,5,'position','int'),(6,1,'qty','decimal'),(7,3,'position','int'),(8,3,'qty','decimal');
    INSERT INTO `cataloginventory_stock`(`stock_id`,`stock_name`) VALUES (1,'Default');
    TRUNCATE TABLE `catalog_product_entity`;
    SET FOREIGN_KEY_CHECKS = 1;

    get the logged user id in magento


    Hi Guys,
    Here is the information for magento logged in users data.
    Just paste this code to your magento template files or php files too.

    echo Mage::helper('customer')->getCustomer()->getId();
    print_r(Mage::helper('customer')->getCustomer()->getData());
    echo Mage::getSingleton('customer/session')->getCustomer()->getId();

    Why PHP Better than ASP???


    PHP, [www.php.net], while loosely based on C and Perl, has never faced the overwhelming complications ASP has. PHP is an object oriented language – though scripts need not necessarily be developed that way (there are still a vast number of developers preferring procedural programming, and PHP caters to both schools). PHP is both cross platform and open source, available for every major operating system and works with most web servers. It is easily extendable by anyone capable of coding in C, and comes pre-bundled with more functionality than ASP could ever offer. Simple capabilities, such as FTP, data compression, file uploads, XML, MD5, encryption and email are not included in ASP and require expensive, third-party packages to be installed. All of this functionality and more are built right into PHP. Complex functions such as dynamic images, IMAP, SNMP, dynamic flash, PDF, native access (non ODBC) to Oracle, Ovrimos, Postgre, Sybase, mySql, MSSQL, Ingres, Interbase and Informix databases, LDAP, and sockets, just to name a few, are available for free to any installation of PHP, but are not (and probably never will be) available with ASP. In addition, one could make the point that PHP is a more mature language than ASP. ASP has only been around since 1996; PHP has been around since 1994, and has a huge base of developers working on it every waking minute of every day; bugs are usually fixed within minutes of being reported and new features are being integrated daily.

    1) ASP is significantly slower than PHP, for obvious reasons. Primarily, PHP runs on notoriously fast Unix and Linux servers which have for years outpaced Windows running on comparable hardware. ASP does not run on any operating system other than Windows, and even then, only in IIS and PWS. I could discuss countless reasons why IIS makes a terrible web server, but that would be a discussion all on it’s own. PHP runs on almost any web server, on almost any platform. I have even built a web server in PHP which was capable of executing PHP scripts.

    2) ASP natively supports only Access and MSSQL, whereas PHP natively supports a huge number of databases. They both support ODBC equally well. MySQL is a database that PHP closely integrates with; it is a very powerful database that rivals Oracle in speed. Like PHP, MySQL is free, and blows most other databases out of the water. Another hidden cost with ASP is the database angle; Microsoft expects you to develop using Access and when your webpage outgrows it, to switch to MSSQL, an extremely expensive option.

    3) While even the best software has glitches, PHP has notoriously few. The PHP development team has an outstanding reputation for fixing bugs, and in order to streamline the process they even have an online system through which new bug reports can be submitted. Most bugs are resolved within 24 hours, and I’m speaking from experience here. There are a huge number of outstanding bugs in ASP which will probably never be fixed. Unless you’re a major corporation, chances are that your bug report to Microsoft will likely go unanswered.

    4) And finally, cost. PHP is free. ASP isn’t free. If you want to use ASP, you have to use IIS, and if you want to use IIS, you have to buy Windows. Traditionally, the cost of Windows has been high. Microsoft has been aggressively trying to reduce this factor but they’re hardly going to give Windows away for free. The cost of running an ASP-based website implies a full Windows server platform; development costs are higher, software licenses are expensive and speed, security and flexibility are all sacrificed.
    There’s a reason that Unix and Linux are dominant in the server market; money, security and performance all speak volumes.