Skip to content

Instantly share code, notes, and snippets.

View seafarer's full-sized avatar
☎️
DM me, maybe

Colin OBrien seafarer

☎️
DM me, maybe
View GitHub Profile
@seafarer
seafarer / Reorder wordpress admin menu
Last active December 20, 2015 03:59
Reorder wordpress admin menu
function custom_menu_order($menu_ord) {
if (!$menu_ord) return true;
return array(
'index.php', // Dashboard
'separator1', // First separator
'edit.php?post_type=page', // Pages
'edit.php?post_type=project', // Custom post type project
'edit.php?post_type=accolade', // Custom post type accolade
'edit.php', // Posts
@seafarer
seafarer / Change wp menu label
Created July 24, 2013 02:46
Change 'posts' to 'blog' in wordpress admin
function change_post_menu_label() {
global $menu;
global $submenu;
$menu[5][0] = 'Blog';
$submenu['edit.php'][5][0] = 'Blog Posts';
$submenu['edit.php'][10][0] = 'Add Blog Post';
echo '';
}
add_action( 'admin_menu', 'change_post_menu_label' );
@seafarer
seafarer / remove-widgets-from-wp-dashboard
Created July 24, 2013 02:54
Remove widgets from wordpress dashboard
function remove_dashboard_widgets() {
global $wp_meta_boxes;
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_drafts']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']);
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
@seafarer
seafarer / wp-post-images
Created July 24, 2013 03:22
Access wordpress post images uploaded and inserted through gallery function
<?php
$args = array(
'numberposts' => -1, // Using -1 loads all posts
'orderby' => 'menu_order', // This ensures images are in the order set in the page media manager
'order'=> 'ASC',
'post_mime_type' => 'image', // Make sure it doesn't pull other resources, like videos
'post_parent' => $post->ID, // Important part - ensures the associated images are loaded
'post_status' => null,
'post_type' => 'attachment'
@seafarer
seafarer / wordpress-gitignore
Last active December 20, 2015 05:58
wordpress gitignore
wp-config.php
wp-content/uploads/
wp-content/blogs.dir/
wp-content/upgrade/
wp-content/backup-db/
wp-content/advanced-cache.php
wp-content/wp-cache-config.php
sitemap.xml
*.log
wp-content/cache/
@seafarer
seafarer / magnific wordpress
Created October 15, 2013 03:15
Integrate magnific popup into wordpress via http://pastebin.com/s3rT3FBr
jQuery(document).ready(function($) {
$('a[href*=".jpg"], a[href*=".jpeg"], a[href*=".png"], a[href*=".gif"]').each(function(){
//single image popup
if ($(this).parents('.gallery').length == 0) {
$(this).magnificPopup({type:'image'});
}
});
//gallery popup
$('.gallery').each(function() {
$(this).magnificPopup({
# Requre a specific version in this file:
# gem 'zurb-foundation', '=4.3.1'
require 'zurb-foundation'
# Require any additional compass plugins here.
# IE 9 and below only support up to 4095 CSS selectors
# This class will split all selectors after that point
class CssSplitter
def self.split(infile, outdir = File.dirname(infile), max_selectors = 4095)
@seafarer
seafarer / wp-category-sort
Created January 2, 2014 21:37
category sort on category archive template
<?php
global $wp_query;
query_posts(
array_merge(
$wp_query->query,
array(
'order' => 'ASC',
'orderby'=>'title',
'posts_per_page' => 20,
)
@seafarer
seafarer / admin-filter
Created February 3, 2014 22:43
Sexy Wordpress admin filter for custom post types with custom taxonomies. Plug and play - no config necessary. Via [stackexchange] (http://wordpress.stackexchange.com/questions/578/adding-a-taxonomy-filter-to-admin-list-for-a-custom-post-type)
function todo_restrict_manage_posts() {
global $typenow;
$args=array( 'public' => true, '_builtin' => false );
$post_types = get_post_types($args);
if ( in_array($typenow, $post_types) ) {
$filters = get_object_taxonomies($typenow);
foreach ($filters as $tax_slug) {
$tax_obj = get_taxonomy($tax_slug);
wp_dropdown_categories(array(
'show_option_all' => __('Show All '.$tax_obj->label ),
@seafarer
seafarer / update-hooks.php
Created February 14, 2014 19:49
drupal update hooks
function MODULE_update_7200() {
if( module_exists('MODULE')) {
module_disable(array('MODULE'));
drupal_uninstall_modules(array('MODULE'));
}
}