Skip to content

Instantly share code, notes, and snippets.

@ossvn
ossvn / acf-form-builder-subscribe-via-mailchimp.php
Last active April 4, 2017 04:26
ACF Form Builder - Register Custom Action - Do your own thing after user press submit button
<?php
/**
* Subscribe via Mailchimp
*/
//Your function name must start with acf_fb_custom_actions_
function acf_fb_custom_actions_subscribe_via_mailchimp($data) {
//We already had $data - you can var_dump() to see what is inside
if ( is_null($data) )
return;
@ossvn
ossvn / woo-extra-addon-security-improve
Created September 12, 2016 06:09
Improve security of upload on frontend for plugin WooCommerce Extra Product Options - It's can be exploited!!
// Find this file class-tm-epo-fields-upload.php
// Find this line $upload = TM_EPO()->upload_file( $_FILES[ $this->attribute ] );
// Replace with following snippet
$ext = strtolower( pathinfo( $_FILES[ $this->attribute ]['name'], PATHINFO_EXTENSION ) );
if (in_array($ext, array('jpg','png','gif', 'bmp'))){
$upload = TM_EPO()->upload_file( $_FILES[ $this->attribute ] );
}
else {
@ossvn
ossvn / dynamic-woocommerce-checkout-field
Created September 11, 2016 16:46
Dynamic WooCommerce Checkout Custom Field - It will dynamic create field for each product in cart. It's great to use in specific selection for each product in cart
add_action( 'woocommerce_before_order_notes', 'music_select' );
function music_select($checkout) {
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
$product_id = $cart_item['product_id'];
$product_name = $cart_item['data']->post->post_title;
woocommerce_form_field( 'music_select_'.$product_id, array(
'type' => 'select',
@ossvn
ossvn / get-languages.php
Last active May 6, 2018 19:52
Get active languages in WPML, It's used in a plugin called "WooCommerce Checkout Advanced Fields and Templates"
<?php
/**
* Get active languages in WPML
* @return array
* @since 1.0
*/
public static function wct_get_languages(){
$languages_arr = array();
$wct_wpml = get_option('wct_wpml');