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-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>
*/
@lunule
lunule / wp--restrict-access-noplugin--01--restrict-access-to-wp-admin-page.php
Last active December 2, 2023 12:53
[WordPress - Access restriction without plugins] #access #restrict #wp #core #collection #bestof #redirect #roles
<?php
// Use the $pagenow global.
if( is_admin() ) {
add_filter( 'init', 'custom_restrict_pages_from_admin' );
}
function custom_restrict_pages_from_admin() {
global $pagenow;
@lunule
lunule / wp--wp-config--tips-n-tricks.php
Last active April 17, 2024 15:18
[WordPress - wp-config.php Tips 'N' Tricks] #collection #bestof #config #wp-config #wp #core
<?php
/**
* WordPress Localized Language, defaults to English.
*
* Change this to localize WordPress. A corresponding MO file for the chosen
* language must be installed to wp-content/languages. For example, install
* de.mo to wp-content/languages and set WPLANG to 'de' to enable German
* language support.
*/
// ------------------------------------------------------------------------------------------------
@lunule
lunule / woo--custom-my-account-tab--01--funcs.php
Last active November 18, 2023 09:51
[WooCommerce - Custom My Account Tab with Custom Form Fields] #woocommerce #my-account #form-handler #form #tabs
<?php
/* Custom fields on WooCommerce My Account
================================================================================================ */
/* Set up custom My Account tab and display the custom form fields
------------------------------------------------------------------------------------------------
Based on https://www.businessbloomer.com/woocommerce-add-new-tab-account-page/
*/
// Register new endpoint (URL) for My Account page
@lunule
lunule / wp-force-ssl-programmatically.md
Created November 16, 2023 16:40
[WordPress - Force SSL Without a Plugin] #wordpress #core #force #ssl

in .htaccess, right before the # END WordPress line

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]

in wp-config.php

@lunule
lunule / wp-user-object-readable-json-encoded.php
Last active January 11, 2024 15:25
[WP - User Object in Readable Format (JSON encoded)] #wp #object #class #user #json
<?php
/**
* FYKI
*
* The user's first and last names are stored within the user_meta!!!
*
* So if you need this data, you can access it by using `get_user_meta( $new_user->ID )`.
*
* Or, you can directly ask for it like this:
*
@lunule
lunule / gmail--collection--tips-n-tricks.md
Created October 19, 2023 15:44
[GMail - Tips 'N' Tricks] #gmail #google #collection #search #filters

GMail Search

  • Search in Trash by date of deletion in:trash after: 2023/10/17