Skip to content

Instantly share code, notes, and snippets.

Coffee is for Committers!

Joseph Dickson josephdickson

Coffee is for Committers!
View GitHub Profile
@josephdickson
josephdickson / index.php
Created Nov 5, 2019
WP dashboard notification sample for functions.php
View index.php
// Place admin message about the Carousel Video and Carousel categories
function pz_carousel_admin_notice() {
if ( is_admin() ) {
if ( in_category('Carousel Video') ) {
$class = 'video-carousel-notice notice notice-info is-dismissible';
$message = __( 'Video Carousel posts are ordered by most recently updated to least. They display on the homepage', 'sample-text-domain' );
printf( '<div class="%1$s"><p>%2$s</p></div>', esc_attr( $class ), esc_html( $message ) );
}
if ( in_category('Carousel') ) {
View jd-check-theme-activity.php
<?php
/**
* @package jd-check-theme-activity
* @version 1.0
*/
/*
Plugin Name: Check Theme Activity
Plugin URI: https://joseph-dickson.com
Description: Dashboard widgets that display which themes are active.
@josephdickson
josephdickson / jd-check-plugin-activity.php
Last active Aug 12, 2019
WordPress Dashboard Widgets display active plugins on a site
View jd-check-plugin-activity.php
<?php
/**
* @package jd-check-plugin-activity
* @version 1.0
*/
/*
Plugin Name: Check Plugin Activity
Plugin URI: https://joseph-dickson.com
Description: Dashboard widgets that display which plugins are active.
View WordPress: Display post title, post thumbnail, and post excerpt
<?php
if ( have_posts() ) :
while ( have_posts() ) : the_post();
echo '<article>';
echo '<a href="' . get_permalink() . '">';
the_title( '<h2 class="entry-title">','</h2>' );
if (has_post_thumbnail() ) {
// get thumbnail id for use later
$thumbnail_id = get_post_thumbnail_id();
@josephdickson
josephdickson / post-page-user-log-in-required-twentynineteen
Last active Apr 29, 2019
Restirct WordPress post or page to logged in users
View post-page-user-log-in-required-twentynineteen
<?php
/**
* Single post and page template for restricting the title and content unless the user is logged in
* Sources:
* https://www.wpbeginner.com/wp-themes/create-custom-single-post-templates-for-specific-posts-or-sections-in-wordpress/
* https://codex.wordpress.org/Conditional_Tags
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/#single-post
*
* @package WordPress
@josephdickson
josephdickson / functions-example.php
Created Oct 18, 2018
Add to functions.php to customize font size options
View functions-example.php
<?php
add_action( 'wp_enqueue_scripts', 'twenty_seventeen_gutenberg_enqueue_styles' );
// Font size options
function mytheme_setup_theme_supported_features() {
add_theme_support( 'editor-font-sizes', array(
array(
'name' => __( 'extra small', 'themeLangDomain' ),
'shortName' => __( 'xs', 'themeLangDomain' ),
'size' => 10,
'slug' => 'extrasmall'
You can’t perform that action at this time.