Skip to content

Instantly share code, notes, and snippets.

View yoren's full-sized avatar

Yoren Chang yoren

View GitHub Profile
@yoren
yoren / fail2ban-regex
Last active August 29, 2015 14:13
Keep WordPress Safe From Brute Force Attack with Fail2ban
fail2ban-regex /var/www/vhosts/your.domain.here/logs/site-folder/access_ssl_log /etc/fail2ban/filter.d/wp-login.conf
@yoren
yoren / scripts-change-name.js
Last active August 29, 2015 14:12
Minification Errors In My AngularJS WordPress Theme
//Main controller
app.controller('Main', ['$scope', '$http', function(a, b) {
b.get('wp-json/posts/').success(function(res){
a.posts = res;
});
}]);
@yoren
yoren / main.html
Last active August 29, 2015 14:12
Use AngularJS Custom Directives In A WordPress Theme
<search-form></search-form>
<ul>
<li ng-repeat="post in posts">
<a href="{{post.ID}}" ng-bind-html="post.title"></a>
<div ng-bind-html="post.content"></div>
</li>
</ul>
@yoren
yoren / content.html
Last active August 29, 2015 14:09
Bypass sanitization for values you know are safe
<h1>{{post.title}}</h1>
<div ng-bind-html="post.content | toTrusted"></div>
@yoren
yoren / content.html
Last active August 29, 2015 14:09
Best Practice to sanitize HTML in AngularJS
<h1>{{post.title}}</h1>
<div ng-bind-html="post.content"></div>
@yoren
yoren / content.html
Created November 5, 2014 09:10
Display a single WordPress post with AngularJS and JSON API
<h1>{{post.title}}</h1>
{{post.content}}
@yoren
yoren / main.html
Last active June 12, 2019 08:39
Display WordPress posts with AngularJS and JSON API
<ul>
<li ng-repeat="post in posts">
<a href="{{post.ID}}">
{{post.title}}
</a>
</li>
</ul>
@yoren
yoren / functions.php
Last active March 13, 2016 00:04
And Hello, AngularJS Route!
<?php
function my_scripts() {
wp_register_script(
'angularjs',
get_stylesheet_directory_uri() . '/bower_components/angular/angular.min.js'
);
wp_register_script(
@yoren
yoren / index.php
Last active March 13, 2016 00:03
Hello, AngularJS!
<!DOCTYPE html>
<html ng-app>
<head>
<base href="/jsonapi/">
<title>AngularJS Demo Theme</title>
<?php wp_head(); ?>
</head>
<body>
<header>
@yoren
yoren / functions.php
Last active March 13, 2016 00:02
Enqueue AngularJS into your theme
<?php
function my_scripts() {
wp_enqueue_script(
'angularjs',
get_stylesheet_directory_uri() . '/bower_components/angular/angular.min.js'
);
wp_enqueue_script(