Skip to content

Instantly share code, notes, and snippets.

View cliffordp's full-sized avatar

Clifford cliffordp

View GitHub Profile
@josetapadas
josetapadas / gist:e5ce791bb5c87d7039f7
Created July 2, 2014 09:53
Simple Google Maps API JavaScript implementation
var google_map = {}
window.googleMapInitialize = function() {
var $map_address = $('#map-address');
var map_options = {
zoom: 17,
};
google_map = {
@ellenmva
ellenmva / my-registered-post-type-handler.php
Created September 12, 2014 21:37
Change registered_post_type $args
<?php
add_action('registered_post_type', 'my_registered_post_type_handler', 10, 2);
function my_registered_post_type_handler($post_type, $args) {
do_action("my_registered_{$post_type}_post_type", $post_type, $args);
}
// Replace foo with your post type slug
add_action('my_registered_foo_post_type', 'my_registered_foo_post_type_handler', 10, 2);
function my_registered_foo_post_type_handler($post_type, $args) {
@cyberhobo
cyberhobo / functions.php
Last active August 29, 2015 14:08
WordPress hook to geocode Gravity Forms fields for Geo Mashup
<?php
/**
* Example WordPress hook to geocode Gravity Forms fields for Geo Mashup.
*
* This example uses a form ID of 2, replace _2 with your form ID,
* 'address' and 'zip' with your Gravity Forms field names, and prefix
* with your unique namespace prefix.
*/
add_action( 'gform_after_submission_2' 'prefix_gform_after_submission_2', 10, 2 );
@myphpmaster
myphpmaster / convert-UNIX-timestamp.js
Last active August 29, 2015 14:10 — forked from kmaida/convert-UNIX-timestamp.js
Convert UNIX timestamp to local time with timezone UTC+/- code
function convertTimestamp(timestamp) {
var d = new Date(timestamp * 1000), // Convert the passed timestamp to milliseconds
yyyy = d.getFullYear(),
mm = ('0' + (d.getMonth() + 1)).slice(-2), // Months are zero based. Add leading 0.
dd = ('0' + d.getDate()).slice(-2), // Add leading 0.
hh = d.getHours(),
h = hh,
min = ('0' + d.getMinutes()).slice(-2), // Add leading 0.
ampm = 'AM',
time;
<?php
/*
Seperate Woocommerce reviews from comments and make a reviews moderation panel.
*/
class PL_Woo_Review_Mods {
function __construct() {
add_action( 'current_screen', array( $this, 'check_current_page' ), 10, 2 );
add_action( 'admin_menu', array( $this, 'add_product_reviews' ) );
}
function check_current_page( $screen ) {
<?php
function compiler_action( $options, $css, $changed_values ) {
$keys = array(
'header_color',
'header_footer_color'
);
$compile = false;
foreach ( $changed_values as $key => $value ) {
if ( in_array( $key, $keys ) ) {
@nickkoskowski
nickkoskowski / gist:2fb00a84b2be7f91cb30
Last active August 29, 2015 14:27
Get a random post link from WP database using query
<?php
function get_random_post_link() {
$args = array(
'orderby' => 'rand',
'posts_per_page' => '1',
);
$wp_query = new WP_Query( $args );
if ( $wp_query->have_posts() ) : while ( $wp_query->have_posts() ) : $wp_query->the_post();
@elimn
elimn / tribe_custom_theme_text.php
Last active September 17, 2015 18:23
MT | TEC | Change the wording of any bit of text in WordPress
<?php
/*
* EXAMPLE OF CHANGING ANY TEXT (STRING) IN THE EVENTS CALENDAR
* See the codex to learn more about WP text domains:
* http://codex.wordpress.org/Translating_WordPress#Localization_Technology
* Example Tribe domains: 'tribe-events-calendar', 'tribe-events-calendar-pro'...
*/
function tribe_custom_theme_text ( $translations, $text, $domain ) {
@elimn
elimn / tribe_related_posts_args_limiter.php
Last active September 22, 2015 19:25
MT | TEC | Limits Related Posts to events within 2 months of event date
@norcross
norcross / rkv_date_convert
Created April 1, 2012 17:20
Convert date entry to UNIX timestamp
// Make two admin-only fields (as text fields)
// and post to the custom fields from Gravity Forms
// instead of the "real" date picker.
// NOTE: change the input IDs to match the ones on your form
function rkv_datesubmit_fix ($form){
//event start date field id is 3
//event end date field ID is 4
$raw_srt = $_POST['input_3'];
$raw_end = $_POST['input_4'];