Skip to content

Instantly share code, notes, and snippets.

View scottopolis's full-sized avatar

Scott Bolinger scottopolis

View GitHub Profile
@scottopolis
scottopolis / appp-media-images.php
Last active December 11, 2019 13:08
Add an image for the AppPresser media player
<?php
/*
Plugin Name: AppPresser Media Images
Plugin URI: https://apppresser.com
Description: Automatically add media images on when a post is saved for posts that have a media url.
Version: 1.0
Author: AppPresser Team
Author URI: http://apppresser.com
License: GPLv2
@scottopolis
scottopolis / gatsby-dynamic.js
Created November 26, 2019 16:09
Dynamic Content in Gatsby with Apollo and WPGraphQL
// This is just for example purposes, copy/pasting this won't work out of context. It is from the Gatsby Publisher theme by Static Fuse.
import React from 'react'
import { Box } from '@chakra-ui/core'
import Layout from '../../components/Layout'
import PostEntry from '../../components/PostEntry'
import Pagination from '../../components/Pagination'
import HeaderArchive from '../../components/HeaderArchive'
import SEO from '../../components/SEO'
import { useQuery } from '@apollo/react-hooks'
import gql from 'graphql-tag'
@scottopolis
scottopolis / woo-iap.php
Last active June 16, 2020 18:43
WooCommerce Memberships In App Purchases for AppPresser
<?php
/*
Plugin Name: In App Purchases for WooCommerce Memberships
Plugin URI: https://apppresser.com
Description: This plugin listens for in app purchases or cancellations and adds/removes members from a membership level.
Version: 2.0.0
Author: Scott Bolinger
Author URI: https://apppresser.com
License: GPLv2
*/
@scottopolis
scottopolis / woo-product-api-filter.php
Last active June 20, 2022 14:47
Modify WooCommerce REST API Product Response
<?php
// add this code to a custom plugin
add_filter( 'woocommerce_rest_prepare_product_object', 'wc_app_add_custom_data_to_product', 10, 3 );
// filter the product response here
function wc_app_add_custom_data_to_product( $response, $post, $request ) {
// in this case we want to display the short description, so we copy it over to the description, which shows up in the app
$response->data['description'] = $response->data['short_description'];
return $response;
@scottopolis
scottopolis / apppresser-filter-welcome-message.php
Last active September 23, 2020 16:06
Filter AppPresser Welcome Message
<?php
// put this code in a plugin
add_filter( 'appp_login_success', 'appp_filter_welcome_message', 10, 2 );
function appp_filter_welcome_message( $data, $user_id ) {
return "Welcome to our app user " . $user_id . "!"; // must be a string, no HTML
@scottopolis
scottopolis / apppresser-iap-rcp.php
Last active June 2, 2020 15:02
Restrict Content Pro In App Purchases
<?php
/*
Plugin Name: AppPresser In App Purchases for Restrict Content Pro (v2)
Plugin URI: https://apppresser.com
Description: This plugin listens for in app purchases or cancellations and adds/removes members from a membership level.
Version: 2.0.0
Author: Scott Bolinger
Author URI: https://apppresser.com
License: GPLv2
*/
@scottopolis
scottopolis / apppresser-admob-interstitial.js
Last active June 14, 2021 08:10
Sample Javascript to show an interstitial ad in an AppPresser app
// https://docs.apppresser.com/article/515-interstitial-ads
(function() {
// show an interstitial when an element with an id of showAd is clicked. For example, add this to your app:
// <button ion-item id="showAd" (click)="pushPage( pages.tab_menu.items[1] )"><ion-icon name="cog" item-left></ion-icon>Show ad and navigate</button>
// you can use any element with the id of showAd, it doesn't have to be a button
// you can also load the interstitial when the app loads by moving it outside the ready function
ready("#showAd", function(element) {
var el = document.getElementById("showAd");
@scottopolis
scottopolis / givewp-apppresser-custom-page.html
Created March 19, 2019 15:44
GiveWP Custom Page Code for AppPresser
<div padding align="center">
<h2 class="red-text">Online Giving</h2>
<p style="font-size:1.6rem;line-height:1.4;margin-bottom:0">Donate today and help us to further our cause in your commmunity.</p>
</div>
<ap-form url="https://mysite.com/donations/donate/" amount="true"></ap-form>
<div padding>
<p>You can also text your donation to (555) 867-5309</p>
@scottopolis
scottopolis / events-calendar-api-apppresser.php
Created February 6, 2019 16:21
Events Calendar to WP-API for AppPresser apps
<?php
/*
Plugin Name: Add Events Calendar to AppPresser
Description: This plugin adds the Events Calendar CPT and some post meta data to the WP-API.
Version: 0.1
Author: Scott Bolinger
Author URI: https://apppresser.com
License: GPLv2
*/
@scottopolis
scottopolis / media-image.php
Created February 4, 2019 22:40
Add media image to posts that have a media url
<?php
// add this code to a plugin, it only needs to run once so remove it when you're done
add_action('admin_init', function() {
$the_query = new WP_Query( array( 'post_type' => 'post', 'posts_per_page' => 999 ) );
// The Loop
if ( $the_query->have_posts() ) {
while ( $the_query->have_posts() ) {
$the_query->the_post();