Get an excerpt for a post outside of the loop

The WordPress get_the_excerpt() function does not behave well outside of a loop.

This will do so nicely:

/**
 * Get the excerpt for a post for use outside of the loop.
 *
 * @param int|WP_Post $post ID or WP_Post object.
 * @param int         Optional excerpt length.
 * @return string Excerpt.
 */
function prefix_get_the_excerpt( $post, $excerpt_length = null ) {

	$excerpt = get_post_field( 'post_excerpt', $post );

	if ( '' === $excerpt ) {

		$content = get_post_field( 'post_content', $post );

		// An empty string will make wp_trim_excerpt do stuff we do not want.
		if ( '' !== $content ) {

			$excerpt = strip_shortcodes( $content );

			/** This filter is documented in wp-includes/post-template.php */
			$excerpt = apply_filters( 'the_content', $excerpt );
			$excerpt = str_replace( ']]>', ']]>', $excerpt );

			if ( ! $excerpt_length ) {
				/** This filter is documented in wp-includes/formatting.php */
				$excerpt_length = apply_filters( 'excerpt_length', 55 );
			}

			/** This filter is documented in wp-includes/formatting.php */
			$excerpt_more = apply_filters( 'excerpt_more', ' ' . '[…]' );

			$excerpt = wp_trim_words( $excerpt, $excerpt_length, $excerpt_more );
		}
	}

	return apply_filters( 'the_excerpt', $excerpt );
}

/**
 * The excerpt for a post for use outside of the loop.
 *
 * @param int|WP_Post $post ID or WP_Post object.
 * @param int         Optional excerpt length.
 */
function prefix_the_excerpt( $post, $excerpt_length = null ) {

	echo wp_kses_post( prefix_get_the_excerpt( $post, $excerpt_length ) );
}

How to cancel Adobe Creative Cloud outside of the US

  1. Log in to your Adobe account.
  2. Click “Cancel Account”.
  3. Ah outside of the US you need to contact support to cancel your account WTF?
  4. Click through several steps to be able to view your contact options.
  5. Log in again.
  6. Chat currently closed, although it is within office hours.
  7. Let’s call support…
  8. Line is dead, no answer.
  9. One last support method is mentioned: “Ask our community”. Yeah right.
  10. Try again tomorrow.

More about: dark patterns.

And then:

Couldn't uninstall Creative Cloud for Desktop

…le sigh…

Using a Wacom CTE-430 Sapphire Tablet with OS X Yosemite

I recently bought a Macbook Air with OS X Yosemite installed and tried to using my spare Wacom Sapphire CTE-430 tablet with it. Wacom unfortunately does not support older tablets. At least not explicitly. As it turns out you can use an older driver to get the tablet up and running. Continue reading “Using a Wacom CTE-430 Sapphire Tablet with OS X Yosemite”