junio 2020

Toolset: Shortcode para visualizar la fecha de modificación de un post

add_shortcode('wpv-post-modified', 'wpv_post_modified_shortcode');
function wpv_post_modified_shortcode($atts) {
if (empty($atts['format'])) {
$atts['format'] = get_option('date_format');
}
return get_the_modified_date($atts['format']);
}
[wpv-post-modified format="d-m-Y"]

https://toolset.com/forums/topic/adding-a-shortcode-for-the-last-modified-date/

Toolset: Shortcode para visualizar la fecha de modificación de un post Leer más »

Bootstrap: Alto y ancho de las imagenes de las cards

/* Equal-height card images, cf. https://stackoverflow.com/a/47698201/1375163*/
.card-img-top {
    /*height: 11vw;*/
    object-fit: cover;
}
  /* Small devices (landscape phones, 576px and up) */
  @media (min-width: 576px) {
    .card-img-top {
        height: 19vw;
    }
  }
  /* Medium devices (tablets, 768px and up) */
  @media (min-width: 768px) {
    .card-img-top {
        height: 16vw;
    }
  }
  /* Large devices (desktops, 992px and up) */
  @media (min-width: 992px) {
    .card-img-top {
        height: 11vw;
    }
  }
  /* Extra large devices (large desktops, 1200px and up) */
  @media (min-width: 992px) {
    .card-img-top {
        height: 11vw;
    }
  }

https://stackoverflow.com/questions/37287153/how-to-get-images-in-bootstraps-card-to-be-the-same-height-width

Bootstrap: Alto y ancho de las imagenes de las cards Leer más »

Woocommerce: Aplicando impuestos / IVA solo en la página de producto de WooCommerce

function edit_price_display($price, $instance) {
    global $product;

    if(is_singular('product')) {
        $price = $product->price;
        $price_incl_tax = $price + round($price * ( 21 / 100 ), 2);
        $price_incl_tax = number_format($price_incl_tax, 2, ",", ".");
        $price = number_format($price, 2, ",", ".");
        $display_price = '<span class="price">';
        $display_price .= '<span class="amount">€ ' . $price_incl_tax .'<small class="woocommerce-price-suffix"> incl BTW</small></span>';
        $display_price .= '<br>';
        $display_price .= '<span class="amount">€ ' . $price .'<small class="woocommerce-price-suffix"> excl BTW</small></span>';
        $display_price .= '</span>';
        echo $display_price;
    } else {
        echo $price;	
    }
}
add_filter('woocommerce_get_price_html', 'edit_price_display', 10, 2);

Visto en tomjesch

Woocommerce: Aplicando impuestos / IVA solo en la página de producto de WooCommerce Leer más »

WordPress: Inhabilitar mostrar entradas y medios de otros usuarios

add_action('pre_get_posts', 'query_set_only_author' );
function query_set_only_author( $wp_query ) {
 global $current_user;
 if( is_admin() && !current_user_can('edit_others_posts') ) {
    $wp_query->set( 'author', $current_user->ID );
    add_filter('views_edit-post', 'fix_post_counts');
    add_filter('views_upload', 'fix_media_counts');
 }
}

Visto en Collectiveray

WordPress: Inhabilitar mostrar entradas y medios de otros usuarios Leer más »

WordPress: Bloquear wp-admin a no administradores

/**
 * Hide admin bar for non-admins
 */
function js_hide_admin_bar( $show ) {
	if ( ! current_user_can( 'administrator' ) ) {
		return false;
	}

	return $show;
}
add_filter( 'show_admin_bar', 'js_hide_admin_bar' );

/**
 * Block wp-admin access for non-admins
 */
function ace_block_wp_admin() {
	if ( is_admin() && ! current_user_can( 'administrator' ) && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
		wp_safe_redirect( home_url() );
		exit;
	}
}
add_action( 'admin_init', 'ace_block_wp_admin' );

WordPress: Bloquear wp-admin a no administradores Leer más »

View select all in filter and live search

<input type="checkbox" id="selecctall_neighborhood" name="selecctall_neighborhood" value="selecctall_neighborhood" class="js-wpv-filter-trigger" [wpv-conditional if=" ('[wpv-search-term param="selecctall_neighborhood"]' eq 'selecctall_neighborhood') "]checked="checked"[/wpv-conditional] />
jQuery( document ).on( 'js_event_wpv_parametric_search_results_updated', function( event, data ) {
    /**
    * data.view_unique_id (string) The View unique ID hash
    * data.layout (object) The jQuery object for the View layout wrapper
    */
    $('#selecctall_neighborhood').click(function(event) {  //on click 
        if(this.checked) { // check select status
            $('#check_neighborhood .js-wpv-filter-trigger').each(function() { //loop through each checkbox
                this.checked = true;  //select all checkboxes with class "checkbox_neighborhood"               
            });
        }else{
            $('#check_neighborhood .js-wpv-filter-trigger').each(function() { //loop through each checkbox
                this.checked = false; //deselect all checkboxes with class "checkbox_neighborhood"                       
            });         
        }
    });
});

Visto en Toolset

View select all in filter and live search Leer más »

Scroll al inicio