Skip to content

Instantly share code, notes, and snippets.

View ravinderk's full-sized avatar

Ravinder Kumar ravinderk

View GitHub Profile
@ravinderk
ravinderk / dynamic_image_resize.php
Created August 26, 2015 17:04
This function use to generate image of different sizes dynamically in wordpress.
if( ! function_exists( 'goorin_resize_image' ) ) :
/**
* Generate image dynamically
*
* @param $post_id
* @param $attachment_id
* @param $filename_suffix
* @param null $width
* @param null $height
@ravinderk
ravinderk / gravity_form_tabindex.php
Created July 31, 2015 11:18
Gravity form same page tabindex problem
/**
* Custom tabindex for gravity form
*/
add_filter( 'gform_tabindex', function( $tabindex, $form ) {
$starting_index = 50;
return GFCommon::$tab_index >= $starting_index ? GFCommon::$tab_index : $starting_index;
}, 999, 2 );
@ravinderk
ravinderk / array_partition.php
Created July 7, 2015 05:48
Partition array into equal parts
/**
*
* @param Array $list
* @param int $p
* @return multitype:multitype:
* @link http://www.php.net/manual/en/function.array-chunk.php#75022
*/
function partition(Array $list, $p) {
$listlen = count($list);
$partlen = floor($listlen / $p);
@ravinderk
ravinderk / wp-config.php
Created June 27, 2015 06:53
wp-config.php file for wordpress
<?php
/**
* The base configurations of the WordPress.
*
* This file has the following configurations: MySQL settings, Table Prefix,
* Secret Keys, WordPress Language, and ABSPATH. You can find more information by
* visiting {@link http://codex.wordpress.org/Editing_wp-config.php Editing
* wp-config.php} Codex page. You can get the MySQL settings from your web host.
*
add_action( 'wp_footer', 'ravs_test' );
function ravs_test(){
$included_files = get_included_files();
$stylesheet_dir = str_replace( '\\', '/', get_stylesheet_directory() );
$template_dir = str_replace( '\\', '/', get_template_directory() );
foreach ( $included_files as $key => $path ) {
$path = str_replace( '\\', '/', $path );
@ravinderk
ravinderk / iframe.php
Last active September 2, 2015 14:31
generate iframe for vimeo and youtube video link
if ( ! class_exists( 'Video_Handler' ) ) :
/**
* This is using for show in video from online video sevices like youtube, wistia, vimeo.
*/
class Video_Handler {
/**
* Get iframe from youtube video url
*
@ravinderk
ravinderk / create_user
Last active August 29, 2015 14:22
create user in database with sql
INSERT INTO `wp_users` (`ID`, `user_login`, `user_pass`, `user_nicename`, `user_email`, `user_url`, `user_registered`, `user_activation_key`, `user_status`, `display_name`) VALUES ('5', 'anattadesign', MD5('Secure2015!'), 'Anatta Design', 'nirav@anattadesign.com', 'http://www.anattadesign.com/', '2015-06-07 00:00:00', '', '0', 'Anatta Design');
INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '5', 'wp_capabilities', 'a:1:{s:13:"administrator";b:1;}');
INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '5', 'wp_user_level', '10');
@ravinderk
ravinderk / shortcode_list.php
Created June 4, 2015 14:57
Get all shortcodes list used on wordpres websote inside post content
add_action( 'wp_footer', 'get_shortcode_list' );
function get_shortcode_list(){
set_time_limit(0);
global $wpdb;
$post_ids = $wpdb->get_results("SELECT ID FROM $wpdb->posts WHERE post_type != 'attachment'", ARRAY_N );
$ids = array();
foreach( $post_ids as $post_id ){
$ids[] = $post_id[0];
}
/*** Start Editig From Below **/
jQuery(document).ready( function( $ ){
//get list items which has sub menu
var dropdown_menu = jQuery('li.menu-item-has-children ');
dropdown_menu.click(function(e){
e.preventDefault();
e.stopPropagation();