Skip to content

Instantly share code, notes, and snippets.

View pagelab's full-sized avatar
🚀

Márcio Duarte pagelab

🚀
View GitHub Profile
@jchristopher
jchristopher / gist:1739212
Created February 4, 2012 17:57
Our final Image of the Month WordPress Widget
<?php
// we can only use this Widget if the plugin is active
if( class_exists( 'WidgetImageField' ) )
add_action( 'widgets_init', create_function( '', "register_widget( 'ITI_Widget_Image_OTM' );" ) );
class ITI_Widget_Image_OTM extends WP_Widget
{
var $image_field = 'image'; // the image field ID
@djekl
djekl / download_file.php
Created November 1, 2012 17:30
Simple PHP download script. Can be adapted to include SQL code for download analytics etc.
<?php
function output_file($file, $name, $mime_type='')
{
/*
This function takes a path to a file to output ($file),
the filename that the browser will see ($name) and
the MIME type of the file ($mime_type, optional).
If you want to do something on download abort/finish,
@plasticmind
plasticmind / gist:4282236
Created December 14, 2012 02:51
Hash Cache
function my_load_meta() {
$script = '/js/script.js';
wp_enqueue_script( 'my-tools', get_template_directory_uri().$script, null, my_version_hash($script) );
$stylesheet = '/style.css';
wp_enqueue_style( 'my-style', get_template_directory_uri().$stylesheet, null, my_version_hash($stylesheet) );
}
add_action('wp_enqueue_scripts', 'my_load_meta');
// Create a hash of the file and pass it back for caching purposes
function my_version_hash($file) {
@Shelob9
Shelob9 / bad.htm
Last active December 19, 2015 03:49
Adding WordPress to Foundation, the right and wrong ways.
<script>
document.write('<script src=/js/vendor/'
+ ('__proto__' in {} ? 'zepto' : 'jquery')
+ '.js><\/script>');
</script>
<script src="/js/foundation.min.js"></script>
<script>
$(document).foundation();
</script>
@robmccormack
robmccormack / mrm_fav_hotkeys.md
Last active December 19, 2015 10:19
mrm_Favorite_Hotkeys - hotkeys and quick tips.
@awestmoreland
awestmoreland / base64-web-font-embed-code
Created August 8, 2013 07:18
Geoff Evason's method of embedding base64-encoded web fonts into CSS file to circumvent CORS in Firefox. http://geoff.evason.name/2010/05/03/cross-domain-workaround-for-font-face-and-firefox https://github.com/geoffevason
@font-face {
font-family: 'MyFontFamily';
src: url('myfont-webfont.eot?') format('embedded-opentype');
}
@font-face {
font-family: 'MyFontFamily';
url(data:font/truetype;charset=utf-8;base64,BASE64_ENCODED_DATA_HERE) format('truetype'),
url(data:font/woff;charset=utf-8;base64,BASE64_ENCODED_DATA_HERE) format('woff'),
url('myfont-webfont.svg#svgFontName') format('svg');
@wpspeak
wpspeak / functions.php
Created August 23, 2013 14:25
Reposition Genesis Comment Form
<?php
// Reposition Genesis Comment Form
add_action( 'genesis_before_comments' , 'wps_post_type_check' );
function wps_post_type_check () {
if ( is_single() ) {
if ( have_comments() ) {
remove_action( 'genesis_comment_form', 'genesis_do_comment_form' );
add_action( 'genesis_list_comments', 'genesis_do_comment_form' , 5 );
@wpspeak
wpspeak / functions.php
Last active December 21, 2015 16:59 — forked from christophercochran/Genesis Layout Logic
Conditionally force layout in Genesis Framework
<?php
/**
* Conditionally force layout in Genesis Framework
*/
function cc_layout_logic() {
/**
* Genesis layout helper functions.
* __genesis_return_content_sidebar
* __genesis_return_sidebar_content
@Vheissu
Vheissu / functions.php
Created October 22, 2012 02:36
Bundling the Advanced Custom Fields plugin into a theme using the TGM Plugin Class
add_action( 'tgmpa_register', 'register_required_plugins' );
// This function is called from the above hook
function register_required_plugins()
{
// The plugins array allows us to define multiple plugins we want to include.
// The commented out example shows how we can include and activation a bundled
// plugin zip file in our theme.
$plugins = array(
/* array(
@chadothompson
chadothompson / wordpress-csv-export.php
Created July 24, 2013 14:33
Exporting WordPress post types, titles and URLs in a CSV format.
<?php
/*
export.php - a script for outputting post type, title and URL in CSV format.
All commas are also stripped from titles in order to keep the CSV format (for HootSuite import) versus keeping the titles as is.
*/
include "wp-load.php";
$posts = new WP_Query('post_type=any&posts_per_page=-1&post_status=publish');