Skip to content

Instantly share code, notes, and snippets.

Michael Dorchain mdorchain

  • Philipppines
Block or report user

Report or block mdorchain

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ChrisFlannagan
ChrisFlannagan / geodistance.php
Created Oct 13, 2017
Calculate distance between to coordinates of latitude and longitude using the WP REST API and return posts ordered by distance from user's coordinates
View geodistance.php
<?php
/**
* Heavily borrowed from: http://xplus3.net/2010/08/08/filtering-on-a-non-standard-database-field-with-wordpress/
**/
class CoordinatesTable extends DB {
protected $db_option = "coordinates_db";
@bekarice
bekarice / registration-order-link-for-woocommerce.php
Last active Sep 16, 2019
Automatically link previous orders to new WooCommerce customer accounts upon registration
View registration-order-link-for-woocommerce.php
@glueckpress
glueckpress / wp-rocket-affiliatewp-cookies-cache.php
Last active Mar 26, 2019
[WordPress][WP Rocket] Creates cached files based on dynamic cookies for AffiliateWP. (WP Rocket 2.7+ required.)
View wp-rocket-affiliatewp-cookies-cache.php
<?php
/**
* Plugin Name: WP Rocket | AffiliateWP Cookie Cache
* Description: Creates a specific cache for each affiliate ref ID.
* Author: WP Rocket Support Team
* Author URI: http://wp-rocket.me/
* Plugin URI: https://gist.github.com/glueckpress/d379c5534708f440942523fe205ec840
* License: GNU General Public License v3 or later
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*/
@mathetos
mathetos / plugin.php
Last active Nov 16, 2019
Dependent Plugin Activation/Deactivation and Alert
View plugin.php
<?php
/*
* Dependent Plugin Activation/Deactivation
*
* Sources:
* 1. https://pippinsplugins.com/checking-dependent-plugin-active/
* 2. http://10up.com/blog/2012/wordpress-plug-in-self-deactivation/
*
*/
@scottopolis
scottopolis / thumbnail-featured-url-wp-api.php
Last active Apr 10, 2016
Add post thumbnail (featured image) url to WP-API response
View thumbnail-featured-url-wp-api.php
@scottopolis
scottopolis / wp-api-user-meta.php
Last active Aug 18, 2019
Add user meta to the WP-API
View wp-api-user-meta.php
<?php
/* Adds all user meta to the /wp-json/wp/v2/user/[id] endpoint */
function sb_user_meta( $data, $field_name, $request ) {
if( $data['id'] ){
$user_meta = get_user_meta( $data['id'] );
}
if ( !$user_meta ) {
return new WP_Error( 'No user meta found', 'No user meta found', array( 'status' => 404 ) );
}
@scottopolis
scottopolis / wp-api-custom-taxonomies.php
Created Oct 27, 2015
Add custom taxonomies to the WP-API
View wp-api-custom-taxonomies.php
<?php
function ms_add_tax_to_api() {
$taxonomies = get_taxonomies( '', 'objects' );
foreach( $taxonomies as $taxonomy ) {
$taxonomy->show_in_rest = true;
}
}
add_action( 'init', 'ms_add_tax_to_api', 30 );
@ultimatemember
ultimatemember / gist:08c7f3369f49021cb749
Last active Apr 4, 2018
How to stop registration using Ultimate Member action hooks
View gist:08c7f3369f49021cb749
/*
You need to hook into um_submit_form_errors_hook with a
priority over 10.
You can stop registration here if the customer_code field does not
match the value you want "ALLOWED_VALUE" in this example
*/
You can’t perform that action at this time.