Skip to content

Instantly share code, notes, and snippets.

View goranseric's full-sized avatar

Goran Šerić goranseric

View GitHub Profile
@goranseric
goranseric / wpengine-cdnurl.php
Created January 14, 2016 17:09 — forked from pospi/wpengine-cdnurl.php
Premodify URLs on WPEngine to directly point to your CDN. Avoids issues some link generators have with HTTP redirects.
<?php
function wpe_noRedirectUrl($srcURL)
{
if (class_exists('WpeCommon')) {
global $wpe_netdna_domains;
static $cdn_domain;
if (!isset($cdn_domain)) {
$wpe_common = new WpeCommon();
if ($wpe_common->is_cdn_enabled()) {
@goranseric
goranseric / get_domain_mapped_url.php
Created January 14, 2016 18:21 — forked from Coopeh/get_domain_mapped_url.php
Get Domain Mapped URL From BlogID
<?php
// Function to get a blog/site's domain mapped url.
//
// You need to call it with a blog ID
//
// Example:
// $custom_blog_id = '14';
// echo get_domain_mapped_url( $custom_blog_id );
//
@goranseric
goranseric / 0_reuse_code.js
Created January 18, 2016 08:53
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@goranseric
goranseric / gist:e95532245c8561254fbd
Created January 18, 2016 10:59 — forked from joshuabaker/gist:313648
Get all images in a HTML string
<?php
/**
* Returns all img tags in a HTML string with the option to include img tag attributes
*
* @author Joshua Baker
*
* @example $post_images[0]->html = <img src="example.jpg">
* $post_images[0]->attr->width = 500
*
@goranseric
goranseric / class-virtualthemedpage-bc.php
Created February 14, 2016 18:45 — forked from brianoz/class-virtualthemedpage-bc.php
WordPress Virtual page with theme
<?php
/*
* Virtual Themed Page class
*
* This class implements virtual pages for a plugin.
*
* It is designed to be included then called for each part of the plugin
* that wants virtual pages.
*
* It supports multiple virtual pages and content generation functions.
@goranseric
goranseric / nav-menu-exporter-importer.php
Created February 17, 2016 06:17 — forked from hissy/nav-menu-exporter-importer.php
[WordPress Plugin] Nav Menu Exporter and Importer / Export and Import nav menus. Requires WordPress Importer plugin.
<?php
/*
Plugin Name: Nav Menu Exporter and Importer
Description: Export and Import nav menus. Requires WordPress Importer plugin
Author: hissy, megumi themes
Version: 0.1
Text Domain: nav-menu-exporter-importer
License: GPL version 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
@goranseric
goranseric / always-login.php
Created March 2, 2016 19:01 — forked from jkudish/always-login.php
Always logged in with WordPress
<?php
/**
* keeps a user always logged in
* don't use this on a production site, ever!
*/
add_action('init', 'auto_login');
add_action('admin_init', 'auto_login');
function auto_login() {
@goranseric
goranseric / osx-for-hackers.sh
Created March 31, 2016 09:55 — forked from brandonb927/osx-for-hackers.sh
OSX for Hackers: Yosemite Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned. Also, please don't email me about this script, my poor inbox...
#!/bin/sh
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
@goranseric
goranseric / jquery.photoswipe.js
Created April 6, 2016 06:14 — forked from kshnurov/jquery.photoswipe.js
PhotoSwipe: init from DOM using jQuery
(function( $ ) {
$.fn.photoswipe = function(options){
var galleries = [],
_options = options;
var init = function($this){
galleries = [];
$this.each(function(i, gallery){
galleries.push({
id: i,
@goranseric
goranseric / gist:fd639d41ff80a548d7708c3c2cdb6e4d
Created May 23, 2016 20:08 — forked from MrDys/gist:3512455
Link directly to an open modal window in Bootstrap
/* If you've ever had the need to link directly to an open modal window with Bootstrap, here's a quick and easy way to do it:
Make sure your modal has an id:
<div class="modal" id="myModal" ... >
Then stick this bit of Javascript at at the end of your document:
*/
$(document).ready(function() {