Skip to content

Instantly share code, notes, and snippets.

View marcosfreitas's full-sized avatar
🔥
Looking forward

Marcos Freitas marcosfreitas

🔥
Looking forward
View GitHub Profile
@marcosfreitas
marcosfreitas / function.php
Created January 8, 2015 15:49
Woocommerce Shipping - Hide standard Shipping Methods when free (local delivery) is available
/* Woocommerce Shipping */
// Hide standard shipping when free is available
// Original script https://gist.github.com/pauloiankoski/9707209
add_filter( 'woocommerce_available_shipping_methods', 'mf_hide_standard_shipping_when_free_is_available' , 10, 1 );
function mf_hide_standard_shipping_when_free_is_available( $available_methods ) {
global $woocommerce;
// First the free shipping method is only available to local delivery
@marcosfreitas
marcosfreitas / functions.php
Created March 10, 2015 02:57
Registering Taxonomies and Post_type - WordPress
// Register Custom Post Type
function c4n_new_post_type() {
$labels = array(
'name' => _x( 'Journals', 'Post Type General Name', 'turing_press' ),
'singular_name' => _x( 'Journal', 'Post Type Singular Name', 'turing_press' ),
'menu_name' => __( 'Journals', 'turing_press' ),
'parent_item_colon' => __( 'Parent Journal:', 'turing_press' ),
'all_items' => __( 'All Journals', 'turing_press' ),
'view_item' => __( 'View Journal', 'turing_press' ),
@marcosfreitas
marcosfreitas / check_if_has_a_string_in_array.asp
Last active August 29, 2015 14:18 — forked from gwobcke/checkIfInArray.asp
Esta função em ASP serve para verificar se um determinado valog existe em um array. Retorna false se não encontrar nada ou retorna a posição (i) onde o valor foi encontrado
<%
Function inArray(byVal value, byVal my_array)
Dim i
inArray = false
For i=0 To Ubound(my_array)
If (my_array(i) = value) Then
inArray = true
Exit Function
End If
@marcosfreitas
marcosfreitas / colors.php
Last active August 29, 2015 14:19
JSON what will be returned to search of Semantic UI - JSON que será retornado para a pesquisa (search) do Semantic UI.
<?php
header('Content-type: application/json; charset=utf-8');
$colors = '{"results" :[
{
"title":"red",
"description":"dark red like blood"
},
{
"title":"green",
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Registration.aspx.cs" Inherits="ITI_Intake_34.Day_5.Registration" %>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="description" content="A form displays a set of related user input fields in a structured way" />
<meta name="keywords" content="html5, ui, library, framework, javascript" />
<title>Semantic Ui</title>
@marcosfreitas
marcosfreitas / woo.text
Last active August 29, 2015 14:26
Wordpress Custom Query - Woocommerce Search Order By Rating
'
1º LEFT OUTER JOIN somente a soma das avaliacoes
2º LEFT OUTER JOIN somente a quantidade das avaliacoes
resulta na média
POSTS, COMENTARIOS, METADADOS_COMENTARIOS
inner join nao vai trazer os posts sem comentarios ou comentarios sem classificacao rating
left outer join vai trazer os posts, comentarios coincidentes no inner (na relacao descrita no ON) e tambem os posts sem comentarios, comentario sem rating
select * from POSTS
select * from COMENTARIOS as c
left outer join METADADOS_COMENTARIOS as mc
/* ==========================================================================
Buttons Class Configurations
========================================================================== */
/*
* Redefinition to bootstrap buttons
*/
.btn, .btn[disabled], .btn:focus, .btn:hover, .btn:active{
color: #333;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
<?php
(..)
$attached_media = get_attached_media( $this->supported_types, $this->post_id );
foreach ($attached_media as $key => $value) {
$attachment_url = $attached_media[$key]->guid;
}
(...)
@marcosfreitas
marcosfreitas / get_categories.php
Last active November 10, 2015 20:04
WORDPRESS: Retrieve children of a parent category - get_categories()
<?php
/* Subcategories of "Journals" (id: 6) */
$categories = get_categories('child_of=6&hide_empty=0');
foreach ($categories as $cat):
/* This get the total of posts in current category of the loop.*/
$total_of_posts_in_category = (int) $cat->count;
$current_category_name = $cat->name;
/* For each category, make the loop for the amount of posts */
@marcosfreitas
marcosfreitas / redirect-site.php
Last active December 4, 2015 15:26
This script will redirect users from determined URL in accord with the your COUNTRY_NAME, COUNTRY_CODE, CITY (name), REGION_CODE or REGION_NAME returned by freegeoip.net webservice
<?php
/**
* This script will redirect users from determined URL in accord with the your:
* COUNTRY_NAME, COUNTRY_CODE, CITY (name), REGION_CODE or REGION_NAME returned by freegeoip.net webservice
* @author Marcos Freitas - marcosfreitas[at]c4network[dot]com[dot]br
* --
* Thanks to freegeoip.net for the 'simple' webservice.
*/
// Redirect function
function Redirect($url, $permanent){