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 | |
class MyCPTs { | |
public function __construct() { | |
add_action( 'init', array ( $this, 'load_cpts'), 0 ); | |
} | |
/** |
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
/** | |
* Hide editor on specific pages. | |
* | |
*/ | |
// admin_init fires too late (I think...), so admin_head it is | |
add_action( 'admin_head', 'hide_text_editor' ); | |
function hide_text_editor() { | |
$post_id = get_the_ID(); | |
// some admin pages have no ID. Bugger off if there isn't an ID. |
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
// Disable WordPress Events and News Dashboard Widget | |
function awc_remove() { | |
remove_meta_box( 'dashboard_primary', get_current_screen(), 'side' ); | |
} | |
add_action( 'wp_network_dashboard_setup', 'awc_remove', 20 ); | |
add_action( 'wp_user_dashboard_setup', 'awc_remove', 20 ); | |
add_action( 'wp_dashboard_setup', 'awc_remove', 20 ); |
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 wrap_event_spans($span){ | |
// The original spit out a <span> with the Month/Year at the top of each month, but... | |
// there also seemed to be empty spans after each event | |
// This screwed up the Foundation XY Grid I wanted to use in List View | |
// So this is 2 birds one stone. Wrap the span, get rid of empty ones. | |
if( !$span ){ | |
return; | |
} | |
$op = '<div class="whatever classes are needed">' . $span . '</div>'; | |
return $op; |
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
// redirect single posts to the archive page, scrolled to the current member. | |
// * this is for a post type of "board_member" | |
add_action( 'template_redirect', function() { | |
if ( is_singular('board_member') ) { | |
// I used the two variables to put the member's name as the ID of the article | |
// so the redirect would automatically scroll. This can be removed. | |
$title = get_the_title(); | |
$url_append = str_replace( ' ', '-', strtolower($title) ); | |
global $post; | |
$redirectLink = get_post_type_archive_link( 'board_member' ) . "#" . $url_append; |
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 CPT_excerpt_counter(){ | |
// make sure to change all occurrences of the counter limit. | |
if ('YOUR_POST_TYPE' == get_post_type()) { | |
echo '<script>jQuery(document).ready(function(){ | |
jQuery("#postexcerpt .handlediv").after("<div style=\"position:absolute;top:12px;right:34px;color:#666;\"><small>Excerpt length: </small><span id=\"excerpt_counter\"></span><span style=\"font-weight:bold; padding-left:7px;\">/ 100</span><small><span style=\"font-weight:bold; padding-left:7px;\">character(s).</span></small></div>"); | |
jQuery("span#excerpt_counter").text(jQuery("#excerpt").val().length); | |
jQuery("#excerpt").keyup( function() { | |
if(jQuery(this).val().length > 100){ | |
jQuery(this).val(jQuery(this).val().substr(0, 100)); |
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
// this runs on init. Just add or remove whatever user role you want to delete. | |
function awc_remove_role() { | |
remove_role( 'customer' ); | |
remove_role( 'shop_manager' ); | |
} | |
add_action( 'init', 'awc_remove_role' ); |
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
// HTML is whatever you like | |
function awc_post_thumbnail_add_description( $content, $post_id ){ | |
$post = get_post( $post_id ); | |
$post_type = $post->post_type; | |
if ( $post_type = 'post') { | |
$content .= "<div style='background-color: #eee;padding: 1rem;'> | |
<h3><label for=\"html\"><strong>Best size: <br>900px wide by 600px tall</strong></label></h3> | |
</div>"; | |
return $content; | |
return $post_id; |
OlderNewer