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
@ramiabraham
ramiabraham / affwp-url-referral-var-shortcode.php
Last active February 16, 2021 17:10
AffiliateWP Custom Referral URL
<?php
/*
Plugin Name: AffiliateWP Custom Referral URL
Plugin URI: http://affiliatewp.com
Description: Adds AffiliateWP Custom Referral URL
Version: 0.1
License: GPL
Author: AffiliateWP
*/

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter

@nadeem-khan
nadeem-khan / change-role-based-on-balance.md
Last active February 6, 2016 20:04 — forked from gabrielmerovingi/change-role-based-on-balance
Change WordPress user role based on Mycred Points

Change WordPress user role based on Mycred Points:

add_filter( 'mycred_add', 'check_for_role_change', 99, 3 );
 function check_for_role_change( $reply, $request, $mycred ) {
// Make sure that if any other filter has declined this we also decline
if ( $reply === false ) return $reply;

// Exclude admins
if ( user_can( $request['user_id'], 'manage_options' ) ) return $reply;
@gabrielmerovingi
gabrielmerovingi / change-role-based-on-balance
Last active July 26, 2017 11:20
Change a users WordPress role based on their current myCRED balance.
/**
* Promote Based on Balance
* Changes a users role based on their myCRED balance.
* @version 1.0.4
*/
add_filter( 'mycred_add_finished', 'check_for_role_change', 99, 3 );
function check_for_role_change( $reply, $request, $mycred ) {
// Make sure that if any other filter has declined this we also decline
if ( $reply === false ) return $reply;
@RafaelFunchal
RafaelFunchal / MailPoet: Redirect After Submit
Last active February 16, 2018 21:54
Redirects to a custom link after submits the subscription form
<script>
(function($){
$(document).ready(function(){
$( 'form.widget_wysija' ).submit(function(e){
e.preventDefault();
setTimeout(function() {
var msg = $( '.wysija-msg' );
if( msg.text() !== '' ){
window.location.replace( 'http://your_thank_you_page_url' );
}
<div class="row">
<div class="col-lg-6">
<?php
echo $this->Form->create($x->createModel(), $x->options());
echo $this->Form->inputs($fields->inputs(), $nulll, fields->options());
$buttons = $x->buttons();
foreach($buttons as $button) {
echo $this->Form->submit($button->name(), $button->options());
@WebEndevSnippets
WebEndevSnippets / functions.php
Created March 3, 2014 19:50
Gravity Forms: Auto login to site after GF User Registration Form Submittal
add_action( 'gform_user_registered','we_autologin_gfregistration', 10, 4 );
/**
* Auto login to site after GF User Registration Form Submittal
*
*/
function we_autologin_gfregistration( $user_id, $config, $entry, $password ) {
wp_set_auth_cookie( $user_id, false, '' );
}
@DevinWalker
DevinWalker / woocommerce-optimize-scripts.php
Last active March 24, 2025 13:09
Only load WooCommerce scripts on shop pages and checkout + cart
/**
* Optimize WooCommerce Scripts
* Remove WooCommerce Generator tag, styles, and scripts from non WooCommerce pages.
*/
add_action( 'wp_enqueue_scripts', 'child_manage_woocommerce_styles', 99 );
function child_manage_woocommerce_styles() {
//remove generator meta tag
remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) );
@woogist
woogist / gist:5934881
Created July 5, 2013 14:23
Automatically add product to cart on visit depending on cart total value
/*
* goes in theme functions.php or a custom plugin
**/
// add item to cart on visit depending on cart total value
add_action( 'init', 'add_product_to_cart' );
function add_product_to_cart() {
if ( ! is_admin() ) {
global $woocommerce;
$product_id = 2831;
$found = false;
@xcommerce-gists
xcommerce-gists / Test HTML code.html
Created September 20, 2012 20:10
How to Test PayPal Payments Standard Buttons.html
<!DOCTYPE html>
<html lang=en>
<head>
<meta charset=utf-8>
<title>Testing a PayPal Payments Standard Button</title>
</head>
<body>
<h2>Buy Strings!</h2>