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
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; ?>
@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",