Skip to content

Instantly share code, notes, and snippets.

View npapratovic's full-sized avatar
🏠
Working from home

NIKOLA PAPRATOVIC npapratovic

🏠
Working from home
View GitHub Profile
@npapratovic
npapratovic / create_featured_image.php
Created April 29, 2020 11:48
Function to create featured image in WP post
@npapratovic
npapratovic / xml-to-wordpress-importer.php
Created April 29, 2020 13:18
Example of custom made import script which imports content from xml file. XMl file is pulled from Access db of ASP.NET powered CMS. This exported file containes information of posts which I used to import in WordPress CMS. Script imports posts and images to gallery. Gallery is made as ACF gallery field. Take a look at this example and use it as …
<?php
/*Only for debugging..*/
error_reporting(E_ALL);
ini_set('display_errors', 'On');
ini_set('max_execution_time', 0); // for infinite time of execution
// require wp-load.php to use built-in WordPress functions
require_once '../wp-load.php';
require_once ABSPATH . 'wp-config.php';
require_once ABSPATH . 'wp-includes/wp-db.php';
<?php
error_reporting(E_ALL);
ini_set('display_errors', 'On');
ini_set('max_execution_time', 0); // for infinite time of execution
// require wp-load.php to use built-in WordPress functions
require_once '../wp-load.php';
require_once ABSPATH . 'wp-config.php';
require_once ABSPATH . 'wp-includes/wp-db.php';
require_once ABSPATH . 'wp-admin/includes/taxonomy.php';
@npapratovic
npapratovic / gist:77e2837a7f9b820e6b1c69c25108afd5
Created May 26, 2020 09:44
fastest-way-to-load-google-fonts.html
<!--
@source https://csswizardry.com/2020/05/the-fastest-google-fonts/
To make the snippets easier to read, I’m going to replace all instances of https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,400;0,700;1,400;1,700 with $CSS.
-->
<!--
- 1. Preemptively warm up the fonts’ origin.
-
- 2. Initiate a high-priority, asynchronous fetch for the CSS file. Works in
- most modern browsers.

Requirements:

  1. Clear cache chrome extenzija: https://chrome.google.com/webstore/detail/clear-cache/cppjkneekbjaeellbfkmgnhonkkjfpdn?hl=en
  2. EditthisCookie chrome extenzija https://chrome.google.com/webstore/detail/editthiscookie/fngmhnnpilhplaeedifhccceomclgfbg?hl=en

VIZUALNI I FUNKCIONALNI PREGLED

  1. Ako su izmjene samo na razini dizajna - razmaci, fontovi, margine, labele - dovoljno je samo napraviti vizualni pregled u preglednicima, i kroz sve uređaje. (VIDI PROVJERA DIZAJNA)
  2. Ako su izmjene funkcionalnosti web stranice pr. dodavanje polja u formi, popup prozori, obavijest o kolačićima, dodavanje videa u pozadinu, integracija sa kalendarom, dodavanje novih oblika plaćanja na web stranicu itd. - tada radimo vizualni i funkcionalni pregled web stranice (VIDI PROVJERA FUNKCIONALNOSTI)
@npapratovic
npapratovic / ajax-call-to-remote-change-DOM.html
Last active July 12, 2022 10:36
On button click start function with ajaxcall to remote to fetch data and store data in another div
<a id="clickme">Click me!</a>
<div id="populateme"></div>
<script>jQuery(function ($) {
$(document).ready(function(){
var getdest = '/session/getdest';
$(document).on('click', '#clickme', function() {
changeDiv();
});
function changeDiv() {
//HTML part
<div class="slider-wrapper">
<button id="right-btn"></button>
<button id="left-btn"></button>
<div class="slider-images">
<img src="img-name.jpg" />
<img src="img-name2.jpg" />
<img src="img-name3.jpg" />
<img src="img-name4.jpg" />
</div>

Commit Message Convention:

Template:

Commit title: type + subject

Commit body

Commit footer

@npapratovic
npapratovic / git-head-status.md
Last active December 8, 2022 14:25
git Attached / Detached HEAD explained

Detached head means:

  1. You are no longer on a branch,
  2. You have checked out a single commit in the history

If you have no changes: you can switch to master by applying the following command

git checkout master

If you have changes that you want to keep:

@npapratovic
npapratovic / git-sync-branch-with-master.md
Last active January 10, 2023 09:52
Sync current branch with master / main branch to avoid merge conflicts
  1. Do all work on separate branch
  2. Commit and push to origin
  3. Checkout master branch
  4. Git pull master
  5. Checkout separate branch
  6. Git merge origin/master branch into separate branch
  7. Git push