Skip to content

Instantly share code, notes, and snippets.

View nikola0203's full-sized avatar

Nikola Milosevic nikola0203

  • SEO 1 Click
  • Belgrade, Serbia
View GitHub Profile
@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 / 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;
}
@gagimilicevic
gagimilicevic / wp-get_id_by_slug
Created September 1, 2017 12:53 — forked from davidpaulsson/wp-get_id_by_slug
WordPress: Get page ID from slug
// Usage:
// get_id_by_slug('any-page-slug');
function get_id_by_slug($page_slug) {
$page = get_page_by_path($page_slug);
if ($page) {
return $page->ID;
} else {
return null;
}
<html>
<head>
<title>Google Maps Multiple Markers</title>
<script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>
</head>
<body>
<div id="map" style="height: 400px; width: 500px;">
</div>
<script type="text/javascript">
@gagimilicevic
gagimilicevic / bootstrap-pagination.php
Created August 23, 2017 08:39 — forked from ediamin/bootstrap-pagination.php
Bootstrap Pagination for WordPress
/*
* custom pagination with bootstrap .pagination class
* source: http://www.ordinarycoder.com/paginate_links-class-ul-li-bootstrap/
*/
function bootstrap_pagination( $echo = true ) {
global $wp_query;
$big = 999999999; // need an unlikely integer
$pages = paginate_links( array(