Skip to content

Instantly share code, notes, and snippets.

Nate Finch n8finch

Block or report user

Report or block n8finch

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
@n8finch
n8finch / 0_reuse_code.js
Created Jun 25, 2014
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
View Random Quote-to-Tweet Machine.markdown
@n8finch
n8finch / controller-example.php
Created Aug 29, 2016
Add a controller in the Angular view to work with
View controller-example.php
//*Add a controller in the Angular view to work with
add_action('genesis_loop', __NAMESPACE__ . '\do_ng_view_content');
function do_ng_view_content() {
$output = '<div ng-controller="example">'.
'<h2>Recent Posts</h2>'.
'{{posts}}'.
'</div>';
echo $output;
}
@n8finch
n8finch / angular-basic-http.js
Created Aug 29, 2016
angular-basic-http.js
View angular-basic-http.js
(function (angular) {
'use strict';
angular.module('myApp', [])
.controller('example', ['$scope', '$http', function ($scope, $http) {
$http({
url: 'https://n8finch.dev/wp-json/wp/v2/posts',
cache: true
}).success(function (res) {
$scope.posts = res;
@n8finch
n8finch / adding-filter-to-rendered-posts.js
Created Aug 29, 2016
adding-filter-to-rendered-posts.js
View adding-filter-to-rendered-posts.js
(function (angular) {
'use strict';
angular.module('myApp', [])
.controller('example', ['$scope', '$http', function ($scope, $http) {
$http({
url: 'https://n8finch.dev/wp-json/wp/v2/posts',
cache: true
}).success(function (res) {
$scope.posts = res;
@n8finch
n8finch / update-the-angular-view.php
Last active Aug 29, 2016
update-the-angular-view.php
View update-the-angular-view.php
//*Add a controller in the Angular view to work with
add_action('genesis_loop', __NAMESPACE__ . '\do_ng_view_content');
function do_ng_view_content() {
$output = '<div ng-controller="example">'.
'<h2>Recent Posts:</h2>'.
'<div class="posts-list" ng-repeat="post in posts">'.
'<div class="single-post">'.
'<h2>{{post.title.rendered}}</h2>'.
'<p>Posted by Name on {{post.date | date:\'longDate\'}}</p>'.
'<img src="http://placekitten.com/g/200/300"/>'.
@n8finch
n8finch / custom-wp-rest-api-routes.php
Created Aug 29, 2016
custom-wp-rest-api-routes.php
View custom-wp-rest-api-routes.php
//* =================================================
//* Mostly from Mor10's Lynda course
//* Add various fields to the WP REST API JSON output
//* https://www.lynda.com/WordPress-tutorials/WordPress-REST-API-WP-API-First-Look/383783-2.html
function register_new_restapi_fields() {
// Add Author Name
register_api_field( 'post',
'author_name',
array(
@n8finch
n8finch / genesis-angular-app-index.html
Created Aug 29, 2016
genesis-angular-app-index.html
View genesis-angular-app-index.html
<div ng-controller="Posts" ng-repeat="post in posts">
<article class="single-post post type-post status-publish format-standard has-post-thumbnail entry">
<header class="entry-header">
<h2 class="entry-title">{{post.title.rendered}}</h2>
<p class="entry-meta">Posted by {{post.author_name}} on {{post.date | date:'longDate'}}</p>
</header>
<img class="attachment-post-image size-post-image wp-post-image" ng-src="{{post.featured_image_src}}"/>
<div class="entry-content">
<p ng-bind-html="post.excerpt.rendered | to_trusted"></p>
<p><a href="#/post/{{post.slug}}">Read more...</a></p>
@n8finch
n8finch / add-new-custom-routes.php
Created Aug 29, 2016
add-new-custom-routes.php
View add-new-custom-routes.php
//*Add a controller in the Angular view to work with
add_action('genesis_loop', __NAMESPACE__ . '\do_ng_view_content');
function do_ng_view_content() {
$output = '<div ng-controller="example">'.
'<div class="posts-list" ng-repeat="post in posts">'.
'<div class="single-post">'.
'<h2>{{post.title.rendered}}</h2>'.
'<p>Posted by {{post.author_name}} on {{post.date | date:\'longDate\'}}</p>'.
'<img ng-src="{{post.featured_image_src}}"/>'.
'<a href="{{post.slug}}">Read more...</a>'.
View genesis-angular-app-file-structure
genesis-angular-gulp
|__assets
|__js
|__app.js (our Angular app)
|__templates
|__app-index.html (our main list of posts from Part 2)
|__page.html (our page view for Pages)
|__single.html (our single view for individual Posts)
You can’t perform that action at this time.