Skip to content

Instantly share code, notes, and snippets.

View faurelia's full-sized avatar

F aur faurelia

View GitHub Profile
@faurelia
faurelia / README.md
Created February 5, 2023 06:09
Specify SSH Key for EACH Repository

Specify SSH Key for EACH Repository

Basic command

ssh -i ~/.ssh/your_private_key' <git command>

Configure your repository using git config (persistent)

@faurelia
faurelia / Role.php
Last active January 27, 2023 17:30
Access Control System
<?php
class Role extends Model
{
const ROLE_ADMIN_ID = 1;
protected $casts = [
'permissions' => 'array',
];
@faurelia
faurelia / functions.php
Last active October 17, 2022 10:50
WordPress: Delete Flamingo Spam on Contact Form 7
<?php
function delete_flamingo_spam()
{
// no. of records to delete each call
$num_records = 25;
$args = array(
'post_type'=> array(
'flamingo_inbound',
@faurelia
faurelia / functions.php
Created April 8, 2022 11:55
WooCommerce: Show Sale Products via Query String
<?php
add_action( 'woocommerce_product_query', 'show_onsale_products' );
function show_onsale_products( $q ){
if ( isset($_GET['on_sale']) ) {
$product_ids_on_sale = wc_get_product_ids_on_sale();
$q->set( 'post__in', $product_ids_on_sale );
}
}
@faurelia
faurelia / input.scss
Created March 22, 2022 07:13
Generated by SassMeister.com.
// WY HOMEPAGE RE-DESIGN
$card-height: 400px;
$logo-height: 24px;
.sticky-logo {
max-height: $logo-height !important;
}
.sticky_header .top-headers-wrapper {
@faurelia
faurelia / functions.php
Last active March 18, 2022 05:31
WooCommerce: Replace product thumbnails with dots navigation
<?php
// options
// array(
// 'rtl' => is_rtl(),
// 'animation' => 'slide',
// 'smoothHeight' => true,
// 'directionNav' => false,
// 'controlNav' => 'thumbnails', // can be boolean
// 'slideshow' => false,
// 'animationSpeed' => 500,
@faurelia
faurelia / functions.php
Created November 25, 2021 10:36
WooCommerce: Check if a product is valid for coupon
<?php
function action_woocommerce_before_shop_loop_item_title() {
$product = wc_get_product();
$coupon = new WC_Coupon('BF50');
if ( $coupon->is_valid_for_product( $product ) ) {
echo '<div class="onsale">Sale!</div>';
}
@faurelia
faurelia / functions.php
Created August 22, 2021 07:30
WooCommerce: Change the Default Selected Payment Gateway
<?php
add_action( 'template_redirect', 'change_default_payment_gateway' );
function change_default_payment_gateway(){
if( is_checkout() && ! is_wc_endpoint_url() ) {
$default_payment_id = 'paytabs_applepay';
WC()->session->set( 'chosen_payment_method', $default_payment_id );
}
@faurelia
faurelia / functions.php
Created August 22, 2021 07:27
WooCommerce: Add Custom Payment Gateway Icon
<?php
// Here a sample using the Paytabs Apple Pay gateway, any of the 2 filter below will work.
// Use this to add additional attribute to the image
add_filter( 'woocommerce_gateway_icon', 'apple_paytabs_gateway_icon', 10, 2 );
function apple_paytabs_gateway_icon( $icon, $id ) {
if ( $id === 'paytabs_applepay' ) {
return '<img src="' . get_stylesheet_directory_uri() . '/assets/applepay.svg' . '" style="height: 21px; margin-bottom: 0 !important;" > ';
@faurelia
faurelia / functions.php
Created August 17, 2021 10:46
WordPress: Add ID on Post List in Admin
<?php
add_filter('manage_{post_type}_posts_columns', 'posts_columns_id');
add_action('manage_{post_type}_posts_custom_column', 'posts_custom_id_columns', 10, 2);
function posts_columns_id($defaults){
$defaults['wp_post_id'] = __('ID');
return $defaults;
}