Skip to content

Instantly share code, notes, and snippets.

View javierarques's full-sized avatar

Javier javierarques

View GitHub Profile
@javierarques
javierarques / gist:5444534
Last active April 6, 2017 14:34
Wordpress. Set custom template for taxonomies. Change default template. template_include filter
// Add the filter
add_filter( 'template_include', 'my_custom_template');
/**
* Returns customized templates for custom taxonomies
*
* @param string $template
* @return string
*/
function my_custom_template ( $template ) {
@javierarques
javierarques / gist:5684664
Created May 31, 2013 12:26
Dropdown for taxonomies
function dropdown_taxonomy ( $taxonomy, $all_option = 'todo') {
$terms = get_terms ( $taxonomy );
?>
<!-- START taxonomy Search -->
<select name="<?php echo $taxonomy ?>">
<option value=''><?php echo $all_option ?></option>
<?php foreach($terms as $term): ?>
<option value="<?php echo $term->name ;?>" <?php selected(get_query_var($taxonomy), $term->name, true) ?>>
<?php echo $term->name ?>
@javierarques
javierarques / gist:5713635
Created June 5, 2013 12:52
Share on Wordpress Compartir en Wordpress Compartir sin los javascript de Facebook ni Twitter en una ventana emergente
<ul class="share-buttons">
<li>¿Te ha gustado? Compártelo!</li>
<li><a href="javascript: return false;" onclick="window.open('http://www.facebook.com/sharer.php?u=<?php the_permalink();?>&t=<?php echo urlencode(get_the_title()) ?>','window','width=550,height=400')" class="btn btn-small"><i class="facebook"></i> Facebook</a></li>
<li><a href="javascript: return false;" onclick="window.open('https://twitter.com/share?url=<?php the_permalink();?>&text=<?php echo get_the_title() ?>&via=cuidadoinfantil','window','width=550,height=400')" class="btn btn-small"><i class="twitter"></i> Twitter</a></li>
<li><a href="javascript: return false;" onclick="window.open('https://plus.google.com/share?url=<?php the_permalink();?>','window','width=450,height=430')" class="btn btn-small"><i class="google"></i> Google+</a></li>
<? /* <li><a href="javascript: return false;" onclick="window.open('https://www.linkedin.com/cws/share?url=<?php the_permalink();?>&title=<?php echo urlencode(get_the_title())?>&original_referer=<?php
@javierarques
javierarques / gist:5956890
Last active December 19, 2015 12:39
Pagination on Buddypress Components. Buddypress pagination. Buddypress rewrite rules
function bp_component_screen_controller() {
global $bp;
//Are we in the current type
if ( $bp->current_component == BP_YOUR_COMPONENT_SLUG ) {
// The directory.
if ( (empty( $bp->current_action ) || ($bp->current_action == 'page')) &&
(empty( $bp->action_variables ) || is_numeric($bp->action_variables[0]))) {
@javierarques
javierarques / gist:6669598
Created September 23, 2013 12:07
CSS3 calendar icon with SASS
// Calendar icon
//------------------------//
.calendar-icon {
// Contenedor principal
display: inline;
float: left;
height: 14px;
margin: 6px 3px 0 0;
position: relative;
@javierarques
javierarques / gist:7150398
Created October 25, 2013 06:52
Unregister wp-login default css
function remove_wp_login_styles () {
add_filter( 'style_loader_tag', '__return_null' );
}
add_action( 'login_init', 'remove_wp_login_styles');
@javierarques
javierarques / gist:8304351
Created January 7, 2014 18:43
[WP] Create post with Contact Form 7 post data via wpcf7_before_send_mail hook
add_action('wpcf7_before_send_mail', 'cf7_create_post', 10, 1);
function cf7_create_post( $data ) {
extract($data->posted_data);
$post_id = wp_insert_post( array(
'post_status' => 'draft',
'post_title' => $nombre,
'post_content' => $consulta
@javierarques
javierarques / gist:8577543
Created January 23, 2014 12:07
Woocommerce - Filter orders in wp-admin by products
/***********************************************************************************
* 2. FILTRO POR PRODUCTOS EN PEDIDOS
***********************************************************************************/
define('FILTRO_PRODUCT_NAME', 'filtro_producto');
define('ORDER_POST_TYPE', 'shop_order');
/**
* Añade la query de las sedes
* Hook 'pre_get_posts'
@javierarques
javierarques / gist:9070480
Created February 18, 2014 12:58
Create multiple Buddypress profile fields. Crear varios campos de Buddypress con una query mysql, en este ejemplo creamos todos los países.
function bulk_insert_buddypress_fields ( $group_id, $parent_id, $type ) {
$fields =
"Afganistán
Albania
Alemania
Andorra
Angola
Anguilla
Antártida
Antigua y Barbuda
@javierarques
javierarques / gist:9919188
Created April 1, 2014 17:42
Removes facebook avatar metas saved by wp fb autoconnect plugin when a Buddypress user upload a new avatar
/**
* Removes facebook avatar URL save in user metas by wp fb autoconnect plugin
* requires Buddypress & wp-fb-autoconnect
* @global type $bp
*/
function remove_facebook_avatar () {
global $bp;
delete_user_meta($bp->displayed_user->id, 'facebook_avatar_full');
delete_user_meta($bp->displayed_user->id, 'facebook_avatar_thumb');
}