Skip to content

Instantly share code, notes, and snippets.

View izzygld's full-sized avatar
❤️
it's nice to be important but it's important to be nice. 🤓

izzy goldman izzygld

❤️
it's nice to be important but it's important to be nice. 🤓
View GitHub Profile
@izzygld
izzygld / ObjectMeta.php
Last active May 31, 2018 15:00
Add: Group Object to WP-Grapql shema
use GraphQL\Type\Definition\ObjectType;
use GraphQL\Type\Definition\Type;
add_action('graphql_page_fields', function($fields) {
$impactType = new ObjectType([
'name' => 'Impact',
'description' => __( 'The description of your process type', 'your-textdomain' ),
'fields' => [
@izzygld
izzygld / Readme.md
Last active July 19, 2018 05:34
Behind the scenes setup for https://resurf.com/

Architecture

Resurf is made of two sites, a wordpress backend, in the wp folder, and a node/express frontend, located in the site folder.

The backend is a standard wordpress site, managed by composer, where wordpress is set to be installed in public/wp (there is an .htaccess file which rewrites the "wp" part of the url away). The wp-graphql plugin is installed which exposes wordpress through a graphql api.

The entry point of the node frontend is site/server.js. graphql-yoga is used to set up a graphql server over express. http-proxy-middleware to proxy parts of wordpress to be exposed throught the frontend (such as wp-admin, etc.). The proxy assumes that wordpress is running on http://wp

Finally, one nuxt nuxt application is setup per theme. The code for each nuxt app is in site/themes. The app to be rendered is determined based on the hostname. There is a manual mapping of subdomains to the application to render.

@izzygld
izzygld / acf-gallery.php
Last active September 13, 2018 05:43
acf gallery images resolver
@izzygld
izzygld / SeoMeta.php
Created May 31, 2018 15:01
Add: SEO Meta Fields WP-Graphql shema
add_action( 'wp_loaded', 'wpse290170_wp_loaded' );
function wpse290170_wp_loaded() {
$types = get_post_types( [
'public' => true
] );
foreach ( $types as $type ){
add_action( "graphql_" . $type . "_fields", function($fields) {
$fields['seo_title'] = [
@izzygld
izzygld / recipe.vue
Last active October 23, 2019 14:46
Google Recipe Schema for vue/json.ld
<template>
<script v-html="jsonld" type="application/ld+json"></script>
</template>
<script>
@Prop()
recipe: Recipe;
get jsonld(): string {
if (this.recipe == null) {
return "{}";
@izzygld
izzygld / class-config.php
Created December 4, 2019 14:16
acf wpgraphql types meta
<?php
/**
* Config for WPGraphQL ACF
*
* @package wp-graphql-acf
*/
namespace WPGraphQL\ACF;
use WPGraphQL\Data\DataSource;
@izzygld
izzygld / se-schema-parent.php
Created February 18, 2020 13:24
Structured data - wordpress theme
// Display Tag code
function ahmedkaludi_structured_data_keyword() {
if ( is_single() ) {
$tags = '"keywords" : [' . strip_tags(get_the_tag_list('"','", "','"')) . ']';
} else { }
echo $tags;
}
function ahmedkaludi_structured_data_output() {
@izzygld
izzygld / repeater-meta.php
Created June 25, 2018 14:22
Hooking up ACF repeater fields to the shema.
//acf stats repeater
array (
'key' => 'field_5a27ee3a83076',
'label' => 'Stats',
'name' => 'stats',
'type' => 'repeater',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array (
@izzygld
izzygld / saves-drafts-posts.php
Created June 21, 2020 13:57
Now pending posts get displayed to anyone and private posts are still only visible to admins
/*
* How to make draft posts or posts in review accessible via full url / slug.
* Source: - https://wordpress.stackexchange.com/questions/218168/how-to-make-draft-posts-or-posts-in-review-accessible-via-full-url-slug
*/
function auto_save_post_status( $post_id, $post, $update ) {
if( $post->post_status == "draft" && ! $post->post_name ) {
remove_action( 'save_post', 'auto_save_post_status', 20, 3 );
<?php
add_filter( "gform_confirmation_anchor",function() {} );
//For backwards compatibility, load wordpress if it hasn't been loaded yet
//Will be used if this file is being called directly
if(!class_exists("RGForms")){
for ( $i = 0; $i < $depth = 10; $i++ ) {
$wp_root_path = str_repeat( '../', $i );