Skip to content

Instantly share code, notes, and snippets.

View jazzsequence's full-sized avatar
🚀
Hacking, probably.

Chris Reynolds jazzsequence

🚀
Hacking, probably.
View GitHub Profile
@jazzsequence
jazzsequence / get_post_types.php
Created August 27, 2015 21:33
function that will return an array of post types for a cmb2 options array
<?php
/**
* Get an array of post types for the options page multicheck array
* @uses get_post_types
* @return array An array of public post types
*/
public function get_post_types() {
/**
<?php
if ( session_id() == '' )
session_start();
/**
* JW Post Types
* @author Jeffrey Way
* @link https://github.com/jazzsequence/Easy-WordPress-Custom-Post-Types
*/
class WDS_Post_Type
@jazzsequence
jazzsequence / p2p-connections-in-search.php
Last active August 29, 2015 14:04
search results that include posts2posts connections
<?php
$do_not_duplicate = array() // initialize the duplicates array. this will keep us from having duplicate posts in the results
/**
* set up an array of arguments to determine post2post relationships
* this stuff gets set up too late to be used in pre_get_posts so
* I have to use query_posts.
*/
$query_args = array(
'connected_type' => 'songs_to_artists',
@jazzsequence
jazzsequence / automatic_feature_image_filter.php
Created August 5, 2014 22:01
Filter the automatic featured images from videos content to pull from a postmeta value
<?php
function filter_featured_images_from_videos( $content ) {
global $post;
$content .= get_post_meta( $post->ID, '_video_url', true );
return $content;
}
add_filter( 'wds_featured_images_from_video_filter_content', 'filter_featured_images_from_videos' );
@jazzsequence
jazzsequence / get_image_size.php
Created August 6, 2014 19:24
get dimensions of an image size
<?php
// use the $_wp_additional_image_sizes global to fetch the dimensions of a given image size.
// this comes via Otto, who is amazing and knows everything: http://wordpress.stackexchange.com/a/28316
function get_image_size( $size = 'thumbnail' ) {
global $_wp_additional_image_sizes;
$width = $_wp_additional_image_sizes[$size]['width'];
$height = $_wp_additional_image_sizes[$size]['height'];
array(
"AF" => "Afghanistan (‫افغانستان‬‎)",
"AX" => "Åland Islands (Åland)",
"AL" => "Albania (Shqipëri)",
"DZ" => "Algeria (‫الجزائر‬‎)",
"AS" => "American Samoa",
"AD" => "Andorra",
"AO" => "Angola",
"AI" => "Anguilla",
"AQ" => "Antarctica",
<?php
class My_Class {
// some variable I want to use later
protected $var_a = '';
// another variable I want to use later
protected $var_b = '';
@jazzsequence
jazzsequence / get_post_by_name.php
Last active August 29, 2015 14:17
get post by name
<?php
/**
* Helper function to get a specific page by a page slug
*
* @param string $slug The slug to look for
* @param string $type What data you want returned. Takes anything that would be
* in a WP_Post object. Defaults to the full post object
* @link https://wordpress.org/support/topic/how-to-check-if-page-exists?replies=8#post-466937
* @link http://stackoverflow.com/questions/14979837/wordpress-query-single-post-by-slug
*/
@jazzsequence
jazzsequence / convert_post_type_to_post.php
Created July 14, 2015 19:46
Simple plugin that converts all the posts in a comma-separated list of post IDs from one post type to another. In this case, it uses a post type named `roadkill-cars` and imports all `roadkill-cars` _except_ the ones defined to `post`s.
<?php
/**
* Plugin Name: Roadkill One-time Cars to Posts Conversion
* Plugin URI: http://webdevstudios.com
* Description: Converts an array of car posts to WordPress posts.
* Version: 0.1.0
* Author: WebDevStudios
* Author URI: http://webdevstudios.com
* Donate link: http://webdevstudios.com
* License: GPLv2
@jazzsequence
jazzsequence / highlight-parent-admin-menu.php
Created September 2, 2015 20:11
Change the parent item of a taxonomy to be a custom options page so the options page is highlighted when you are editing that taxonomy instead of the post type.
<?php
public function hooks() {
add_filter( 'parent_file', array( $this, 'highlight_admin_menu' ) );
}
public function highlight_admin_menu( $slug ) {
global $parent_file;
$screen = get_current_screen();