Skip to content

Instantly share code, notes, and snippets.

View bitflower's full-sized avatar

Matthias Max bitflower

View GitHub Profile
@bitflower
bitflower / dl-file.php
Last active October 18, 2023 18:00 — forked from hakre/dl-file.php
File protection depending on ACF (Advanced custom fields) field.
<?php
/*
* dl-file.php
*
* Protect uploaded files with login.
*
* @link http://wordpress.stackexchange.com/questions/37144/protect-wordpress-uploads-if-user-is-not-logged-in
*
* @author hakre <http://hakre.wordpress.com/>
* @license GPL-3.0+
<?php
/*
* Notes:
*
* activate the json-rest-api plugin - then add this code to your functions.php file
*
* now the following ajax call should work:
*
jQuery.ajax({
class MAP_API_DemoItemType extends WP_JSON_CustomPostType {
protected $base = '/map/demo';
protected $type = 'demo';
public function register_routes( $routes ) {
$routes = parent::register_routes( $routes );
return $routes;
}
}
@bitflower
bitflower / classie.js
Last active August 29, 2015 14:12 — forked from desandro/classie.js
/*!
* classie - class helper functions
* from bonzo https://github.com/ded/bonzo
*
* classie.has( elem, 'my-class' ) -> true/false
* classie.add( elem, 'my-new-class' )
* classie.remove( elem, 'my-unwanted-class' )
*/
/*jshint browser: true, strict: true, undef: true */
app.filter('trusthtml', ['$sce', function ($sce) {
return function(t) {
return $sce.trustAsHtml(t)
}
}]);
<?php
/**
* UserAgentDetector
*
* @author Exadra37
* @license Free to use at your own risk. Provided as it is, without any warranty that will work for you.
* @link http://presta-hosting.com
* @version 1.0.1
* @since v.1.0.0 - 09/03/2014
/* Original is in LESS and can be found here: https://gist.github.com/gefangenimnetz/3ef3e18364edf105c5af */
@mixin material-shadow($level:1){
@if $level == 1 {
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
}
@else if $level == 2 {
box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
}
img
// graycity($gray, $opacity)
@include graycity(0.5, 0.7)
@bitflower
bitflower / ng-really.js
Last active August 29, 2015 14:24 — forked from asafge/ng-really.js
/**
* A generic confirmation for risky actions.
* Usage: Add attributes: ng-really-message="Are you sure"? ng-really-click="takeAction()" function
*/
angular.module('app').directive('ngReallyClick', [function() {
return {
restrict: 'A',
link: function(scope, element, attrs) {
element.bind('click', function() {
var message = attrs.ngReallyMessage;
@bitflower
bitflower / font_grabber.rb
Last active August 29, 2015 14:25 — forked from ttscoff/font_grabber.rb
Give it a <link> from Google fonts and get back CSS with fonts embedded
#!/usr/bin/ruby
# encoding: utf-8
# Grab google web fonts and embed them as base64 data URIs
# <http://brettterpstra.com/2015/03/14/embedding-google-web-fonts/>
require 'base64'
if ARGV.length > 0
input = ARGV
elsif STDIN.stat.size > 0
input = STDIN.read.strip.split(/\n+/)