Skip to content

Instantly share code, notes, and snippets.

Avatar

Travis Smith wpsmith

View GitHub Profile
@wpsmith
wpsmith / gist:69b098157391b9eee174
Last active Aug 25, 2015 — forked from billerickson/gist:1298344
Full Content in Display Posts Shortcode plugin
View gist:69b098157391b9eee174
<?php
/**
* Full Content in Display Posts Shortcode plugin
* @author Bill Erickson
* @link http://wordpress.org/extend/plugins/display-posts-shortcode/
*
* @param string $output the original markup for an individual post
* @param array $atts all the attributes passed to the shortcode
* @param string $image the image part of the output
* @param string $title the title part of the output
@wpsmith
wpsmith / debug-css-suffix.php
Last active Aug 26, 2015
PHP: Creates debug suffix for CSS & JS.
View debug-css-suffix.php
<?php
$suffix = ( ( defined( 'WP_DEBUG' ) && WP_DEBUG ) || ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ) ? '.css' : '.min.css';
@wpsmith
wpsmith / javascript_resources.md
Created Feb 3, 2014 — forked from jookyboi/javascript_resources.md
Here are a set of libraries, plugins and guides which may be useful to your Javascript coding.
View javascript_resources.md

Libraries

  • jQuery - The de-facto library for the modern age. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
  • Backbone - Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
  • AngularJS - Conventions based MVC framework for HTML5 apps.
  • Underscore - Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects.
  • lawnchair - Key/value store adapter for indexdb, localStorage
@wpsmith
wpsmith / theme_update.php
Last active Aug 29, 2015
PHP: Prevent Theme from Updating
View theme_update.php
<?php
add_filter( 'http_request_args', 'gs_prevent_theme_update', 5, 2 );
/**
* Don't update theme from .org repo.
*
* If there is a theme in the repo with the same name,
* this prevents WP from prompting an update. Future proofs themes.
*
* @since 1.1.0
@wpsmith
wpsmith / gs_projects_rewrite.php
Last active Aug 29, 2015
PHP: Adjust the rewrite of a registered post type.
View gs_projects_rewrite.php
<?php
add_action( 'registered_post_type', 'gs_projects_rewrite', 10, 2 );
/**
* Modify registered post type menu label
*
* @param string $post_type Registered post type name.
* @param array $args Array of post type parameters.
*/
function gs_projects_rewrite( $post_type, $args ) {
@wpsmith
wpsmith / user-password.sql
Created Feb 15, 2014
SQL: Reset User Password
View user-password.sql
UPDATE wp_users SET user_pass =md5('newpassword') WHERE user_login = 'yourusername');
UPDATE myprefix_users SET user_pass =md5('newpassword') WHERE user_login = 'yourusername');
@wpsmith
wpsmith / default-admin-name.sql
Created Feb 15, 2014
SQL: Change Default Administrator Name
View default-admin-name.sql
UPDATE wp_users SET user_login = 'NewName' WHERE user_login = 'Admin';
UPDATE myprefix_users SET user_login = 'NewName' WHERE user_login = 'Admin';
@wpsmith
wpsmith / get-admins.sql
Created Feb 15, 2014
SQL: Get all administrators
View get-admins.sql
SELECT u.ID, u.user_login, u.user_nicename, u.user_email FROM wp_users u INNER JOIN wp_usermeta m ON m.user_id = u.ID WHERE m.meta_key = 'wp_capabilities' AND m.meta_value LIKE '%admin%' ORDER BY u.user_registered
SELECT u.ID, u.user_login, u.user_nicename, u.user_email FROM myprefix_users u INNER JOIN myprefix_usermeta m ON m.user_id = u.ID WHERE m.meta_key = 'myprefix_capabilities' AND m.meta_value LIKE '%admin%' ORDER BY u.user_registered
@wpsmith
wpsmith / delete-unknown-users.sql
Created Feb 15, 2014
SQL: Delete Unknown Users, i.e., users not found in comments or as an author of a post. Do not use this script for community sites or sites with Subscribers.
View delete-unknown-users.sql
DELETE FROM wp_users WHERE ID > 1 AND ID NOT IN (SELECT DISTINCT post_author FROM wp_posts) AND ID NOT IN (SELECT DISTINCT user_id FROM wp_comments);
DELETE FROM wp_usermeta WHERE user_id > 1 AND user_id NOT IN (SELECT DISTINCT post_author FROM wp_posts) AND user_id NOT IN (SELECT DISTINCT user_id FROM wp_comments);
DELETE FROM wp_links WHERE link_owner > 1 AND link_owner NOT IN (SELECT DISTINCT post_author FROM wp_posts) AND link_owner NOT IN (SELECT DISTINCT user_id FROM wp_comments);
DELETE FROM myprefix_users WHERE ID > 1 AND ID NOT IN (SELECT DISTINCT post_author FROM myprefix_posts) AND ID NOT IN (SELECT DISTINCT user_id FROM myprefix_comments);
DELETE FROM myprefix_usermeta WHERE user_id > 1 AND user_id NOT IN (SELECT DISTINCT post_author FROM myprefix_posts) AND user_id NOT IN (SELECT DISTINCT user_id FROM myprefix_comments);
DELETE FROM myprefix_links WHERE link_owner > 1 AND link_owner NOT IN (SELECT DISTINCT post_author FROM myprefix_posts) AND link_owner NOT IN (SELECT DISTINCT user_id FROM mypre
@wpsmith
wpsmith / new-admin.sql
Created Feb 15, 2014
SQL: Add New Admin User. In the example below, I am using an ID of 2. Change this number to the next user available, or some safe high number.
View new-admin.sql
INSERT INTO databasename.wp_users (ID, user_login, user_pass, user_nicename, user_email, user_url, user_registered, user_activation_key, user_status, display_name) VALUES ('2', 'admin_demo', MD5('demo_password'), 'Travis Smith', 'no-reply@wpsmith.net', 'http://wpsmith.net/', '2014-02-15 00:00:00', '', '0', 'Travis Smith');
INSERT INTO databasename.wp_usermeta (umeta_id, user_id, meta_key, meta_value) VALUES (NULL, '2', 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');
INSERT INTO databasename.wp_usermeta (umeta_id, user_id, meta_key, meta_value) VALUES (NULL, '2', 'wp_user_level', '10');
INSERT INTO databasename.myprefix_users (ID, user_login, user_pass, user_nicename, user_email, user_url, user_registered, user_activation_key, user_status, display_name) VALUES ('2', 'admin_demo', MD5('demo_password'), 'Travis Smith', 'no-reply@wpsmith.net', 'http://wpsmith.net/', '2014-02-15 00:00:00', '', '0', 'Travis Smith');
INSERT INTO databasename.myprefix_usermeta (umeta_id, user_id, meta_key, meta_value) VAL
You can’t perform that action at this time.