Skip to content

Instantly share code, notes, and snippets.

View MrJoshFisher's full-sized avatar

Josh Fisher MrJoshFisher

View GitHub Profile
{
"packages": [
{
"name": "ATTinyCore",
"maintainer": "Spence Konde",
"websiteURL": "https://github.com/SpenceKonde/ATTinyCore",
"email": "",
"help": {
"online": ""
},
@MrJoshFisher
MrJoshFisher / functions.php
Last active April 3, 2024 11:02
[Remove WordPress Logo From Admin]
/**
* Remove Wordpress Logo From Admin
*/
add_action( 'wp_before_admin_bar_render', function(){
global $wp_admin_bar;
$wp_admin_bar->remove_menu( 'wp-logo' );
}, 0 );
@MrJoshFisher
MrJoshFisher / functions.php
Created September 13, 2023 10:33
[Remove Posts] #wordpress
// ************* Remove default Posts type since no blog *************
// Remove side menu
add_action( 'admin_menu', 'remove_default_post_type' );
function remove_default_post_type() {
remove_menu_page( 'edit.php' );
}
// Remove +New post in top Admin Menu Bar
@MrJoshFisher
MrJoshFisher / functions.php
Created May 25, 2023 14:39
[Add Custom Admin Column To Order Table] #woocommerce
//Add content
function action_woocommerce_admin_order_item_values( $product, $item, $item_id ) {
// WC_Order_Refund OR WC_Order_item
if ( $item->get_type() == 'shop_order_refund' ) {
$item = new WC_Order_Refund( $item_id );
} else {
$item = new WC_Order_Item_Product( $item_id );
// Only for "line_item" items type, to avoid errors
if ( ! $item->is_type( 'line_item' ) ) return;
@MrJoshFisher
MrJoshFisher / functions.php
Created May 12, 2023 10:23
[Add Coupons To Order And Email] #woocommerce #wordpress
add_filter( 'woocommerce_get_order_item_totals', 'add_coupons_codes_line_to_order_totals_lines', 10, 3 );
function add_coupons_codes_line_to_order_totals_lines( $total_rows, $order, $tax_display ) {
// Exit if there is no coupons applied
if( sizeof( $order->get_used_coupons() ) == 0 )
return $total_rows;
$new_total_rows = []; // Initializing
foreach($total_rows as $key => $total ){
$new_total_rows[$key] = $total;
@MrJoshFisher
MrJoshFisher / functions.php
Last active May 4, 2023 13:48
[WordPress Meta Box] #wordpress
function jobs_metaboxes( ) {
global $wp_meta_boxes;
add_meta_box('job_details', __('Job Details'), 'job_details_func', 'jobs', 'normal', 'high');
}
add_action( 'add_meta_boxes_jobs', 'jobs_metaboxes' );
function job_details_func()
{
global $post;
@MrJoshFisher
MrJoshFisher / functions.php
Created February 28, 2023 10:02
[Add custom admin column] #wordpress #php
add_filter('manage_product_posts_columns' ,'custom_post_type_columns');
function custom_post_type_columns($columns){
// Remove Author and Comments from Columns and Add custom column 1, custom column 2 and Post Id
$columns['badge'] = 'Badge';
return $columns;
}
add_action( 'manage_product_posts_custom_column' , 'fill_custom_post_type_columns', 10, 2 );
@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() ) {