Skip to content

Instantly share code, notes, and snippets.

View allysonsouza's full-sized avatar
💻
Doing some WordPress stuff...

Allyson Souza allysonsouza

💻
Doing some WordPress stuff...
View GitHub Profile
@allysonsouza
allysonsouza / example-page-template-archive.php
Last active August 29, 2015 14:03
Page Template as Archive for CPT
<?php
/* Este é o conteúdo de uma template page a ser exibido por uma página com slug = 'portfolio', tal como o post_type
A criação do CPT está com o argumento 'has_archive' => false, e a template page funciona normalmente, exceto quando é necessário
exibir uma página que não seja a primeira: www.meusite.com.br/portfolio/page/2 etc.
*/
//Pagination
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
@allysonsouza
allysonsouza / multidimensional-empty-array.js
Last active August 29, 2015 14:03
Multidimensional Empty Arrays in JavaScript
var App = {
cols: 3,
init: function() {
var siblings = [];
for(var i = 0; i < this.stage.rows; i++) {
siblings[i] = [];
}
@allysonsouza
allysonsouza / icon-font-associative-array.php
Created July 28, 2014 18:30
Icon Font Associative Array
<?php
/**
* Return an associative array with name and code of the icon from the icon font given in $path argument
*
* @version 0.0.1
*
* @return array Associative array, in the form [name] => [code] of the icon font
*/
function icon_array( $path ) {
@allysonsouza
allysonsouza / game-loop.js
Last active August 29, 2015 14:04
Ensaios de um pattern de Game Loop no JavaScript
(function () {
'use strict';
/*
* ImageRect
*/
function ImageRect() {
this.sx = 3584; //source x
this.sy = 0; //source y
this.sw = 512; //source width
@allysonsouza
allysonsouza / class-metabox.php
Created August 19, 2014 21:26
Odin Metabox - Show by screen id
<?php
/**
* Odin_Metabox class.
*
* Built Metaboxs.
*
* @package Odin
* @category Metabox
* @author WPBrasil
* @version 2.1.4
@allysonsouza
allysonsouza / register-cpt-example.php
Created October 7, 2014 14:35
Register Post Type Example
<?php
public function create_post_type() {
$labels = array(
'name' => 'Archives',
'singular_name' => 'Archive',
'menu_name' => 'Archives',
'name_admin_bar' => 'Archives',
'add_new' => 'Add New',
'add_new_item' => 'Add New Archive',
'new_item' => 'New Archive',
@allysonsouza
allysonsouza / remove-enqueued-style.php
Created October 14, 2014 17:52
Remove enqueued theme style in WordPress
<?php
global $wp_styles;
$num = count($wp_styles->queue);
for( $i = 0; $i < $num; $i++){
if( $wp_styles->queue[$i] != 'admin-bar' ){
unset($wp_styles->queue[$i]);
}
}
@allysonsouza
allysonsouza / theme_imgs_function.php
Created November 11, 2014 17:40
Return the theme images directory.
<?php
/**
* Return the theme images directory.
*
* @package Theme
* @since 1.0.0
*
* @return string Theme assets/images directory.
*/
function theme_imgs() {
@allysonsouza
allysonsouza / runningvms
Created December 4, 2014 00:14
List all running VirtualBoxes
VBoxManage list runningvms
@allysonsouza
allysonsouza / gameloop.js
Last active September 11, 2015 03:18
JavaScript Simple Didatic Game Loop
var canvas;
var contexto;
var naveX = 400;
var naveY = 400;
function init() {
canvas = document.getElementById("game");
contexto = canvas.getContext('2d');
nave = document.getElementById("nave");