Installing Let’s Encrypt on Ubuntu 16.04 with Apache server

sudo apt-get install python-letsencrypt-apache

Resource: How To Secure Apache with Let’s Encrypt on Ubuntu 16.04
Resource: How to install and use Let’s Encrypt on a Ubuntu Server for SSL security

WooCommerce 3.1.2: How to restore “add to cart” button in product category page

I noticed “add to cart” (or “select option” for variable products) buttons are no longer there with the most recent version of WooCommerce.
I checked content-product.php to see if the button was removed…it was not according to their template comment:

/**
 * The template for displaying product content within loops
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/content-product.php.
 *
 * HOWEVER, on occasion WooCommerce will need to update template files and you
 * (the theme developer) will need to copy the new files to your theme to
 * maintain compatibility. We try to do this as little as possible, but it does
 * happen. When this occurs the version of the template file will be bumped and
 * the readme will list any important changes.
 *
 * @see     https://docs.woocommerce.com/document/template-structure/
 * @author  WooThemes
 * @package WooCommerce/Templates
 * @version 3.0.0
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly
}

global $product;

// Ensure visibility
if ( empty( $product ) || ! $product->is_visible() ) {
	return;
}
?>
<li <?php post_class(); ?>>
	<?php
	/**
	 * woocommerce_before_shop_loop_item hook.
	 *
	 * @hooked woocommerce_template_loop_product_link_open - 10
	 */
	do_action( 'woocommerce_before_shop_loop_item' );

	/**
	 * woocommerce_before_shop_loop_item_title hook.
	 *
	 * @hooked woocommerce_show_product_loop_sale_flash - 10
	 * @hooked woocommerce_template_loop_product_thumbnail - 10
	 */
	do_action( 'woocommerce_before_shop_loop_item_title' );

	/**
	 * woocommerce_shop_loop_item_title hook.
	 *
	 * @hooked woocommerce_template_loop_product_title - 10
	 */
	do_action( 'woocommerce_shop_loop_item_title' );

	/**
	 * woocommerce_after_shop_loop_item_title hook.
	 *
	 * @hooked woocommerce_template_loop_rating - 5
	 * @hooked woocommerce_template_loop_price - 10
	 */
   
	do_action( 'woocommerce_after_shop_loop_item_title' );

	/**
	 * woocommerce_after_shop_loop_item hook.
	 *
	 * @hooked woocommerce_template_loop_product_link_close - 5
	 * @hooked woocommerce_template_loop_add_to_cart - 10
	 */
    
   	do_action( 'woocommerce_after_shop_loop_item' );
	?>
</li>

Regardless, the button is still not there so I added the button again in the current theme’s functions.php (since I wasn’t making any other overwrite):

//woocommerce - restore "add to cart" button in product category page
add_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 20 );

And voila, it’s back.

The same disappearance behavior was observed in multiple themes…so I’m suspecting something happened in WooCommerce plugin (as opposed to a theme-related bug).

Include CSS the right way in a WordPress’ child theme

We really should be using wp_enqueue_style functions to include your theme’s stylesheets rather than using @import statements. The enqueue functions allows us to specify dependencies in much better way.

//enqueue style for child theme
function  custom_child_enqueue_styles(){
	// enqueue parent styles
	wp_enqueue_style('parent-theme', get_template_directory_uri() . '/style.css' );
	// enqueue child styles - style.css
	wp_enqueue_style('parent-theme-child', get_stylesheet_directory_uri() .'/style.css', array('parent-theme'));
	// enqueue child styles - scss/child.css
	wp_enqueue_style('parent-theme-child-scss', get_stylesheet_directory_uri() .'/scss/child.css', array('parent-theme', 'parent-theme-child'));
}
add_action('wp_enqueue_scripts', 'custom_child_enqueue_styles');

Finger Lake Triathlon 2017 – Olympic Distance Result

Official Result:

Total Time: 3:34:25
Place: 116 (out of 139)
Place Female Only: 30 (out of 42)
Place Female Age Group 40-45: 4 (out of 6)
Swim: 39:26 (2:38 100s pace)
Bike: 1:43:15 (14.17 mile per hour)
Run: 1:05:48 (10:37 per mile)

Thoughts on the race:

I’m just happy that I finished the race….without resorting to walking. I’ve been slacking with training. 15 lbs more than last year’s race…and let me assure you, it’s not muscle weight gain.

I swam half breaststroke, half freestyle. My priority was conserving energy for later, and I think I made the right decision. Unlike last year, the water wasn’t shallow so we weren’t dolphin diving much.

Last week, when I did a dry run of the entire olympic course, I run out of fuel and had a energy crash. So I decided to refuel twice, one at the beginning of the bike route, and another at the halfway into the bike route. I went with Honey Stinger Waffles, and it worked well. Except that I should have opened the wrapper before getting on the bike. I almost lost balance trying to open that thing.

And the run, I knew I was going to be slower than last year…especially carrying extra 15 lbs & doubling the distance. I’m pretty happy that I was under 11 minutes per mile. And because I refueled properly, I had enough energy to complete the run without exhausting myself.

Next Goals:

Run – under 10 minutes per mile
Bike – over 15 miles per hour
Swim – 100% freestyle
Overall – less than 3:30:00 total time.

I already signed up with a group swimming lessons for the fall. Hopefully, I can finally swim faster with freestyle than breaststroke next year. I’ve been working on my arm during the summer. This fall I will be working on my legs, and the winter lessons will be putting the two together to get the form right.

Next race is Wineglass half marathon in Corning in about 4 weeks. My goal is to run daily, bike twice a week, and swim once a week. I’ll need to start counting calorie intakes to lose some weight so that it will be easy on my knees. I probably have to give up the daily Starbucks drink for a while too (maybe reduce it to every other day).

CLI command cheatsheet – Git

I still can’t memorize these:

## To stage your whole working tree:
git commit -a

## to force commit
git push origin master --force

##clone to a specific folder
git clone https://example.com/path/to/gitfile.git destination-folder-name

CSS Trick – anchor position adjustment

HTML

<ul>
  <li><a href="#link1"</li>
  <li><a href="#link2"</li>
</ul>
<a name="link1" class="anchor"></a>
<p>Some content goes here.</p>
<a name="link2" class="anchor"></a>
<p>Some content goes here.</p>

CSS

.anchor {/*anchor link*/
	display: block; 
	position: relative; 
	top: -50px; 
	visibility: hidden;
}

How to change thumbnail size for Divi’s gallery module

post_thumbnails_divi.php is where Elegant Themes‘ Divi specifies the custom image sizes:

add_theme_support( 'post-thumbnails' );

global $et_theme_image_sizes;

$et_theme_image_sizes = array(
	'400x250'  => 'et-pb-post-main-image',
	'1080x675' => 'et-pb-post-main-image-fullwidth',
	'400x284'   => 'et-pb-portfolio-image',
	'510x382'   => 'et-pb-portfolio-module-image',
	'1080x9999' => 'et-pb-portfolio-image-single',
	'400x516'   => 'et-pb-gallery-module-image-portrait',
	'2880x1800' => 'et-pb-post-main-image-fullwidth-large',
);

$et_theme_image_sizes = apply_filters( 'et_theme_image_sizes', $et_theme_image_sizes );
$crop = apply_filters( 'et_post_thumbnails_crop', true );

if ( is_array( $et_theme_image_sizes ) ){
	foreach ( $et_theme_image_sizes as $image_size_dimensions => $image_size_name ){
		$dimensions = explode( 'x', $image_size_dimensions );

		if ( in_array( $image_size_name, array( 'et-pb-portfolio-image-single' ) ) )
			$crop = false;

		add_image_size( $image_size_name, $dimensions[0], $dimensions[1], $crop );

		$crop = apply_filters( 'et_post_thumbnails_crop', true );
	}
}

I wanted to modify the “et-pb-gallery-module-image-portrait” thumbnail size to be 500×500. Since I was using a child theme, my thought was to copy the post_thumbnails_divi.php into the child theme and change the value there.

…Nope, that didn’t work.
Continue reading “How to change thumbnail size for Divi’s gallery module”

Musselman Weekend 2017 – MiniMusselman Result

Official Result:

Total Time: 2:02:52
Swim: 18:38
Bike: 1:03:24
Run: 32:41
Overall Place: 485/612
Female Place: 222/317
Age Group: 31/42

Thoughts:

Not too happy about the result: 1) 10 lbs heavier than last year, 2) bottom 1/4 on average compared to right about 1/2 last year 3) has been lazy and not training enough
On the positive side, I did swim in freestyle most of the time (I’d say about 90 %), and I did run all the way, no walking.
Next race is Olympic distance at Finger Lake in Sept…I need to get serious about training…and cut out cheese, bread, and wine.

Rochester Duathlon 2017 – Sprint Distance Result

Official Result:

1:44:23 for 2.5K run + 14 miles bike + 5K run

We didn’t have a tracker on this event, so pretty much the total time is the only data I got. No each segment data or transition time. Also due to the weather the bike route got changed (distance changed).

#4 of 7 (right in the middle) for my age group (female only)
#11 of 20 (again right in the middle) for all female
#32 of 43 for all participant

Thoughts:

I think I did good considering…I run all the way (no walk) and I biked faster than my commute mode most of the time.

Need to cut out binge eating before the race…that is don’t eat 4.5 donuts 2 days before the race thinking that’s the only unhealthy food you are gonna eat and you can surely burn that off. Then a day before the race you end up eating a BOX of ice cream sandwiches ( = 12 sandwiches) because…I don’t know because there is a box of them in the freezer. Then you realize the food at the race looks awesome and you can’t stop yourself after the race….because you’re hungry.

I think I gained 5 pounds by doing the race.

Finger Lake Triathlon 2016 – Sprint Distance Result

Official Result:

Total Time: 1:45:56
Place: 207 (out of 353)
Place Female Only: 70 (out of 167)
Place Female Age Group 40-45: 6 (out of 17)
Swim: 16:06 (2:09 100s pace)
Bike: 54:34 (15.28 mile per hour)
Run: 30:20 (9:47 per mile)

Thoughts on the race:

Didn’t have to swim really…99% of the time I was doing dolphin dive because the water was shallow. Nice water temp at 71F. Waiting for the race was the worst part. The wind was pretty strong during the bike ride but I was expecting that…so no surprise there. The cool temp made the running much easier than the practice on Thursday…I think that’s the reason I was able to run under 10 min per mile (for the first time ever!). Need to get myself a pump. My tire was almost flat in the morning….luckily I was able to borrow one from a guy nearby. Need to figure out the best place to put the bike number…I got a bunch of paper cuts on my legs. That was annoying.

Next Goals:

Run – under 9 minutes per mile (next month)
Bike – over 16 miles per hour (next month)
Swim – 100% freestyle (that’s for next year)
Overall – less than 1:40:00 total time, would like to be top half for overall place.
I need to take swimming lessons over the winter. I’d like to squeeze a couple of dives too if I can (I need to find away to pay for all that)