Skip to content

Instantly share code, notes, and snippets.

View reatlat's full-sized avatar
🖖
Live long and prosper!

Alex Zappa reatlat

🖖
Live long and prosper!
View GitHub Profile
@reatlat
reatlat / custom-gravatar.php
Last active April 10, 2024 01:50
This snippet allows users to upload a custom avatar image.
<?php
/**
* Custom Gravatar
*
* This snippet adds a custom gravatar field to the user profile page.
* It also adds a filter to replace the default gravatar with the custom one.
* To make it work, you need to have Advanced Custom Fields plugin installed and activated.
*
* Usage:
* 1. Copy this snippet to your theme's directory (e.g. /wp-content/themes/your-theme/inc/custom-gravatar.php)
@reatlat
reatlat / no_mp.bat
Created April 8, 2024 23:46 — forked from natesubra/no_mp.bat
Disable Windows Defender - Powershell
# disable
powershell -command 'Set-MpPreference -DisableRealtimeMonitoring $true -DisableScriptScanning $true -DisableBehaviorMonitoring $true -DisableIOAVProtection $true -DisableIntrusionPreventionSystem $true'
# Or exclude
powershell -command 'Add-MpPreference -ExclusionPath "c:\temp" -ExclusionProcess "c:\temp\yourstuffs.exe"'
@reatlat
reatlat / function.php
Created March 22, 2024 04:18 — forked from mattclements/function.php
Wordpress Disable Comments (add to function.php)
<?php
add_action('admin_init', function () {
// Redirect any user trying to access comments page
global $pagenow;
if ($pagenow === 'edit-comments.php') {
wp_redirect(admin_url());
exit;
}
@reatlat
reatlat / countries-with-states-provinces-regions.js
Last active February 14, 2024 00:06 — forked from shanebo/countries-with-states-provinces-regions
All countries with their states/provinces/regions in json
var countries = {
"Afghanistan": [
"Badakhshan",
"Badghis",
"Baghlan",
"Balkh",
"Bamian",
"Daykondi",
"Farah",
"Faryab",
@reatlat
reatlat / example.html
Last active February 12, 2024 01:30 — forked from hijonathan/example.html
Generate a unique id in a Jinja template.
<!-- Jinja Unique ID Generator -->
{% macro random_int(len) -%}
{% for n in range(len) %}
{{ [0,1,2,3,4,5,6,7,8,9]|random }}
{% endfor %}
{%- endmacro %}
{% macro unique_id(count_groups=5, group_len=6, separator='-') -%}
{% set parts %}
@reatlat
reatlat / prevent-reload-page.js
Last active October 10, 2023 12:14
Enhance your website's debugging experience with prevent-reload-page.js
window.onbeforeunload = function(e) {
var message = "Your confirmation message goes here.", e = e || window.event;
// For IE and Firefox
if (e) {
e.returnValue = message;
}
// For Safari
return message;
};
@reatlat
reatlat / slugify.twig
Last active July 29, 2023 18:49 — forked from xavianaxw/slugify.html
Hubspot | slugify() | Converting text into slug for Hubspot
{# Helpers: slugify #}
{# Returns the slug version of a string #}
{# Parameters #}
{# string | String to convert into a slug | Required #}
{# How to import this macro to my module #}
{# {% from '[folder]/slugify.html' import slugify %} #}
{# How to use this macro #}
@reatlat
reatlat / debug.php
Last active July 24, 2023 23:44
Debug pretty print for PHP
<?php
/**
* Debug pretty print
* @author https://github.com/reatlat
*/
if (!function_exists('php_pretty_print')) :
/**
* Debug helper
* Pretty print the array
*/
@reatlat
reatlat / wp_auto_login.php
Last active April 28, 2023 01:31
Automatically login a single WordPress user upon arrival to main page.
<?php
/**
* @name WP Auto Login
* @desc Automatically login a single WordPress user upon arrival to main page.
* @author Alex Zappa
* @link https://gist.github.com/reatlat/b3de420eee85cac3e344f981e8f27f87
*/
function auto_login() {
if (!is_user_logged_in()) {
// Admin user_id
@reatlat
reatlat / simple-menu.twig
Created April 22, 2023 00:55
HubSpot simple menu example
{% set node = menu(module.menu_field) %}
<ul>
{% for child in node.children %}
<li class="{{ 'has-children' if child.children }} menu-main-item-{{child.level}}">
<a href="{{child.url}}" target="{{ child.linkTarget }}">{{ child.label }}</a>
{% if child.children %}
<ul style="background: yellow">
{% for child2 in child.children %}
<li class="menu-child-depth-{{child2.level}}">