Skip to content

Instantly share code, notes, and snippets.

<?php
/*
Plugin Name: WordPress Importer
Plugin URI: http://wordpress.org/extend/plugins/wordpress-importer/
Description: Import posts, pages, comments, custom fields, categories, tags and more from a WordPress export file.
Author: wordpressdotorg
Author URI: http://wordpress.org/
Version: 0.6.1
Text Domain: wordpress-importer
License: GPL version 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
@cfxd
cfxd / gulp_module_installation
Last active January 29, 2019 20:04
Gulpfile and module installation for UnCSS + Gulp + Sage 8.3.0
$ npm install gulp-uncss gulp-exec --save-dev
<?php
function create_date_column_for_issues($issue_columns) {
$issue_columns['date'] = 'Date';
return $issue_columns;
}
add_filter('manage_edit-issue_columns', 'create_date_column_for_issues');
@cfxd
cfxd / sync
Last active July 15, 2018 02:07
Database sync Ansible playbook run with ansible-playbook sync.yml -i hosts/sync -e "src=development dest=staging site=cfx"
[development]
127.0.0.1 ansible_ssh_port=2222 ansible_ssh_private_key_file=/Users/cfx/Sites/trellis/.vagrant/machines/default/virtualbox/private_key
[staging]
my-staging.com
@cfxd
cfxd / gist:9ddbba4607ceec5a2a2e
Last active February 2, 2021 10:02
Install The CSS3 Font Converter (http://www.useragentman.com/blog/the-css3-font-converter/) on OS X Yosemite for on demand @font-face conversion on the command line. Also see http://cfxdesign.com/css3-font-converter-is-a-command-line-font-face-converter
1. $ brew install fontforge ttf2eot ttfautohint
2. $ brew tap bramstein/webfonttools && brew install sfnt2woff
3. Download/clone https://github.com/google/woff2 into any handy dir
cd into dir and:
$ git submodule init
$ git submodule update
$ make clean all
then:
@cfxd
cfxd / restrict_media_library_by_width.php
Created March 8, 2015 16:24
Restrict the WordPress Media Library selection modal to images of a certain width (or by any other metadata). See http://wordpress.stackexchange.com/questions/180500/filter-media-library-items-by-size/
function restrict_media_library_by_width($query) {
$include = array();
$exclude = array();
$temp_query = new WP_Query($query);
if($temp_query->have_posts()) {
while($temp_query->have_posts()) {
$temp_query->the_post();
$meta = wp_get_attachment_metadata(get_the_ID());
$meta['mime-type'] = get_post_mime_type(get_the_ID());
if(isset($meta['mime-type']) &&
@cfxd
cfxd / gf_make_submit_input_into_a_button_element.php
Last active August 29, 2015 14:16
Change Gravity Forms <input> into a <button> while preserving attributes and custom submit text.
function gf_make_submit_input_into_a_button_element($button_input, $form) {
preg_match("/<input([^\/>]*)(\s\/)*>/", $button_input, $button_match);
$button_atts = str_replace("value='".$form['button']['text']."' ", "", $button_match[1]);
return '<button '.$button_atts.'>'.$form['button']['text'].'<i class="fa fa-refresh"></i></button>';
}
add_filter('gform_submit_button', 'gf_make_submit_input_into_a_button_element', 10, 2);
@cfxd
cfxd / _select2.less
Last active August 29, 2015 14:13
Select2 LESS for Select2 3.5.2, Bootstrap 3.x and Roots theme. See http://discourse.roots.io/t/adding-a-library-without-less-files/2760
.select2-container {
margin: 0;
position: relative;
display: inline-block;
/* inline-block for ie7 */
zoom: 1;
*display: inline;
vertical-align: middle;
padding-right: 8px;
padding-left: 8px;
@cfxd
cfxd / acf_taxonomy_hierarchy.php
Last active February 9, 2017 22:47
Add taxonomy hierarchy (parent and child) matching to Advanced Custom Fields
<?php
function add_child_and_parent_to_acf_taxonomy_choices($choices) {
$tax_choices = array();
foreach($choices as $taxonomy => $c) {
$tax_choices[$taxonomy] = $c;
if($taxonomy != 'all' && is_taxonomy_hierarchical($taxonomy)) {
$tax_choices[$taxonomy.'-tax_parent'] = $c.' (parent)';
$tax_choices[$taxonomy.'-tax_child'] = $c.' (child)';
}
@cfxd
cfxd / restrict_wp_image_upload_dimensions.php
Created December 25, 2014 19:45
Restrict WordPress Media image upload dimensions
<?php
function restrict_image_upload_size($file) {
if(!stristr($file['type'], 'image')) { // only run on images
return $file;
}
$img = getimagesize($file['tmp_name']);
$minimum = array('width' => '1024', 'height' => '768');
$width = $img[0];