Skip to content

Instantly share code, notes, and snippets.

View taricco's full-sized avatar

taricco

  • Seattle, WA
View GitHub Profile
/** Post Categories Menu Shortcode
Shortcode: [insert_post_categories]
–––––––––––––––––––––––––––––––––––––––––––––––––– **/
function list_post_categories_shortcode( $atts ) {
// Updated default values for 'taxonomy' and 'post_type'
$atts = shortcode_atts( array(
'taxonomy' => 'category', // Default category taxonomy
'post_type' => 'post', // Default post type
), $atts );
// VERSION 1 - Show 65d 2h 21m 57s
<p id="countdownTimer"></p>
<script type="text/javascript">
function updateCountdown() {
// Set the target date and time
var targetDate = new Date('March 16, 2024 12:00:00').getTime();
// Get the current date and time
/*** Disable the singular post page for CPT
–––––––––––––––––––––––––––––––––––––––––––––––––– ***/
add_action( 'template_redirect', 'wsv_redirect_cpt' );
function wsv_redirect_cpt() {
if ( is_singular( 'cpt' )) {
wp_redirect( '/', 301 );
exit;
}
}
// https: //gist.github.com/Nerd-Rush/294f491cc1211903b40f7370ad6081aa
function custom_admin_notice_with_logo() {
$user_id = get_current_user_id();
if (get_user_meta($user_id, 'custom_notice_dismissed', true) !== 'yes') {
if (current_user_can('administrator') || current_user_can('editor')) {
$nonce = wp_create_nonce('custom_notice_dismiss_nonce');
$image_url = 'https://nerdrush.com/wp-content/uploads/2023/08/Nerd-Rush-Logo-Blue-2023.svg'; // External image URL
?>
<div class="notice notice-warning custom-notice" style="padding-top: 20px;">
<img src="<?php echo esc_url( $image_url ); ?>" alt="Logo" style="width: 120px; display: block; margin-bottom: 10px;">
// Facts Data
<?php if( have_rows('facts_data') ): ?>
<?php while( have_rows('facts_data') ): the_row();
// Get sub field values.
$type = get_sub_field('facts_data_type');
$value = get_sub_field('facts_data_value');
?>
<div class="gb-container facts-data-wrapper">
<p class="gb-headline facts-data-type gb-headline-text"><?php echo esc_html($type); ?>: <span class="facts-data-value"><?php echo esc_html($value); ?></span></p>
</div>
//Dynamic font sizing with media queries
<script type="text/javascript">
function adjustFontSizeAndLineHeight() {
var elements = document.getElementsByClassName('stats-data-value');
for (var i = 0; i < elements.length; i++) {
var length = elements[i].innerText.length;
var isSmallScreen = window.innerWidth <= 1024;
let fontSize;
/*** Disable the editor for Private Pages CPT in the Client Portal plugin
–––––––––––––––––––––––––––––––––––––––––––––––––– ***/
function wsv_disable_editor_for_private_page() {
remove_post_type_support( 'private-page', 'editor' );
}
add_action( 'init', 'wsv_disable_editor_for_private_page' );