Skip to content

Instantly share code, notes, and snippets.

View mircian's full-sized avatar
:shipit:

Mircea Sandu mircian

:shipit:
View GitHub Profile
@mircian
mircian / class-m-custom-uploads-filename.php
Last active December 12, 2017 15:15
Change the name of files uploaded through the media uploader.
<?php
/**
* Class M_Custom_Uploads_Filename
*/
class M_Custom_Uploads_Filename {
/**
* M_Custom_Uploads_Filename constructor.
*/
/**
* Alter the query vars to include products which have the meta we are searching for.
*
* @param array $query_vars The current query vars.
*
* @return array
*/
function m_request_query( $query_vars ) {
global $typenow;
@mircian
mircian / woocommerce_simple_add_to_cart.js
Created September 29, 2018 12:30
Create a simple function which you can globally call to easily add a product to the cart by id.
<script type="text/javascript">
function m_wc_add_to_cart( product_id ) {
if ( 'undefined' === typeof wc_add_to_cart_params ) {
// The add to cart params are not present.
return false;
}
var data = {
product_id: product_id,