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 / 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 / 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}}">
@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 / 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 / debugLog.js
Last active October 31, 2022 18:07
GTM dataLayer example
module.exports = (...args) => {
if (location.hostname.match("local"))
console.log("🦄:", ...args);
};
<?php
return [
'&#xE84D;' => '3d_rotation',
'&#xE190;' => 'access_alarm',
'&#xE191;' => 'access_alarms',
'&#xE192;' => 'access_time',
'&#xE84E;' => 'accessibility',
'&#xE84F;' => 'account_balance',
'&#xE850;' => 'account_balance_wallet',
<a href="#" onclick="download_table_as_csv('my_id_table_to_export');">Download as CSV</a>