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 November 22, 2022 16:11
[Checkbox to Checkout] #wordpress #woocommerce
add_action( 'woocommerce_review_order_before_submit', 'bt_add_checkout_checkbox', 10 );
/**
* Add WooCommerce additional Checkbox checkout field
*/
function bt_add_checkout_checkbox() {
woocommerce_form_field( 'checkout_checkbox', array( // CSS ID
'type' => 'checkbox',
'class' => array('form-row mycheckbox'), // CSS Class
@MrJoshFisher
MrJoshFisher / scripts.js
Created November 7, 2022 16:09
[Google Map with Multiple Markers and Info Windows]
function initMap() {
const map = new google.maps.Map(document.getElementById("map"), {
zoom: 10,
center: { lat: 51.3055106, lng: 0.3105068 },
});
setMarkers(map,locations);
}
function setMarkers(map,locations){
var marker, i
var infowindow = new google.maps.InfoWindow();
@MrJoshFisher
MrJoshFisher / functions.php
Last active November 7, 2022 10:22
[WordpressPagination]
$args = array(
'post_type' => 'product',
'posts_per_page' => 12,
'order' => 'desc',
'orderby' => 'date',
'paged' => (get_query_var('paged') ? get_query_var('paged') : 1)
);
$post_query = new WP_Query($args);
if($post_query->have_posts() ) {
@MrJoshFisher
MrJoshFisher / functions.php
Created November 2, 2022 10:18
[Widget] #wordpress
// Creating the widget
class spacer_widget extends WP_Widget {
function __construct() {
parent::__construct('spacer_widget', __('Spacer', 'spacer_widget_domain'), array( 'description' => __( 'Spacer widget', 'spacer_widget_domain' )));
}
public function widget( $args, $instance ) {
$space_px = apply_filters( 'space_px', $instance['space_px'] );
echo $args['before_widget'];
@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; ?>