Skip to content

Instantly share code, notes, and snippets.

César Ribeiro chrdesigner

Block or report user

Report or block chrdesigner

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@chrdesigner
chrdesigner / functions.php
Last active Dec 12, 2015
Transform HEX to RGB with PHP
View functions.php
<?php
function hex2RGB($hex) {
$hex = str_replace("#", "", $hex);
if(strlen($hex) == 3) {
$r = hexdec(substr($hex,0,1).substr($hex,0,1));
$g = hexdec(substr($hex,1,1).substr($hex,1,1));
$b = hexdec(substr($hex,2,1).substr($hex,2,1));
} else {
$r = hexdec(substr($hex,0,2));
$g = hexdec(substr($hex,2,2));
@chrdesigner
chrdesigner / main.js
Last active Sep 14, 2017
Máscara em jQuery para o oite e nove dígitos
View main.js
// <![CDATA[
jQuery(function($) {
$.mask.definitions['~']='[+-]';
//Inicio Mascara Telefone
$('input[type=tel]').focusout(function(){
var phone, element;
element = $(this);
element.unmask();
phone = element.val().replace(/\D/g, '');
if(phone.length > 10) {
@chrdesigner
chrdesigner / main.js
Created Dec 10, 2015
Script for reload only different Browser Width
View main.js
//Create the VAR for get browser size
var windowWidth = $(window).width();
$(window).bind('resize', function(e) {
//Verification with my VAR windowWidth is different Window size
if(windowWidth != $(window).width()){
//Create a delay for reload
if (window.RT) clearTimeout(window.RT); window.RT = setTimeout(function() {
this.location.reload(false);
}, 200);
@chrdesigner
chrdesigner / main.js
Created Oct 11, 2015
jQuery: addClass in <html> if size bellow 415
View main.js
var $window = $(window), $html = $('html');
$window.resize(function resize(){
if ($window.width() < 415) {
return $html.addClass('mobile');
}
$html.removeClass('mobile');
}).trigger('resize');
@chrdesigner
chrdesigner / functions.php
Last active Nov 3, 2017
Display Groups of Custom Posts by their Custom Taxonomy Term
View functions.php
<?php
$post_type = 'post';
// Get all the taxonomies for this post type
$taxonomies = get_object_taxonomies( (object) array( 'post_type' => $post_type ) );
foreach( $taxonomies as $taxonomy ) :
// Gets every "category" (term) in this taxonomy to get the respective posts
$terms = get_terms( $taxonomy,
@chrdesigner
chrdesigner / functions.php
Last active Jan 4, 2016
Set a custom post type to not show up on the frontend - WordPress
View functions.php
<?php
function chr_redirect_post_type() {
global $wp_query;
if ( is_post_type_archive('sliders') || is_singular('sliders') ) :
$url = get_bloginfo('url');
wp_redirect( esc_url_raw( $url ), 301 );
exit();
endif;
}
add_action ( 'template_redirect', 'chr_redirect_post_type', 1);
View functions.php
<?php
// Remove o Field de Informação adicional
add_filter( 'woocommerce_checkout_fields' , 'alter_woocommerce_checkout_fields' );
function alter_woocommerce_checkout_fields( $fields ) {
unset($fields['order']['order_comments']);
return $fields;
}
// Remove o título de Informação adicional
add_filter( 'woocommerce_enable_order_notes_field', '__return_false' );
@chrdesigner
chrdesigner / functions.php
Last active Sep 4, 2015
Function - Disable Checkout for some Countries and States
View functions.php
<?php
/*
* Function - Disable Checkout for some Countries and States
*/
function wc_checkout_validation() {
$shipping_country = ! empty( $_POST['shipping_country'] ) ? $_POST['shipping_country'] : $_POST['billing_country'];
$shipping_state = ! empty( $_POST['shipping_state'] ) ? $_POST['shipping_state'] : $_POST['billing_state'];
// Add here States : More example look here -> wp-content/plugins/woocommerce/i18n/states/
@chrdesigner
chrdesigner / functions.php
Last active Aug 25, 2015
Function - Remove Loop/Single Button Add to Cart
View functions.php
<?php
/*
* Function - Remove Loop/Single Button Add to Cart
*/
add_action('init','remove_add_to_cart');
function remove_add_to_cart(){
if(is_user_logged_in()){}else{
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
View archive-product.php
<?php
/*
* WP_Query - Show in your result search page, How many, products were found.
*/
$mySearch =& new WP_Query("s=$s & showposts=-1"); $num = $mySearch->post_count; ?>
<h1 class="page-title search-products-alert">
Foram encontrados <strong><?php echo $num;?></strong> resultados para a busca: <strong><?php echo get_search_query(); ?></strong>
</h1>
You can’t perform that action at this time.