Skip to content

Instantly share code, notes, and snippets.

View jan-koch's full-sized avatar

Jan Koch jan-koch

View GitHub Profile
function wpi_s2_payment_notification() {
if ( !empty( $_GET['yourauthenticationtoken']) && 'yes' === $_GET['yourauthenticationtoken'] ) {
// in the URL, I have '?yourauthenticationtoken=yes', that's what I'm looking for here.
// make sure the request comes from a valid user
if ( !empty( $_GET['user_id'] ) ) {
// Load the user data for the new license
$user_id = (integer) esc_attr( $_GET['user_id'] );
function wpi_s2_cancellation_notification() {
if ( !empty( $_GET['yourauthenticationtoken']) && 'yes' === $_GET['yourauthenticationtoken'] ) {
// in the URL, I have '?yourauthenticationtoken=yes', that's what I'm looking for here.
// Only process requests for valid users
if ( !empty( $_GET['user_id'] ) ) {
$user_id = (integer) esc_attr( $_GET['user_id'] );
$user = new WP_User($user_id);
function wpi_check_with_license_server() {
$license = get_option( 'youroptionfield' );
$api_params = array(
'slm_action' => 'slm_check',
'secret_key' => VALIDATION_KEY,
'license_key' => $license,
);
// Send query to the license manager server
This is my gist content. Just a test :)
@jan-koch
jan-koch / woo-hidden-input.php
Created November 15, 2018 14:49
Example implementation for a hidden field as WooCommerce product meta field, in the "General" tab.
<?php
function prefix_add_hidden_input() {
$args = array(
'value' => '', // meta_value, meta_key is the id
'class' => '',
'id' => '' // required, makes the meta_key for storing the value
);
woocommerce_wp_hidden_input( $args );
}
@jan-koch
jan-koch / block.js
Created December 11, 2018 16:22
Functionality for the Gutenberg block to embed Github gists
/**
* BLOCK: wpmastery-code-block
*
* Registering a basic block with Gutenberg.
* Simple block, renders and saves the same content without any interactivity.
*/
// Import CSS.
import './style.scss';
import './editor.scss';
@jan-koch
jan-koch / sticky-menu.js
Created March 5, 2019 05:46
Small JavaScript snippet to make the Genesis site header stick to the top when scrolling down.
jQuery(function ($) {
$(window).scroll(function () {
var yPos = ($(window).scrollTop());
if (yPos > 200) { // show sticky menu after screen has scrolled down 200px from the top.
// add a custom class to the site header for custom styling.
$(".site-header").addClass("is-sticky");
// if you feel brave, switch logos (e.g. to match different background colors).
$("img.custom-logo").attr("src", "http://localhost/wp-content/path/to/sticky-logo.svg");
} else {
@jan-koch
jan-koch / git-create-repo.sh
Created May 22, 2019 06:16
A simple bash script to create a repository from the console.
#! /usr/bin/bash
NAME=$1
TYPE=$2
echo "Creating the repository"
gh re --browser false --new "$NAME" --type "$TYPE"
mkdir "$NAME"
cd "$NAME"
@jan-koch
jan-koch / git-create-repo.sh
Last active May 24, 2019 13:06
A simple bash script to create a repository from the console. Be sure to replace "USERNAME" with your Github user name. This script utilizes nodegh.io.
#! /usr/bin/bash
NAME=$1
TYPE=$2
echo "Creating the repository"
gh re --browser false --new "$NAME" --type "$TYPE"
mkdir "$NAME"
cd "$NAME"
@jan-koch
jan-koch / docker-compose.yml
Created June 8, 2019 13:43
Example of a docker-compose file to create a local WordPress development setup with Docker.
version: '3.2'
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: on-failure
environment:
# Grab this data from wp-config.php
# TODO: Update DB_HOST in wp-config.php to "db:port"