Skip to content

Instantly share code, notes, and snippets.

View jcasabona's full-sized avatar

Joe Casabona jcasabona

View GitHub Profile
@jcasabona
jcasabona / refer-discount.php
Created August 14, 2018 13:48
Discount Referrer Pseudo Code
<?php
add_action('woocommerce_before_cart_table', 'discount_frol_url');
function discount_from_url() {
global $woocommerce;
if( 'https://wpsessions.com' == wp_get_referer() ) {
$coupon_code = 'WPSESSIONS';
if (!$woocommerce->cart->add_discount( sanitize_text_field( $coupon_code ))) {
$woocommerce->show_messages();
}
@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",
@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 / 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 / howibuit.md
Last active September 4, 2019 13:40
Guest Notes for How I Built It Podcast

Guest Notes for How I Built It Podcast

Tips for Good Recording

I'll be doing dual track recording, but if you could record audio on your side that would be great! That way if we see a dip in connection or get weird quality, I can do some track-layering action. To do that:

On a Mac

screenshot 2016-07-29 14 05 25

@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
);
<?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 / 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 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();