Skip to content

Instantly share code, notes, and snippets.

View ioniacob's full-sized avatar
🐌
Exploring the code is like life itself.

Ion Iacob ioniacob

🐌
Exploring the code is like life itself.
View GitHub Profile
@ioniacob
ioniacob / gist:c7dd4254292c18506aee05704419d6d8
Created November 11, 2016 23:45 — forked from corsonr/gist:7839908
Automatically add product to cart on visit - WooCommerce
/*
* Add item to cart on visit
*/
function add_product_to_cart() {
if ( ! is_admin() ) {
global $woocommerce;
$product_id = 64;
$found = false;
//check if product already in cart
if ( sizeof( $woocommerce->cart->get_cart() ) > 0 ) {
@evrpress
evrpress / Add user to list after click on link
Last active February 27, 2017 09:58
Assigns a subscriber to a certain list if a certain link has been clicked
<!--
Via: http://stackoverflow.com/questions/400212/how-do-i-copy-to-the-clipboard-in-javascript
-->
<textarea class="js-copytextarea">Hello I'm some text</textarea>
<button class="js-textareacopybtn">Copy Text</button>
<script>
@sc0ttkclark
sc0ttkclark / add-product-to-cart.php
Last active March 5, 2020 08:28 — forked from kloon/gist:2376300
WooCommerce Automatically add product to cart on site visit
<?php
/*
* This code goes into theme functions.php or a custom plugin
*/
/**
* Add product to cart on page load
*/
function add_product_to_cart() {
/**
* Block Negative Balances
* Stop users from logging into your website if they have a negative
* myCRED balance.
* @version 1.0
*/
add_filter( 'authenticate', 'mycred_block_negative_balances', 990, 3 );
function mycred_block_negative_balances( $user, $username, $password ) {
// Make sure myCRED is installed
/**
* Insert Comment Appreciation
* Lets insert the mycred_send shortcode after the comment
* text if a user can afford to use it (and is logged in.
* @version 1.0.1
*/
add_filter( 'comment_text', 'my_custom_comment_text', 10, 2 );
function my_custom_comment_text( $comment_text, $comment = NULL ) {
// Make sure the current user is logged in
@amdrew
amdrew / affiliate-info.php
Last active May 22, 2022 20:54
AffiliateWP - Affiliate Info. Retrieve affiliate information via PHP function calls
<?php
$info = affiliatewp_affiliate_info()->functions;
$name = $info->get_affiliate_name();
$email = $info->get_affiliate_email();
$website = $info->get_affiliate_website();
$bio = $info->get_affiliate_bio();
$gravatar = $info->get_affiliate_gravatar();
$twitter = $info->get_twitter_username();
@ioniacob
ioniacob / Wordpress functions.php
Last active September 12, 2015 18:47
Personal Wordpress functions.php
// Additional Functions
// =============================================================================
add_action( 'affwp_process_register_form', 'affwp_custom_process_register_form' );
/* Auto enables the "Enable New Referral Notifications" checkbox on the "Settings" tab of the affiliate area when an affiliate is added. */
function affwp_custom_auto_enable_affiliate_referral_notifications( $add ) {
update_user_meta( affwp_get_affiliate_user_id( $add ), 'affwp_referral_notifications', true );
}
add_action( 'affwp_insert_affiliate', 'affwp_custom_auto_enable_affiliate_referral_notifications' );
/** Adds a log out link to the top of the affiliate area */
@escopecz
escopecz / commands.php
Last active April 18, 2023 22:43 — forked from alanhartless/cron.php
Script to run Mautic (https://mautic.org) commands from a URL.
<?php
if (!isset($_GET['ILoveMauticReallyIDo'])) {
echo 'The secret phrase is wrong.';
die;
}
$link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$allowedTasks = array(
'cache:clear',
@ultimatemember
ultimatemember / gist:643cd90967e5e415378d
Last active June 20, 2020 21:32
Custom profile tab example: showing user pages
/* add a custom tab to show user pages */
add_filter('um_profile_tabs', 'pages_tab', 1000 );
function pages_tab( $tabs ) {
$tabs['pages'] = array(
'name' => 'Pages',
'icon' => 'um-faicon-pencil',
'custom' => true
);
return $tabs;
}