Skip to content

Instantly share code, notes, and snippets.

David Artiss dartiss

Block or report user

Report or block dartiss

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
dartiss / cp_detect.php
Created Nov 3, 2018
ClassicPress detection
View cp_detect.php
* ClassicPress detection
* Check if ClassicPress is in use. The check is a seperate function, instead of simply using the current function_exists
* in case the method of detection needs to change.
function is_classicpress() {
dartiss / config-plugin-header.php
Created Sep 12, 2018
Header for a WordPress site configuration plugin
View config-plugin-header.php
Plugin Name: Configuration
Plugin URI:
Description: Configuration Settings for
Author: David Artiss
Author URI:
dartiss / draft-menu.php
Last active Sep 7, 2018
Add a link to draft posts in your WordPress admin
View draft-menu.php
function add_drafts_to_menu() {
global $wpdb;
$author = get_current_user_id();
// Get total number of draft posts. If more than zero add a sub-menu option
$all_posts = $wpdb -> get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'draft'" );
if ( $all_posts > 0 ) {
dartiss / functions.php
Created Jul 11, 2018
Switch off 'Try Gutenberg' callout
View functions.php
remove_action( 'try_gutenberg_panel', 'wp_try_gutenberg_panel' );
dartiss / yourplugin.php
Last active Jul 10, 2018
Check for a minimum level of PHP and stop activation if the current host is below this
View yourplugin.php
function check_php_level() {
$php = '[[your minimum PHP level]]'; // Minimum PHP level required
/* translators: %1$s: required PHP version, %2$s: current PHP level */
$message = sprintf( __( 'The [[your plugin name]] plugin requires PHP version %1$s or greater but you are using version %2$s. The plugin has NOT been activated.', '[[your text-domain]]' ), $php, PHP_VERSION );
$title = __( 'Plugin Activation Error', '[[your text-domain]]' );
if ( version_compare( PHP_VERSION, $php, '<' ) ) {
dartiss / functions.php
Last active Jun 12, 2018
Detect Gutenberg use
View functions.php
function is_gutenberg() {
global $post;
if ( function_exists( 'gutenberg_post_has_blocks' ) && gutenberg_post_has_blocks( $post->ID ) {
return true;
} else {
return false;
View plugin-example.php
Plugin Name: Plugin Example
Description: An example plugin
Version: 1.0
Author: [Your name]
Author URI: [Your website]
View code-embed.php
function embed_code( $content ) {
global $post;
$i = 1;
while ( $i < 6 ) {
$code = 'CODE' . $i;
dartiss / functions.php
Last active Mar 25, 2018
Add Gutenberg promo to the site of WordPress posts
View functions.php
function add_gutenberg_promo( $content ) {
global $post;
if ( function_exists( 'gutenberg_post_has_blocks' ) && gutenberg_post_has_blocks( $post->ID ) && is_single() ) {
$content = '<div style="background:#fff8c4; border:1px solid #f2c779; border-radius:10px; padding:10px; margin-bottom:10px;">This post was created using Gutenberg, the new editor, coming soon, for WordPress. You can <a href="">learn more about it here</a>, <a href="">try the Beta plugin</a> or simply <a href="">try it out for yourself</a>, no site required.</div>' . $content;
dartiss / function.php
Last active Mar 8, 2018
Adding AdSense Auto ads to your WordPress site
View function.php
function google_autoads() {
[[insert your AdSense script here]]
add_action( 'wp_head', 'google_autoads' );
You can’t perform that action at this time.