Skip to content

Instantly share code, notes, and snippets.

View kreativan's full-sized avatar

Ivan Milincic kreativan

View GitHub Profile
@kreativan
kreativan / wordpress_cpt_admin_columns.php
Created March 13, 2024 10:10
Wordpress Custom Post Types - Admin Columns
<?php
/**
* Admin Columns
* @example
*
new Admin_Columns('my_post_type', [
'order' => __('Order'),
'image' => __('Image'),
]);
@kreativan
kreativan / acf-page-builder.php
Created February 12, 2024 13:44
acf-page-builder.php
<?php
/**
* Page Builder
* @example tpf_include('html/page-builder', $args);
* @param string $folder - folder path from where to include blocks
* @param string $container - container class
* @param string $display - default display option, should be a class that defines space and style
* @param array $layout_settings - individual layout settings
*
@kreativan
kreativan / repeater.js
Last active June 13, 2020 19:51
JavaScript Repeater. Dynamically add input fields... optimized for uikit. To init, add click event listener to the `add` button, specify container 'id='lngs'' element and array of fields... You just need html container and add button: ```
function createInput(name, placeholder = "") {
let input = document.createElement("INPUT");
input.setAttribute("type", "text");
input.setAttribute("name", name);
input.setAttribute("placeholder", placeholder)
input.classList.add("uk-input");
return input;
@kreativan
kreativan / uikit-gallery.html
Last active August 4, 2020 16:22
Crreate gallery using uikit lightbox.
@kreativan
kreativan / fs-video.html
Created August 26, 2019 10:46
Open video on click in fullscreen, trigger event on fullscreen exit/change
<script>
/**
* @param {string} id video element css ID
*
*/
function openFullscreen(id) {
event.preventDefault();
elem = document.getElementById(id);
/**
* Gradient color mixin
* Works great with text & icons fonts
*/
.gradient-color-mixin(@color, @color-2, @deg: 90deg) {
color: transparent;
background-image: -webkit-linear-gradient(@deg, @color-2 0%, @color 100%);
background-image: -moz-linear-gradient(@deg, @color-2 0%, @color 100%);
background-image: linear-gradient(@deg, @color-2 0%, @color 100%);
-webkit-background-clip: text;
@kreativan
kreativan / animate-numbers.js
Last active August 22, 2019 16:37
Animate numbers, when they enter viewport using uikit scrollspy componenet
function animateNumbers() {
var elements = document.querySelectorAll(".tm-animate-number");
elements.forEach(e => {
let current = 0;
let end = e.getAttribute("data-number");
let end_2 = (end > 200) ? end - 50 : end;
let increase_by = (end > 200) ? 23 : 1;
<?php
/*
* REST Helper.
*
* Copyright (c) 2014 Camilo Castro <camilo@cervezapps.cl>
*
* Some portions of code are based on the Lime Project
* https://github.com/aheinze/Lime/
* Copyright (c) 2014 Artur Heinze
*
<?php
function getUserIP() {
// Get real visitor IP behind CloudFlare network
if (isset($_SERVER["HTTP_CF_CONNECTING_IP"])) {
$_SERVER['REMOTE_ADDR'] = $_SERVER["HTTP_CF_CONNECTING_IP"];
$_SERVER['HTTP_CLIENT_IP'] = $_SERVER["HTTP_CF_CONNECTING_IP"];
}
$client = @$_SERVER['HTTP_CLIENT_IP'];
$forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];
$remote = $_SERVER['REMOTE_ADDR'];
@kreativan
kreativan / dropzone.php
Last active February 11, 2024 12:17
Upload files with dropzone.js and php
<?php
// process $_POST request
if(isset($_POST["submitDropzone"])) {
// Do something
print_r($_POST);
}
?>