Skip to content

Instantly share code, notes, and snippets.

View pagelab's full-sized avatar
🚀

Márcio Duarte pagelab

🚀
View GitHub Profile
@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',
@pagelab
pagelab / font-awesome.css.sass
Last active August 29, 2015 14:02 — forked from mbreit/font-awesome.css.sass
Font-awesome Sass mixin
$fontawesome_path: "." !default
@font-face
font-family: 'FontAwesome'
src: font-url('#{$fontawesome_path}/fontawesome-webfont.eot')
src: font-url('#{$fontawesome_path}/fontawesome-webfont.eot?#iefix') format("embedded-opentype"), font-url('#{$fontawesome_path}/fontawesome-webfont.woff') format("woff"), font-url('#{$fontawesome_path}/fontawesome-webfont.ttf') format("truetype")
font-weight: normal
font-style: normal
@mixin icon($icon)
<?php
// Standard Size Thumbnail
if(false === get_option("thumbnail_crop")) {
add_option("thumbnail_crop", "1"); }
else {
update_option("thumbnail_crop", "1");
}
// Medium Size Thumbnail
if(false === get_option("medium_crop")) {
@pagelab
pagelab / waitforfinalevent.js
Created June 13, 2014 21:16
jQuery: fire event after window resize is completed
jQuery(document).ready(function($) {
var waitForFinalEvent = (function () {
var timers = {};
return function (callback, ms, uniqueId) {
if (!uniqueId) {
uniqueId = "Don't call this twice without a uniqueId";
}
if (timers[uniqueId]) {
clearTimeout (timers[uniqueId]);
<?php
/**
* handle the calculation
* @param integer $seconds [description]
* @return [type] [description]
*/
function rkv_calc_read_time( $seconds = 0 ) {
// calc the minutes
@pagelab
pagelab / deactivate-plugin.php
Created July 7, 2014 12:55
Deactivating a WordPress Plugin Automatically
<?php
/**
* Deactivates a WordPress Plugin Automatically
*
* @copyright PressCoders
* @license http://www.gnu.org/licenses/gpl-2.0.html
* @link http://www.presscoders.com/2011/11/deactivate-wordpress-plugin-automatically/
*
*/
@pagelab
pagelab / functions.php
Created July 9, 2014 18:39
Wordpress: function to filter the excerpt
<?php
/******************************************************************************
* @Author: Boutros AbiChedid
* @Date: June 20, 2011
* @Websites: http://bacsoftwareconsulting.com/ ; http://blueoliveonline.com/
* @Description: Preserves HTML formating to the automatically generated Excerpt.
* Also Code modifies the default excerpt_length and excerpt_more filters.
*******************************************************************************/
function custom_wp_trim_excerpt($text) {
$raw_excerpt = $text;
@pagelab
pagelab / functions.php
Created July 10, 2014 18:57
Pre-populate content editor by post type
<?php
function my_preset_content() {
global $post;
if ( $post->post_content == '' and $post->post_type == 'custom_post_type' ) {
$default_content = 'my preset content here';
} else {
<?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
/**
* Theme Activation Tour
*
* This class handles the pointers used in the introduction tour.
* @package Popup Demo
*
*/
class WordImpress_Theme_Tour {