Skip to content

Instantly share code, notes, and snippets.

public function ttr_container( $content ) {
$custom_content = '';
if(0 == 0) {
ob_start();
$this->social_share();
$custom_content .= ob_get_contents();
ob_end_clean();
}
$custom_content .= '<div class="ttr_start"></div>';
$custom_content .= $content;
@goranefbl
goranefbl / plugin.php
Created November 26, 2015 18:42 — forked from kevinwhoffman/plugin.php
Dependent Plugin Activation/Deactivation and Alert
<?php
/*
* Dependent Plugin Activation/Deactivation
*
* Sources:
* 1. https://pippinsplugins.com/checking-dependent-plugin-active/
* 2. http://10up.com/blog/2012/wordpress-plug-in-self-deactivation/
*
*/
@goranefbl
goranefbl / functions.php
Last active June 10, 2017 13:29
WooCommerce = Price per country
<?php
// Add Canada Price to Woo as custom field and change per country.
// You can add as many as you need
add_action( 'woocommerce_product_options_pricing', 'add_can_price_box' );
function add_can_price_box() {
woocommerce_wp_text_input( array( 'id' => 'can_price', 'class' => 'wc_input_price_extra_info short', 'label' => __( 'Price in Canadian $', 'woocommerce' ) ) );
}
// This one is for saving above fields
add_action('woocommerce_process_product_meta', 'save_can_price', 2, 2);
function save_can_price($post_id, $post) {
@goranefbl
goranefbl / woo-email.php
Created January 16, 2016 09:37
Use woocommerce email template header/footer with your plugin
public function gens_send_email($user_id,$coupon_code) {
if ( !$user_id || !$coupon_code) {
return false;
}
global $woocommerce;
$mailer = $woocommerce->mailer();
$user_info = get_userdata($user_id);
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "https://connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
window.fbAsyncInit = function() {
FB.init({
appId : 'app_id',
<?php
/**
* @package AMRW
* @subpackage Admin functions
*/
/**
* Class AMRW_Page_Template
register_post_type('product',
array( 'labels' => array(
'name' => __( 'Product', 'wpgens' ), /* This is the Title of the Group */
'singular_name' => __( 'Product', 'wpgens' ), /* This is the individual type */
'all_items' => __( 'All Products', 'wpgens' ), /* the all items menu item */
'add_new' => __( 'Add New Product', 'wpgens' ), /* The add new menu item */
'add_new_item' => __( 'Add New Product', 'wpgens' ), /* Add New Display Title */
'edit' => __( 'Edit', 'wpgens' ), /* Edit Dialog */
'edit_item' => __( 'Edit Product', 'wpgens' ), /* Edit Display Title */
'new_item' => __( 'New Product', 'wpgens' ), /* New Display Title */
/* Input type Select - kreirati neke JS funkcije za reuse
======================= */
var selects = document.getElementsByClassName('input__field--select');
[].forEach.call(selects,function(select){
var docFrag = document.createDocumentFragment(),
mainNode = document.createElement('div'),
span = document.createElement('span'),
ul = document.createElement('ul');
{
"took":3,
"timed_out":false,
"_shards":{
"total":6,
"successful":6,
"failed":0
},
"hits":{
"total":1,
@goranefbl
goranefbl / gist:8eac228f6e8f7ae439222d24e482d129
Created November 2, 2016 23:48 — forked from madrobby/gist:9476733
Download a single file from a private GitHub repo. You'll need an access token as described in this GitHub Help article: https://help.github.com/articles/creating-an-access-token-for-command-line-use
curl -H 'Authorization: token INSERTACCESSTOKENHERE' -H 'Accept: application/vnd.github.v3.raw' -O -L https://api.github.com/repos/owner/repo/contents/path