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-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
@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-selectbox.php
Created November 15, 2018 13:09
Example of adding a select box to the "General" product data tab.
<?php
function prefix_add_selectbox() {
$args = array(
'id' => 'my_new_select', // required. The meta_key ID for the stored value
'wrapper_class' => '', // a custom wrapper class if needed
'desc_tip' => true, // makes your description show up with a "?" symbol and as a tooltip
'description' => __('My awesome select box', 'your_text_domain'),
'label' => __( 'My New Select', 'your_text_domain' ),
'options' => array(
'value1' => __( 'Text 1', 'your_text_domain' ),
@jan-koch
jan-koch / woo-radio-button.php
Last active January 23, 2021 15:09
Example implementation of radio buttons as product meta fields, in the "General" tab.
<?php
function prefix_add_radio_buttons() {
$args = array(
'label' => '', // Text in the label in the editor
'class' => 'prefix_radio', // custom class
'style' => '',
'wrapper_class' => '', // custom wrapper class
'value' => '', // if empty, retrieved from meta_value where id is the meta_key
'id' => '', // required, will be used as meta_key for this field
'name' => 'my_radio_buttons', // required if you want only one option to be selected at a time
@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 / woo-checkbox-input.php
Created November 15, 2018 14:54
Example for implementing a checkbox as WooCommerce product meta field, in the "General" tab.
<?php
function prefix_add_checkbox() {
$args = array(
'label' => '', // Text in the editor label
'class' => '',
'style' => '',
'wrapper_class' => '', // custom CSS class for styling
'value' => '', // meta_value where the id serves as meta_key
'id' => '', // required, it's the meta_key for storing the value (is checked or not)
'name' => '',