Skip to content

Instantly share code, notes, and snippets.

View mor10's full-sized avatar

Morten Rand-Hendriksen mor10

View GitHub Profile
@mor10
mor10 / functions.php
Created July 11, 2016 20:14
Alternative method for adding parent theme stylesheet to WordPress child theme
<?php
// Enqueue the parent theme stylesheet, then the child theme stylesheet.
// Used in place of @import rule in child theme style.css
function child_theme_name_enqueue_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', array( 'parent-style' ) );
}
add_action( 'wp_enqueue_scripts', 'child_theme_name_enqueue_styles' );
@mor10
mor10 / leos-twisty-toy.ino
Created February 7, 2018 02:15
Arduino script for detecting three analog potentiometer inputs and output four LEDs: red, green, blue, and RGB
// Pin declarations
int potPinR= A0; // Declare potPinR to be analog pin A0
int potPinG= A1; // Declare potPinG to be analog pin A1
int potPinB= A2; // Declare potPinB to be analog pin A2
int LEDPinR= 9; // Declare LEDPinR to be arduino pin 9
int LEDPinG= 10; // Declare LEDPinR to be arduino pin 10
int LEDPinB= 11; // Declare LEDPinR to be arduino pin 11
// Variables
int readValueR; // Use to store value from red potentiometer
@mor10
mor10 / functions.php
Created July 11, 2016 23:44
Custom page template with no sidebar for Twenty Sixteen child theme
<?php
/**
* Adds custom classes to the array of body classes.
*
* @param array $classes Classes for the body element.
* @return array (Maybe) filtered body classes.
*/
function wpcampus_body_classes( $classes ) {
// Adds a class of no-sidebar to custom no-sidebar page template.
if ( is_page_template('page-no-sidebar.php') ) {
@mor10
mor10 / header.php
Last active October 16, 2019 10:53
Reposition header image and logo in Twenty Sixteen child theme
<?php
/**
* Custom header for the WPCampus child theme.
* Moves the header image to the top.
*
* The template for displaying the header
*
* Displays all of the head element and everything up until the "site-content" div.
*
* @package WordPress
@mor10
mor10 / Component.php
Created July 22, 2019 22:54
Add color palette option to Customizer in WP Rig theme
<?php
/**
* WP_Rig\WP_Rig\Customizer\Component class
*
* @package wp_rig
*/
namespace WP_Rig\WP_Rig\Customizer;
use WP_Rig\WP_Rig\Component_Interface;
@mor10
mor10 / wpcampus-functionality.php
Created July 12, 2016 22:14
Create custom taxonomies (hierarchical and non-hierarchical) in a WordPress plugin
<?php
// Create two taxonomies, Class and Year, for the post type "Lecture"
function wpcampuscpt_lecture_taxonomies() {
// Add Class taxonomy, make it hierarchical (like categories)
$labels = array(
'name' => _x( 'Classs', 'taxonomy general name' ),
'singular_name' => _x( 'Class', 'taxonomy singular name' ),
'search_items' => __( 'Search Classes' ),
'all_items' => __( 'All Classes' ),
'parent_item' => __( 'Parent Class' ),
@mor10
mor10 / my-responsive-thumbnail.php
Created May 28, 2014 01:46
Basic function to create responsive featured image in WordPress. Code to be added to functions.php.
<?php
/**
* Create function my_responsive_thumbnail() to output responsive featured image
* Function can be called from within the loop of any template file using my_responsive_thumbnail(get_the_ID());
*/
function my_responsive_thumbnail($post_id){
// Get the featured image ID
$attachment_id = get_post_thumbnail_id($post_id);
// Get the alt text or set the $alt_text variable to the post title if no alt text exists
@mor10
mor10 / functions.php
Created July 11, 2016 21:04
Change default fonts in Twenty Sixteen Child Theme
<?php
// Override the parent theme fonts
function twentysixteen_fonts_url() {
$fonts_url = 'https://fonts.googleapis.com/css?family=Playfair+Display:400,400i,700,700i,900,900i|Roboto+Slab:400,700';
return $fonts_url;
}
?>
@mor10
mor10 / openweatherAPI.json
Last active January 11, 2024 20:18
OpenWeather OpenAPI schema
{
"openapi": "3.1.0",
"info": {
"title": "OpenWeatherMap One Call API",
"description": "Provides access to current weather, hourly forecast, and daily forecast data.",
"version": "v1.0.0"
},
"servers": [
{
"url": "https://api.openweathermap.org"
@mor10
mor10 / Related-Component.php
Last active March 13, 2024 12:57
Extend WP Rig to display related posts using the REST API