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 / 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
@lunule
lunule / sublime-text--collection--tips-n-tricks.md
Last active March 2, 2026 00:13
[Sublime Text - Tips 'N' Tricks] #sublime #sublime-text #text #search #replace #tips #collection #regex

0. Remove empty lines

  • Find & Replace, make sure the regex option is active
  • Find: ^\s*\n
  • Replace: `` (blank)

1. Exclude folders from Find in Files

@lunule
lunule / wp--add-lastlogin-&-regdate-cols-to-user-table.php
Last active September 22, 2023 15:23
[WordPress - Add Last Login and Registration Date Columns to User Table] #wp #wordpress #core #sortable #login #security #column #date #time #woocommerce #cell #row #registration #register
<?php
/**
* Add sortable Last Login column to users table
*
* Edited from Misha Rudrastyh's original @
* https://rudrastyh.com/wordpress/sortable-users-last-login-column.html
*/
// Collect login timestamp upon login events
function collect_login_timestamp( $user_login, $user ) {
@lunule
lunule / wp--extended-has-block.php
Created September 6, 2023 22:01
[WP Core - Extended has_block checker with support to reusable blocks] #gutenberg #wp #wordpress #core #has_block #block #blocks #conditionals #checker #check
<?php
/**
* Determines whether a $post or a string contains a specific block type,
* including blocks that are included in reusable blocks.
*
* @author Jb Audras – @audrasjb on socials.
*
* @param string $block_name Full Block type to look for.
* @param int|string|WP_Post|null $post Optional. Post content, post ID, or post object. Defaults to global $post.
* @return bool Whether the post content contains the specified block.
@lunule
lunule / wp--target-search-no-results.php
Created September 6, 2023 02:21
[WP - Target Search No Results page] #core #wp #wordpress #search #no #results #query #wp_query #global #globals #conditionals
<?php
global $post, $wp_query;
if (
is_search() &&
0 === $wp_query->found_posts
) :
// do something
@lunule
lunule / acf--get-field-data-while-parse-blocks.php
Last active September 5, 2023 14:52
[ACF - Get get_field() data while using parse_blocks] #acf #get_field #php #parse_blocks #parse #get #blocks #block #field #fields
<?php
/**
* Based on this one:
* https://portalzine.de/dev/php/advanced-custom-fields-get-gutenberg-blocks-data/
*/
// Parse blocks from post content
$blocks = parse_blocks( $post->post_content );
$img_Arr = [];
@lunule
lunule / easings-pt1.scss
Created August 5, 2023 17:59 — forked from terkel/_easing.scss
Timing functions for CSS animations and transitions
// _easing.scss, CSS easing functions - gist.github.com/terkel/4377409
// Based on Caesar - matthewlein.com/ceaser
$linear: cubic-bezier( 0.250, 0.250, 0.750, 0.750 );
$ease: cubic-bezier( 0.250, 0.100, 0.250, 1.000 );
$ease-in: cubic-bezier( 0.420, 0.000, 1.000, 1.000 );
$ease-out: cubic-bezier( 0.000, 0.000, 0.580, 1.000 );
$ease-in-out: cubic-bezier( 0.420, 0.000, 0.580, 1.000 );
$ease-in-quad: cubic-bezier( 0.550, 0.085, 0.680, 0.530 );