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 / gist:2cfe1f4663bd6ec93ae6
Created December 23, 2014 14:20
Bootstrap: Open dropdown / Nav sub menu on hover with fade in & transform
@-webkit-keyframes fadeIn {
0% {
opacity: 0;
transform: translate(0, 20px);
}
100% {
opacity: 1;
transform: translate(0, 0);
}
}
@bitflower
bitflower / gist:75034fe5eda50ee21784
Created December 30, 2014 17:26
More nice fonts for Chrome :-)
@media screen {
html {
-webkit-font-smoothing: antialiased;
}
}
@bitflower
bitflower / gist:1a7efbcbec19079414d0
Created December 30, 2014 18:05
Activate CORS for WP-API (JSON REST API)
/**
* bitflower: Activate CORS for WP-API (JSON REST API)
*/
do_action("json_api", $controller, $method);
add_action( 'json_api', function( $controller, $method )
{
# DEBUG
// wp_die( "To target only this method use <pre><code>add_action('$controller-$method', function(){ /*YOUR-STUFF*/ });</code></pre>" );
header( "Access-Control-Allow-Origin: *" );
}, 10, 2 );
@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 */
@bitflower
bitflower / gist:bd7b9cceead1ff914e75
Created January 8, 2015 07:09
Stop scroll bouncing on touch devices
// Stop scroll bouncing
document.ontouchmove = function(e) {
e.preventDefault();
};
@bitflower
bitflower / gist:e63cf54f8c6af27e39c5
Created January 9, 2015 11:49
Activate CORS in PHP
// First line of first PHP file
header( "Access-Control-Allow-Origin: *" );
@bitflower
bitflower / gist:65d8d9fd46f2a10c5795
Created January 12, 2015 10:22
Add CORS support to DaftMonk/angular-fullstack YO generator
1. npm install cors
2. then in the app module:
var cors = require('cors');
//add cors to do the cross site requests
app.use(cors());