This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from nameparser import HumanName | |
import pandas as pd | |
def parse_names_from_file(input_file_path, output_file_path): | |
# Read the names from a file | |
with open(input_file_path, 'r') as file: | |
names = file.read().splitlines() | |
# Parse the names using the nameparser library | |
parsed_names = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import re | |
import json | |
# Directory containing the JSON files | |
json_dir = '/path/to/dir' | |
urls_file_path = '/path/to/urls.txt' | |
with open(urls_file_path, 'r') as file: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ADD USER ROLE BASED ON PRODUCT ID */ | |
function change_role_on_purchase($order_id) { | |
$order = new WC_Order($order_id); | |
$items = $order->get_items(); | |
foreach ($items as $item) { | |
$product_name = $item['name']; | |
$product_id = $item['product_id']; | |
$product_variation_id = $item['variation_id']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* DISPLAY AVATAR & USER SHORTCODE - CONDITIONAL */ | |
function display_current_user_shortcode() | |
{ | |
global $current_user; | |
$user = wp_get_current_user(); | |
$avatar = get_avatar($current_user->ID, 32, '', '', $args = array('class' => 'rounded-circle')); | |
$custom_avatar = get_avatar('https://url-to-custom-avatar.webp'); | |
$first = $user->user_firstname; | |
$display = $user->display_name; | |
$email = $user->user_email; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ADD AVATAR/USER MENU ITEM */ | |
add_filter( 'wp_nav_menu_objects', 'my_dynamic_menu_items', 10 ); | |
function my_dynamic_menu_items( $menu_items ) { | |
foreach ( $menu_items as $menu_item ) { | |
if ( strpos($menu_item->title, '#profile_name#') !== false) { | |
$menu_item->title = str_replace("#profile_name#", wp_get_current_user()->user_login .' '. get_avatar( wp_get_current_user()->user_email, 50), $menu_item->title); | |
} | |
} | |
return $menu_items; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# inspired by https://gist.github.com/rjnienaber/af47fccb8410926ba7ea35f96c3b87fd | |
# remove bundled ImageMagick | |
sudo apt remove imagemagick -y | |
# install base dependencies | |
sudo apt-get install -y \ | |
libde265-dev \ | |
libdjvulibre-dev \ | |
libfftw3-dev \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* REPLACE EXISTING AVATAR CLASS */ | |
add_filter('get_avatar','change_avatar_css'); | |
function change_avatar_css($class) { | |
$class = str_replace('class="avatar avatar-96', 'class="avatar-225 rounded-circle', $class); | |
return $class; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* WOO MEMBERSHIPS TABLE SHORTCODE - WITH HEADER */ | |
function ploa_woo_memberships_shortcode() { | |
if (!function_exists('wc_memberships') || is_admin()) { | |
return; | |
} | |
ob_start(); | |
?> | |
<div class="woocommerce"> | |
<h2><?php esc_html_e('My Membership', 'textdomain'); ?></h2> | |
<?php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* WOO CHANGE RETURN TO SHOP MESSAGE */ | |
add_filter('gettext', 'ploa_translate_woocommerce_strings', 999, 3); | |
function ploa_translate_woocommerce_strings($translated, $untranslated, $domain) { | |
if (!is_admin() && 'woocommerce' === $domain) { | |
switch ($translated) { | |
case 'Return to shop': | |
$translated = 'Return to awards area.'; | |
break; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* WOOCOMMERCE CHANGE MYACCOUNT TO LOGIN */ | |
add_filter('wp_nav_menu_items', 'dynamic_menu_item_label', 9999, 2); | |
function dynamic_menu_item_label($items, $args) { | |
if (!is_user_logged_in()) { | |
$items = str_replace("My Account", "Login", $items); | |
} | |
return $items; | |
} |
NewerOlder