Skip to content

Instantly share code, notes, and snippets.


Martin Lindgren MartinL83

Block or report user

Report or block MartinL83

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
MartinL83 / react-bootstrap-breakpoints.js
Created Nov 19, 2017
A simple React HOC to feed css breakpoint data to a component.
View react-bootstrap-breakpoints.js
import React, { Component } from 'react';
import _ from 'lodash';
HOC to feed breakpoints data to child component.
Breakpoint data is based on Bootstrap's breakpoints
Using lodash throttle to optimize the high rate of events being fired.
export const Breakpoints = (WrappedComponent) => {
MartinL83 / popper-react-wrapper.js
Last active Oct 22, 2017
A simple React component for positioning elements with Popper.js
View popper-react-wrapper.js
// NOTE: This component requires React 16 or newer.
// Usage:
parent={<div>Parent element</div>}
target={ (style) => (
<div style={style}>Popper element</div>
MartinL83 / material-ui-tab-links.jsx
Created Aug 14, 2017
Material-UI, changing URL when clicking on a Tab
View material-ui-tab-links.jsx
MartinL83 / main.js
Last active Dec 18, 2016
Bootstrap 4 JS and Meteor
View main.js
// Import tether.js
// We also add 'global.Tether' as a workaround for Meteor.
import tether from 'tether';
global.Tether = tether;
// Import Bootstrap js.
bootstrap = require('bootstrap');
MartinL83 / bootstrap-confirm.js
Last active Aug 29, 2015
Simple confirm modal on inputs / links / whatever trough data-attr. Will launch a (Twitter) Bootstrap modal on elements that have a data-confirm-action="confirm". Some settings available. **Needs loads of improvements**
View bootstrap-confirm.js
// Confirmation modal on elements that have 'confirm' class.
// Will launch a modal and ask for confirmation.
// data-confirm-action="confirm" - Will enable the confirm modal
// data-confirm-title="" - Custom title, optional
// data-confirm-text="" - Custom modal text, optional.
;(function ( $, window, document, undefined ) {
// Create the defaults once
var pluginName = "confirmAction",
defaults = {
MartinL83 / filterSelectByParent.js
Last active Aug 29, 2015
Small jQuery plugin to filter a child <select> based on a parent <select>.
View filterSelectByParent.js
Based on:
Filter child select from selected parent select option.
Will look for parent (options) value in child data-parent"XX".
<select id="parent">
<option value="1">Group 1</option>
<option value="2">Group 2</option>
MartinL83 / read_rss.php
Created Sep 24, 2013
Wordpress read external RSS
View read_rss.php
<?php // Source: ?>
<?php include_once(ABSPATH.WPINC.'/feed.php');
$rss = fetch_feed('');
$maxitems = $rss->get_item_quantity(5);
$rss_items = $rss->get_items(0, $maxitems);
<?php if ($maxitems == 0) echo '<li>No items.</li>';
// Loop through each feed item and display each item as a hyperlink.
MartinL83 / Datepicker swedish localization
Created Sep 21, 2013
Swedish translation for jQuery UI´s datepicker, as well as the timepicker addon.
View Datepicker swedish localization
$.datepicker.regional['sv'] = {
closeText: 'Stäng',
prevText: '< Föregående',
nextText: 'Nästa >',
currentText: 'Nu',
monthNames: ['Januari','Februari','Mars','April','Maj','Juni','Juli','Augusti','September','Oktober','November','December'],
monthNamesShort: ['Jan','Feb','Mar','Apr','Maj','Jun','Jul','Aug','Sep','Okt','Nov','Dec'],
dayNamesShort: ['Sön','Mån','Tis','Ons','Tor','Fre','Lör'],
dayNames: ['Söndag','Måndag','Tisdag','Onsdag','Torsdag','Fredag','Lördag'],
dayNamesMin: ['Sö','Må','Ti','On','To','Fr','Lö'],
MartinL83 / Create page on theme activation
Created Jul 23, 2013
Wordpress - Create page on theme activation
View Create page on theme activation
if (isset($_GET['activated']) && is_admin()){
$new_page_title = 'This is the page title';
$new_page_content = 'This is the page content';
$new_page_template = ''; //ex. template-custom.php. Leave blank if you don't want a custom page template.
$page_check = get_page_by_title($new_page_title);
$new_page = array(
'post_type' => 'page',
'post_title' => $new_page_title,
'post_content' => $new_page_content,
'post_status' => 'publish',
View WP Hook - CPT publish
// function to be executed when a custom post type is published
function run_when_post_published()
// your function code here
// replace {custom_post_type_name} with the name of your post type
add_action('new_to_publish_{custom_post_type_name}', 'run_when_post_published');
add_action('draft_to_publish_{custom_post_type_name}', 'run_when_post_published');
add_action('pending_to_publish_{custom_post_type_name}', 'run_when_post_published');
You can’t perform that action at this time.