Skip to content

Instantly share code, notes, and snippets.

@wp126
wp126 / function.php
Created September 2, 2022 05:40
Send forcefully email to woocommerce on status changed
add_action( 'woocommerce_order_status_split-order', 'bbloomer_status_custom_notificationa', 20, 2 );
function bbloomer_status_custom_notificationa( $order_id, $order ) {
$mailer = WC()->mailer()->get_emails();
$mailer['wc_order_status_email_107387']->trigger( $order_id );
}
@wp126
wp126 / function.php
Created August 29, 2022 05:06
Create Situations in BuddyPress Email
<?php
/**
* Plugin Name: Run Action User
* Description:
* Version: 1.0
* Copyright: 2022
* Text Domain: run-action-user
* Domain Path: /languages
*/
@wp126
wp126 / index.py
Last active August 24, 2022 12:39
Convert Csv to Json in Python
import csv
import json
# Function to convert a CSV to JSON
# Takes the file paths as arguments
def make_json(csvFilePath, jsonFilePath):
# create a dictionary
data = {}
@wp126
wp126 / function.php
Created August 5, 2022 10:59
create custom post type
<?php
function create_posttype() {
register_post_type( 'movies',
// CPT Options
array(
'labels' => array(
'name' => __( 'Movies' ),
'singular_name' => __( 'Movie' )
),
@wp126
wp126 / base64tomedia.php
Last active September 21, 2022 09:22
Upload a base64 string as image to the WordPress media library
function save_image( $base64_img, $title ) {
require_once( ABSPATH . 'wp-admin/includes/image.php' );
// Upload dir.
$upload_dir = wp_upload_dir();
$upload_path = str_replace( '/', DIRECTORY_SEPARATOR, $upload_dir['path'] ) . DIRECTORY_SEPARATOR;
$img = str_replace( 'data:image/png;base64,', '', $base64_img );
$img = str_replace( ' ', '+', $img );
$decoded = base64_decode( $img );