Skip to content

Instantly share code, notes, and snippets.

View scottopolis's full-sized avatar

Scott Bolinger scottopolis

View GitHub Profile
@scottopolis
scottopolis / angular-base64-factory
Last active August 31, 2015 18:22
AngularJS Base64 Factory
angular.module('myApp.services', [])
.factory('Base64', function() {
var keyStr = 'ABCDEFGHIJKLMNOP' +
'QRSTUVWXYZabcdef' +
'ghijklmnopqrstuv' +
'wxyz0123456789+/' +
'=';
return {
encode: function (input) {
@scottopolis
scottopolis / wp-api-jquery-ajax.html
Last active October 6, 2015 06:20
Simple WP-API Ajax to get posts
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<title>My App</title>
<style type="text/css">
body {
@scottopolis
scottopolis / wp-api-cpt.php
Last active June 23, 2017 19:23
Add multiple custom post types to the WP-API
<?php
// This is a temporary solution until register_post_type_args is available
// After adding your CPT, you can find it at mysite.com/wp-json/wp/v2/[slug]
function sb_add_cpts_to_api() {
global $wp_post_types;
// Add CPT slugs here
$arr = ['fake','movie','books'];
@scottopolis
scottopolis / wp-api-custom-taxonomies.php
Created October 27, 2015 22:27
Add custom taxonomies to the WP-API
<?php
function ms_add_tax_to_api() {
$taxonomies = get_taxonomies( '', 'objects' );
foreach( $taxonomies as $taxonomy ) {
$taxonomy->show_in_rest = true;
}
}
add_action( 'init', 'ms_add_tax_to_api', 30 );
@scottopolis
scottopolis / wp-api-user-meta.php
Last active April 18, 2020 19:13
Add user meta to the WP-API
<?php
/* Adds all user meta to the /wp-json/wp/v2/user/[id] endpoint */
function sb_user_meta( $data, $field_name, $request ) {
if( $data['id'] ){
$user_meta = get_user_meta( $data['id'] );
}
if ( !$user_meta ) {
return new WP_Error( 'No user meta found', 'No user meta found', array( 'status' => 404 ) );
}
@scottopolis
scottopolis / thumbnail-featured-url-wp-api.php
Last active April 10, 2016 20:17
Add post thumbnail (featured image) url to WP-API response
@scottopolis
scottopolis / appbuddy-login-modal-toolbar.php
Created November 9, 2015 18:37
AppBuddy use login modal
<?php
/*
* Show login button in toolbar if user not logged in. AppBuddy only
* Put this code in a child theme functions.php file
*/
function my_appbuddy_modal_btn( $button ) {
$args = '';
@scottopolis
scottopolis / apppresser-custom-loop.php
Last active April 5, 2016 20:21
Create a custom loop for an AppPresser page
/* Custom Loop for a page in an AppPresser app */
function app_custom_loop( $content ) {
// edit this with your desired page slug
if( is_page( 'featured' ) ) {
// add your custom query args here
$args = array();
@scottopolis
scottopolis / custom-menu-profile.php
Last active May 26, 2016 18:12
Add Buddypress profile to left menu in AppPresser app
<?php
// Add BuddyPress profile to sidebar. Should check if appwoo is active, or double profiles will show.
// Author: Scott Bolinger https://apppresser.com
add_action( 'appp_left_panel_before', 'ion_bp_profile', 99 );
function ion_bp_profile() {
if( !is_user_logged_in() )
return;
@scottopolis
scottopolis / register-link.php
Created May 26, 2016 18:12
Add BuddyPress register link to login modal for AppPresser