This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Gets the attachment ID from a URL | |
* Credit: https://philipnewcomer.net/2012/11/get-the-attachment-id-from-an-image-url-in-wordpress/ | |
**/ | |
function pn_get_attachment_id_from_url( $attachment_url = '' ) { | |
global $wpdb; | |
$attachment_id = false; | |
// If there is no url, return. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: WDS GIF API | |
* Plugin URI: http://webdevstudios.com | |
* Description: Adds a Custom Post Type to store GIFs and an API JSON Endpoint to access GIFs by a tag. | |
* Author: WebDevStudios | |
* Author URI: http://webdevstudios.com | |
* Version: 1.0.0 | |
* License: GPLv2 | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Adds a separator in the admin menu to separate our custom menu items. | |
*/ | |
function add_admin_menu_separator() { | |
global $menu; | |
$menu[29] = array( | |
0 => '', | |
1 => 'read', | |
2 => 'separator29', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function comic_sans_roulette() { | |
$random = mt_rand( 0, 9 ); | |
if ( $random == 0 ) { | |
echo '<style>* { font-family: "Comic Sans MS" !important; }</style>'; | |
} | |
} | |
add_action( 'wp_head', 'comic_sans_roulette' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Detect the Browser | |
*/ | |
function dlf_ie() { | |
$ie_version = ''; | |
if ( strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6.') !== false ) { | |
$ie_version = 'ie6'; | |
} elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 7.') !== false ) { | |
$ie_version = 'ie7'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Below is the code generated by GenerateWP for our custom post type and our | |
* custom field. We pasted this into our theme's functions.php file and it | |
* could also be added to a plugin file. | |
*/ | |
// Register Custom Post Type | |
function wpmke_employees() { | |
$labels = array( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function displayLocationDropdown() { | |
$html = ''; | |
$html .= '<form class="location-select" method="post">'; | |
$html .= '<select id="location-selector" name="location" class="location">'; | |
$tag = wp_tag_cloud( array( | |
'format' => 'array', |