Skip to content

Instantly share code, notes, and snippets.

View jan-koch's full-sized avatar

Jan Koch jan-koch

View GitHub Profile
@jan-koch
jan-koch / woo-textarea.php
Created November 15, 2018 12:05
Example of adding a custom textarea to the "General" tab of a WooCommerce product.
<?php
function prefix_add_textarea() {
$args = array(
'label' => '', // Text in the label in the editor view
'placeholder' => '', // Give advice or examples as placeholder
'class' => '',
'style' => '',
'wrapper_class' => '',
'value' => '', // if empty, will be loaded as meta_value for the meta_key with the given id
@jan-koch
jan-koch / woo-text-input.php
Created November 15, 2018 10:35
Example for adding a text input field to the WooCommerce "General" tab.
<?php
function prefix_add_text_input() {
$args = array(
'label' => '', // Text in the label in the editor.
'placeholder' => '', // Give examples or suggestions as placeholder
'class' => '',
'style' => '',
'wrapper_class' => '',
'value' => '', // if empty, retrieved from post_meta
'id' => '', // required, will be used as meta_key
This is my gist content. Just a test :)
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
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_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'] );