Skip to content

Instantly share code, notes, and snippets.

View christianwach's full-sized avatar
Thinking time

Christian Wach christianwach

Thinking time
View GitHub Profile
@pento
pento / stars-block.js
Last active January 4, 2022 14:00
Gutenberg Stars Block
( function( blocks, element ) {
var el = element.createElement;
function Stars( { stars } ) {
return el( 'div', { key: 'stars' },
'★'.repeat( stars ),
( ( stars * 2 ) % 2 ) ? '½' : '' );
}
blocks.registerBlockType( 'stars/stars-block', {
@fjarrett
fjarrett / unautop-func.php
Last active April 6, 2022 16:57
Inverse behavior to the wpautop() function found in WordPress
<?php
/**
* Replaces paragraph elements with double line-breaks.
*
* This is the inverse behavior of the wpautop() function
* found in WordPress which converts double line-breaks to
* paragraphs. Handy when you want to undo whatever it did.
*
* @see wpautop()
#!/bin/bash
remote_hosts_file="http://winhelp2002.mvps.org/hosts.txt"
hosts_file_loc="/etc/hosts"
main() {
printf "Downloading file...\n"
wget -q -O /tmp/hosts.new $remote_hosts_file
printf "Removing windows line breaks...\n"
@r-a-y
r-a-y / warnings.php
Last active August 17, 2023 11:46
Suppress warnings created by certain plugins and themes in WordPress.
/**
* Suppress errors generated by specified WordPress plugins.
*
* Put this in /wp-content/mu-plugins/
*
* @param string $errno The error number.
* @param string $errstr The error message.
* @param string $errfile Path to the file that caused the error.
* @param int $errline Line number of the error.
* @return bool True to suppress error reporting; false to use default error handler.
@JonathanReeve
JonathanReeve / gist:b82a6c27493232bb0216
Last active August 29, 2015 14:07
Fix bp-groupblog links not working for public blogs of private groups
/**
* Override default BP Groupblog nav item functionality
*/
function my_custom_groupblog_setup_nav() {
// only add for groups
if ( !bp_is_group() ) return;
// only act if blog not embedded in group template
$checks = get_site_option('bp_groupblog_blog_defaults_options');
@imath
imath / bpgmq.php
Created November 4, 2013 03:39
This is the complete class for the BuddyPress Codex article : Group Meta Queries: Usage Example. You can test it copying it in the functions.php of your active theme
<?php
/* you can copy & paste from here */
//it's important to check the BP_Group_Extension is available
if( class_exists( 'BP_Group_Extension' ) ) :
/**
* This is a quick and dirty class to illustrate "bpgmq"
* bpgmq stands for BuddyPress Group Meta Query...
* The goal is to store a groupmeta in order to let the community administrator
@thefuxia
thefuxia / function.network_menu_page_url.php
Last active December 26, 2015 23:39
function network_menu_page_url()
<?php
/**
* Get the URL for a network plugin page.
*
* @param string $menu_slug
* @param string $parent_file
* @return string|bool Url or FALSE on failure
*/
function network_menu_page_url( $menu_slug = '', $parent_file = '' ) {

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 or .bash_profile file (with no trailing slash):

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

@eduardozulian
eduardozulian / wp-customize-image-reloaded.php
Last active November 16, 2023 02:50
Extend WP_Customize_Image_Control class allowing access to files uploaded within the same context.
<?php
/**
* Customize Image Reloaded Class
*
* Extend WP_Customize_Image_Control allowing access to uploads made within
* the same context
*/
class My_Customize_Image_Reloaded_Control extends WP_Customize_Image_Control {
/**
* Constructor.
@malarkey
malarkey / Contract Killer 3.md
Last active April 16, 2024 21:44
The latest version of my ‘killer contract’ for web designers and developers

When times get tough and people get nasty, you’ll need more than a killer smile. You’ll need a killer contract.

Used by 1000s of designers and developers Clarify what’s expected on both sides Helps build great relationships between you and your clients Plain and simple, no legal jargon Customisable to suit your business Used on countless web projects since 2008

…………………………