Skip to content

Instantly share code, notes, and snippets.

@juanmafla
juanmafla / filesize.php
Created March 17, 2023 14:19
Wordpress file size
/* get width and height */
$file= wp_get_attachment_image_src( 1118, 'medium');
$image_width= $file[1];
$image_height= $file[2];
/*get file size */
$filemeta= wp_get_attachment_metadata(1118); //1118 is attachment ID
$upload_dir= wp_upload_dir();
$filemeta_array = explode("/", $filemeta['file']);
function bp_nouveau_get_group_potential_invites( $args = array() ) {
$r = bp_parse_args( $args, array(
'group_id' => bp_get_current_group_id(),
'type' => 'alphabetical',
'per_page' => 20,
'page' => 1,
'search_terms' => false,
'member_type' => false,
'user_id' => 0,
<?php
$args = array(
'post_type' => 'comentarios_facebook',
'post_status' => 'publish',
);
$comentarios = new WP_Query( $args );
if( $comentarios->have_posts() ) :
?>
<ul>
function exclude_sub_units($query) {
if(!is_admin() || wp_doing_ajax() ) {
@juanmafla
juanmafla / proportions.php
Created August 22, 2017 19:58
Calculate proportions in php
function propor($nwidth, $nheight, $mwidth, $mheight) {
$percentChange = $nwidth / $mwidth;
$newHeight = round( ( $percentChange *$mheight ) );
if($nheight==$newHeight ) {
return true;
} else {
return false;
}
@juanmafla
juanmafla / get-taxonomy.php
Last active August 12, 2017 16:23
Wordpress get taxonomy terms
<ul class="categories">
<?php
$terms = get_terms(array(
'taxonomy' => 'maquinaria_tax',
'hide_empty' => false,
));
foreach ($terms as $term) {
@juanmafla
juanmafla / functions.php
Created July 25, 2017 17:01
Wordpress. Login user after registration. (After a user has successfully registered, login automatically)
// add this to functions.php file
function reg_new_user( $user_id ) {
$userdata= get_userdata($user_id); // get new user data by ID
wp_set_current_user( $user_id, $userdata->user_email ); //set user with ID and E-mail
wp_set_auth_cookie( $user_id ); // set cookie by user ID
do_action( 'wp_login', $userdata->user_email ); // wp_login action hook with user E-mail
@juanmafla
juanmafla / supply-social-sharing
Created April 9, 2016 15:41 — forked from cshold/supply-social-sharing
A snippet for social sharing buttons in a Shopify theme. Notice the use of theme settings to show/hide each button.
{% comment %}
This snippet is used to showcase each collection during the loop,
'for product in collection.products' in list-collections.liquid.
{% endcomment %}
{% assign shareCountClass = '' %}
{% if template contains 'article' or template contains 'blog' %}
{% capture permalinkURL %}{{ shop.url }}{{ article.url }}{% endcapture %}
@juanmafla
juanmafla / related-products.liquid
Created April 9, 2016 01:57 — forked from carolineschnapp/related-products.liquid
Related Products — to add to product.liquid
@juanmafla
juanmafla / 0_reuse_code.js
Last active August 29, 2015 14:10
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console