Skip to content

Instantly share code, notes, and snippets.

@xavierlopez
xavierlopez / functions.php
Last active November 15, 2021 07:21
How to get related course from product (LearnDash WooCommerce integration)
//Here we get an array of related LearnDash courses related to a WC_Product
$courses_id = get_post_meta( $product->get_id(), '_related_course',true);
@ideadude
ideadude / pmpro_allow_weak_passwords.php
Created May 12, 2020 21:18
Tell PMPro allow weak passwords on the change password and reset password forms.
/**
* Tell PMPro allow weak passwords on the change password and reset password forms.
* Requires PMPro v2.3.3+
*/
add_filter( 'pmpro_allow_weak_passwords', '__return_true' );
@dangoodman
dangoodman / functions.php
Created April 10, 2020 17:46
WooCommerce: allow HTML in shipping option labels
<?php
// Paste everything below this line to your child-theme's functions.php file.
// Cancel sanitizing for all shipping option labels starting with 'HTML:'.
remove_filter('woocommerce_shipping_rate_label', 'sanitize_text_field');
add_filter('woocommerce_shipping_rate_label', function($label) {
if (substr_compare($label, 'HTML:', 0, 5) === 0) {
$label = ltrim(substr($label, 5));
}
@igorbenic
igorbenic / functions-2.php
Last active July 31, 2022 22:26
How to Move Payments on WooCommerce Checkout | https://www.ibenic.com/move-payments-woocommerce-checkout
<?php
/**
* Adding the payment fragment to the WC order review AJAX response
*/
add_filter( 'woocommerce_update_order_review_fragments', 'my_custom_payment_fragment' );
/**
* Adding our payment gateways to the fragment #checkout_payments so that this HTML is replaced with the updated one.
*/
function my_custom_payment_fragment( $fragments ) {
@davidwolfpaw
davidwolfpaw / gravity-forms-confirmation-remain.php
Last active April 1, 2024 06:26
Keep Gravity Forms Displayed After Submission
<?php
// Allow the Gravity form to stay on the page when confirmation displays.
add_filter( 'gform_pre_submission_filter', 'dw_show_confirmation_and_form' );
function dw_show_confirmation_and_form( $form ) {
// Inserts a shortcode for the form without title or description
$shortcode = '[gravityform id="' . $form['id'] . '" title="false" description="false"]';
// Ensures that new lines are not added to HTML Markup
ob_start();
@nicomollet
nicomollet / elementorcssinhead.php
Last active December 6, 2022 09:21
Load Elementor styles on all pages in the head to avoid CSS files being loaded in the footer
<?php
/**
* Load Elementor styles on all pages in the head to avoid CSS files being loaded in the footer
*/
function elementor_css_in_head(){
if(class_exists('\Elementor\Plugin')){
$elementor = \Elementor\Plugin::instance();
$elementor->frontend->enqueue_styles();
}
if(class_exists('\ElementorPro\Plugin')){
@hirejordansmith
hirejordansmith / insert-content-wordpress-after-certain-amount-paragraphs.php
Created December 6, 2016 13:59
Insert Content in WordPress after a certain amount of paragraphs
<?php
//Insert ads after second paragraph of single post content.
add_filter( 'the_content', 'prefix_insert_post_ads' );
function prefix_insert_post_ads( $content ) {
$ad_code = '<div>Ads code goes here</div>';
if ( is_single() && ! is_admin() ) {
return prefix_insert_after_paragraph( $ad_code, 2, $content );
}
return $content;
}
@eyecatchup
eyecatchup / mr.robot_season-2_easter-egg-sites.md
Last active April 4, 2024 10:39
A collection of "Mr. Robot" Season 2 Easter Egg Sites. #mrrobot #hackingrobot #robotegg
@james2doyle
james2doyle / jquery.getStylesheet.js
Created February 3, 2016 21:05
An implementation of $.getScript but for stylesheets. Call it $.getStylesheet
(function($) {
$.getStylesheet = function (href) {
var $d = $.Deferred();
var $link = $('<link/>', {
rel: 'stylesheet',
type: 'text/css',
href: href
}).appendTo('head');
$d.resolve($link);
return $d.promise();
@rmorse
rmorse / sf-pro-v2-ajax-events.js
Last active November 9, 2024 21:04
Search & Filter Pro v2 - Ajax Events
//detects the start of an ajax request being made
$(document).on("sf:ajaxstart", ".searchandfilter", function(){
console.log("ajax start");
});
//detects when the ajax request has finished and the content has been updated
// - add scripts that apply to your results here
$(document).on("sf:ajaxfinish", ".searchandfilter", function(){
console.log("ajax complete");
//so load your lightbox or JS scripts here again