Skip to content

Instantly share code, notes, and snippets.

View sethrubenstein's full-sized avatar

Seth Rubenstein sethrubenstein

View GitHub Profile
@sethrubenstein
sethrubenstein / gist:9487249
Last active August 29, 2015 13:57
Social Tools & Widget
<?php
/**
* Suite of tools and actions for social media
*
*/
$facebook_app_id = '1411050029147291';
function social_tools($tool) {
$twitter_count = get_post_meta( get_the_ID(), "_tweet_count", true );
$facebook_count = get_post_meta( get_the_ID(), "_facebook_count", true );
@sethrubenstein
sethrubenstein / map_embed.html
Created March 12, 2014 17:22
New Google Maps Embed API Iframe
<iframe width="600" height="450" frameborder="0" style="border:0" src="https://www.google.com/maps/embed/v1/place?q=ESCAPED&ADDRESS&HERE&key=AIzaSyAVp82PapI7DK5xUxD-OHN7HqirLMDDKa4"></iframe>
p:first-child:first-letter { float: left; color: #903; font-size: 75px; line-height: 60px; padding-top: 4px; padding-right: 8px; padding-left: 3px; font-family: Georgia; }
@sethrubenstein
sethrubenstein / searchform.php
Created April 26, 2014 22:30
Proper WordPress Search Box
<?php
/**
* Theme Default Search Box
*/
?>
<form role="search" method="get" id="searchform" action="<?php echo home_url( '/' ); ?>">
<div id="searchsubmit" class="dashicons dashicons-search" /></div>
<input type="search" value="" name="s" id="s" placeholder="Search"/>
<input type="submit" id="submitsearch" value=""/>
<script>
<?php
/**
* On an early action hook, check if the hook is scheduled - if not, schedule it.
*/
function prefix_setup_schedule() {
if ( ! wp_next_scheduled( 'prefix_hourly_event' ) ) {
wp_schedule_event( time(), 'hourly', 'prefix_hourly_event');
}
}
@sethrubenstein
sethrubenstein / get_youtube_id.php
Created July 17, 2014 19:44
Get The Youtube ID from a Youtube URL in the contents of a WordPress Post
<?php
function catch_youtube_url() {
global $post, $posts;
ob_start();
ob_end_clean();
$youtube_url = '/https?:\/\/(?:www\.)?youtu(?:\.be|be\.com)\/watch(?:\?(.*?)&|\?)v=([a-zA-Z0-9_\-]+)(\S*)/i';
$url = preg_match($youtube_url, $post->post_content, $matches);
@sethrubenstein
sethrubenstein / gist:2abe3b3237c8b812f298
Created August 18, 2014 15:42
The proper way on publish_post hook to ensure your function is only running once on the actual publishing
$_POST['post_status'] == 'publish' && $_POST['original_post_status'] != 'publish'
@sethrubenstein
sethrubenstein / search-by-date.php
Created August 27, 2014 18:11
Make SearchWP return results by date rather than relevance. Place this in your theme's functions.php file.
<?php
// This will make the search return results ordered by date rather than relevance.
add_filter( 'searchwp_return_orderby_date', '__return_true' );
@sethrubenstein
sethrubenstein / woocommerce-mobile-forms.css
Created September 1, 2014 23:07
Make WooCommerce Forms More Mobile Responsive
/* START Make the cart table responsive */
/* http://css-tricks.com/responsive-data-tables/ */
@media screen and (max-width: 600px) {
/* Force table to not be like tables anymore */
.woocommerce-page table.shop_table,
.woocommerce-page table.shop_table thead,
.woocommerce-page table.shop_table tbody,
.woocommerce-page table.shop_table th,
<?php
/*
* Converts CSV to JSON
* Example uses Google Spreadsheet CSV feed
* csvToArray function I think I found on php.net
*/
header('Content-type: application/json');
// Set your CSV feed