Skip to content

Instantly share code, notes, and snippets.

View pagelab's full-sized avatar
🚀

Márcio Duarte pagelab

🚀
View GitHub Profile
@pagelab
pagelab / Two functions for better smilies in WordPress
Last active August 29, 2015 13:57
Two simple functions to allow better smilies in WordPress. Drop one of them (not both) in your functions.php
/**
* Filter smilies to allow SVG format with PNG fallback (IE7-IE8)
* @license http://www.gnu.org/licenses/gpl-3.0.html
* @since 1.0.0
*/
add_filter('smilies_src','my_svg_smilies_src', 1, 10);
function my_svg_smilies_src($img_src, $img, $siteurl) {
$img = rtrim($img, "gif"); // Remove GIF
<?php
/**
* Adds a simple WordPress pointer to Settings menu
*/
function thsp_enqueue_pointer_script_style( $hook_suffix ) {
// Assume pointer shouldn't be shown
$enqueue_pointer_script_style = false;
<?php
# License: Public Domain
# I recommend replacing 'my_' with your own prefix.
function my_template_path() {
return My_Wrapping::$main_template;
}
<?php namespace PaintedCloud\WP\Classes;
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
class CustomTaxonomy {
protected $textdomain;
protected $taxonomies;
public function __construct ( $textdomain )
<?php namespace PaintedCloud\WP\Classes;
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
class CustomPost {
protected $textdomain;
protected $posts;
public function __construct( $textdomain )
<?php
/**
* Show Mad Mimi subscriber count w/cache.
*/
function jm_madmimi_subscribers() {
$email = '';
$api = '';
// check and get cached subscriber count
@pagelab
pagelab / critical-rendering-path.html
Created May 1, 2014 13:44
Measuring Critical Rendering Path with navigation timing (Google)
<html>
<head>
<title>Critical Path: Measure</title>
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link href="style.css" rel="stylesheet">
<script>
function measureCRP() {
var t = window.performance.timing,
interactive = t.domInteractive - t.domLoading,
@-webkit-keyframes float-up {
0% { opacity: 0; top: 4rem; }
100% { opacity: 1; top: 0; }
}
.float-up {
opacity: 0;
position: relative;
-webkit-animation-name: float-up;
-webkit-animation-duration: .3s;
<?php
add_action( 'tgmpa_register', 'register_required_plugins' );
// This function is called from the above hook
function register_required_plugins()
{
// The plugins array allows us to define multiple plugins we want to include.
// The commented out example shows how we can include and activation a bundled
// plugin zip file in our theme.
@pagelab
pagelab / gettext.php
Last active August 29, 2015 14:01
Using gettext/ngetext to replace array of words in wp admin
<?php
add_filter( 'gettext', 'wps_translate_words_array' );
add_filter( 'ngettext', 'wps_translate_words_array' );
function wps_translate_words_array( $translated ) {
$words = array(
// 'word to translate' = > 'translation'
'Posts' => 'Article',
'Post' => 'Articles',
'Pages' => 'Stuffing',