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 / 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';
@npapratovic
npapratovic / create_featured_image.php
Created April 29, 2020 11:48
Function to create featured image in WP post
@npapratovic
npapratovic / import-ics-feed-to-wordpress.php
Last active February 11, 2020 12:45
Import data to WordPress from .ics feed of most popular booking websites (airbnb.com, booking.com, expediapartnercentral.com)
<?php
error_reporting(-1); // reports all errors
ini_set("display_errors", "1"); // shows all errors
ini_set("log_errors", 1);
ini_set('user_agent','Mozilla/4.0 (compatible; MSIE 6.0)');
// https://github.com/MartinThoma/ics-parser/blob/master/class.iCalReader.php
require_once 'class.iCalReader.php';
@npapratovic
npapratovic / .htaccess
Created December 2, 2019 12:12 — forked from ScottPhillips/.htaccess
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@npapratovic
npapratovic / wordpress-disable-comments.php
Last active November 8, 2019 09:00
Wordpress disable comments without plugin, remove links from admin menu (add this code-snippet to functions.php)
<?php
/*Disable comments from WordPress*/
add_action('admin_init', function () {
// Redirect any user trying to access comments page
global $pagenow;
if ($pagenow === 'edit-comments.php') {
wp_redirect(admin_url());
exit;
}
@npapratovic
npapratovic / console.log.css
Created September 5, 2019 06:41
See the size of each element on the page, their margin and their padding
/*Different depth of nodes will use different colour allowing you to see the size of each element on the page, their margin and their padding. Now you can easily identify inconsistencies.
*/
* { background-color: rgba(255,0,0,.2); }
* * { background-color: rgba(0,255,0,.2); }
* * * { background-color: rgba(0,0,255,.2); }
* * * * { background-color: rgba(255,0,255,.2); }
* * * * * { background-color: rgba(0,255,255,.2); }
* * * * * * { background-color: rgba(255,255,0,.2); }
* * * * * * * { background-color: rgba(255,0,0,.2); }
* * * * * * * * { background-color: rgba(0,255,0,.2); }
@npapratovic
npapratovic / mobile-first-css.css
Created April 11, 2019 15:45
mobile-first-css-breakpoints
/* smartphones, portrait iPhone, portrait 480x320 phones (Android) */
@media (min-width:320px) {
}
/* smartphones, Android phones, landscape iPhone */
@media (min-width:480px) {
}
/* Set the background color of body to tan */
body {
background-color: tan;
}
/* On screens that are 1200px or less, set the background color to red */
@media screen and (max-width: 1200px) {
body {
background-color: red;
}
CREATE TABLE `users` (
`id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`username` varchar(50) NOT NULL,
`first_name` varchar(50) NOT NULL,
`last_name` varchar(50) NOT NULL,
`email` varchar(100) NOT NULL,
`birth_date` date NOT NULL,
`password` varchar(100) NOT NULL,
`spol` varchar(2) NOT NULL,
`country` varchar(100) NOT NULL
<?php
session_start();
// variable declaration
$username = "";
$country = "";
$email = "";
$first_name = "";
$last_name = "";
$birth_date = "";