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 | |
function exclude_cats() { | |
if( ! current_user_can( 'manage_options' ) ) { | |
add_filter( 'list_terms_exclusions', 'exclude_args', 10, 2 ); | |
} | |
} | |
function exclude_args( $exclusions, $args ) { | |
$current_user = wp_get_current_user(); |
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 | |
function theme_menu_append( $items ) { | |
$prepend = ""; | |
$append = ""; | |
$prepend .= "<li>First item always!</li>"; | |
$append .= "<li>This is the 2nd to last item</li>"; | |
$append .= "<li>This is the very last item</li>"; | |
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 | |
$gallery = get_post_gallery( get_the_ID(), false ); | |
echo 'IDs: ' . $gallery['ids']; | |
foreach( $gallery['src'] AS $src ) | |
{ | |
echo $src; | |
} |
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
function force_utf8( $string ) { | |
$utf8 = ""; | |
$string = str_split( $string ); | |
for ( $i = 0; $i < count( $string ); $i++ ) { | |
$utf8 .= mb_convert_encoding( $string[$i], "UTF-8", mb_detect_encoding( $string[$i] ) ); | |
} | |
return $utf8; | |
} |
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
$fetched = '21082013'; | |
date_default_timezone_set( 'UTC' ); | |
$date = DateTime::createFromFormat( 'dmY', $fetched ); | |
echo $date->format( 'Y-m-d' ); |
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
function my_post_check() | |
{ | |
if ( isset( $_POST['myslug-name'] ) ) | |
{ | |
Do form stuff here | |
} | |
} | |
add_action( 'init', 'my_post_check' ); |
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
/* | |
* Function for modifying the main query | |
*/ | |
function modify_the_loop( $query ) { | |
// Check that this is the main query, not a secondary one, and trigger if it's the author page' | |
if ( $query->is_main_query() && $query->is_author() ) | |
{ | |
$query->set( 'post_type', array( 'post', 'page', 'CPT', 'CPT2' ) ); | |
} | |
} |
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 | |
function theme_custom_post_type() { | |
$labels = array( | |
'name' => _x( 'Clues', 'post type general name' ), | |
'singular_name' => _x( 'Clue', 'post type singular name' ), | |
'add_new' => _x( 'Add', 'book' ), | |
'add_new_item' => __( 'Add clue' ), | |
'menu_name' => __( 'Clues' ) | |
); | |
$args = array( |
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 | |
function theme_rewrites( $wp_rewrite ) { | |
$rules = array( | |
'coordinates/([^/]+)/?$' => 'index.php?pagename=coordinates&coords=$matches[1]', | |
); | |
$wp_rewrite->rules = array_merge( $rules, $wp_rewrite->rules ); | |
} | |
add_action( 'generate_rewrite_rules', 'theme_rewrites' ); |
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
jQuery(document).ready(function($){ | |
var _custom_media = true, | |
_orig_send_attachment = wp.media.editor.send.attachment; | |
$('#myMediaArea').click(function(e) { | |
var send_attachment_bkp = wp.media.editor.send.attachment; | |
var button = $(this); | |
var id = button.attr('id').replace('_button', ''); | |
_custom_media = true; |