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 / website.txt
Created October 23, 2019 10:33
How to create Wordpress Responsive Images with srcset
https://alexwright.net/blog/web-design/responsive-images-wordpress/
@Soullighter
Soullighter / single.php
Last active October 9, 2019 11:36
Wordpress ACF repeater - Get content by row and put in the_content() - paragraph counter
<?php
$rows = get_field('sidebar_commercials', 'option' ); // get all the rows
// $rand_row = $rows[ array_rand( $rows ) ]; // get a random row
$row_count = count(get_field('sidebar_commercials', 'option')); // Count
if ($row_count >= 1) {
$first_baner = $rows[0];
$baner_image_first = $first_baner['widget_commercial_image' ]; // get the sub field value
@Soullighter
Soullighter / blog-page.php
Created October 9, 2019 11:33
ACF repeater - Get content by row
<?php
$rows = get_field('sidebar_commercials', 'option' ); // get all the rows
// $rand_row = $rows[ array_rand( $rows ) ]; // get a random row
$row_count = count(get_field('sidebar_commercials', 'option')); // Count
if( $the_query->current_post === 2 ) {
if ($row_count >= 1) {
$first_baner = $rows[0];
$baner_image_first = $first_baner['widget_commercial_image' ]; // get the sub field value
@Soullighter
Soullighter / svg-path.js
Created July 31, 2019 10:55
Convert SVG path to SVG x,y cordinate to HTML coordinates
// Convert SVG path to HTML x,y cordinate
// Length of path
var pathLength = Math.floor( this.getTotalLength() );
prcnt = pathLength / 100;
// Get x and y values at a certain point in the line
pt = this.getPointAtLength(prcnt);
pt.x = Math.round(pt.x);
pt.y = Math.round(pt.y);
@Soullighter
Soullighter / svg-coordinates.js
Created July 31, 2019 10:52
Convert SVG <rect> x,y cordinate to HTML cordinate
// Convert SVG <rect> x,y cordinate to HTML cordinate
var svg = this;
var svg_el = document.getElementsByClassName(element_class);
var rootSVG = document.querySelector("#front-view svg");
var point = rootSVG.createSVGPoint();
var matrix, position;
matrix = svg_el[0].getCTM();
point.x = svg.attr('x');
point.y = svg.attr('y');
position = point.matrixTransform(matrix);
@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' ),
@Soullighter
Soullighter / insta-oembed.php
Last active October 10, 2021 07:42
Get Instagram API SINGLE Post with OEmbed in PHP
<!-- IMPORTANT!!! If you want to use OEmbed like this your Instagram profile MUST BE PUBLIC -->
<?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);
@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 / set-visitor-cookie.js
Created April 17, 2019 12:06
Set Cookie for first time visitor
@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