Skip to content

Instantly share code, notes, and snippets.

View marktenney's full-sized avatar

Mark Tenney marktenney

View GitHub Profile
<?php
function cornerstone_group_leaders_shortcode() {
global $post;
$post_id = $post->ID;
// Retrieve the leader post IDs for the current post ID
$leader_ids = get_post_meta( $post_id, 'leaders', true );
// Generate the output
<?php
add_filter( 'rwmb_meta_boxes', 'dgtl_register_meta_boxes_cache_exclusion' );
function dgtl_register_meta_boxes_cache_exclusion( $meta_boxes ) {
$meta_boxes[] = [
'title' => 'Cache Control',
'id' => 'cache-control',
'post_types' => [
'post',
'page'
/* Styles for wireframes at dev.digitalchurch.website/wireframe */
.bg-img-placeholder > .fl-row-content-wrap,
.bg-img-placeholder > .fl-col-content {
background-color: #1a202b;
background-image: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDAiIGhlaWdodD0iNDAiIHZpZXdCb3g9IjAgMCA0MCA0MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSIjMTQxNjFiIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Ik0wIDQwTDQwIDBIMjBMMCAyME00MCA0MFYyMEwyMCA0MCIvPjwvZz48L3N2Zz4=);
background-size: 24px;
}
.fl-builder-content a.fl-button *, .fl-builder-content a.fl-button:visited * {
@marktenney
marktenney / limit-teams-per-league.php
Created March 14, 2021 13:53
Use the max_teams value to determine how many sp_teams can be added to a league (cpt)
<?php
// changing the league status
add_action('updated_post_meta', 'change_league_status', 0, 4);
function change_league_status($meta_id, $post_id, $meta_key, $meta_value) {
$active_teams = get_post_meta( $post_id, 'active_teams' ); // getting active teams id's
$max_teams = (int)get_post_meta( $post_id, 'max_teams' )[0]; // getting number of max teams
$active_teams_length = count($active_teams); // getting active teams length
if($active_teams_length === $max_teams){
@marktenney
marktenney / replace-wordpress-logo-in-block-editor.css
Created February 24, 2021 18:05
Replace the Wordpress Logo in the Gutenberg Block Editor Toolbar
.edit-post-fullscreen-mode-close.has-icon,
.edit-post-fullscreen-mode-close.has-icon:hover {
background-color:#4353fa;
background-image:url('https://digitalchurchplatform.com/wp-content/uploads/sites/179/2020/09/cropped-DigitalChurchFavicon.png');
background-position: center;
background-size:cover;
}
a.components-button > svg {
opacity:0;
@marktenney
marktenney / functions.php
Created January 18, 2021 20:18
Filter Beaver Builder Posts Module to Display User Enrolled Courses
<?php
function fl_builder_loop_query_args_filter( $query_args ) {
$current_user = get_user_by( 'id', $atts['user_id'] );
$user_courses = ld_get_mycourses( $atts['user_id'], $atts );
if ( 'enrolled-courses' == $query_args['settings']->id ) {
$query_args['id'] = $user_courses;
}
@marktenney
marktenney / bb-kadence-styles.css
Last active January 27, 2022 10:24
Allow Beaver Builder to Inherit Colors from Kadence Theme
/*
* Add these to a stylesheet to allow Beaver Builder Modules to inherit colors
* from Kadence Theme's global color palette
*/
/* Let's start with Buttons */
.fl-builder-content a.fl-button *,
.fl-builder-content a.fl-button:visited * {
color:unset;
}
<?php
add_filter( 'um_default_settings_values', 'change_um_defaults', 10, 1 );
function change_um_defaults( $settings ) {
// Set default emaiil sender here
$settings = array (
'mail_from_addr' => 'notifications+test@digitalchurchplatform.com',
'mail_from' => 'Digital Church Platform',
);
@marktenney
marktenney / generate-post-title-from-custom-fields.php
Last active September 24, 2020 18:59
generate-post-title-from-custom-fields.php
<?php
function update_post( $post_id ) {
$firstname = rwmb_meta('person_firstname');
$lastname = rwmb_meta('person_lastname');
$post = array(
'ID' => $post_id,
'post_title' => $firstname . ' ' . $lastname,
'post_name' => $post_id,
@marktenney
marktenney / ultimatum.php
Created September 13, 2020 23:08
Use this to disable the wordpress editor for pages and allow only the Beaver Builder page builder.
<?php
function disable_gutenberg_4_bb( $can_edit, $post_type ) {
if($post_type=="page"){
$can_edit = false;
remove_post_type_support( 'page', 'editor' );
?>
<style>.fl-enable-editor, .fl-builder-admin-tabs {display: none !important ;}.fl-builder-admin-ui {display:block !important;}</style>
<?php
}