Skip to content

Instantly share code, notes, and snippets.

Matthew Boynes mboynes

Block or report user

Report or block mboynes

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
@mboynes
mboynes / gist:a3f65eb29c8e06ddd8c6cbece0f88ae6
Created May 1, 2019 — forked from mannieschumpert/gist:8886289
Code Examples from Andrew Nacin's "Current User Can Watch This Talk"
View gist:a3f65eb29c8e06ddd8c6cbece0f88ae6
<?php
// If you can edit pages, you can edit widgets
add_filter( 'user_has_cap',
function( $caps ) {
if ( ! empty( $caps['edit_pages'] ) )
$caps['edit_theme_options'] = true;
return $caps;
} );
@mboynes
mboynes / ngrok-and-jetpack.md
Created Dec 20, 2018 — forked from mjangda/ngrok-and-jetpack.md
How to connect ngrok to your local WordPress environment (props @DanReyLop)
View ngrok-and-jetpack.md

How to develop with Jetpack locally with ngrok

To connect Jetpack in your local installation, you'll need a way for WP.com servers to reach your server. That can be done in a number of different ways:

  • You can open your router's ports and use your public IP
  • You can use some kind of Dynamic DNS provider.

But these options fall short of ngrok, which is a "localhost tunnel". It basically allows the Internet to hit a local port on your machine without worrying about ports or IPs.

As long as ngrok is running, Jetpack / WP.com will be able to communicate with your local site. This will allow remote modules like Site Search and Manage to work.

@mboynes
mboynes / jetpack-popular-posts.php
Created Mar 12, 2018
Get popular posts using Jetpack
View jetpack-popular-posts.php
@mboynes
mboynes / demo-datasource-cap.php
Created Dec 8, 2016
Demo of Fieldmanager_Datasource_CAP
View demo-datasource-cap.php
<?php
require_once( __DIR__ . '/inc/class-fieldmanager-datasource-cap.php' );
add_action( 'fm_post_post', function() {
$fm = new \Fieldmanager_Group( [
'name' => 'byline',
'limit' => 0,
'label' => __( 'Author', 'cap-sandbox' ),
'sortable' => true,
'add_more_label' => __( 'Add a coauthor', 'cap-sandbox' ),
@mboynes
mboynes / class-fieldmanager-datasource-cap.php
Created Dec 8, 2016
Co-Authors Plus datasource for Fieldmanager
View class-fieldmanager-datasource-cap.php
<?php
if ( class_exists( 'Fieldmanager_Datasource' ) ) {
/**
* Custom Fieldmanager Datasource for Co-Authors Plus.
*/
class Fieldmanager_Datasource_CAP extends Fieldmanager_Datasource {
/**
@mboynes
mboynes / trait-alley-cli-bulk-task.php
Created Mar 24, 2016
WP-CLI methods to iterate over any number of posts efficiently and reliably
View trait-alley-cli-bulk-task.php
<?php
/**
* Chunk up the task when you need to iterate over many posts.
*
* For instance, to iterate over every post on the site and add post meta:
*
* $this->bulk_task( function( $post ) {
* update_post_meta( $post->ID, 'some_meta', 'some value' );
* } );
@mboynes
mboynes / class-fieldmanager-context-termpage.php
Last active Oct 4, 2016
Use fieldmanager to create meta boxes on a subpage from a term
View class-fieldmanager-context-termpage.php
<?php
if ( class_exists( 'Fieldmanager_Context_Term' ) ) {
/**
* Use fieldmanager to create meta boxes on a subpage from a term
*/
class Fieldmanager_Context_Termpage extends Fieldmanager_Context_Term {
/**
@mboynes
mboynes / fieldmanager-demo-2.php
Last active Aug 29, 2015
Slideshow demo for Fieldmanager.org
View fieldmanager-demo-2.php
<?php
// using Fieldmanager for a slideshow - any number of slides,
// with any number of related links
add_action( 'fm_post_post', function() {
$fm = new Fieldmanager_Group( array(
'name' => 'slideshow',
'limit' => 0,
'label' => __( 'New Slide', 'your-domain' ),
'label_macro' => array( __( 'Slide: %s', 'your-domain' ), 'title' ),
'add_more_label' => __( 'Add another slide', 'your-domain' ),
@mboynes
mboynes / fieldmanager-demo-1.php
Last active Aug 29, 2015
Demo for fieldmanager.org
View fieldmanager-demo-1.php
<?php
// put this in functions.php or an include file
add_action( 'fm_post_post', function() {
$fm = new Fieldmanager_Group( array(
'name' => 'contact_information',
'children' => array(
'name' => new Fieldmanager_Textfield( __( 'Name', 'your-domain' ) ),
'phone_number' => new Fieldmanager_Textfield( __( 'Phone Number', 'your-domain' ) ),
'website' => new Fieldmanager_Link( __( 'Website', 'your-domain' ) ),
),
@mboynes
mboynes / codesniffer.ruleset.xml
Created Mar 20, 2015
WordPress Codesniffer ruleset starting point
View codesniffer.ruleset.xml
<?xml version="1.0"?>
<ruleset name="WordPress Theme Coding Standards Configuration">
<!-- Set a description for this ruleset. -->
<description>Code standard rules to check against a WordPress Theme.</description>
<exclude-pattern>tests/*</exclude-pattern>
<exclude-pattern>inc/cli.php</exclude-pattern>
<!-- Include the WordPress VIP ruleset -->
<rule ref="WordPress-VIP">
You can’t perform that action at this time.