Skip to content

Instantly share code, notes, and snippets.

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

George Tsiokos geotsiokos

🏠
Working from home
View GitHub Profile
@geotsiokos
geotsiokos / gist:643e76be168b86e350ddb0690b8ed871
Created June 23, 2017 13:24
Referring Affiliate's avatar - example shortcode
add_action( 'init', 'referring_affiliate_avatar_shortcode' );
function referring_affiliate_avatar_shortcode() {
add_shortcode( 'referring-affiliate-avatar', 'referring_affiliate_avatar' );
}
function referring_affiliate_avatar( $atts ) {
$output = '';
if ( !is_admin() ) {
if ( !class_exists( "Affiliates_Service" ) ) {
include_once( AFFILIATES_CORE_LIB . '/class-affiliates-service.php' );
$affiliate_id = Affiliates_Service::get_referrer_id();
add_filter( 'affiliates_new_affiliate_user_registration_message', 'example_user_registration_message', 10, 2 );
function example_user_registration_message( $message, $params ) {
$message = 'Write here whatever you prefer your user should read in the welcome email.';
$message .= 'User info can be found in the params array, like user object, username, user_id';
return $message;
}
add_filter( 'groups_import_export_new_user_registration_subject', 'example_groups_import_export_new_user_registration_subject', 10, 3 );
function example_groups_import_export_new_user_registration_subject( $subject, $user_id, $plaintext_pass ) {
$subject = 'Here you can add whatever you like to display as subject, in the notification mail a user receives for his new account';
return $subject;
}
add_filter( 'groups_import_export_new_user_registration_message', 'example_groups_import_export_new_user_registration_message', 10, 3 );
function example_groups_import_export_new_user_registration_message( $message, $user_id, $plaintext_pass ) {
$message = 'Here you can add whatever you like to display as message, in the notification mail a user receives for his new account';
@geotsiokos
geotsiokos / archive_sm_options.desktop
Last active May 27, 2018 17:15
An example to add options like extract, extract to folder and compress to the Service Menu of Konqueror file manager for KDE. Works with KDE, Konqueror 4.x.x and ark.
[Desktop Entry]
Type=Service
ServiceTypes=KonqPopupMenu/Plugin
MimeType=application/octet-stream;inode/directory
Actions=extract;extractTo;compress
[Desktop Action extract]
Name=Extract Here
Icon=ark
Exec=ark --batch %f
add_filter( 'affiliates_notifications_tokens', 'example_affiliates_notifications_tokens' );
function example_affiliates_notifications_tokens( $tokens ) {
$tokens['your_token_name'] = 'your_token_value';
return $tokens;
}
add_filter( 'affiliates_supported_currencies', 'example_affiliates_supported_currencies' );
function example_affiliates_supported_currencies( $currencies ) {
$currencies[] = 'INR';
return $currencies;
}
add_action( 'woocommerce_after_account_downloads', 'example_woocommerce_after_account_downloads' );
function example_woocommerce_after_account_downloads() {
if (
class_exists( 'Groups_Group' ) &&
class_exists( 'Groups_User_Group' )
) {
$group_ids = Groups_Group::get_group_ids();
$user_id = get_current_user_id();
foreach ( $group_ids as $group_id ) {
if ( Groups_User_Group::read( $user_id, $group_id ) ) {
function my_affiliates_permanent_my_users( $atts ){
$output = "";
if ( is_user_logged_in() ) {
$user = wp_get_current_user();
$args = array(
'meta_key' => Affiliates_Permanent::REFERRER,
'meta_value' => $user->ID
);
$users = get_users( $args );
@geotsiokos
geotsiokos / gist:9c31282bba00efa97145676d2c5dbfd4
Created October 12, 2019 11:26
Modify "Thanks for signing up!" message for new affiliate registrations
add_filter( 'affiliates_thanks_sign_up_text', 'example_affiliates_thanks_sign_up_text' );
function example_affiliates_thanks_sign_up_text( $text ) {
// the default text is this:
$text = '<p>' . esc_html__( 'Thanks for signing up!', 'affiliates' ) . '</p>';
return $text;
}
@geotsiokos
geotsiokos / functions.php
Created November 4, 2019 16:46
Display referring affiliate id in a column when visiting shop orders in WP back-end
add_filter( 'manage_edit-shop_order_columns', 'custom_shop_order_column', 20 );
function custom_shop_order_column($columns) {
$reordered_columns = array();
// Inserting columns to a specific location
foreach( $columns as $key => $column){
$reordered_columns[$key] = $column;
if ( $key == 'order_status' ) {
// Inserting after "Status" column
$reordered_columns['my-column1'] = esc_html( 'Referrer' );