Skip to content

Instantly share code, notes, and snippets.

View raftaar1191's full-sized avatar
🏠
Working from home

Deepak Gupta raftaar1191

🏠
Working from home
View GitHub Profile
@raftaar1191
raftaar1191 / command-line
Created June 11, 2021 06:59
Move GIT comment, tag and branch from 1 repo to another
https://stackoverflow.com/questions/8538362/how-do-i-move-a-git-repo-from-beanstalk-to-github
# In this example, we use an external account named extuser and
# a GitHub account named ghuser to transfer repo.git
@raftaar1191
raftaar1191 / functions.php
Last active April 28, 2021 10:03
Change the Donation Receipt text in Receipt page of GiveWP
/**
* Call before the Donation Receipt text is display
*/
function give_custom_give_payment_receipt_header_before_callback() {
add_filter( 'gettext', 'child_give_text_switcher', 10, 3 );
}
add_action( 'give_payment_receipt_header_before', 'give_custom_give_payment_receipt_header_before_callback' );
// if ( isset( $_GET['debug123'] ) ) {
function bb_track_log( $end = false ) {
static $starttime;
if ( ! $end ) {
$starttime = time();
register_shutdown_function(
function() {
bb_track_log( true );
}
@raftaar1191
raftaar1191 / functions.php
Created July 2, 2020 04:33
Woo Subscription Update Download permissions
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
/**
* Set the schedule action hook for update the permission
*/
function file_update_permission_as_schedule_recurring_action( $product_id, $new_download_ids ) {
@raftaar1191
raftaar1191 / functions.php
Created May 19, 2020 14:54
ACF allow file upload from froutend
function bb_theme_giveaway_edit_posts_callback( $capabilities ) {
if ( is_page( 'giveaway' ) || ( ! empty( $_SERVER ) && ! empty( $_SERVER['HTTP_REFERER'] ) && strpos( $_SERVER['HTTP_REFERER'], '/giveaway/' ) !== false ) ) {
$capabilities['upload_files'] = 1;
$capabilities['edit_posts'] = 1;
$capabilities['edit_post'] = 1;
$capabilities['edit_published_posts'] = 1;
}
return $capabilities;
@raftaar1191
raftaar1191 / functions.php
Created May 11, 2020 09:54
ACF custom required field message
function bbdfy_acf_require_custom_message( $field ) {
acf_render_field_setting(
$field,
array(
'label' => __( 'Custom Error Message', 'acf' ),
'instructions' => __( 'Error Message to display when feidls is require and not submitted.', 'acf' ),
'type' => 'textarea',
'name' => 'custom_error_message',
'rows' => 5,
),
@raftaar1191
raftaar1191 / .aliases
Created February 3, 2020 10:07
aliases that are loaded in OM ZSH
# πŸ“– WP CLI Auto Completion
# autoload bashcompinit
# bashcompinit
# source ~/wp-completion.bash
# πŸ“Œ Helpers
alias reload_alias="source ~/.zshrc"
alias edit_zsh="code ~/.zshrc"
alias edit_alias="code ~/.aliases"
alias edit_hosts="code /etc/hosts"
@raftaar1191
raftaar1191 / functions.php
Created January 27, 2020 08:14
Filter to Sort CPT via taxonomies in CPT DashBoard area
/**
* Add filter in the CPT
*/
function CPT_filter_by_taxonomies( $post_type, $which ) {
// Apply this only on a specific post type
if ( 'CPT' !== $post_type ) {
return;
}
@raftaar1191
raftaar1191 / my.sql
Created December 17, 2019 11:17
Delete all the shop_subscription, Licences and Orders and Users
DELETE FROM wp_postmeta where post_id IN (SELECT ID from wp_posts where post_type = 'shop_subscription' );
DELETE FROM wp_comments where comment_post_ID IN (SELECT ID from wp_posts where post_type = 'shop_subscription' );
DELETE from wp_posts where post_type = 'shop_subscription'
@raftaar1191
raftaar1191 / custom-woocommerce-weebhook.php
Last active December 12, 2019 08:08
Custom WooCommerce Webhook
<?php
/**
* Plugin Name: Custom WooCommerce Webhook
* Plugin URI: https://raftaar1191.com/
* Description: This plugin provided a demo of Custom WooCommerce Webhook
* Author: raftaar1191
* Author URI: https://profiles.wordpress.org/raftaar1191/
* Version: 1.0.0
*/