This file contains hidden or 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: GGA Twitter Card | |
Description: Adds Twitter card meta tags to the header | |
Author: @GunGeekATX | |
*/ | |
add_action('wp_head', 'gga_twitter_card_wp_head'); | |
function gga_twitter_card_wp_head() { |
This file contains hidden or 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
// add to header.php prior to wp_head() | |
$custom_css_file = get_post_meta( get_the_id(), $key = 'custom-css-file', $single = true ); | |
if (false !== $custom_css_file && !empty($custom_css_file)) | |
wp_enqueue_style( get_the_id() . '-custom-css-file', get_template_directory_uri() . '/' . $custom_css_file, array(), $version_tag_here ); |
This file contains hidden or 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
// via http://www.paulund.co.uk/change-the-enter-title-text-for-custom-post-types | |
// just saving it here for later reference | |
function change_default_title( $title ){ | |
$screen = get_current_screen(); | |
if ( $screen->post_type == 'product' ) { | |
return 'Enter New Product Here'; | |
} | |
} | |
add_filter( 'enter_title_here', 'change_default_title' ); |
This file contains hidden or 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 | |
// some defaults | |
$start = new DateTime('2013-04-11'); | |
$end = new DateTime('2013-05-09'); | |
$current = new DateTime('2013-04-19'); | |
if (isset($_REQUEST['s'])) | |
$start = new DateTime($_REQUEST['s']); |
This file contains hidden or 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 | |
/* | |
* Sample code for using WordPress as a REST API endpoint (vs AJAX Admin) | |
* Author: Pete Nelson @GunGeekATX | |
* | |
* 1) Create a page called API in WordPres | |
* 2) Create a file called page-api.php in your theme directory | |
* 3) Add code as-needed | |
* | |
*/ |
This file contains hidden or 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 | |
/* | |
Author: Pete Nelson @GunGeekATX | |
Expands upon the Custom Meta Boxes library to provide a user-facing input form, | |
list & detail page of custom post types. This code sample doesn't include all the libraries | |
such as jQuery tablesorter or validate but can be found elsewhere easily enough. | |
*/ |
This file contains hidden or 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: GGA Joomla Content Importer | |
Description: Imports articles from Joomla 1.5x into WordPress | |
Author: <a href="https://twitter.com/GunGeekATX" target="_blank">@GunGeekATX</a> | |
Version: 1.1 | |
*/ | |
class ggaJoomlaArticleImporter |
This file contains hidden or 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: My Document Permalink | |
Description: Custom post type (my-document) for docs (PDFs, etc) | |
Version: 1.0 | |
Author: Pete Nelson | |
*/ | |
add_action('init', 'my_register_document_post_type'); |
This file contains hidden or 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
add_filter( 'post_type_link', 'my_post_type_link', 10, 3); | |
function my_post_type_link($permalink, $post, $leavename) { | |
if ($post->post_type == 'my-post-type') { | |
$meta = get_post_meta($post->ID, '_my-post-meta', true); | |
if (isset($meta) && !empty($meta)) | |
$permalink = home_url( "my-friendly-url/" . $meta . "/" . $post->post_name . "/"); | |
} | |
return $permalink; |
This file contains hidden or 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
/* actions fired when listing/adding/editing posts or pages */ | |
/* admin_head-(hookname) */ | |
add_action( 'admin_head-post.php', 'admin_head_post_editing' ); | |
add_action( 'admin_head-post-new.php', 'admin_head_post_new' ); | |
add_action( 'admin_head-edit.php', 'admin_head_post_listing' ); | |
function admin_head_post_editing() { | |
echo 'you are editing a post'; | |
} |