Skip to content

Instantly share code, notes, and snippets.

View nickcernis's full-sized avatar

Nick Cernis nickcernis

  • Innsbruck, Austria
  • 11:37 (UTC +02:00)
View GitHub Profile
@nickcernis
nickcernis / functions.php
Last active August 24, 2022 18:10
Set Genesis static homepage site title and entry title heading levels to h1 and h2
<?php
add_filter( 'genesis_entry_title_wrap', 'custom_homepage_title_to_h2' );
/**
* Set page title to h2 on a static homepage if Genesis SEO is not in use.
*
* @param string $wrap The original wrap.
* @return string The new wrap.
*/
function custom_homepage_title_to_h2( $wrap ) {
if ( is_front_page() && ! is_home() && ! genesis_seo_active() ) {
@nickcernis
nickcernis / wp-cli-snippets.md
Last active August 10, 2022 12:00
WP-CLI snippets

Delete all menus

wp menu list --format=ids | xargs wp menu delete

Delete posts of one type in bulk

wp post list --post_type='post-type-here' --format=ids | xargs wp post delete --force
@nickcernis
nickcernis / mailchimp-popup-for-wordpress.md
Last active July 28, 2022 14:49
MailChimp Popup Script that works with WordPress sites

MailChimp's default popup scripts can break on WordPress sites that use jQuery/jQuery UI unless you include their embed code as the final elements before the closing body tag.

Including them in this way isn't always possible or easy with WordPress.

The code below is an alternative implementation of the loader that forces MailChimp's popup scripts to appear below all other scripts upon page load.

To use it, modify the baseUrl, uuid, and lid attributes with the ones from the original popup script that MailChimp supplies.

@nickcernis
nickcernis / intellij-transparent-mac.md
Last active June 7, 2022 08:22
IntelliJ IDEA JetBrains make Mac titlebar transparent

To make the Mac titlebar transparent in IntelliJ IDEA, CLion, Rider, PhpStorm, WebStorm, and other JetBrains products:

  1. Help → Edit Custom Properties…
  2. Add this line to the file, save, and restart: ide.mac.transparentTitleBarAppearance=true

It should then take on the base colour of your theme.

@nickcernis
nickcernis / functions.php
Created November 29, 2021 17:21
Prevent footer text escaping in Genesis
<?php
// Omit the opening <?php above when adding this to your active theme's functions.php.
add_filter( 'genesis_footer_output', 'custom_genesis_do_footer_unmodified' );
/**
* Outputs Genesis footer text without calling `wp_kses_post()`
* to strip attributes for security purposes.
*/
function custom_genesis_do_footer_unmodified() {
$footer_text = genesis_get_option( 'footer_text' );
@nickcernis
nickcernis / functions.php
Last active September 6, 2020 06:34
Genesis Simple Share Shortcode
<?php
// Adds a [social-icons] shortcode to output Genesis Simple Share icons in posts
// https://wordpress.org/plugins/genesis-simple-share/
// Add the code below to your active theme's functions.php file,
// or use in a site-specific plugin.
// The shortcode takes no attributes; change your icon settings via Genesis → Simple Share.
add_shortcode( 'social-icons', 'gss_shortcode' );
@nickcernis
nickcernis / functions.php
Last active August 6, 2020 14:39
Count widgets that are active for the current WPML language
<?php
/**
* Count widgets in a given sidebar, taking WPML language switching into account.
*
* Assumes widget languages are switched with the WPML String Translation or WPML Widgets plugins.
*
* @param string $id The sidebar ID.
*
* @return int The count of widgets in the sidebar.

Keybase proof

I hereby claim:

  • I am nickcernis on github.
  • I am nickcernis (https://keybase.io/nickcernis) on keybase.
  • I have a public key ASBvU4zu6cS48NykeyxX4A6zupanqwouo_gAEMuMysQSBgo

To claim this, I am signing this object:

@nickcernis
nickcernis / functions.php
Last active May 12, 2020 12:47
Wrap Genesis titles with a link on singular posts and pages
<?php
add_filter( 'genesis_post_title_output', 'custom_wrap_singular_titles_with_links', 10, 3 );
/**
* Wrap the post title with a link on singular entries.
*
* @param string $output The original title output (title content and tags).
* @param string $wrap The title tag.
* @param string $title The content of the title tag.
* @return string The new title output.
*/
@nickcernis
nickcernis / add-editor-layout-classes.js
Last active February 20, 2020 09:09
Add Genesis layout class to Gutenberg editor pages (admin)
// Add genesis layout classes to the Block Editor.
// File lives in the theme's /js/ folder.
wp.domReady(function () {
yourTheme.updateLayoutClass();
var layouts = document.querySelector(".genesis-layout-selector");
if( layouts ) {
layouts.addEventListener("input", function (e) {
yourTheme.updateLayoutClass();