Skip to content

Instantly share code, notes, and snippets.

View Soullighter's full-sized avatar
Fast forward

Stefan Repac Soullighter

Fast forward
  • Novi Sad, Serbia
View GitHub Profile
@Soullighter
Soullighter / Wordpress gitignore default
Last active June 16, 2016 14:19
Wordpress gitignore default
*~
.DS_Store
.svn
.cvs
*.bak
*.swp
Thumbs.db
wp-config.php
wp-content/uploads/
wp-content/blogs.dir/
@Soullighter
Soullighter / Lightbox image centering
Last active June 28, 2016 04:14
How to center image vertically in lightbox
// STEP 1:
// Inside the start function, at around line 170 I commented out the assignation of the 'top' property, like this:
// Position Lightbox
var top = $window.scrollTop() + this.options.positionFromTop;
var left = $window.scrollLeft();
this.$lightbox.css({
// top: top + 'px', // comment out this line
left: left + 'px'
}).fadeIn(this.options.fadeDuration);
<?php
/* Get the Page Slug to Use as a Body Class, this will only return a value on pages! */
$class = '';
/* is it a page */
if( is_page() ) {
global $post;
/* Get an array of Ancestors and Parents if they exist */
$parents = wp_get_post_parent_id( $post->ID );
$id = ($parents) ? $parents: $post->ID;
@Soullighter
Soullighter / Browser detect
Created April 4, 2017 07:28
Browser detect
$(document).ready(function(){
/* Get browser */
$.browser.chrome = /chrome/.test(navigator.userAgent.toLowerCase());
/* Detect Chrome */
if($.browser.chrome){
/* Do something for Chrome at this point */
alert("You are using Chrome!");
@Soullighter
Soullighter / Terminal
Last active September 13, 2018 09:01
Importing large SQL in MAMP, Apple macOS
/Applications/MAMP/Library/bin/mysql --host=localhost -uroot -proot DB-Name < /your/data/base/path.sql
@Soullighter
Soullighter / gist:f9685f0ad016aefc0d2886c1d3725645
Created January 28, 2019 13:27
Changing PHP version in SiteGround with .htaccess
https://www.reviewplan.com/wp-content/uploads/2018/07/Siteground-php-version-change-edit.jpg
If you want to update to PHP 7.2– AddHandler application/x-httpd-php72 .php .php5 .php4 .php3
For PHP 7.1– AddHandler application/x-httpd-php71 .php .php5 .php4 .php3
For PHP 7.0– AddHandler application/x-httpd-php70 .php .php5 .php4 .php3
For PHP 5.6– AddHandler application/x-httpd-php56 .php .php5 .php4 .php3
For PHP 5.5– AddHandler application/x-httpd-php55 .php .php5 .php4 .php3
So, copy and paste one of the lines from above to change the PHP version of your website.
For example, we have pasted the line‘AddHandler application/x-httpd-php72 .php .php5 .php4 .php3’ as we wanted to switch to PHP version 7.2
@Soullighter
Soullighter / Function to Convert stdClass Objects to Multidimensional Arrays
Created March 27, 2019 11:29
Function to Convert stdClass Objects to Multidimensional Arrays
function objectToArray($d) {
if (is_object($d)) {
// Gets the properties of the given object
// with get_object_vars function
$d = get_object_vars($d);
}
if (is_array($d)) {
/*
* Return array converted to object
@Soullighter
Soullighter / set-visitor-cookie.js
Created April 17, 2019 12:06
Set Cookie for first time visitor
@Soullighter
Soullighter / insta-token.php
Last active May 7, 2019 09:32
Get Instagram API Posts with Token in PHP
<?php
// Using curl because if you use file_get_contents() it need more then 10s page to be loaded...
function curl_get_contents($url) {
// Initiate the curl session
$ch = curl_init();
// Set the URL
curl_setopt($ch, CURLOPT_URL, $url);
// Removes the headers from the output
curl_setopt($ch, CURLOPT_HEADER, 0);
// Return the output instead of displaying it directly
@Soullighter
Soullighter / custom-wp-login.php
Created June 5, 2019 20:40
Custom WP Login /w redirection and error fields
<?php
function custom_login_shortcode() {
if ( ! is_user_logged_in() ) { // Display WordPress login form:
$args = array(
'redirect' => home_url() . '/alumni/',
'form_id' => 'loginform-custom',
'label_username' => __( 'Korisničko ime ili Email' ),
'label_password' => __( 'Lozinka' ),
'label_remember' => __( 'Zapamti me' ),
'label_log_in' => __( 'Prijavi se' ),