Automating my local dev environment with Laravel Valet and WP-CLI

laravel-valet

When I set up my new machine, I decided to get rid of MAMP and Vagrant, my previous local development tools of choice. While they worked well for me, I needed something a bit different. I need to be able to spin up a fresh installation of WordPress, run a few tests, and burn it all down a few minutes later.

A few months ago, I discovered Laravel Valet. Valet is a tool relying on Caddy and Dnsmasq, allowing you to spin up PHP projects in a few seconds. You can learn more about it here. It seemed like the perfect tool for me, so I decided to combine it with WP-CLI to quickly launch WordPress sites on my laptop.

Let’s dive into the different steps I follow to get this to work.

On Repeat Today: Roudoudou

18 years later, I still get goose bumps when listening to that song. I first heard that song in a documentary named “Les Yeux Dans Les Bleux”. Back in 1998, France was hosting the Football World Cup, and a journalist followed the French team every day and night, during pre-cup training and during the tournament. It gave us a very intimate view into their motivations, their every-day struggles, as if we had been with them.

18 ans plus tard, j’ai toujours la chair de poule lorsque j’écoute cette chanson. Je lai entendu pout la première fois dans le documentaire “Les Yeux Dans Les Bleux”, en 1998. Si vous n’avez pas vu ce documentaire et si vous êtes un peu intéressés par le foot, je vous conseille de vous le procurer. Si vous l’avez déjà vu, c’est peut être le moment de le regarder une nouvelle fois 😊

Le film nous avait donné une vision différente de l’équipe, leurs motivations, leurs problèmes de tous les jours, et l’union de tous les joueurs. Bref, à voir et revoir !

Ready for The Defenders?

Did you like Marvel’s Daredevil, season 1 and 2? You probably watched Jessica Jones as well, where we got to know Luke Cage and discovered that all 3 characters lived in the same city and would maybe make a good team.

Well, that’s happening! Make note, as there are 3 more series coming up on Netflix for you:

Marvel’s Luke Cage

Marvel’s Iron Fist

A new hero joins the team! I’m so waiting for that one. It has a nice mystical feeling to it, a la Doctor Strange. And, you know, Kung Fu! :)

Marvel’s The Defenders

And finally, the whole team coming together!

A new apartment

Home Sweet Home!

About a year ago, Adri and I bought a new apartment. Over the months that followed, we planned, scheduled, and worked with contractors to make this place our home. After 10 months of work, we’re quite happy with the result!

For posterity’s sake, here are a few pictures of the process.

Continue reading

Jetpack: Add Related Posts to your RSS feed

dupondt-related

I got an interesting question in the Jetpack support forums today. Levy wanted to display Related Posts in their RSS feed.

Jetpack displays Related Posts at the bottom of single posts by default, but like with other modules, you can customize Related Posts. In this post, we’ll use the the_content filter and the raw Jetpack Related Posts class to build our own unordered list of Related Posts, and add it to the bottom of the post content in RSS feeds.

Quick note before we start:

  • You’ll want to add that code to a functionality plugin like this one.
  • Nothing will happen if you’re not using Jetpack and its Related Posts module.
/**
 * Add Jetpack Related Posts to RSS feed.
 *
 * @see https://wordpress.org/support/topic/2927523
 */
function jeherve_related_posts_feed( $content ) {
	// Return early if we're not in the RSS feed.
	if ( ! is_feed() ) {
		return $content;
	}

	// If Jetpack and Related Posts are active, let's get started.
	if ( class_exists( 'Jetpack_RelatedPosts' ) && method_exists( 'Jetpack_RelatedPosts', 'init_raw' ) ) {
		$related = Jetpack_RelatedPosts::init_raw()
			->set_query_name( 'jetpackme-shortcode' ) // Optional, name can be anything
			->get_for_post_id(
				get_the_ID(),
				array( 'size' => 3 )
			);

		if ( $related ) {
			$related_list = '';

			foreach ( $related as $result ) {
				// Get the related post IDs
				$related_post_id = get_post( $result[ 'id' ] );

				/**
				 * From there you can do just about anything, using the post IDs.
				 *
				 * In this example, we'll build an unordered list.
				 */
				$related_list .= sprintf(
					'<li><a title="%1$s" href="%2$s">%3$s</a></li>',
					esc_attr( get_the_title( $related_post_id ) ),
					get_permalink( $related_post_id ),
					get_the_title( $related_post_id )
				);
			}

			/**
			 * Let's wrap all those related posts in ul tags, and add that list to the end of our post content.
			 *
			 * We will also add a headline, but only if it was set to be displayed in your Jetpack Related Posts settings.
			 */
			$related_options = Jetpack_Options::get_option( 'relatedposts' );
			if ( $related_options['show_headline'] ) {
				$headline = sprintf(
					'<h3 class="jp-relatedposts-headline"><em>%s</em></h3>',
					esc_html__( 'Related', 'jetpack' )
				);
			} else {
				$headline = '';
			}

			return sprintf(
				'%1$s%2$s<ul class="jp-relatedposts">%3$s</ul>',
				$content,
				apply_filters( 'jetpack_relatedposts_filter_headline', $headline ),
				$related_list
			);
		}

		return $content;
	}

	// Last fallback, just in case Jetpack and Related Posts aren't there anymore.
	return $content;
}
add_filter( 'the_content', 'jeherve_related_posts_feed' );