Skip to content

Instantly share code, notes, and snippets.

@alexpos
alexpos / gist:5677692
Created May 30, 2013 13:08
git notes
# shortform git commands
alias g='git'
# Restore deleted file from GIT repository
git checkout $(git rev-list -n 1 HEAD -- "$file")^ -- "$file"
# Remove .git dirs
find . -name ".git" -type d -exec rm -rf {} \;
# Top Ten of the most active committers in git repositories
@alexpos
alexpos / versioned style
Created May 29, 2013 17:54
Versioning WordPress style
/**
* Enqueue scripts and styles
*/
function version_id() {
if ( WP_DEBUG )
return time();
$my_theme = wp_get_theme();
$thversion = $my_theme->Version;
return $thversion;
@alexpos
alexpos / cbqc_remove_boxes
Created May 29, 2013 09:57
Remove meta-boxes
function cbqc_remove_boxes() {
// Remove boxes I don’t like
// *** For posts *** //
// Custom Fields
remove_meta_box( ‘postcustom’ , ‘post’ , ‘normal’ );
// Excerpt
remove_meta_box( ‘postexcerpt’ , ‘post’ , ‘normal’ );
// Trackbacks
remove_meta_box( ‘trackbacksdiv’ , ‘post’ , ‘normal’ );
@alexpos
alexpos / cpt_dashboard
Created May 29, 2013 07:56
custom post types to the "Right Now" box on the Dashboard
// Add all custom post types to the "Right Now" box on the Dashboard
// CPTs auf der Startseite des Dashboards auflisten
add_action( 'right_now_content_table_end' , 'kh_right_now_content_table_end' );
function kh_right_now_content_table_end() {
$args = array(
'public' => true ,
'_builtin' => false
);
$output = 'object';
<?php
/*
Plugin Name: MyWidget
Description: Description
Author: Pixolin
*/
/********************
* add a new Widget to WP_Widget class
@alexpos
alexpos / gist:5622003
Created May 21, 2013 18:16
Post Formats and WP 3.6
add_filter( 'enable_post_format_ui', '__return_false' );
function word_count() {
$content = get_post_field( 'post_content', $post->ID );
$word_count = str_word_count( strip_tags( $content ) );
return $word_count;
}
;;; pbcopy.el --- Emacs Interface to pbcopy
;; Copyright (C) 2011 Daniel Nelson, based on xclip.el, by Leo Shidai Liu
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;; This file is distributed in the hope that it will be useful,
<?php
add_filter( 'preprocess_comment', 'minimal_comment_length' );
function minimal_comment_length( $commentdata ) {
$minimalCommentLength = 20;
if ( strlen( trim( $commentdata['comment_content'] ) ) < $minimalCommentLength )
{
wp_die( 'All comments must be at least ' . $minimalCommentLength . ' characters long.' );
}
@alexpos
alexpos / templatedebug
Created March 24, 2013 15:29
Add the below snippet into your functions.php file and it will return the current theme template WordPress is using in the console.
function templatedebug() {
global $template; $curtemplate=basename($template);
?>
<script type="text/javascript">
console.log(<?php echo "\"current template: ".$curtemplate."\""; ?>);
</script>
<?php
}
add_action( 'wp_footer', 'templatedebug' );