Skip to content

Instantly share code, notes, and snippets.

Mark Wilkinson wpmark

Block or report user

Report or block wpmark

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
@wpmark
wpmark / wp-featured-image-url.php
Created Nov 18, 2012
Get WordPress Featured Image URL
View wp-featured-image-url.php
@wpmark
wpmark / mdw_user_has_blog_role.php
Created Nov 22, 2012
Check User is a Blog User on Network Site
View mdw_user_has_blog_role.php
<?php
/* protects site from those who are not assigned to it */
function mdw_user_has_blog_role() {
/* get the global blog id */
global $blog_id;
/* check user is part of this blog, and die if they are not */
if( ! is_blog_user( $blog_id ) )
wp_die( __("You are trying to access a site that you are not allowed to see. Naughty you!") );
@wpmark
wpmark / gist:4534059
Last active Dec 11, 2015
Adding a Custom table in WordPress using a WordPress plugin.
View gist:4534059
<?php
function wpct_create_db_table() {
global $wpdb;
/* create the table name using the wordpress table prefix for this site */
$wpct_tablename = $wpdb->prefix . "wpct";
/* setup the structure of the table creating these as a variable */
@wpmark
wpmark / gist:4534269
Created Jan 14, 2013
Add data to a Custom WordPress table
View gist:4534269
<?php
/* create a function to get the values from this page load */
function wpct_track_content() {
/* call the global post variable to gain access to post data */
global $post;
/* setup an array to store all our values */
$wpct_post_values = array();
@wpmark
wpmark / gist:5007195
Last active Jul 26, 2017
Plugin to add a dropdown list of users in the WordPress admin bar with a link to switch to that user (requires the User Switching plugin by http://profiles.wordpress.org/johnbillion/).
View gist:5007195
<?php
/**
Plugin Name: User Switching in Admin Bar
Plugin URI: http://markwilkinson.me
Description: Build upon the User Switching plugin (http://wordpress.org/extend/plugins/user-switching/) by John Blackbourn and adds a dropdown list of users in the WordPress admin bar with a link to switch to that user.
Author: Mark Wilkinson
Author URI: http://markwilkinson.me
Version: 1.0
*/
@wpmark
wpmark / wp-sidebar-menu.php
Created Oct 20, 2013
WordPress Sidebar Menu for Pages
View wp-sidebar-menu.php
<?php
/* check whether the current post has a parent */
if( $post->post_parent ) {
/* get the ancestors/parent of the current post */
$pxjn_ancestors = get_post_ancestors( $post->ID );
/* count the number of parents retrieved less 1 */
$pxjn_root = count( $pxjn_ancestors ) -1;
@wpmark
wpmark / gist:8160972
Last active Sep 9, 2017
Remove WordPress admin menu items for certain users.
View gist:8160972
<?php
/* add our function to the admin meny action */
add_action( 'admin_menu', 'pxjn_remove_menus', 999 );
function pxjn_remove_menus() {
/* get the current user id */
$pxjn_current_user_id = $current_user->ID; // get the user ID
@wpmark
wpmark / local-config.php
Created Jan 10, 2014
Local Config file for WordPress Multisite.
View local-config.php
<?php
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'db_name');
/** MySQL database username */
define('DB_USER', 'db_user');
/** MySQL database password */
define('DB_PASSWORD', 'db_password');
@wpmark
wpmark / mdw-activation-plugin.php
Last active Jan 3, 2016
Plugin which runs a function to activate other plugins when new sites are created.
View mdw-activation-plugin.php
<?php
/*
Plugin Name: Multisite Site Creation Activation Plugin
Plugin URI:
Description: Plugin which runs a function to activate other plugins when new sites are created.
Version: 1.0
Author: Mark Wilkinson
Author URI: http://markwilkinson.me
License: GPLv2 or later
*/
@wpmark
wpmark / gist:9069976
Created Feb 18, 2014
Change Whistles WordPress Plugin Post Type Labels
View gist:9069976
<?php
/***************************************************************
* Function pxlcore_whistles_post_labels()
* Changes the post labels for the Whistles post type.
***************************************************************/
function pxlcore_whistles_post_labels( $labels ) {
$labels->name = 'Snippets';
$labels->singular_name = 'Snippet';
$labels->menu_name = 'Snippets';
You can’t perform that action at this time.