Skip to content

Instantly share code, notes, and snippets.

View DrewAPicture's full-sized avatar

Drew Jaynes DrewAPicture

View GitHub Profile
@DrewAPicture
DrewAPicture / class-wp-docs-collection.php
Last active December 21, 2015 23:48
get_pages args docs
<?php
/**
* WP Docs Collection Class
*
* Stores data sets commonly referenced in WordPress inline documentation.
*
* @since 3.7.0
*/
class WP_Docs {
<?php
class Unnamed_Theme {
public function __construct() {
add_filter( 'login_redirect', array( $this, 'login_redirect' ), 10, 3 );
}
public function login_redirect( $redirect_to, $request, $user ) {
return admin_url( 'media-new.php' );
}
@DrewAPicture
DrewAPicture / update_image_date.php
Last active December 22, 2015 02:49
Use attachment date from EXIF data on image upload.
<?php
class Unnamed_Theme {
public function __construct() {
add_filter( 'wp_update_attachment_metadata', array( $this, 'update_image_date' ), 10, 2 );
}
/**
* Update the 'post_date' field with the date in the image meta
*
* @param array $data The attachment meta array.
@DrewAPicture
DrewAPicture / update_post_fields.php
Created September 2, 2013 17:49
Update post fields (counter part to get_post_field()
<?php
/**
* Update one or more post fields
*
* @global wpdb $wpdb
*
* @param array $field Array of field/value pairs to update.
* @param WP_Post|int $post Post object or id.
*
* @return int|bool Number of updated rows, false on failure.
<?php
/**
* @type string 'sort_column' What columns to sort pages by, comma-separated.
* Default 'post_title'. Accepts 'post_author', 'post_date', 'post_title', 'post_name', 'post_modified', 'post_modified_gmt', 'post_parent', 'menu_order', 'ID', 'rand', 'comment_count').
*
<?php
/**
* Filter the link query arguments.
*
* Allows modification of the link query arguments before querying.
*
* @since 3.7.0
*
* @param array $query {
* An array of query arguments.
@DrewAPicture
DrewAPicture / query_params.php
Last active December 22, 2015 15:18
WP_Query hash notation
<?php
/**
* @param array $query {
* WP_Query parameters.
*
* @type int 'author' Author id, or comma-separated list of ids
* @type string 'author_name' Use 'user_nicename'
* @type array 'author__in' Array of author ids to query from.
* @type array 'author__not_in' Array of author ids not to query from.
* @type int 'cat' Category id or comma-separated list of ids (this or any children)
<?php
function filter_menu_order( $order ) {
return array(
'index.php','separator1', 'edit.php', 'edit.php?post_type=page',
'users.php', 'upload.php', 'edit-comments.php', 'separator2', 'themes.php',
'plugins.php', 'tools.php', 'options-general.php', 'separator-last'
);
}
add_filter( 'menu_order', 'filter_menu_order' );
add_filter( 'custom_menu_order', '__return_true' );
<?php
/**
* @type string|bool $avatar_dir The name of the subdirectory where the requested avatar should
* be found. If no value is passed, 'avatar_dir' is inferred from 'object': 'user' becomes
* 'avatars', 'group' becomes 'group-avatars', 'blog' becomes 'blog-avatars'. Remember that
* this string denotes a subdirectory of BP's main avatar directory (usually based on
* {@link wp_upload_dir()}); it's a string like 'group-avatars' rather than the full directory
* path. Generally, it'll only be necessary to override the default value if storing avatars
* in a non-default location. Defaults to false (auto-detected).
* @type int|bool $width Requested avatar width. The unit is px. This value is used to build the
<?php
function can_haz_link( $id ) {
?>
<a href="#">Can haz link?</a>
<?php
}
add_action( 'wpmublogsaction', 'can_haz_link' );