Skip to content

Instantly share code, notes, and snippets.

@w3human
w3human / gist:d6ab11f0b3d7d4d4670c
Last active August 29, 2015 14:01
pA form validation...
jQuery(document).ready(function() {
jQuery("form[name='cartForm']").on("submit", function(event) {
jQuery("form[name='cartForm'] input[required], form[name='cartForm'] select[required]").each(function() {
if (jQuery(this).val() == "") {
jQuery(this).addClass("error");
}
else {
jQuery(this).removeClass("error");
}
}).each(function() {
@w3human
w3human / AioSeo.php
Last active November 3, 2023 23:19
WordPress SEO Modification Helpers For Popular SEO Plugins. Yoast And AIO.
<?php
class PLUGIN_DataTypeSlug_AIOseo{
public function __construct() {
$this->option = new Options();
$this->data = new Apiu();
}
@w3human
w3human / Shortcode_SearchAndResults.php
Created May 23, 2023 19:10
Shortcodes With Template Filters... Search And Result API Integration Example.
<?php
class Plugin_Shortcodes_SearchAndResults {
public function __construct() {
$this->data = new Api();
$this->options = new Options();
$this->_params = new Params();
add_shortcode('search-form', [$this, '_form']);
add_shortcode('result', [$this, '_results']);
@w3human
w3human / Template.php
Last active June 10, 2024 23:36
How To Use API Data For a Single in a WordPress Custom Post Type
<?php
class Plugin_DataTypeSlug_Template {
public function __construct() {
$this->option = new Options();
}
public function add_actions_and_filters() {
@w3human
w3human / Search.js
Last active May 24, 2023 00:14
ES6 Search And Results
var _API={};
_API.call_api=function(method, path, passing_data) {
var xhttp = new XMLHttpRequest();
return new Promise(function(resolve, reject) {
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
@w3human
w3human / single-team.php
Created May 24, 2023 21:24
WordPress Plugin Example With Custom Post Type And Meta Box...
<?php get_header(); ?>
<div class="container">
<div class="row">
<div class="col-lg-10 col-lg-offset-1">
<div class="row">
<section class="col col-md-9 col-main" role="main">
<?php if (have_posts()): ?>
<?php while (have_posts()) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
@w3human
w3human / WordPressNinjaFormGA4Event.js
Last active May 24, 2023 22:03
How To Add Google Analytics Event Tracking To WordPress Ninja Forms Plugin
function ga_event(category, action, label, value) {
if (typeof gtag !== 'undefined') {
gtag('event', action, {
'event_category': category,
'event_label': label,
'event_value': value,
'event_callback': function() {
console.log('ga event callback ('+ action +' - '+ category +' - '+ label +')');
@w3human
w3human / MiniSliders.js
Created June 22, 2023 14:18
An Old Slider I Wrote In JavaScript
var miniSlider_data=new Object();
function changeSlideOnMiniSlider(eleID, slideNum) {
if (eleID!=undefined && slideNum!=undefined && eleID in miniSlider_data) {
var aMiniSliders_data=miniSlider_data[(eleID)];
if (slideNum=="next" || slideNum=="back") {
for (es=0; es < aMiniSliders_data['slides'].length; es++) {
if (! new RegExp("( |)(hideSlide)", "g").test(aMiniSliders_data['slides'][es].className)) {
eval("var slideNum="+ ((slideNum=="next")?((es==(aMiniSliders_data['slides'].length-1))?"0":"es+1"):((es==0)?(aMiniSliders_data['slides'].length-1):"es-1")));
<?php
add_filter('template_redirect', function() {
global $wp_query;
if(! empty($wp_query->query_vars["xml_listings_sitemap"]) ) {
$wp_query->is_404 = false;
header('Content-type: application/xml; charset=utf-8');
print "Welcome To Tic-Tac-Toe\n"
"""
THE BOARD
|{0}|{1}|{2}|
|{3}|{4}|{5}|
|{6}|{7}|{8}|
"""
winningCombinations = [[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]];