Skip to content

Instantly share code, notes, and snippets.

View nickdavis's full-sized avatar

Nick Davis nickdavis

View GitHub Profile
@imjasonh
imjasonh / markdown.css
Last active January 3, 2025 20:15
Render Markdown as unrendered Markdown (see http://jsbin.com/huwosomawo)
* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
}
@seedprod
seedprod / gist:7de2027ad32e1a5ee8d9
Last active December 20, 2017 18:44
Replace HelpScout Docs default Contact Us link, add menu item and custom styles, example at http://support.seedprod.com
<!-- Replace default Contact Us url in HelpScout Docs with custom url and add a My Account link to the top menu -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(function() {
$("#contact a,#sbContact,#sbContactMobile, #contactMobile a").attr("href", "https://app.sellwp.co/seedprod/ticket").text('Open a Ticket');
$( "#mainNav .nav" ).append( "<li><a href='http://www.seedprod.com/members'>My Account</a></li>" );
});
</script>
<!-- SeedProd.com custom styles -->
@m1r0
m1r0 / wp_insert_attachment_from_url.php
Last active August 1, 2024 04:14
WP: Insert attachment from URL
<?php
/**
* Insert an attachment from a URL address.
*
* @param string $url The URL address.
* @param int|null $parent_post_id The parent post ID (Optional).
* @return int|false The attachment ID on success. False on failure.
*/
function wp_insert_attachment_from_url( $url, $parent_post_id = null ) {
<?php
/**
* EA Genesis Child.
*
* @package EAGenesisChild
* @since 1.0.0
* @copyright Copyright (c) 2014, Contributors to EA Genesis Child project
* @license GPL-2.0+
*/
@thomasgriffin
thomasgriffin / gist:74156ddc84489e6c79a5
Created August 14, 2014 13:24
Add custom field link to featured content slider in Soliloquy.
<?php
add_filter( 'soliloquy_output_item_data', 'tgm_soliloquy_custom_image_link', 10, 3 );
function tgm_soliloquy_custom_taxonomy_text( $item, $id, $data, $i ) {
// If not the slider you want to target, return.
if ( 324 !== $data['id'] ) {
return $item;
}
// Since this is a FC slider, $id will be the post ID for the item.
<?php
// Repeater field called 'be_section' with 'title' and 'description' subfields
$sections = get_post_meta( get_the_ID(), 'be_section', true );
for( $i = 0; $i < $sections; $i++ ) {
$title = esc_html( get_post_meta( get_the_ID(), 'be_section_' . $i . '_title', true );
$description = get_post_meta( get_the_ID(), 'be_section_' . $i . '_description', true );
echo '<div class="section"><h2>' . $title . '</h2>' . wpautop( $description ) . '</div>';
}
@fabrizim
fabrizim / acf-customizer-patch.php
Last active January 17, 2024 02:30
Plugin to allow for Advanced Custom Fields to be used in widgets within the Customizer
<?php
/*
Plugin Name: ACF Customizer Patch
Plugin URI: https://gist.github.com/fabrizim/9c0f36365f20705f7f73
Description: A class to allow acf widget fields to be stored with normal widget settings and allow for use in customizer.
Author: Mark Fabrizio
Version: 1.0
Author URI: http://owlwatch.com/
*/
class acf_customizer_patch
@siteoptimo
siteoptimo / WP_User_Query Order by RAND
Last active November 8, 2022 19:34
This will allow to order a wordpress user query by random.
<?php
// put this in your functions.php
add_filter('pre_user_query', function(&$query) {
if($query->query_vars["orderby"] == 'rand') {
$query->query_orderby = 'ORDER by RAND()';
}
});
// Query will look like this:
$args = array('orderby' => 'rand', 'number' => 5);
@amdrew
amdrew / gist:8816385
Created February 5, 2014 02:18
Easy Digital Downloads - Auto Register. Let the user define password
<?php
/*
Plugin Name: Easy Digital Downloads - Auto Register - Extend
Plugin URI: http://sumobi.com/shop/edd-auto-register/
Description: Extends the functionality of Auto Register
Version: 1.0
Author: Andrew Munro, Sumobi
Author URI: http://sumobi.com/
License: GPL-2.0+
License URI: http://www.opensource.org/licenses/gpl-license.php
@thomasgriffin
thomasgriffin / gist:8011487
Created December 17, 2013 19:53
Append a final slide to Dynamic sliders (assuming that the gallery is tied to a post ID and not using a custom ID).
<?php
add_filter( 'tgmsp_dynamic_individual_slide', 'tgm_soliloquy_add_custom_slides', 10, 4 );
function tgm_soliloquy_add_custom_slides( $slider, $id, $image, $i ) {
// Append custom slides to the end of the slider.
if ( ($i-1) == count( get_children( array( 'post_parent' => $id ) ) ) ) :
// If you want more than one image, just copy and paste the code below as many times as you need.
$slider .= '<li class="soliloquy-item">';
$slider .= '<img class="soliloquy-item-image" src="http://cdn.soliloquywp.com/wp-content/uploads/2012/02/fast.jpg" title="your image title" alt="your alt text" />';
$slider .= '<div class="soliloquy-caption">';