Skip to content

Instantly share code, notes, and snippets.

View JoelEadeDesign's full-sized avatar

Joel Eade JoelEadeDesign

View GitHub Profile
@JoelEadeDesign
JoelEadeDesign / functions.php
Last active August 14, 2024 06:25
Elementor Device Preview Width iPhone 14 (393x852px)
/**
* Elementor Device Preview Sizes
*
* @return void
*/
function add_custom_elementor_editor_css() {
if ( \Elementor\Plugin::$instance->editor->is_edit_mode() ) {
echo '<style>
/* iPhone 14 – smallest viewport the responsive preview can be */
@JoelEadeDesign
JoelEadeDesign / functions.php
Created April 23, 2024 01:58
Elementor Display Conditions for Page Templates
<?php
/**
* Elementor Conditions based on Page Template
*
* @return void
*/
add_action( 'elementor/theme/register_conditions', function( $conditions_manager ) {
class Page_Template_Condition extends ElementorPro\Modules\ThemeBuilder\Conditions\Condition_Base {
@JoelEadeDesign
JoelEadeDesign / function-snippet.php
Last active May 13, 2024 03:27
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);