Skip to content

Instantly share code, notes, and snippets.

View kreativan's full-sized avatar

Ivan Milincic kreativan

View GitHub Profile
@kreativan
kreativan / wordpress-cron.php
Created May 19, 2024 19:26
Wordpress Cron Job
<?php
namespace Kreativan;
if (!defined('ABSPATH')) {
exit;
}
class CronJob {
public function __construct($plugin_file) {
@kreativan
kreativan / reCaptcha-Ajax-Submit.js
Last active May 10, 2024 07:25
Google reCaptcha php Class
const formSubmitRecapcha = function (site_key = "") {
grecaptcha.ready(function () {
grecaptcha.execute(site_key, {
action: 'contact'
}).then(function (token) {
// Get #recaptchaResponse field and populate it's value
var recaptchaResponse = document.getElementById('recaptchaResponse');
recaptchaResponse.value = token;
//
// Make the Ajax Call
@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 / 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
*
@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);
}
?>