Skip to content

Instantly share code, notes, and snippets.

View espellcaste's full-sized avatar

Renato Alves espellcaste

View GitHub Profile
@ffigiel
ffigiel / README.md
Last active August 29, 2015 13:56
Flexible svg sprites

Flexible svg sprites

I've been fiddling with svg sprites a bit today, trying to handle them in such way that you could use any unit you like to specify their size. Here's what I came up with.

(You could use this method for bitmap sprites as well, but I don't see much sense in this!)

Presumptions

All images in the sprite must share the same width or height, preferably both. Note that maintaining rules for images with several different aspect ratios may be problematic.

@sbrajesh
sbrajesh / hide-user-on-directory.php
Last active August 29, 2015 14:00
Hide Logged in user on BuddyPress directory
add_filter('bp_ajax_querystring', 'devb_hide_user_on_directory', 15, 2);
function devb_hide_user_on_directory( $query_string, $object ){
if( !is_user_logged_in() )
return $query_string;
if( $object != 'members' || isset( $_REQUEST['search_terms'] ) && $_REQUEST['search_terms'] ) //updated to not hide from sarch
return $query_string;
<?php
/**
* Plugin Name: bbPress Permalinks
* Plugin URI: http://korobochkin.com/
* Description: Change bbPress permalinks. ID number instead of topic slug. This links better than default if you have Cyrilic or other non english charackters in forum's and topic's slugs. forums/forum/FORUM_SLUG/ &rarr; forums/forum/ID/. forums/topic/TOPIC_SLUG/&rarr;forums/topic/ID/
* Author: Kolya Korobochkin
* Author URI: http://korobochkin.com/
* Version: 1.0.0
* Text Domain: bbpress_permalinks
* Domain Path: /languages/
@bsbeeks
bsbeeks / Custom login page
Created January 13, 2015 16:18
Wordpress Snippets
// Custom Logo Link
function wpc_url_login() {
return "http://twentycms.com/";
}
add_filter('login_headerurl', 'wpc_url_login');
// Custom Login Styles (including logo)
function login_css() {
wp_enqueue_style( 'login_css', get_template_directory_uri() . '/css/login.css' );
}
@jg314
jg314 / comment_reply_emails.php
Created March 23, 2015 14:00
Send comment reply emails to the parent comment author automatically in WordPress.
<?php
add_action( 'wp_set_comment_status', 'wi_comment_notification', 99, 2 );
function wi_comment_notification( $comment_id, $comment_status ){
$comment_object = get_comment( $comment_id );
if( $comment_status == 'approve' && $comment_object->comment_parent > 0 ){
$comment_parent = get_comment( $comment_object->comment_parent );
$mailcontent = 'Hi ' . $comment_parent->comment_author . ',<br><br>';
$mailcontent .= $comment_object->comment_author . ' replied to your comment on <a href="' . get_permalink( $comment_parent->comment_post_ID ) . '">' . get_the_title( $comment_parent->comment_post_ID ).'</a> with the following:';
$mailcontent .= '<blockquote>' . $comment_object->comment_content . '</blockquote>';
@rachelbaker
rachelbaker / bp-default-ajax-loader.php
Created July 21, 2012 02:43
BuddyPress Load Default Ajax Scripts into Custom Theme
<?php
function bp_custom_include_ajax() {
global $bp;
require_once( BP_PLUGIN_DIR . '/bp-themes/bp-default/_inc/ajax.php' );
if ( !is_admin() ) {
// Register buttons for the relevant component templates
// Messages button
if ( bp_is_active( 'messages' ) )
@boonebgorges
boonebgorges / bbg-is-admin.php
Created November 28, 2012 22:20
A function for reliably testing whether you're in the WordPress Dashboard
<?php
/**
* Are we looking at the WordPress admin?
*
* Because AJAX requests are sent to wp-admin/admin-ajax.php, WordPress's
* is_admin() function returns true when DOING_AJAX. This function contains
* logic to test whether AJAX requests are coming from the front end or from
* the Dashboard.
*
* @return bool
@desandro
desandro / transition-scroll-to.js
Created December 4, 2012 16:50
Use CSS transitions to scroll to element
( function( window, undefined ) {
'use strict';
// helper function
function capitalize( str ) {
return str.charAt(0).toUpperCase() + str.slice(1);
}
// ========================= getStyleProperty by kangax ===============================
@ribeiroevandro
ribeiroevandro / create-site
Last active December 21, 2015 01:08
Script for creating Virtual Servers On Apache
#!/bin/bash
# Script for creating Virtual Servers On Apache
# Check for the correct parameters
if [ $# -eq 0 ]; then
echo 'Você precisa passar o domínio a ser criado como parâmetro'
echo 'Uso: create-site your-domain.com'
exit 0
fi
@claudiosanches
claudiosanches / script.js
Created August 30, 2013 20:30
WordPress - Video Shortcode responsive
jQuery(document).ready(function($) {
// Responsive wp_video_shortcode().
$(".wp-video-shortcode")
.css("max-width", "100%")
.parent("div")
.css("width", "auto");
});