Skip to content

Instantly share code, notes, and snippets.

View loorlab's full-sized avatar
💻
💥👩‍🚀👨‍🚀💥

LOOR Lab loorlab

💻
💥👩‍🚀👨‍🚀💥
View GitHub Profile
@loorlab
loorlab / enable_webp_WP.php
Last active February 7, 2024 19:59
Allow WebP Upload in WordPress
<?php
//enable upload for webp image files.
function webp_upload_mimes($existing_mimes) {
$existing_mimes['webp'] = 'image/webp';
return $existing_mimes;
}
add_filter('mime_types', 'webp_upload_mimes');
// functions.php
//enable preview / thumbnail for webp image files.
@loorlab
loorlab / rewrite_title_archives_WP.php
Last active October 12, 2023 21:31
Rewrite Title - To change the default output of get_the_archive_title() in WordPress, you can use the get_the_archive_title filter. This allows you to modify the title displayed for archive pages such as category, tag, date, and author archives.
<?php
// functions.php
function custom_archive_title($title) {
if (is_category()) {
$title = 'Category: ' . single_cat_title('', false);
} elseif (is_tag()) {
$title = 'Tag: ' . single_tag_title('', false);
} elseif (is_author()) {
$author = get_queried_object();
$title = 'Author: ' . $author->display_name;
@loorlab
loorlab / ACF_Relationship_WP.php
Created September 2, 2023 22:32
ACF Relationship - Shortcode
<?php
/* Recent Post | image */
function show_related_posts($atts) {
$atts = shortcode_atts(array(
'post_id' => get_option('page_on_front'),
), $atts);
$related_post_ids = get_field('recent_post', $atts['post_id']);
if ($related_post_ids) {
@loorlab
loorlab / minifier.php
Created August 7, 2023 02:44 — forked from abranhe/minifier.php
WordPress Minifier
<?php
/**
* W3C Fix and HTML minifier
* Nobody knows how this work, so don't touch it!!!
*
* https://wordpress.stackexchange.com/a/227896/129134
* https://stackoverflow.com/a/41148695
*/
@loorlab
loorlab / load_multiple_gltf_models.js
Created June 9, 2023 21:49
Load Multiple GLTF - Three.js
const gltfLoader = new GLTFLoader()
// Array de archivos GLTF
const gltfFiles = [
'models/Model/glTF/model1.gltf',
'models/Model/glTF/model2.gltf'
//'models/Model/glTF/other_model.gltf'
];

.htaccess Snippets

NOTE: .htaccess files are for people that do not have rights to edit the main server configuration file. They are intrinsically slower and more complicated than using the main config. Please see the howto in the httpd documentation for further details.

Disclaimer: While dropping the snippet into an .htaccess file is most of the time sufficient, there are cases when certain modifications might be required. Use at your own risk.

IMPORTANT: Apache 2.4 introduces a few breaking changes, most notably in access control configuration. For more information, check the upgrading document as well as this issue.

Credits

What we are doing here is mostly collecting useful snippets from all over the interwebs (for example, a good chunk is from Apache Server Configs) into one

<?php
// Trigger Holiday Mode
add_action ('init', 'bbloomer_woocommerce_holiday_mode');
// Disable Cart, Checkout, Add Cart
function bbloomer_woocommerce_holiday_mode() {
@loorlab
loorlab / functions.php
Created March 18, 2023 04:58 — forked from mrwweb/functions.php
Example Child Theme Files
<?php
/*
Important!
Make sure to replace {my_} with your theme's unique prefix.
All future functions you write should use that same prefix.
Example: mrwnten_parent_theme_enqueue_styles()
*/
add_action( 'wp_enqueue_scripts', '{my_}parent_theme_enqueue_styles' );
@loorlab
loorlab / hide_elementor_admin_menus_WP.php
Created December 14, 2022 20:57
Hide Elementor Admin Menus - WordPress
<?php
function plt_hide_elementor_menus() {
//Hide "Elementor".
remove_menu_page('elementor');
//Hide "Elementor → Settings".
remove_submenu_page('elementor', 'elementor');
//Hide "Elementor → Role Manager".
remove_submenu_page('elementor', 'elementor-role-manager');
//Hide "Elementor → Tools".
remove_submenu_page('elementor', 'elementor-tools');
@loorlab
loorlab / fix_sticky_header_overlaps_anchor_elementor_css_WP.css
Created November 28, 2022 21:36
Fix: Sticky Header Overlaps Anchor in Elementor - WordPress
body:not(.elementor-editor-active) .elementor-widget-menu-anchor {
position: relative;
z-index: -1;
}
body:not(.elementor-editor-active) .elementor-menu-anchor:before {
content: "";
display: block;
height: 100px; // fixed header height
margin: -100px 0 0; // negative fixed header height
visibility: hidden;