Skip to content

Instantly share code, notes, and snippets.

@noameppel
noameppel / getMediumData.php
Last active September 26, 2019 01:56
Standalone PHP script to fetch latest Medium Posts
<?php
function getMediumData()
{
$handle = curl_init();
$url = "https://api.rss2json.com/v1/api.json?rss_url=https%3A%2F%2Fmedium.com%2Ffeed%2Fmorpheus-network";
// Set the url
curl_setopt($handle, CURLOPT_URL, $url);
// Set the result output to be a string.
@noameppel
noameppel / memberpress-add-remove-roles.php
Last active June 5, 2017 04:38
MemberPress Add/Remove Roles
<?php
/*
* [csnnaa_remove_additional_roles]
* Remove additional role when transaction is created/edited/expires
*/
function csnnaa_remove_additional_roles($roles, $wp_user)
{
$mepr_user = new MeprUser($wp_user->ID);
$active = $mepr_user->active_product_subscriptions('ids');
@noameppel
noameppel / wp_options_chart.php
Created December 6, 2016 13:02
Charts the number of options in the wp_options table using autoload.
<?php
// Version 1.0
// Author Noam Eppel noam@cleanforest.co
// Related: https://pressjitsu.com/blog/optimizing-wp-options-for-speed/
//
// Requires jquery.canvasjs.min.js from http://canvasjs.com/download-html5-charting-graphing-library/
// Hello WP. Update the path to the wp-load.php file.
require_once '../wp-load.php';
@noameppel
noameppel / memberpress_mailchimp_mergetags.php
Last active June 8, 2021 05:38
Hooks in to MemberPress $args array before sending new member info to MailChimp.
<?php
/**
* [cleanforest_mepr_add_my_tags]
* Hooks in to MemberPress $args array before sending new member info to MailChimp.
* Used to add custom MERGETAG information.
*/
function cleanforest_mepr_add_my_tags($args, $contact)
{
// MMERGE3 State
$state = get_user_meta($contact->ID, 'mepr-address-state', true);
@noameppel
noameppel / display_user_application_form.php
Created August 20, 2015 03:50
Searches GravityForm Entries. Uses get_entries()
<?php
/**
* [display_user_application_form]
* Searches GravityForm Entries. Uses get_entries()
* Will display form results where do_action( 'form-display', $arg = '' ); is in the template.
* https://www.gravityhelp.com/documentation/article/api-functions/#get_entries
*/
function display_user_application_form() {
$search_criteria = array(
'status' => 'active',
@noameppel
noameppel / package.json
Created March 3, 2015 16:09
Sample package.json
{
"frontend": {
"name": "name",
"stylesheets": "scss",
"javascripts": "js"
},
"name": "grunt-with-node-sass",
"version": "0.9.5",
"devDependencies": {
"bower-move": "^1.0.1",
@noameppel
noameppel / Gruntfile.js
Created March 3, 2015 16:08
Sample Gruntfile.js
module.exports = function(grunt) {
// Load multiple grunt tasks using globbing patterns
// This module will read the dependencies/devDependencies/peerDependencies in
// the package.json and load grunt tasks that match the provided patterns.
// Load all grunt tasks:
require('load-grunt-tasks')(grunt);
var PathConfig = require('./grunt-settings.js');
@noameppel
noameppel / wp_custom_registration_fields.php
Last active August 29, 2015 14:03
Add custom fields (First name, Last name) to the WordPress registration form.
<?php
/**
* Custom Login Fields
*/
// Add a new form elements
add_action('register_form','custom_register_form');
function custom_register_form (){
@noameppel
noameppel / cfs-edd-custom-discount.php
Created June 3, 2014 20:02
Allows Easy Digital Downloads discount codes to be passed via URL.
<?php
/**
Plugin Name: CFS EDD Custom Discount
Plugin URI: http://cleanforest.co
Description: Allows EDD discount codes to be passed via URL.
Author: Noam Eppel
Version: 0.99
Author URI: http://cleanforest.co
License: GNU General Public License (Version 2 - GPLv2)
*/
@noameppel
noameppel / dev-server-media-files.php
Created April 2, 2014 20:00
Any media file not on development server will be loaded from live server.
<?php add_action('init', 'my_replace_image_urls' );
function my_replace_image_urls() {
if ( defined('WP_SITEURL') && defined('LIVE_SITEURL') ) {
if ( WP_SITEURL != LIVE_SITEURL ){
add_filter('wp_get_attachment_url', 'my_wp_get_attachment_url', 10, 2 );
}
}
}
function my_wp_get_attachment_url( $url, $post_id) {