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 | |
if ( function_exists( 'add_shortcode' ) && ! function_exists( 'add_shortcake' ) ) { | |
// tasty WordPress add_shortcode alias, for @technosailor | |
function add_shortcake( $tag, $func ) { | |
add_shortcode( $tag, $func ); | |
} | |
} |
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 | |
/* | |
Plugin Name: GGA SSH2 Sample | |
Description: Sample SSH2 upload | |
Author: Pete Nelson (@GunGeekATX) | |
Version: 1.0 | |
*/ | |
if (!defined( 'ABSPATH' )) exit('restricted access'); |
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 | |
/** | |
* Plugin Name: GGA API Helper | |
* Description: Prevents certain plugins from being loaded during API requests to reduce overhead. | |
* Author: Pete Nelson (@GunGeekATX) | |
* Version: 1.0.0 | |
*/ | |
/* |
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 | |
/* | |
Plugin Name: Revisions in List Table | |
Description: Allows a list of revisions to display in the dashboard list tables | |
Author: Pete Nelson | |
Version: 1.0 | |
*/ | |
if ( ! defined( 'ABSPATH' ) ) exit( 'restricted access'); |
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 | |
/* | |
Plugin Name: Timeline Express Custom Icon Filter Test | |
*/ | |
add_filter( 'timeline-express-custom-icon-html', 'pn_timeline_express_custom_icon_html_test', 10, 3 ); | |
function pn_timeline_express_custom_icon_html_test( $html, $post, $timeline_express_options ) { | |
$custom_png_icon = get_post_meta( $post->ID, '_custom_png_icon', true ); |
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 | |
// reference https://github.com/WP-API/WP-API/blob/develop/lib/infrastructure/class-wp-rest-server.php | |
// serve_request() function | |
add_filter( 'rest_pre_serve_request', 'multiformat_rest_pre_serve_request', 10, 4 ); | |
function multiformat_rest_pre_serve_request( $served, $result, $request, $server ) { | |
// assumes 'format' was passed into the intial API route | |
// example: https://baconipsum.com/wp-json/baconipsum/test-response?format=text |
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 | |
add_filter( 'rest_prepare_post', array( $this, 'add_featured_image_link' ), 10, 3 ); | |
public function add_featured_image_link( $data, $post, $request ) { | |
if ( has_post_thumbnail( $post->ID ) ) { | |
$featured_image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' ); | |
$data->add_link( 'featured_image', $featured_image[0], array( 'width' => absint( $featured_image[1] ), 'height' => absint( $featured_image[2] ) ) ); | |
} |
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 | |
// restrict access to the media endpoint | |
add_action( 'init', function() { | |
// _add_extra_api_post_type_arguments() in the WP REST API sets this to true | |
// we'll turn it off for unauthenticated requests | |
global $wp_post_types; | |
$wp_post_types['attachment']->show_in_rest = is_user_logged_in(); |
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 | |
add_filter( 'rest_pre_dispatch', 'rest_api_disallow_non_ssl', 10, 3 ); | |
function rest_api_disallow_non_ssl( $response, $server, $request ) { | |
if ( ! is_ssl() ) { | |
$response = new WP_Error( 'rest_forbidden', __( "SSL is required to access the REST API" ), array( 'status' => 403 ) ); | |
} |
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 | |
add_filter( 'rest_url', 'force_https_rest_url', 10, 4 ); | |
function force_https_rest_url( $url, $path, $blog_id, $scheme ) { | |
return set_url_scheme( $url, 'https' ); // force the Link header to be https | |
} | |