Posts

Showing posts from December, 2015

How to disable scroll effect in map html using css and jquery

Below is a sample of code for disable scroll on mouse scroll <style>     .scrolloff {         pointer-events: none;     } </style> <div id="googlemap" class="map">     <iframe id="gmap" src="https://www.google.com/maps/embed/v1/place?key=AIzaSyCjUE83FHrXTQWf9umcNDzyu0s7aNzHszw     &q=Space+Needle,Seattle+WA" width="100%" height="500" frameborder="0" ></iframe> </div> <script>     $(document).ready(function () {         $('#gmap').addClass('scrolloff');                               $('#googlemap').on("mouseup",function(){                     $('#gmap').addClass('scrolloff');                     });         $('#googlemap').on("mousedown",function(){                    $('#gmap').removeClass('scrolloff');         });         $("#gmap").mouseleave(function () {                  

How to allow custom shortcodes in custom widgets or in widgets in wordpress

For allow shortcodes in widgets we need to add 2 filters for render shortcodes. 1). Add below filter for remove auto p tag for widget area.. So our shortcode output will not wrapped by p tag   add_filter( 'widget_text', 'shortcode_unautop');  2) .Below filter will allow widget text to rendor shortcode add_filter( 'widget_text', 'do_shortcode', 11);

How to add a custom menu properties in menu item in wordpress

For add a custom menu properties in menu item just copy and paste below code into your theme's functions.php file or into your custom plugin file and do field's changes according to your need. Here i add a custom menu icon option for menu item. add_filter( 'wp_setup_nav_menu_item', 'rj_add_custom_nav_fields' );         // save menu custom fields add_action( 'wp_update_nav_menu_item',  'rj_update_custom_nav_fields', 10, 3 ); // edit menu walker add_filter( 'wp_edit_nav_menu_walker',  'rj_edit_walker', 10, 2 ); function rj_add_custom_nav_fields( $menu_item ) {             $menu_item->icon = get_post_meta( $menu_item->ID, '_menu_item_icon', true );         return $menu_item; } function rj_update_custom_nav_fields( $menu_id, $menu_item_db_id, $args ) {      // Check if element is properly sent         if ( is_array( $_REQUEST['menu-item-icon']) ) {             $icon_value = $_REQUEST['menu-item-icon'

How to backup wordpress database without phpmyadmin using php code

Just copy below code and run this code to take a backup of your website . <?php require 'wp-load.php'; global $wpdb;         $tables = $wpdb->get_results( 'SHOW TABLES', ARRAY_N );         $return = '';         foreach ( $tables as $table ) {             $num_fields = sizeof( $wpdb->get_results( 'DESCRIBE `' . $table[0] . '`;' ) );             $return .= 'DROP TABLE IF EXISTS `' . $table[0] . '`;';             $row2 = $wpdb->get_row( 'SHOW CREATE TABLE `' . $table[0] . '`;', ARRAY_N );             $return .= PHP_EOL . PHP_EOL . $row2[1] . ";" . PHP_EOL . PHP_EOL;                             $result = $wpdb->get_results( 'SELECT * FROM `' . $table[0] . '`;', ARRAY_N );                 foreach ( $result as $row ) {                     $return .= 'INSERT INTO `' . $table[0] . '` VALUES(';                     for ( $j = 0; $j < $num_fields; $j ++ ) {