Skip to content

Instantly share code, notes, and snippets.

View MrJoshFisher's full-sized avatar

Josh Fisher MrJoshFisher

View GitHub Profile
@MrJoshFisher
MrJoshFisher / functions.php
Created September 20, 2022 11:26
[Disable Google Fonts Elementor] #google #elementor
// Disable Google Fonts in Elementor
add_filter( 'elementor/frontend/print_google_fonts', '__return_false' );
@MrJoshFisher
MrJoshFisher / functions.php
Created July 29, 2022 11:40
[Remove Pages, Menu Items, Notifications from Wordpress Admin] #wordpress
add_action( 'admin_bar_menu', 'remove_wp_nodes', 999 );
function remove_wp_nodes()
{
global $user_ID;
global $wp_admin_bar;
if ( current_user_can( 'editor' ) ) {
$wp_admin_bar->remove_menu('wp-logo');
$wp_admin_bar->remove_menu('comments');
@MrJoshFisher
MrJoshFisher / SSH
Created July 25, 2022 11:46
[AWS Bitnami Wordpress Permission Fix] #wordpress #aws
sudo chown -R bitnami:daemon /opt/bitnami/apps/wordpress/htdocs
sudo find /opt/bitnami/apps/wordpress/htdocs -type d -exec chmod 775 {} \;
sudo find /opt/bitnami/apps/wordpress/htdocs -type f -exec chmod 664 {} \;
@MrJoshFisher
MrJoshFisher / functions.php
Created July 8, 2022 09:01
[Make Coupon Requirement For Product]
add_action( 'woocommerce_check_cart_items', 'mandatory_coupon_for_specific_items' );
function mandatory_coupon_for_specific_items() {
$targeted_ids = array(37); // The targeted product ids (in this array)
$coupon_code = 'summer2'; // The required coupon code
$coupon_applied = in_array( strtolower($coupon_code), WC()->cart->get_applied_coupons() );
// Loop through cart items
foreach(WC()->cart->get_cart() as $cart_item ) {
// Check cart item for defined product Ids and applied coupon
@MrJoshFisher
MrJoshFisher / cart.php
Created July 7, 2022 16:01
[Add Cart / Checkout Field Woocommerce]
<form class=" woocommerce-cart-form">
...
<input type="hidden" id="cart_extra_option" name="cart_extra_option" value="value" >
<input type="hidden" id="cart_total_price" name="cart_total_price" value="value">
...
</form>
@MrJoshFisher
MrJoshFisher / PHPfile.php
Created June 17, 2022 11:43
[Register Sidebar]
<?php if ( is_active_sidebar( 'sidebar-1' ) ) : ?>
<div id="secondary" class="widget-area" role="complementary">
<?php dynamic_sidebar( 'sidebar-1' ); ?>
</div>
<?php endif; ?>
@MrJoshFisher
MrJoshFisher / functions.php
Created June 17, 2022 11:05
[Removing all "unnecessary" meta tags from the <head>]
//remove_action( 'wp_head', 'wp_enqueue_scripts', 1 );
remove_action( 'wp_head', 'feed_links', 2 );
remove_action( 'wp_head', 'feed_links_extra', 3 );
remove_action( 'wp_head', 'rsd_link' );
remove_action( 'wp_head', 'wlwmanifest_link' );
remove_action( 'wp_head', 'index_rel_link' );
remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 );
remove_action( 'wp_head', 'start_post_rel_link', 10, 0 );
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );
@MrJoshFisher
MrJoshFisher / scripts.js
Created March 16, 2022 09:49
[Reviews.io Widget]
<link rel="stylesheet" type="text/css" href="https://widget.reviews.co.uk/floating-widget/css/dist.css">
<script src="https://widget.reviews.co.uk/rich-snippet-reviews-widgets/dist.js" type="text/javascript"></script>
<script>
window.onload = function() {
richSnippetReviewsWidgets({
store: "<store-name>",
primaryClr: "#f47e27",
widgetName: "floating-widget",
numReviews: 40,
floatPosition: "right",
@MrJoshFisher
MrJoshFisher / .htaccess
Created December 24, 2021 10:47
[.htaccess redirects]
1. Redirect All Web Traffic
If you have existing code in your .htaccess, add the following:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L]
2. Redirect Only a Specific Domain
For redirecting a specific domain to use HTTPS, add the following:
RewriteEngine On
@MrJoshFisher
MrJoshFisher / script.js
Created November 18, 2021 13:11
[Event Tracking]
// mailto function
$('a[href^="mailto:"]').click(function(){
var emaillink=jQuery(this).attr('href');
gtag('event', 'contact', { 'event_category' : 'Email Enquiry', 'event_action' : 'Mailto Click', 'event_label' : emaillink});
return true;
});
// tel: function
$('a[href^="tel:"]').click(function(){