Code Snippets
Recent Code Snippets
Jetpack: remove External Media from the block editor
This PHP code snippet removes Jetpack’s External Media feature by hooking into the block editor assets and adding JavaScript to remove the external media hooks. This ensures that the external media functionality is disabled when using Jetpack.
September 13, 2022
Jetpack Related Posts
A collection of useful snippets to modify Jetpack Related Posts.
September 13, 2022
Jetpack: Add UTM Tracking to Sharing Buttons
PHP/** * Overwrite the links used in Jetpack's Sharing module. * * @see https://wordpress.org/support/topic/how-to-use-utm-codes-with-jetpack-sharing * * @param string $url *…
September 13, 2022
Jetpack Subscriptions
PHP/** * Redirect all successful subscription submissions to a 'thank-you' page. */ function hlabs_custom_sub_redirect_page( $result ) { if ( 'success'…
September 13, 2022
Date & Time Snippets for WordPress
PHP$time_now = new DateTimeImmutable( 'now', wp_timezone() ); $time_tonight = new DateTimeImmutable( 'today 24:00', wp_timezone() ); $seconds_remaining = $time_tonight->getTimestamp() - $time_now->getTimestamp();
September 13, 2022
Jetpack
Enable Development Mode: Choose modules to be activated by default: Deactivate All Jetpack Modules by Default Completely Hide Modules from the Jetpack Page Turn off Jetpack publish by default:
September 13, 2022
Jetpack Photon Snippets
Determine if Jetpack is installed and can generate photon URLs: Determine whether photon is an active Jetpack module: Example how to apply photon to any image you wish to load via custom theme: Example with argument: Set custom photon arguments for all photon urls: Set header Image to use photon: Supported query arguments: Parameter Description […]
September 13, 2022
Block Editor social icons open in new tab and add hover titles
Changes social links to target a new tab.
September 11, 2022