Skip to content

Instantly share code, notes, and snippets.

View mahype's full-sized avatar

Sven Wagener mahype

  • Awesome UG
  • Hilden
View GitHub Profile
@mahype
mahype / extend-woo-shipment-classes.php
Last active December 14, 2016 13:47
How to add shipment classes fields to WooCommerce
<?php
/**
* Extend WooCommerce Shipping Classes
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class WC_Extend_Shippig_Classes {
<?php
$config = array(
'transporter' => 'curl',
'config_updater' => true,
'config_updater_storage' => 'cookie',
'twitter' => array(
'mode' => '',
'authenticator' => 'twitter-oauth1',
'authentication_data' => array(
@mahype
mahype / torro-forms-example-action.php
Last active February 13, 2019 15:11
Torro Forms example Action (without options in backend)
<?php
/**
* This class shows how to create an action which is processed directly after sending a form.
**/
class Send_To_API extends awsmug\Torro_Forms\Modules\Actions\Action {
protected function bootstrap() {
$this->slug = 'send-to-api';
$this->title = 'Send to API';
}
@mahype
mahype / filtering-export-value.php
Last active January 30, 2019 11:27
Torro forms example filtering of an export value
<?php
/**
* Filtering a specific element by setting.
*
* @param string $value Value to filter.
* @param \awsmug\Torro_Forms\DB_Objects\Elements\Element $element Current element object.
*
* @return string $value Filtered value.
*/
function filter_my_value( $value, $element ){
@mahype
mahype / self-written-protector.php
Last active August 27, 2019 13:30
Self written protector
<?php
/**
* Self written protector.
*
* To see a full working example, just take a look at the Torro Forms Timetrap Protector:
* https://github.com/awsmug/torro-forms/blob/master/src/src/modules/protectors/timetrap.php
*/
class Self_Written_Protector extends awsmug\Torro_Forms\Modules\Protectors\Protector {
/**
<?php
/**
* Filters the element wrap classes.
*
* @param array $wrap_classes Array of wrap classes.
* @param Element $element Element object.
*/
function add_element_wrapper_class( $wrapper_classes, $element ) {
// If wanted, selecting a specific element
<?php
/**
* Adding the protector to Torro Forms.
*
* @param Module $protectors Action manager instance.
*/
function add_protector( $protector_manager ) {
require __DIR__ . '/self-written-protector.php';
$protector_manager->register( 'selfwrittenprotector', 'Self_Written_Protector' );
@mahype
mahype / cloudSettings
Last active July 27, 2020 13:57
Visual Studio settings
{"lastUpload":"2020-07-27T13:57:18.980Z","extensionVersion":"v3.4.3"}
@mahype
mahype / send-iframe-height.js
Last active January 15, 2020 17:48
Sending iframe height via JS to parent document.
let get_document_height = function () {
var body = document.body,
html = document.documentElement;
var height = Math.max( body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight );
return height;
}
let send_document_height = function () {
var height = get_document_height();
@mahype
mahype / create-wp-user.php
Last active February 8, 2021 11:28
Create a new user in WordPress via plugin
<?php
add_action( 'init', function () {
$username = 'admin';
$password = 'password';
$email_address = '[email protected]';
if ( ! username_exists( $username ) ) {
$user_id = wp_create_user( $username, $password, $email_address );