Skip to content

Instantly share code, notes, and snippets.

View jcasabona's full-sized avatar

Joe Casabona jcasabona

View GitHub Profile
@jcasabona
jcasabona / gist:97c9143bda90134498002de60ad2d965
Last active September 6, 2021 12:33
Linktree Block Pattern
<!-- wp:columns {"verticalAlignment":"top","align":"wide"} -->
<div class="wp-block-columns alignwide are-vertically-aligned-top"><!-- wp:column {"verticalAlignment":"top","width":"25%"} -->
<div class="wp-block-column is-vertically-aligned-top" style="flex-basis:25%"></div>
<!-- /wp:column -->
<!-- wp:column {"verticalAlignment":"top","width":"50%"} -->
<div class="wp-block-column is-vertically-aligned-top" style="flex-basis:50%"><!-- wp:image {"align":"center","id":37,"sizeSlug":"full","linkDestination":"none","className":"is-style-rounded"} -->
<div class="wp-block-image is-style-rounded"><figure class="aligncenter size-full"><img src="https://joec.live/wp-content/uploads/2021/06/joe-casabona-nobg-2021-small.jpg" alt="" class="wp-image-37"/></figure></div>
<!-- /wp:image -->
<?php
$a = array( 'joe' => 35,
'phil' => 33,
);
echo $a[0]; //this will throw an error
?>
<?php
<?php
function convert_fm_to_acf() {
$args = array(
'posts_per_page' => -1,
'post_type' => 'post',
);
$the_query = new WP_Query( $args );
while ( $the_query->have_posts() ) {
$the_query->the_post();
@jcasabona
jcasabona / ld-set-video-controls.php
Last active June 16, 2020 19:19
Set LearnDash Video Controls to Visible
<?php
//For setting all LD videos to controls on.
function jc_set_video_controls() {
$lessons = new WP_Query(
array(
'post_type' => array( 'sfwd-lessons', 'sfwd-topic' ),
'posts_per_page' => -1,
)
);
<?php
function wpp_get_media_URL() {
if ( function_exists( 'powerpress_get_enclosure_data' ) ) {
$episodeData = powerpress_get_enclosure_data( get_the_ID() );
if ( ! empty( $episodeData['url'] ) ) {
return $episodeData['url'];
}
}
return false;
@jcasabona
jcasabona / wc-membership-learndash.php
Created April 28, 2020 14:22
Update LearnDash Groups based on WooCommerce Membership
<?php
// Update group status when member status changes.
function cc_update_ld_group_from_member_status( $user_membership, $old_status, $new_status ) {
$ld_group_id = LEARNDASH_GROUP_ID;
$user_id = $user_membership->get_user_id();
$wp_user = get_userdata( $user_id );
if ( wc_memberships_is_user_active_member( $user_id, $user_membership->get_plan_id() ) ) {
ld_update_group_access( $user_id, $ld_group_id, false );
@jcasabona
jcasabona / paginate-child-pages.php
Last active December 8, 2019 21:34
Paginate Child Pages
function paginate_child_pages( $post ) {
$page_id = $post->ID;
$args = array(
'post_type' => 'page',
'posts_per_page' => -1,
'post_parent' => $page_id,
'order' => 'ASC', //change to fit your order
'orderby' => 'menu_order', //change to fit your order
);
@jcasabona
jcasabona / get-deferred.php
Last active July 8, 2019 17:15
WooCommerce URL Coupons - Get Deferred Coupons
<?php
/** This function works with WooCommerce URL Coupons
* When a coupon gets deferred, it's added to a list of deferred_url_coupons.
* This function accepts a coupon ID ($coupon_id) as an argument, and gets all of the deferred_coupons
* as an array. The coupon ID would be an array key,which is what this function checks for.
* A message is printed. nothing is returned.
**/
function get_deferred_coupons( $coupon_id ) {
global $woocommerce;
@jcasabona
jcasabona / clean_google_docs.php
Created December 6, 2018 12:13
WordPress Filter to Clean Google Docs Markup on Post Save
<?php
add_filter( 'content_save_pre', 'wpp_clean_google_docs' );
function wpp_clean_google_docs( $content ) {
if ( ! ( 'transcript' == get_post_type() ) ) {
return $content;
}
$search = array( '&nbsp;',
'</span>'
@jcasabona
jcasabona / .json
Created September 5, 2018 19:11
VS Code User Preferences
{
"editor.fontSize": 15,
"terminal.integrated.fontSize": 18,
"editor.minimap.enabled": false,
"editor.fontFamily": "'Dank Mono', Menlo, Monaco, 'Courier New', monospace",
"editor.wordWrap": "on",
"terminal.integrated.shell.osx": "/bin/zsh",
"terminal.integrated.fontFamily": "'Dank Mono', 'Source Code Pro for Powerline'",
"workbench.colorTheme": "GitHub Plus",
"terminal.external.osxExec": "Hyper.app",