This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@media screen { | |
html { | |
-webkit-font-smoothing: antialiased; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*! | |
* 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 */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Stop scroll bouncing | |
document.ontouchmove = function(e) { | |
e.preventDefault(); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// First line of first PHP file | |
header( "Access-Control-Allow-Origin: *" ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.filter('trusthtml', ['$sce', function ($sce) { | |
return function(t) { | |
return $sce.trustAsHtml(t) | |
} | |
}]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// You could use Math.floor and some additional arithmetics: | |
Math.floor(15.7784514000 * 100) / 100 | |
// Or convert the number into a string, match the number up to the second decimal place and turn it back into a number: | |
Number(15.7784514000.toString().match(/^\d+(?:\.\d{0,2})?/)) | |
// Then you can still call toFixed to get a string with a fixed number of decimal places. |
OlderNewer