Skip to content

Instantly share code, notes, and snippets.

View gagimilicevic's full-sized avatar

Milicevic Dragan gagimilicevic

View GitHub Profile
@gagimilicevic
gagimilicevic / ajax.js
Created March 6, 2018 11:46 — forked from nikola0203/ajax.js
Wordpress, AJAX call, Bootsrap modal popup. AJAX function to retrieve, WooCommerce single product page, through the Bootstrap modal popup.
jQuery(document).ready(function($){
// Quick view ajax function on products page
$('.quick-view-link, .quick-view-button').on('click', function() {
var post_id = $(this).data('id');
$.ajax({
url : modal_ajax.url,
type : 'post',
data : {
@gagimilicevic
gagimilicevic / gist:43dca2d6e84eed0306f2061ff9f99806
Created November 14, 2017 13:22 — forked from jmertic/gist:5730287
Sample PHP script for connecting to the new RESTful SugarCRM REST API in 6.7 and later.
<?php
// specify the REST web service to interact with
$baseurl = '<<instanceurl>>/rest/v10';
/**
* Authenicate and get back token
*/
$curl = curl_init($baseurl . "/oauth2/token");
curl_setopt($curl, CURLOPT_POST, true);
@gagimilicevic
gagimilicevic / functions.php
Created November 9, 2017 14:58
Change file upload locations - Gravity Forms
function change_upload_path( $path_info, $form_id ) {
$path_info['path'] = get_home_path().'wp-content/uploads/docs/';
$path_info['url'] = get_site_url().'/wp-content/uploads/docs/';
return $path_info;
}
add_filter( 'gform_upload_path', 'change_upload_path', 10, 2 );
@gagimilicevic
gagimilicevic / gist:5fa660b42436d9a4a40e77d61632fd2b
Created November 1, 2017 19:15 — forked from bryceadams/gist:db6c8669e9e99cb2808c
Clear WooCommerce Cart (when not cart/checkout)
/**
* Clears WC Cart on Page Load
* (Only when not on cart/checkout page)
*/
add_action( 'wp_head', 'bryce_clear_cart' );
function bryce_clear_cart() {
if ( wc_get_page_id( 'cart' ) == get_the_ID() || wc_get_page_id( 'checkout' ) == get_the_ID() ) {
return;
}
@gagimilicevic
gagimilicevic / geocoder_example.html
Created October 23, 2017 10:16 — forked from lazarofl/geocoder_example.html
Google Maps V3 - Geocoder example
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<title>Google Maps JavaScript API v3 Example: Geocoding Simple</title>
<link href="https://developers.google.com/maps/documentation/javascript/examples/default.css" rel="stylesheet">
<script src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script>
@gagimilicevic
gagimilicevic / swedish_mobile_phone_regex.rb
Created October 6, 2017 12:56 — forked from sandnuggah/swedish_mobile_phone_regex.rb
Regular Expression for validating swedish mobile phone numbers.
/A\+?(?:0{0,2}[46]*){1}7{1}[0-9]{8}/z
// Shortcode
// source : https://wpbakery.atlassian.net/wiki/pages/viewpage.action?pageId=524362
if(!function_exists('carousel_content')){
function carousel_content( $atts, $content = null ) {
return '<div class="owl-carousel content-carousel content-slider">'.do_shortcode($content).'</div>';
}
add_shortcode('carousel_content', 'carousel_content');
}
@gagimilicevic
gagimilicevic / kunena
Created September 18, 2017 09:52 — forked from csotelo/kunena
Kunena converter for bbPress 2.4
<?php
/**
* Implementation of Example converter.
*/
class Kunena extends BBP_Converter_Base {
function __construct() {
parent::__construct();
$this->setup_globals();
@gagimilicevic
gagimilicevic / image-upload-field-custom-taxonomy
Created September 5, 2017 13:34 — forked from mathetos/image-upload-field-custom-taxonomy
Add Image Upload Field to Custom Taxonomy
<?php
/* Add Image Upload to Series Taxonomy */
// Add Upload fields to "Add New Taxonomy" form
function add_series_image_field() {
// this will add the custom meta field to the add new term page
?>
<div class="form-field">
<label for="series_image"><?php _e( 'Series Image:', 'journey' ); ?></label>
@gagimilicevic
gagimilicevic / latest-and-first.php
Created September 4, 2017 09:20 — forked from gbyat/latest-and-first.php
get latest and first post in WordPress
/******************************************
* get latest post
* use in loop if ( is_latest() ) { stuff; }
******************************************/
function is_latest() {
global $post;
$loop = get_posts( 'numberposts=1' );
$latest = $loop[0]->ID;
return ( $post->ID == $latest ) ? true : false;
}