Skip to content

Instantly share code, notes, and snippets.

View samikeijonen's full-sized avatar
🏠
Working from home

Sami Keijonen samikeijonen

🏠
Working from home
View GitHub Profile
@samikeijonen
samikeijonen / icon-nav.php
Last active September 11, 2016 09:20
Icons to navigation
<?php
/**
* Add SVG icon for dropdown in primary navigation.
*
* @since 1.0.0
*
* @param string $item_output The menu item output.
* @param WP_Post $item Menu item object.
* @param int $depth Depth of the menu.
* @param array $args wp_nav_menu() arguments.
@samikeijonen
samikeijonen / dynamic-sidebar-params.php
Last active August 25, 2016 18:18
Add content to recent post widget. In this case just before after_widget parameter.
<?php
/**
* Add content to Recent Posts Widget.
*
* @since 1.0.0
*
* @param array $params Array of widget arguments.
* @return array Modified 'after_widget' argument.
*/
function prefix_add_content_to_recent_post_widget( $params ) {
@samikeijonen
samikeijonen / sanse-100.php
Last active May 24, 2017 15:13
You want Sanse theme to get 100/100 in Google Page Speed? No problem. With this plugin theme styles are placed inline in the header, and we're done.
<?php
/**
* Plugin Name: Sanse 100
* Plugin URI: https://foxland.fi/
* Description: Load Sanse theme styles inline in the header.
* Version: 1.2.1
* Author: Sami Keijonen
* Author URI: http://foxnet.fi/
* Text Domain: sanse-100
* Domain Path: /languages
Onpas taas kiva kun on kesä. Linnut visertää, ihmiset tuoksuu saunan puhtaalle ja pieni sadekaan ei tunnu luonnon harmoniaa haittaavan.
On se vaan niin mukavan rauhallista viettää kesälomaa mökillä ja kuunnella laineiden liplatusta. Hyttysten leikkisän syöntikilpailun
seuraaminenkin on yksinäiselle ihmiselle yllättävän mukavaa puhaa. Tulkaa vaan kaikki hyttyset ja paarmat tännepäin!
Taidanpa kuitenkin soittaa ruotsinserkulle Håkanille, josko hän ehtisi pitkästä aikaa käymään visiitillä.
<?php
/**
* Handles JavaScript detection.
*
* Adds a `js` class to the root `<html>` element when JavaScript is detected.
*
* @since Twenty Sixteen 1.0
*/
function twentysixteen_javascript_detection() {
@samikeijonen
samikeijonen / attendee-list.php
Last active December 17, 2019 06:06
Display posts by alphabetical order in a way that first letter of each name is presented.
<?php
/**
* Display 'attendee' post type in alphabetical order by it's category.
*
* The output looks like this:
*
* A
* Ace Bill
* Alb Nick
.icon {
display: inline-block;
fill: currentColor;
height: 1em;
width: 1em;
vertical-align: middle;
position: relative; /* Align more nicely with capital letters */
top: -0.0625em;
}
@samikeijonen
samikeijonen / social-menu.php
Last active April 14, 2022 17:35
SVG social menu markup
<nav class="menu-social social-navigation menu" role="navigation">
<?php wp_nav_menu(
array(
'theme_location' => 'social',
'container_class' => 'social-menu-wrapper',
'menu_id' => 'menu-social-items',
'menu_class' => 'menu-social-items',
'depth' => 1,
'link_before' => '<span class="screen-reader-text">',
@samikeijonen
samikeijonen / inline-svg-sprite.php
Last active May 8, 2016 09:35
Inline SVG sprite
<body>
<?php
// 1. Include SVG images from assets/images folder right after <body> element.
$svg_icons = get_template_directory() . '/assets/images/svg-icons.svg';
require_once( $svg_icons );
// 2. Include for example Twitter icon from SVG sprite. This can be anywhere in your markup.
?>
<svg class="icon icon-twitter">
@samikeijonen
samikeijonen / add-menu-item-class.php
Last active May 7, 2016 09:34
Add category slug in WordPress menu <li> element using nav_menu_css_class filter.
<?php
/**
* Add category slug as a class to 'categories' menu <li> element.
*
* @since 1.0.0
*
* @param array $classes The CSS classes that are applied to the menu item's `<li>` element.
* @param object $item The current menu item.
* @param array $args An array of {@see wp_nav_menu()} arguments.
* @return array Menu <li> element classes.