Skip to content

Instantly share code, notes, and snippets.

View tivnet's full-sized avatar

TIV NET tivnet

View GitHub Profile
@tivnet
tivnet / woocommerce_multicurrency_create_order_example.php
Created December 21, 2020 17:03
WooCommerce Multicurrency: create order programmatically
function ___return_currency_USD() {
return 'USD';
}
// Temporarily set active currency to "USD".
\add_filter( 'woocommerce_multicurrency_override_currency', '___return_currency_USD' );
// Create order programmatically.
$logger = \wc_get_logger();
$product_id = 10;
@tivnet
tivnet / woopaywall_hide_after_purchase
Created June 19, 2020 02:47
Paywall for WooCommerce: shortcode "woopaywall_hide_after_purchase"
[woopaywall_hide_after_purchase]
The content placed here is shown only until paid.
Hey, here is a sales pitch! You definitely must buy this NOW!
[/woopaywall_hide_after_purchase]
@tivnet
tivnet / woopaywall_show_after_purchase
Last active December 16, 2021 19:08
Paywall for WooCommerce: shortcode [woopaywall_show_after_purchase]
[woopaywall_show_after_purchase]
The content placed here is hidden until paid.
For example, you can hide a YouTube video here:
[video src="https://www.youtube.com/watch?v=z6e_W6L6sTg"]
[/woopaywall_show_after_purchase]
@tivnet
tivnet / ACE Editor: submit, beautify and minify.html
Last active January 24, 2023 20:17
ACE Editor: submit, beautify and minify
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>ACE Editor: submit, beautify and minify</title>
<style type="text/css" media="screen">
#ace_js, #ace_css {
width: 95%;
height: 15em;
border: 1px solid silver;
@tivnet
tivnet / verup.sh
Created April 24, 2017 20:41
Plugin/Theme ZIP to Git keeping composer.json
#!/bin/bash
if test -z ${1}; then
echo "Syntax: ${0} folder-name-same-as-zip-file";
exit 2;
fi
mv ${1} ${1}.S && \
unzip -q ${1}.zip && \
rm ${1}.zip && \
@tivnet
tivnet / a2site.sh
Created March 16, 2017 18:29
A simplified version of a2ensite/a2dissite. Works under Windows with no symlinking.
#!/bin/bash
# A simplified version of a2ensite/a2dissite. Works under Windows with no symlinking.
# Author: Gregory Karpinsky (@tivnet)
if [ ! -d sites-available ]
then
echo "Wrong folder!"
exit 2;
fi
@tivnet
tivnet / apigen-hooks.php
Created November 2, 2016 17:58
Generate list of hooks (for WPGlobus)
<?php
/**
* File: apigen-hooks.php
*
* NOTE: this code is used internally in WPGlobus project.
* It's a W.I.P. - please use it, but do not forget to adapt for your project.
*
* @package WPGlobus\APIGen
* @author Gregory Karpinsky (@tivnet)
*/
@tivnet
tivnet / to-folders-by-date.sh
Created July 19, 2016 14:45
Split files into folders by EXIF original date
#!/bin/bash
for f in `find . -name "*.jpg"`; do dd=`exif -t "Date and Time (Original)" --machine-readable $f | cut -f1 -d" " | sed s/:/-/g`; mkdir -p $dd && mv $f $dd/; done
@tivnet
tivnet / wc-api-manager-fix-2.php
Last active February 1, 2021 17:49
WooCommerce API Manager: Fix 2
<?php
// plugins/woocommerce-api-manager/includes/class-wc-am-update-api.php
// Add `$response->tested` to show "100% compatible" on the Updates page.
case 'pluginupdatecheck':
$response->id = $post_id;
$response->slug = ! empty( $this->slug ) ? $this->slug : $slug;
$response->plugin = $plugin_name;
$response->new_version = $api_data[ '_api_new_version' ];
$response->url = $api_data[ '_api_plugin_url' ];
@tivnet
tivnet / wc-api-manager-fix-1.php
Last active October 5, 2018 09:50
WooCommerce API Manager: Fix 1
<?php
// class WC_Api_Manager_Helpers
// Status can be lowercase.
public function is_user_subscription_active( $status ) {
// Wrong:
// return $status == 'Active' || $status == 'Pending Cancellation' ? true : false;
// Correct:
return ( strtolower( $status ) === 'active' || $status === 'Pending Cancellation' );
}