Skip to content

Instantly share code, notes, and snippets.

View finallyRaunak's full-sized avatar
💻
Writing Useless commit messages

Raunak Gupta finallyRaunak

💻
Writing Useless commit messages
View GitHub Profile
@finallyRaunak
finallyRaunak / resume.json
Last active November 15, 2020 13:35
resume.json (test)
{
"basics": {
"name": "Himanshi Gupta",
"label": "Account Executive",
"image": "",
"summary": "An Accounts Executive with work experience of three years looking forward to pursuing a higher role in the field of audit and accounting. To work in a highly challenging and competitive environment where I would be able to explore my abilities and hence contribute to the best of myself towards the growth of the organization as well as myself.",
"email": "[email protected]",
"phone": "+91-896-227-4042",
"location": {
"address": "16B Gopal Chandra Mukherjee Road.",
@finallyRaunak
finallyRaunak / order_report_1.sql
Last active March 16, 2017 07:57
Get WooCommerce Get Order ID by Product/Post ID or Product SKU
SELECT p.ID AS order_id,
p.post_date AS order_date,
woi.order_item_name AS product_title,
woim.meta_key
FROM wp_posts AS p
INNER JOIN wp_woocommerce_order_items AS woi ON p.ID = woi.order_id
INNER JOIN wp_woocommerce_order_itemmeta AS woim ON woi.order_item_id = woim.order_item_id
WHERE p.post_type = 'shop_order'
AND p.post_status IN ('wc-completed', 'wc-processing', 'wc-on-hold')
AND woim.meta_key = '_product_id'
@finallyRaunak
finallyRaunak / new_gist_file.php
Last active September 18, 2019 14:09
How To add custom column in WooCommerce product listing backend page.
//_related_ids => a:4:{i:0;i:2462;i:1;i:2466;i:2;i:2469;i:3;i:2472;}
//manage_product_posts_custom_column
add_filter('manage_edit-product_columns', 'related_product_col');
function related_product_col($columns) {
$new_columns = (is_array($columns)) ? $columns : array();
$new_columns['RELATED'] = 'Related Product';
return $new_columns;
}
@finallyRaunak
finallyRaunak / db-backup-script.sh
Last active November 6, 2016 11:34
Shell script to take a database backup.
#!/bin/sh
#----------------------------------------------------
# MySQL Database backup script; which the created file to an another server.
# Created on: 28 Oct, 2016.
# Version: 2
#----------------------------------------------------
FILE=/home/username/public_html/backup_dir/my_db_file.sql.`date +"%Y%m%d"`
# (1) set up all the mysqldump variables
DBSERVER=db_host
DATABASE=db_name
@finallyRaunak
finallyRaunak / redirect-wp-post.php
Created October 27, 2016 14:30
Redirects wordpress posts to new url: site.com/blog/post-name
<?php
/**
* Add new rewrite rule
*/
function create_new_url_querystring() {
add_rewrite_rule(
'blog/([^/]*)$',
'index.php?name=$matches[1]',
'top'
);
@finallyRaunak
finallyRaunak / new_gist_file.php
Last active November 2, 2016 18:53
WordPress delete media on post/page/product deletion
<?php
function delete_associated_media($id) {
$media = get_children(array(
'post_type' => 'attachment',
'post_parent' => $id,
'post_status' => 'inherit',
//'post_mime_type' => 'image/jpeg',
'numberposts' => -1
@finallyRaunak
finallyRaunak / new_gist_file.php
Created October 27, 2016 12:32
Adding .active class to active menu item
<?php
add_filter('nav_menu_css_class' , 'special_nav_class' , 10 , 2);
function special_nav_class($classes, $item){
if( in_array('current-menu-item', $classes) ){
$classes[] = 'active ';
}
return $classes;
}
@finallyRaunak
finallyRaunak / wp_get_attachment.php
Created October 27, 2016 11:32
Get attachment details by id
<?php
function wp_get_attachment( $attachment_id ) {
$attachment = get_post( $attachment_id );
return array(
'alt' => get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ),
'caption' => $attachment->post_excerpt,
'description' => $attachment->post_content,
'href' => get_permalink( $attachment->ID ),
@finallyRaunak
finallyRaunak / new_gist_file.php
Created October 27, 2016 11:28
To add custom post_types in search result of wordpress.
<?php
//to include search result
function searchfilter($query) {
if ($query->is_search && !is_admin() ) {
$query->set('post_type',array('post','page', 'readers-corners', 'todays-facts'));
}
return $query;
}
@finallyRaunak
finallyRaunak / wp-head-tag-remove.php
Created October 27, 2016 11:26
Remove auto generated head tags.
<?php
//Remove WooCommerce Generator Tag in Version 2.1.0+
function remove_woo_commerce_generator_tag()
{
remove_action('wp_head','wc_generator_tag');
}
add_action('get_header','remove_woo_commerce_generator_tag');
//Remove WP Generator Meta Info: