Skip to content

Instantly share code, notes, and snippets.

@ericakfranz
ericakfranz / custom-html-js-validation-example.html
Last active May 19, 2021 16:43
Example of a Custom HTML form with Javascript validation for OptinMonster
<form id="campaign-{{id}}" novalidate class="{{ns}}" method="POST" action="submit.php">
<input id="name" type="text" placeholder="First and Last Name" required />
<input id="email" type="email" placeholder="Email" required />
<span class="error"></span>
<input type="submit" name="submit" value="Submit" />
</form>
<script>
(function() {
const form = document.getElementById('campaign-{{id}}');
@helgatheviking
helgatheviking / wordpress-add-custom-menu-meta-fields.php
Created February 26, 2020 02:06
Add an example custom meta field to WordPress menu and display text on front-end (Requires WP5.4)
<?php
/**
* Add custom fields to menu item
*
* This will allow us to play nicely with any other plugin that is adding the same hook
*
* @param int $item_id
* @params obj $item - the menu item
* @params array $args
@adriansuter
adriansuter / cert-template.conf
Last active July 1, 2024 23:16
Xampp SSL Certificate Creator for Windows (advanced version of https://shellcreeper.com/how-to-create-valid-ssl-in-localhost-for-xampp/)
[ req ]
default_bits = 2048
default_keyfile = server-key.pem
distinguished_name = subject
req_extensions = req_ext
x509_extensions = x509_ext
string_mask = utf8only
[ subject ]
@echo off
set /p domain="Enter Domain: "
set OPENSSL_CONF=../conf/openssl.cnf
if not exist .\%domain% mkdir .\%domain%
..\bin\openssl req -config cert.conf -new -sha256 -newkey rsa:2048 -nodes -keyout %domain%\server.key -x509 -days 3650 -out %domain%\server.crt
echo.
echo -----
[ req ]
default_bits = 2048
default_keyfile = server-key.pem
distinguished_name = subject
req_extensions = req_ext
x509_extensions = x509_ext
string_mask = utf8only
[ subject ]
@ohiosveryown
ohiosveryown / change-class-on-scroll.html
Last active May 9, 2024 16:56
Vanilla JS – change/add class based on scroll position.
// https://codepen.io/cmykw/pen/gemxJm
// layout
<nav/>
// style
<style>
body { min-height: 200vh; }
nav {
@Kelderic
Kelderic / custom_post_types.php
Last active August 8, 2023 13:39
This is set of helper classes to create and manage custom post types for WordPress. It gets added to a theme's logic folder, or libs or includes folders, and included in functions.php. Then the primary tracker class is initiated once, and used to create new CTPs.
<?php
/***********************************************************************/
/*************************** TRACKER CLASS ***************************/
/***********************************************************************/
if ( ! class_exists( 'Custom_Post_Types_Manager' ) ) {
class Custom_Post_Types_Manager {
@bryanwillis
bryanwillis / debug-atts.php
Last active July 29, 2019 23:52
This allows you to debug all of the known genesis attributes available for filtering. Genesis attributes are used for adding classes, schema.org markup, id's, and any other html attributes to elements. Drop this in your functions.php
<?php
/**
* Debug Genesis Attributes
* @author Bryan Willis
*/
add_action( 'wp_footer', 'debug_genesis_attr_filters' );
function debug_genesis_attr_filters()
{
global $wp_filter; // current_filter() might be a better way to do this
$genesis_attr_filters = array ();
/**
* This Google Sheets script keeps data in the specified column sorted any time
* the data changes.
*
* After much research, there wasn't an easy way to automatically keep a column
* sorted in Google Sheets, and creating a second sheet to act as a "view" to
* my primary one in order to achieve that was not an option. Instead, I
* created a script that watches for when a cell is edited and triggers
* an auto sort.
*
@cjkoepke
cjkoepke / functions.php
Created July 12, 2014 20:11
Modify User Profile Widget's Gravatar Size in Genesis Child Theme
<?php
/**
*
* Modify the size of the Gravatar in the User Profile Widget
*
* @author Calvin Koepke
* @since 1.0.0
*/
add_filter( 'genesis_gravatar_sizes', 'ck_user_profile' );
function ck_user_profile( $sizes ) {