Skip to content

Instantly share code, notes, and snippets.

View lunule's full-sized avatar

lunule lunule

  • Vigilante One
  • Brno
View GitHub Profile
@lunule
lunule / wp--elementor--if-widget-loaded.php
Last active August 24, 2024 08:18
[WordPress - Elementor | Check if specific Elementor widget is loaded/used] #wp #elementor #widget #shortcode
<?php
global $post;
if ( is_a($post, 'WP_Post') ) :
$post_id = $post->ID;
$elementor_data = get_post_meta($post_id, '_elementor_controls_usage', true);
$has_fl_map = array_key_exists('fl-map', $elementor_data);
@lunule
lunule / js--mobile-checkers.js
Last active August 24, 2024 08:11
[JavaScript - Mobile Checkers] #collection #js #mobile #os
/**
* VERSION 1 - DEVICE-SPECIFIC + GLOBAL
* -----------------------------------------------------------------------------------------------------
*/
const checkIphone = () => {
const u = navigator.userAgent
return !!u.match(/iPhone/i)
},
checkAndroid = () => {
@lunule
lunule / php--mime-types.php
Last active July 24, 2024 05:50 — forked from plasticbrain/gist:3887245
PHP: mime types (array format)
<?php
$mime_types = array(
'.3dm' => 'x-world/x-3dmf',
'.3dmf' => 'x-world/x-3dmf',
'.a' => 'application/octet-stream',
'.aab' => 'application/x-authorware-bin',
'.aam' => 'application/x-authorware-map',
'.aas' => 'application/x-authorware-seg',
'.abc' => 'text/vnd.abc',
'.acgi' => 'text/html',
@lunule
lunule / highlight-js--basic-setup.css
Created June 9, 2024 00:16
[Highlight.js - Basic Setup] #highlight-js #syntax-highlighter
/* Copy Button plugin
------------------------------------------------------------------------------------------------
@here https://github.com/arronhunt/highlightjs-copy/styles/highlightjs-copy.css
*/
.hljs-copy-wrapper {
position: relative;
overflow: hidden;
}
.hljs-copy-wrapper:hover .hljs-copy-button,
@lunule
lunule / splidejs--multiple-on-same-page.js
Created May 24, 2024 00:53
[Splide JS - Multiple Sliders on the Same Page] #splide #multiple #sliders
const opts = {
// ...
}
document.querySelectorAll('.my-splide-class').forEach( function(carousel) {
const mySplide = new Splide( carousel, opts );
// ...
@lunule
lunule / wp--prefix-custom-menu-items.php
Last active May 14, 2024 18:33
[WP - Prefix CUSTOM Menu Items Beginning with an '/' Character with the Site Url] #wordpress #wp #core #menu #prefix #site #url #site_url #custom
<?php
// Automatically add site url to menu CUSTOM links
// Automatically add site url to menu CUSTOM links
function jd_prefix_custom_menu_items( $items, $args ) {
// loop through menu-objects (the links)
foreach ($items as $key => $item) :
// check if link begins with '/'
if ( $item->object == 'custom' && substr($item->url, 0, 1) == '/' ) {
@lunule
lunule / wp-fse--remove-preregistered-patterns--pt1.php
Last active March 20, 2024 01:48
[WP - Full Site Editing - Remove Preregistered Patterns] #unregister #deregister #remove #prevent #wp #fse #patterns https://www.wpexplorer.com/how-to-disable-wordpress-gutenberg-block-patterns/
<?php
/**
* @here https://www.wpexplorer.com/how-to-disable-wordpress-gutenberg-block-patterns/
*/
//Remove core patterns:
//
//The following code will remove the default core patterns that are installed in WordPress natively.
add_action( 'after_setup_theme', function() {
<?php
function get_decorated_diff($old, $new){
$from_start = strspn($old ^ $new, "\0");
$from_end = strspn(strrev($old) ^ strrev($new), "\0");
$old_end = strlen($old) - $from_end;
$new_end = strlen($new) - $from_end;
$start = substr($new, 0, $from_start);
$end = substr($new, $new_end);
@lunule
lunule / wp--disable-quote-autoformat.php
Created January 1, 2024 17:01
[WordPress - Disable WP's Auto Formatting of Quotes Into Curly Quotes] #wp #core #quotes #quotation-marks http://forum.bytesforall.com/showthread.php?t=2932
<?php
remove_filter ('single_post_title', 'wptexturize');
remove_filter ('bloginfo', 'wptexturize');
remove_filter ('wp_title', 'wptexturize');
// Additionally, you can remove the filter for other locations as well:
remove_filter ('category_description', 'wptexturize');
remove_filter ('list_cats', 'wptexturize');
remove_filter ('comment_author', 'wptexturize');
remove_filter ('comment_text', 'wptexturize');
@lunule
lunule / wp-buttons.css
Last active December 7, 2023 21:46 — forked from SeanTOSCD/wp-buttons.css
WordPress Admin Style Buttons
/*
wp admin style buttons:
To use for links styled as buttons, add a class attribute to the
<a> tag and add "button" as a value. This sets up the basic button
structure. Then you choose which button you want to use. Add a
value of "blue" for the blue button or "gray" for the gray button.
Ex. <a href="#" class="button blue">Blue Button</a>
*/