This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'graphql_register_types', function() { | |
register_graphql_connection([ | |
'fromType' => 'RootQuery', | |
'toType' => 'Post', | |
'fromFieldName' => 'popularPosts', | |
'connectionTypeName' => 'RootQueryToPopularPostsConnection', | |
'resolve' => function( $root, $args, \WPGraphQL\AppContext $context, $info ) { | |
$resolver = new \WPGraphQL\Data\Connection\PostObjectConnectionResolver( $root, $args, $context, $info ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Node modules | |
import { ApolloClient } from 'apollo-client'; | |
import { HttpLink } from 'apollo-link-http'; | |
import { InMemoryCache, defaultDataIdFromObject } from 'apollo-cache-inmemory'; | |
import { ApolloLink } from 'apollo-link'; | |
import { onError } from 'apollo-link-error'; | |
import { get, isEmpty } from 'lodash'; | |
// Local imports | |
import { typeDefs, resolvers } from './schema'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'graphql_PostObjectsConnectionOrderbyEnum_values', function( $values ) { | |
$values['LIKE_COUNT'] = [ | |
'value' => 'like_count', | |
'description' => __( 'The number of likes on the post', 'wp-graphql' ), | |
]; | |
return $values; | |
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'graphql_register_types', function() { | |
$post_types = WPGraphQL::$allowed_post_types; | |
if ( ! empty( $post_types ) && is_array( $post_types ) ) { | |
foreach ( $post_types as $post_type ) { | |
$post_type_object = get_post_type_object( $post_type ); | |
/** | |
* Get the Type name with ucfirst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wp comment list --field=comment_ID --'comment_author'='ActionScheduler' --number=1000 | xargs wp comment delete --force | |
wp post list --field=ID --post_type=scheduled-action --posts_per_page=1000 | xargs wp post delete --force | |
wp post list --field=ID --post_type=scheduled-action --posts_per_page=1000 --post_status=trash | xargs wp post delete --force | |
wp post list --field=ID --post_type=scheduled-action --posts_per_page=1000 --post_status=cancel | xargs wp post delete --force |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<figure class="placeholder" data-large="{path to large image}"> | |
<img src="{path to small image}" class="img-small loaded" alt="{alt}" /> <!-- small image about 50px wide and height to match ratio; keep to less than 3k --> | |
<div style="padding-bottom: {image ratio}%;"></div> <!-- ratio is height-in-px/width-in-px * 100 --> | |
</figure> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Code goes in theme functions.php or a custom plugin | |
add_filter( 'pre_option_woocommerce_enable_guest_checkout', 'conditional_guest_checkout_based_on_product' ); | |
function conditional_guest_checkout_based_on_product( $value ) { | |
$restrict_ids = array( 1, 2, 3 ); // Replace with product ids which cannot use guest checkout | |
if ( WC()->cart ) { | |
$cart = WC()->cart->get_cart(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo curl -o /usr/local/bin/imgcat -O https://raw.githubusercontent.com/gnachman/iTerm2/master/tests/imgcat && sudo chmod +x /usr/local/bin/imgcat | |
# If you have a better way to fix the permissions, comment below! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Bonfire: Reverse a String | |
// Author: @jacobarriola | |
// Challenge: http://www.freecodecamp.com/challenges/bonfire-reverse-a-string# | |
// Learn to Code at Free Code Camp (www.freecodecamp.com) | |
function reverseString(str) { | |
return str.split("").reverse().join(""); | |
} | |
reverseString("hello"); |
NewerOlder