Skip to content

Instantly share code, notes, and snippets.

@laverboy
Last active August 29, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save laverboy/e4b218be29cf690ae545 to your computer and use it in GitHub Desktop.
Save laverboy/e4b218be29cf690ae545 to your computer and use it in GitHub Desktop.
Singleton Pattern for functions.php
<?php namespace CharityPress\Functions;
/**
* Enqueue scripts and styles.
*/
class DashboardWidget extends Singleton {
//required function
public function init() {
add_action( 'wp_dashboard_setup', [ $this, 'intro_widget' ] );
}
public function intro_widget() {
wp_add_dashboard_widget( 'custom_help_widget', 'Theme Introduction', 'intro_widget_output' );
}
public function intro_widget_output() {
echo '<p>Welcome to Charity Press! Need help? Contact the developers <a href="mailto:info@reasondigital.com">here</a>.</p>';
}
}
<?php
require "vendor/autoload.php";
CharityPress\Functions\DashboardWidget::get_instance();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment