Skip to content

Instantly share code, notes, and snippets.

View gagimilicevic's full-sized avatar

Milicevic Dragan gagimilicevic

View GitHub Profile
@gagimilicevic
gagimilicevic / facebook_page_latest_post_no_php_sdk.php
Created November 22, 2018 22:52 — forked from biojazzard/facebook_page_latest_post_no_php_sdk.php
Get Latest Post From a Facebook Page without PHP SDK (Graph Version v2.5)
<?php
/*
1.- Create an App.
2.- Go to: https://developers.facebook.com/tools/explorer/
+ Select your new created app on the right top.
+ Select "Get App Token"
@gagimilicevic
gagimilicevic / thz_disable_gutenberg.php
Created October 25, 2018 11:40 — forked from danyj/thz_disable_gutenberg.php
Disable Gutenberg globally or for specific post types for WordPress 5.0 and UP
<?php
/*
* Disable Gutenberg globally
* use this if you prefer one-liner
* add_filter('use_block_editor_for_post', '__return_false');
*/
function _thz_filter_disable_block_editor(){
return false;
}
add_filter( 'use_block_editor_for_post', '_thz_filter_disable_block_editor' );
# Install brew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# Install composer
brew install homebrew/php/composer
### PHPCS
composer global require "squizlabs/php_codesniffer=*"
# Add to your .bash_profile
@gagimilicevic
gagimilicevic / getdates.js
Created September 17, 2018 10:46 — forked from miguelmota/getDates.js
Get dates in between two dates with JavaScript.
// Returns an array of dates between the two dates
var getDates = function(startDate, endDate) {
var dates = [],
currentDate = startDate,
addDays = function(days) {
var date = new Date(this.valueOf());
date.setDate(date.getDate() + days);
return date;
};
while (currentDate <= endDate) {
@gagimilicevic
gagimilicevic / file-upload-handler.php
Created May 18, 2018 14:02 — forked from daltonrooney/file-upload-handler.php
Multi-file WordPress uploads from the front-end
<?php /* This function attaches the image to the post in the database, add it to functions.php */
function insert_attachment($file_handler,$post_id,$setthumb='false') {
// check to make sure its a successful upload
if ($_FILES[$file_handler]['error'] !== UPLOAD_ERR_OK) __return_false();
require_once(ABSPATH . "wp-admin" . '/includes/image.php');
require_once(ABSPATH . "wp-admin" . '/includes/file.php');
require_once(ABSPATH . "wp-admin" . '/includes/media.php');
@gagimilicevic
gagimilicevic / nationality.html
Created May 16, 2018 10:04 — forked from didats/nationality.html
Nationality List in HTML Dropdown
<select name="nationality">
<option value="">-- select one --</option>
<option value="afghan">Afghan</option>
<option value="albanian">Albanian</option>
<option value="algerian">Algerian</option>
<option value="american">American</option>
<option value="andorran">Andorran</option>
<option value="angolan">Angolan</option>
<option value="antiguans">Antiguans</option>
<option value="argentinean">Argentinean</option>
@gagimilicevic
gagimilicevic / taxonomy-slug-as-custom-post-type.php
Last active April 10, 2018 08:16 — forked from fomigo/taxonomy-slug-as-custom-post-type.php
wp: CUSTOM TAXONOMY WITH SAME SLUG AS CUSTOM POST TYPE
<?php
/*
* Source: http://someweblog.com/wordpress-custom-taxonomy-with-same-slug-as-custom-post-type/
*/
// rewrite urls
function taxonomy_slug_rewrite($wp_rewrite) {
$rules = array();
@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 / 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;
}