Skip to content

Instantly share code, notes, and snippets.

View tharlab's full-sized avatar
💭
I may be slow to respond.

Hary AK tharlab

💭
I may be slow to respond.
  • TharLab
  • east java
View GitHub Profile
@tharlab
tharlab / create-woocommerce-order-dynamically.php
Created December 12, 2023 02:34 — forked from corsonr/create-woocommerce-order-dynamically.php
Create a WooCommerce Order Dynamically
<?php
/*
* Create order dynamically
*/
add_action( 'woocommerce_before_checkout_form', 'create_order' );
function create_order() {
global $woocommerce;
@tharlab
tharlab / gist:437084a25c0c966cdfb40cc3e5669cf9
Created May 5, 2023 15:23 — forked from markjaquith/gist:6225805
WordPress multi-tenant directory structure sharing core files for opcode awesomeness, fast deployments, and low disk usage. With inspiration from @weskoop. "=>" indicates a symlink.
sites
|__ ms.dev
| |__ content
| |__ index.php
| |__ wp => ../../wordpress/stable
| |__ wp-config.php
|__ one.dev
| |__ content
| |__ index.php
| |__ wp => ../../wordpress/stable
@tharlab
tharlab / wc-redirect-after-add-to-cart.php
Created May 20, 2022 15:12 — forked from JeroenSormani/wc-redirect-after-add-to-cart.php
WooCommerce redirect after add to cart
/**
* Redirect to checkout at add-to-cart action.
*/
function redirect_to_checkout() {
return WC()->cart->get_checkout_url();
}
add_filter( 'woocommerce_add_to_cart_redirect', 'redirect_to_checkout' );
------------------------------------
@tharlab
tharlab / refund_order.php
Created February 17, 2021 11:57 — forked from igorbenic/refund_order.php
How to Create WooCommerce Refunds Programmatically | ibenic.com/how-to-create-woocommerce-refunds-programmatically
<?php
/**
* Process Order Refund through Code
* @return WC_Order_Refund|WP_Error
*/
function ibenic_wc_refund_order( $order_id, $refund_reason = '' ) {
$order = wc_get_order( $order_id );
// IF it's something else such as a WC_Order_Refund, we don't want that.
@tharlab
tharlab / mycred-exclude-user-filter-example1
Created December 14, 2020 16:24 — forked from mycred/mycred-exclude-user-filter-example1
Example 1: Exclude users with the subscriber role in WordPress from using myCRED.
/**
* Exclude Subscribers
* @mycred
* @version 1.0
*/
add_filter( 'mycred_exclude_user', 'mycredpro_exclude_wp_subscribers', 10, 2 );
function mycredpro_exclude_wp_subscribers( $exclude, $user_id ) {
// Exclude subscribers
if ( ! user_can( $user_id, 'edit_posts' ) ) return true;
@tharlab
tharlab / imageProxy.php
Created August 2, 2020 13:00 — forked from carloscarucce/imageProxy.php
basic PHP image proxy (that works ... )
<?php
$url = isset($_GET['url']) ? $_GET['url'] : null;
if (!$url) {
die('Please, inform URL');
}
$imgInfo = getimagesize( $url );
Download Google Drive files with WGET
Example Google Drive download link:
https://docs.google.com/open?id=[ID]
To download the file with WGET you need to use this link:
https://googledrive.com/host/[ID]
Example WGET command:
@tharlab
tharlab / gist:7095c95448eb574861268608d1755550
Created January 29, 2020 01:13 — forked from sbrajesh/gist:cc37e8794527f86046e1d880490d974b
BuddyPress Private Message Rate Limiter, Role based customization
/**
* Get the applicable limit for the given role.
*
* @param string $role role name.
*
* @return array
*/
function buddydev_custom_get_role_based_message_limit( $role ) {
@tharlab
tharlab / wpcom-cdn.php
Created December 6, 2019 03:06 — forked from Volnus/wpcom-cdn.php
Use the WP.com Photon image CDN without installing JetPack
<?php
/**
* Plugin Name: Photon CDN
* Version: 1.3
* Description: Use the WP.com Photon image CDN without installing JetPack
* Author: Scott Hartley
* Credit: Original by Zachary Scott
*/
namespace zacscott;
@tharlab
tharlab / bp-profile-tab-and-subnav.php
Created September 13, 2019 08:22 — forked from shanebp/bp-profile-tab-and-subnav.php
BuddyPress add profile tab and subnav
function add_animal_tabs() {
global $bp;
bp_core_new_nav_item( array(
'name' => 'Animals',
'slug' => 'animals',
'parent_url' => $bp->displayed_user->domain,
'parent_slug' => $bp->profile->slug,
'screen_function' => 'animals_screen',
'position' => 200,