Skip to content

Instantly share code, notes, and snippets.

View JoelEadeDesign's full-sized avatar

Joel Eade JoelEadeDesign

View GitHub Profile
@JoelEadeDesign
JoelEadeDesign / function-snippet.php
Created March 19, 2024 00:32
WP Codebox 2 Device Preview
<?php
/**
* Responsive Preview WP Codebox
*
* @return void
*/
add_action("admin_head", "add_responsive_buttons_to_wpcodebox");
function add_responsive_buttons_to_wpcodebox()
{
@JoelEadeDesign
JoelEadeDesign / functions.php
Created June 3, 2022 00:57
Function to control WooCommerce Order Status by User Role
<?php
/* Source: https://quadlayers.com/change-order-status-automatically-in-woocommerce/ */
function user_role_order_status( $order_id ) {
if ( ! $order_id ) { return; }
$order = wc_get_order( $order_id );
// Change db prefix `wp_` of `wp_capabilities`, if required
$usermeta = get_user_meta( get_current_user_id(),'wp_capabilities', true );
// Enter the user role name to apply this function to
<?php
/*
* Allow Jet Smart Filters to show published posts
*/
add_action( 'elementor/query/jet-smart-filters', function( $query ) {
// Add `jet-smart-filters` to `Query ID` of `Post` widget
$query->set( 'post_status', [ 'publish' ] );
} );
?>
@JoelEadeDesign
JoelEadeDesign / elementor-custom-fonts.php
Created January 7, 2019 00:41
Add Custom Font Names to Elementor & GeneratePress Font Family drop-down
/* ------------------------------------
/* CUSTOM FONTS
/* ------------------------------------ */
/* ELEMENTOR */
function modify_controls( $controls_registry ) {
// First we get the fonts setting of the font control
$fonts = $controls_registry->get_control( 'font' )->get_settings( 'options' );
// Then we append the custom font family in the list of the fonts we retrieved in the previous step
$new_fonts = array_merge( [ 'Biotif' => 'system' ], $fonts );
@JoelEadeDesign
JoelEadeDesign / elementor-custom-fonts.php
Created October 22, 2018 22:59
Add theme fonts to Elementor' Style Font Family Select Menus
<?php
/**
* Elementor Custom Fonts
* Source: https://merianos.wordpress.com/2017/09/22/elementor-register-custom-font-family-in-the-fonts-control/
*/
function modify_controls( $controls_registry ) {
// First we get the fonts setting of the font control
$fonts = $controls_registry->get_control( 'font' )->get_settings( 'options' );
// Then we append the custom font family in the list of the fonts we retrieved in the previous step
@JoelEadeDesign
JoelEadeDesign / Remove COD for User Role Stockist
Last active August 29, 2015 14:22
WooCommerce Remove COD for User Role of Stockist
/* REMOVE COD FOR USER ROLE STOCKIST */
add_filter( 'woocommerce_available_payment_gateways', 'sow_checkout_restrictions', 10, 1 );
function sow_checkout_restrictions( $available_gateways ) {
global $woocommerce;
if (!empty(current_user_can('stockist') )) {
unset( $available_gateways['cod'] );
@JoelEadeDesign
JoelEadeDesign / Exclude Free Shipping
Last active August 29, 2015 14:22
WooCommerce Exclude Free Shipping For Specific User Roles
<?php
/* Free shipping for non-stockists
* Adapted from Sean Barton's snippet
* http://www.sean-barton.co.uk/2014/04/wordpress-snippet-woocommerce-free-shipping-role/#.VW_FaVyqpBc
* Click "Clear transients" (WooCommerce > System Status > Tools) if it's not working.
*/
add_filter( 'woocommerce_package_rates', 'my_woocommerce_set_free_shipping_for_certain_users', 10, 1);
@JoelEadeDesign
JoelEadeDesign / SassMeister-input.scss
Created June 1, 2015 11:15
Generated by SassMeister.com.
// ----
// libsass (v3.2.4)
// ----
.woo_sc_links {
margin: 0 0 30px;
}
.woo_sc_link {
width: auto!important;
@JoelEadeDesign
JoelEadeDesign / gist:d0334fb8bb77dcec2300
Last active August 29, 2015 14:05
Fixed Position Button for WooFramework 6
/* ----------------------------- */
/* ADMIN CSS
/* Pop this in your theme's functions.php file
/* ----------------------------- */
add_action('admin_head', 'my_custom_css');
function my_custom_css() {
echo '<style>
.wf-wrap p.submit {