Skip to content

Instantly share code, notes, and snippets.

View ashleycam3ron's full-sized avatar

Ashley N Cameron ashleycam3ron

View GitHub Profile
@cogentParadigm
cogentParadigm / wordpress.php
Created March 20, 2010 03:33
Automated Wordpress Installer
#!/usr/bin/php
<?php
$usage = "Automated Wordpress installer\nby Ali Gangji\nUsage: wordpress install_dir -u dbuser -p dbpass -d dbname\nOptions:\n";
$usage .= " -u dbuser Database username\n";
$usage .= " -p dbpass Database password\n";
$usage .= " -d dbname Database name\n";
$usage .= " -h dbhost Database host\n";
$usage .= " --private Hide blog from search engines\n";
$usage .= " --prefix prefix Database prefix\n";
if ($argc < 2) {
@ScottPhillips
ScottPhillips / .htaccess
Created February 2, 2012 04:30
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@BronsonQuick
BronsonQuick / loop_through_post_attachments.php
Created March 4, 2012 06:56
A WordPress loop to display post/page attachments
<?php /*
* This is just a simple loop to display 7 attachments attached to a post or page in WordPress
* You can change 'medium' and 'thumbnail' to add sizes you have definied in your theme by the add_image_size function
* in WordPress
*/
?>
<div id="thumbs" class="pic_list">
<ul class="thumbs">
<?php /* Time to create a new loop that pulls out the first 7 image attachments for this post */
$args = array( 'post_type' => 'attachment', 'numberposts' => 7, 'post_status' => null, 'post_parent' => $post->ID );
@jonathanmoore
jonathanmoore / gist:2640302
Created May 8, 2012 23:17
Get the share counts from various APIs

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

@v9n
v9n / Get object taxonomy of a custom post type.php
Created May 9, 2013 18:12
It's easy to get a list of taxonomy. wp_get_post_terms, get_term_list,..do the job. However, in the case you don't know the taxonomy name, then here is the code to find out it. This is take from WordPress core file. Meaning the function we need is: get_object_taxonomies
<?php
function get_post_taxonomies($post) {
// Passing an object
// Why another var?? $output = 'objects'; // name / objects
$taxonomies = get_object_taxonomies($post, 'objects');
/*// Passing a string using get_post_type: return (string) post, page, custom...
$post_type = get_post_type($post);
$taxonomies = get_object_taxonomies($post_type, 'objects');*/
@bMinaise
bMinaise / gf-mpnav.php
Created October 18, 2013 19:03
Multi-Page Navigation Steps Gravity Forms https://gist.github.com/spivurno/
<?php
/**
* Multi-page Navigation
* http://gravitywiz.com/
*/
class GWMultipageNavigation {
private $script_displayed;
<div id="multiscroll">
<div class="ms-left">
<div class="ms-section">Section 1 left</div>
<div class="ms-section">Section 2 left</div>
<div class="ms-section">Section 3 left</div>
</div>
<div class="ms-right">
<div class="ms-section">Section 1 right</div>
<div class="ms-section">Section 2 right</div>
<div class="ms-section">Section 3 right</div>
@daronspence
daronspence / Front End Registration Form with ACF Fields
Last active February 3, 2020 15:24
Register front end form ACF wordpress
<?php if( !is_user_logged_in() ) : ?>
<form action="<?php echo site_url('wp-login.php?action=register', 'login_post') ?>" method="post">
<input type="text" name="user_login" value="Username" id="user_login" class="input" />
<input type="text" name="user_email" value="E-Mail" id="user_email" class="input" />
<?php do_action('register_form'); ?>
<input type="submit" value="Register" id="register" />
</form>
<?php else : echo 'You are already logged in.'; endif; ?>
@lukecav
lukecav / functions.php
Created November 11, 2016 21:45
Expire posts to draft using a datepicker field in ACF
// Expire events
if ($expireTransient = get_transient($post->ID) === false) {
set_transient($post->ID, 'set for 1 minutes', 1 * MINUTE_IN_SECONDS );
$today = date('Y-m-d H:i:s', current_time('timestamp', 0));
$args = array(
'post_type' => 'events',
'posts_per_page' => 200,
'post_status' => 'publish',
'meta_query' => array(
array(