Skip to content

Instantly share code, notes, and snippets.

View glueckpress's full-sized avatar

Caspar Hübinger glueckpress

View GitHub Profile
@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() ) );
@eduardozulian
eduardozulian / wp-get-image-sizes.php
Created September 6, 2013 18:23
Get all the registered image sizes along with their dimensions
<?php
/**
* Get all the registered image sizes along with their dimensions
*
* @global array $_wp_additional_image_sizes
*
* @link http://core.trac.wordpress.org/ticket/18947 Reference ticket
* @return array $image_sizes The image sizes
*/
function _get_all_image_sizes() {
@bueltge
bueltge / gist:1559249
Created January 4, 2012 09:19
Custom Query Shortcode: Run a Loop inside any Post/Page
<?php
/**
* Plugin Name: Custom Query Shortcode
* Plugin URI:
* Description: Run a Loop inside any Post/Page via Shortcode <code>[loop]</code>
* Version: 0.0.1
* License: GPLv3
* Author: Frank B&uuml;ltge
* Author URI: http://bueltge.de/
*/
@bueltge
bueltge / wp-i18n-cheatsheet.md
Last active April 2, 2022 13:57
WordPress i18n Cheatsheet

WordPress i18n CheatSheet

Whenever I write plugins or themes, there is one thing that needs a little extra attention and is quite frankly hard to get right: Translatable text. This list should helps me to find the right way fast.

Props to Alex Kirk, there list it inside a quiz.

You want to output the username in a sentence.

Assume that the $username has been escaped using esc_html().

@mgibbs189
mgibbs189 / functions.php
Created November 1, 2016 18:34
FacetWP - accessibility support
<?php
add_filter( 'facetwp_assets', function( $assets ) {
$assets['accessibility.js'] = FACETWP_URL . '/assets/js/src/accessibility.js';
return $assets;
});
@aarongustafson
aarongustafson / watchResize.js
Last active September 16, 2019 14:37
Efficient callback management for window.onresize
(function( window ){
window.watchResize = function( callback ){
var resizing;
callback.size = 0;
function done()
{
var curr_size = window.innerWidth;
clearTimeout( resizing );
resizing = null;
// only run on a true resize
@franz-josef-kaiser
franz-josef-kaiser / client_admin_notices.php
Last active August 30, 2019 13:04
Gibt für Kunden Notizen über Änderungen zu WordPress im Adminbereich aus.
<?php
/**
* Plugin Name: Info zu WP-Änderungen
* Description: Informiert Kunden über Änderungen im WordPress Core, der Sprachdatei, etc.
* Version: 15122012.1423
* Author: Franz Josef Kaiser <wecodemore@gmail.com>
* Author URI: https://plus.google.com/107110219316412982437/posts
* License: The MIT License (MIT)
* LicenseURI: http://www.opensource.org/licenses/mit-license.php
*/
@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;
@sergejmueller
sergejmueller / .htaccess
Created December 21, 2011 14:12
Beispiel einer .htaccess Datei unter WordPress
# Admin absichern
<Files wp-login.php>
AuthName "Admin-Bereich"
AuthType Basic
AuthUserFile /var/www/pfad/.htpasswd
require valid-user
</Files>
# Zugriff verweigern