Skip to content

Instantly share code, notes, and snippets.

View romuloctba's full-sized avatar
:octocat:

RcDev romuloctba

:octocat:
View GitHub Profile
@romuloctba
romuloctba / app.js
Created December 8, 2014 22:54
Factory AngularJS to consume WP-API REST
app.factory('API', function($resource){
var url = "http://www.urldomeusite.com.br/site/wp-json/";
var API = {
posts: $resource(url+'posts/:id'),
taxonomies: $resource(url+'taxonomies/:taxonomy/terms/:term')
};
return API;
})
.woocommerce.single-product .product .summary .variations {
width: 100%;
}
.woocommerce.single-product .product .summary .variations td {
display: block;
width: 100%;
}
.woocommerce.single-product .product .summary .variations td label {
font-family: 'Nunito', Helvetica, Arial, sans-serif;
letter-spacing: 0px;
@romuloctba
romuloctba / getCoords
Created February 17, 2015 06:40
Geolocation get coords
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function (position) {
alert("Lat: " + position.coords.latitude + " Long: " + position.coords.longitude);
}, function () {
//handleNoGeolocation(browserSupportFlag);
});
}
@romuloctba
romuloctba / loop-name.php
Last active August 29, 2015 14:16
Custom Wordpress Loop with custom fields from types plugin
<?php
$args = array(
'post_type' => 'post-slug',
'posts_per_page' => 6
);
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
//customfields
$cfname = get_post_meta( $post->ID, 'wpcf-CFSLUGHERE', true);
?>
@romuloctba
romuloctba / functions.php
Created March 2, 2015 19:28
Enqueue and add javascript to wordpress themes
<?php
function loadScripts() {
wp_register_script( 'main', get_template_directory_uri() . '/js/main.js', array( 'jquery' ) );
wp_enqueue_script( 'main' );
}
add_action( 'wp_enqueue_scripts', 'loadScripts' );
//don't even bother to close the php tag!
@romuloctba
romuloctba / addOrder.php
Created March 20, 2015 13:15
WooCommerce new order programatically (untested yet)
function add_import_order( $row ) {
// create new order
$order = new ImportOrder();
// done this before?
$order->exists = order_exists( $row[PayPalCols::TRANSACTION_ID] );
// add a bunch of fields
$order->date = $row[PayPalCols::DATE];
@romuloctba
romuloctba / functions.php
Created March 20, 2015 13:17
WooCommerce new order programatically (simpler, untested yet)
<?php //from http://stackoverflow.com/a/26588393/1576978
$address = array(
'first_name' => 'Fresher',
'last_name' => 'StAcK OvErFloW',
'company' => 'stackoverflow',
'email' => 'test@test.com',
'phone' => '777-777-777-777',
'address_1' => '31 Main Street',
'address_2' => '',
'city' => 'Chennai',
@romuloctba
romuloctba / create_key.php
Created March 24, 2015 19:16
Create Client Key without wp-cli
<?php
/*
Plugin Name: Cria Key
Plugin URI: http://rcdev.com.br/palestra/_clients/angularJs
Description: Cria Keys e Secre para o wp_oauth sem necessidade de usar o WP-CLI (que só roda em Unix)
Author: Romulo_Ctba
Author URI:http://rcdev.com.br/romulo
Version: 0.1
License: GPLv2
*/
@romuloctba
romuloctba / functions.php
Created April 1, 2015 09:40
Include all post types in archive page
function archiveAll( $query ) {
if( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) {
$query->set( 'post_type', array(
'post', 'myCustomPostSlugHere'
));
return $query;
}
}
add_filter( 'pre_get_posts', 'archiveAll' );
@romuloctba
romuloctba / functions.php
Created April 1, 2015 09:41
Create sidebar/widget area in WordPress
function criaSidebars() {
register_sidebar( array(
'name' => 'Sidebar Principal',
'id' => 'main-sidebar',
'before_widget' => '<div>',
'after_widget' => '</div>',
'before_title' => '<h2 class="">',
'after_title' => '</h2>',
) );
}