Skip to content

Instantly share code, notes, and snippets.

View glueckpress's full-sized avatar

Caspar Hübinger glueckpress

View GitHub Profile
@2ndkauboy
2ndkauboy / _respond-to-ie.scss
Last active October 13, 2015 00:28
A simple mixin that takes a target size and adds a min-width media query and a IE fallback given by a variable for the content.
@mixin respond-to-ie($size){
@if $old-ie {
@content;
} @else {
@media all and (min-width: $size) {
@content;
}
}
}
@israelcurtis
israelcurtis / gist:3798347
Created September 28, 2012 06:57
Use the get_post_field() function to get any of the wp_posts column fields #wordpress #php
<?php
echo get_post_field('post_content', $post_id); // retrieve content
echo get_post_field('post_name', $post_id); // retrieve the slug
?>
@johnpbloch
johnpbloch / README.md
Created August 23, 2012 13:55
A bash script to make .pot files for WordPress plugins

Installation

To install, you need to have the WordPress i18n library on your computer. Check it out using SVN:

sudo svn co http://i18n.svn.wordpress.org/tools/trunk/ /usr/lib/wpi18n

You don't have to put the library in /usr/lib/wpi18n, but if you don't put it there, make sure to set the $WP_I18N_LIB environment variable in your .bashrc file (with no trailing slash):

export WP_I18N_LIB="/path/to/i18n/lib"

@kovshenin
kovshenin / something.php
Created July 10, 2012 07:17
Yes, you can use printf and sprintf in WordPress too!
<?php
// Dirty, easy to miss a ' or " or .
echo '<a href="' . get_permalink() . '" class="link">' . get_the_title() . '</a>';
// Clean, easier to read
printf( '<a href="%s" class="link">%s</a>', get_permalink(), get_the_title() );
// Almost as clean, and more secure, maybe a little paranoic :)
printf( '<a href="%s" class="link">%s</a>', esc_url( get_permalink() ), esc_html( get_the_title() ) );
@thefuxia
thefuxia / remove-admin-bar-wp-menu.php
Last active August 5, 2017 08:15
Remove WP Menu From Tool Bar
<?php # -*- coding: utf-8 -*-
/**
* Plugin Name: Remove WP Menu From Tool Bar
*/
add_action( 'add_admin_bar_menus', function(){
remove_action( 'admin_bar_menu', 'wp_admin_bar_wp_menu' );
});
@bueltge
bueltge / example.php
Created April 21, 2012 21:24
WordPress Widget Order via CSS; Here is a simple filter to automatically add a class attribute like widget-order-1 to all widgets within sidebars
add_action( 'init', 'add_widget_order_class' );
function add_widget_order_class() {
global $wp_registered_sidebars, $wp_registered_widgets;
$sidebars = wp_get_sidebars_widgets();
if ( empty( $sidebars ) )
return;
foreach ( $sidebars as $sidebar_id => $widgets ) {
@bueltge
bueltge / gist:2304293
Created April 4, 2012 18:01
Remove hierarchy on WordPress Category meta box
add_action( 'add_meta_boxes', 'do_my_meta_boxes' );
function do_my_meta_boxes( $post_type ) {
remove_meta_box( 'my_taxonomydiv', $post_type, 'side' );
add_meta_box( 'my_taxonomydiv', 'My Taxonomy', 'my_meta_box', $post_type, 'side' );
}
function my_meta_box( $post, $meta_box ) {
$taxonomy = 'my_taxonomy';
$tax = get_taxonomy( $taxonomy );
@luetkemj
luetkemj / wp-query-ref.php
Last active April 25, 2024 09:37
WP: Query $args
// This gist is now maintained on github at https://github.com/luetkemj/wp-query-ref
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.github.io
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/4.9.4/src/wp-includes/query.php
*/
@ocean90
ocean90 / fbcbfwss.php
Last active February 11, 2023 22:03
WordPress Plugin: Filename-based cache busting for scripts/styles.
<?php
/**
* Plugin Name: Filename-based cache busting
* Version: 0.3
* Description: Filename-based cache busting for WordPress scripts/styles.
* Author: Dominik Schilling
* Author URI: https://dominikschilling.de/
* Plugin URI: https://gist.github.com/ocean90/1966227/
*
* License: GPLv2 or later
@r-a-y
r-a-y / shortcode.php
Created February 22, 2012 21:01
Check if a shortcode exists in WordPress
<?php
if ( ! function_exists( 'shortcode_exists' ) ) :
/**
* Check if a shortcode is registered in WordPress.
*
* Examples: shortcode_exists( 'caption' ) - will return true.
* shortcode_exists( 'blah' ) - will return false.
*/
function shortcode_exists( $shortcode = false ) {
global $shortcode_tags;