Skip to content

Instantly share code, notes, and snippets.

@oterox
oterox / gist:03c928bca4a9961a24a5
Created March 8, 2015 08:00
mysql create database and user
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'password';
CREATE DATABASE demo;
GRANT ALL PRIVILEGES ON *.* TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;
@oterox
oterox / style.css
Created July 22, 2015 11:58
css columns
/* Column Classes
------------------------------------------------------------ */
.five-sixths,
.four-fifths,
.four-sixths,
.one-fifth,
.one-fourth,
.one-half,
.one-sixth,
@oterox
oterox / query_results.php
Last active August 29, 2015 14:27
Sorting Query Results by Multiple Meta Keys
<?php
// Query Arguments
$args = array(
'post_type' => 'review',
'posts_per_page' => 10,
'paged' => get_query_var( 'paged', false ),
'meta_query' => array(
'relation' => 'AND',
'be_top_pick' => array(
'key' => 'be_top_pick',
@oterox
oterox / page-template.php
Created August 13, 2015 09:31
Add page template from plugin
class PageTemplater {
/**
* A Unique Identifier
*/
protected $plugin_slug;
/**
* A reference to an instance of this class.
*/
@oterox
oterox / snnipets.php
Last active June 13, 2016 09:51
woocommerce snippets
<?php
add_filter('add_to_cart_redirect', 'themeprefix_add_to_cart_redirect');
function themeprefix_add_to_cart_redirect() {
global $woocommerce;
$checkout_url = $woocommerce->cart->get_checkout_url();
return $checkout_url;
}
//Add New Pay Button Text
<?php
/**
* Plugin Name: ox Core
* Plugin URI: https://github.com/citricamente/ox-core
* Version: 0.2
* Author: Citricamente
* License: GPL2
* Text Domain: barcelo-core
* Domain Path: /languages
*/
@oterox
oterox / rewrites.php
Last active October 10, 2018 11:45
Custom rewrite rules
add_filter('post_type_link', 'ox_post_type_link', 1, 3);
function ox_post_type_link( $link, $post = 0 ){
if ( $post->post_type == 'plan' ){
$terms = wp_get_object_terms( $post->ID, 'tax_destination' );
if (!is_wp_error($terms) && !empty($terms) && is_object($terms[0]))
$taxonomy_slug = $terms[0]->slug;
return home_url( $taxonomy_slug .'/' . $post->post_name );
@oterox
oterox / functions.php
Created April 28, 2019 15:14
WP Rest API cpt
/**
* Add REST API support to an already registered post type.
*/
add_filter( 'register_post_type_args', 'my_post_type_args', 10, 2 );
function my_post_type_args( $args, $post_type ) {
if ( 'destination' === $post_type ) {
$args['show_in_rest'] = true;
@oterox
oterox / class-wc-api-custom.php
Last active April 28, 2019 15:18
Cutom API class woocommerce
<?php
class WC_API_Custom extends WC_API_Resource {
protected $base = '/experiences';
public function register_routes( $routes ) {
$routes[ $this->base ] = array(
array( array( $this, 'get_experiences' ), WC_API_Server::READABLE )
);
return $routes;
@oterox
oterox / scroll-anchor.js
Last active May 30, 2019 08:51
Scroll anchor jquery
$(window).load(function(){
// Quitamos el # del hash
var hash = location.hash.replace('#','');
//Si hay un hash es que vamos a mostrar un tipo de pista
if(hash != ''){
//Hacemos scroll al id que viene en el hash y le quitamos 50px para que aparezca debajo del menú
$('html, body').animate({ scrollTop: $('#' + hash).offset().top - 50}, 1000);
}