Skip to content

Instantly share code, notes, and snippets.

View khleomix's full-sized avatar

JC Palmes khleomix

View GitHub Profile
@khleomix
khleomix / function.php
Created September 6, 2024 15:05
LD Course Point remove decimals
function custom_remove_decimals_from_course_points( $output, $atts ) {
if ( isset( $atts['show'] ) && $atts['show'] == 'course_points' ) {
// Remove decimal points by casting to an integer
$output = intval( $output );
}
return $output;
}
add_filter( 'learndash_course_info', 'custom_remove_decimals_from_course_points', 10, 2 );
@khleomix
khleomix / customize-user-profile.php
Created August 20, 2024 21:05
WP User Profile Customization
// Define the function to customize user profile fields
function customize_user_profile_fields() {
?>
<style type="text/css">
/* Remove optional fields from the user profile page */
#your-profile .form-table:first-of-type,
#your-profile h3:first-of-type,
#your-profile .user-nickname-wrap,
#your-profile .user-url-wrap,
#your-profile .user-display-name-wrap,
@khleomix
khleomix / tailwind.config.js
Last active May 1, 2023 20:54
Theme.json and Tailwind
const fs = require( 'fs' );
const path = require( 'path' );
const themeJsonPath = path.join( __dirname, 'theme.json' );
const themeJson = fs.readFileSync( themeJsonPath );
const theme = JSON.parse( themeJson );
const { palette } = theme.settings.color;
const colors = palette.reduce(( acc, item ) => {
const [color, number] = item.slug.split( '-' );
@khleomix
khleomix / acf-location-rules.php
Last active March 29, 2023 19:50
ACF Location rules for Multisite
<?php
// Display specific ACF groups on selected sites only for Multisite.
if ( is_multisite() ) :
add_filter( 'acf/location/rule_types', 'acf_location_rule_type_multisite' );
add_filter( 'acf/location/rule_values/site', 'acf_location_rule_values_multisites' );
add_filter( 'acf/location/rule_match/site', 'acf_location_rules_match_site', 10, 3 );
endif;
function acf_location_type_multisite( $choices ) {
@khleomix
khleomix / functions.php
Created March 7, 2023 18:44
Add post type slug before taxonomy slug for post link
<?php
/**
* Create the WordPress rewrite rule to handle third level slugs for videos.
*
*/
function video_cpt_generating_rule( $wp_rewrite ) {
$rules = [];
$terms = get_terms( [
'taxonomy' => 'series',
'hide_empty' => false,
@khleomix
khleomix / acf-gravity-forms-select.php
Created October 31, 2022 21:19
ACF Gravity Forms Select
<?php
/**
* Populate ACF select field options with Gravity Forms form ID
*/
function acf_populate_gf_forms_ids( $field ) {
if ( class_exists( 'GFFormsModel' ) ) {
$choices = [];
foreach ( \GFFormsModel::get_forms() as $form ) {
$choices[ $form->id ] = $form->title;
@khleomix
khleomix / taxonomy-filter.php
Last active March 16, 2022 18:51
Order posts by taxonomy
<?php
/**
* Show all posts based on taxonomy meta key.
*
* @return WP_Query $courses New WP_Query containing courses.
*/
function display_posts_taxonomy_order() {
$term_args = array(
'taxonomy' => 'discipline',
@khleomix
khleomix / smoothscroll.js
Last active March 10, 2022 19:40
Smooth Scroll to div on load
/**
* File search.js
*
* Scroll to div on load.
*
*/
const divToScroll = document.getElementById( 'scroll-here' );
document.addEventListener( 'DOMContentLoaded', function ( event ) {
@khleomix
khleomix / wistia-player.php
Created March 4, 2022 19:51
Wistia Background Video
<?php
/**
* MODULE - Wistia Player.
*
* Autoplay nuted Wistia Video in the background and remove from DOM when done.
*/
/**
* Accepts 'class','wistia_id'.
*/
@khleomix
khleomix / vimeo-video.php
Last active March 4, 2022 16:48
Vimeo Background
<?php
/**
* Shortcode to display Vimeo video.
*
* @param array $args Parameters include vimeo_id and more.
* @author JC Palmes
*/
function embed_vimeo_video( $args = [] ) {
// Set defaults.