Skip to content

Instantly share code, notes, and snippets.

@tomharrigan
tomharrigan / news-custom-post-type.php
Created August 29, 2017 16:45
Change the post type used for news functionality in VoiceWP
function my_voicewp_post_types( $post_types ) {
return array( 'my-custom-post-type' );
}
add_filter( 'voicewp_post_types', 'my_voicewp_post_types' );
@tomharrigan
tomharrigan / alexawp_news_request.php
Last active February 7, 2017 15:36
Testing purposes only. NOT suitable for production
public function alexawp_news_request( WP_REST_Request $request ) {
$body = $this->access_protected( $request, 'body' );
//if ( ! empty( $body ) ) {
try {
//$alexa_settings = get_option( 'alexawp-settings' );
//$app_id = $alexa_settings['news_id'];
//$certificate = new \Alexa\Request\Certificate( $request->get_header( 'signaturecertchainurl' ), $request->get_header( 'signature' ), $app_id );
$alexa = new \Alexa\Request\IntentRequest( $body, $app_id );
@tomharrigan
tomharrigan / remove_single.php
Last active December 17, 2015 20:56
Remove is_single() from check of supported screens
add_filter( 'infinite_transporter_archive_supported', 'infinite_transporter_remove_single' );
function infinite_transporter_remove_single( $supported ) {
$supported = current_theme_supports( 'infinite-transporter' ) && ( is_home() || is_archive() || is_search() );
return $supported;
}
@tomharrigan
tomharrigan / gist:707c0c264aaf2feda07d
Created June 10, 2015 23:08
Add image to RSS feed
/**
* Add namespace for the featured image to RSS feed
*
* @return string
*/
function rss_img_adding_yahoo_media_tag(){
echo 'xmlns:media="http://search.yahoo.com/mrss/"';
}
add_action( 'rss_ns', 'rss_img_adding_yahoo_media_tag' );
add_action( 'rss2_ns', 'rss_img_adding_yahoo_media_tag' );
function mobile_single_post_ad( $content ) {
if( wp_is_mobile() && is_single() ) {
$limit = 100; //word limit
$contents = explode("</p>", $content);
$words = 0;
$displayed = false;
foreach ($contents as $paragraph) {
$words = $words + str_word_count($paragraph);
echo $paragraph . "</p>";
add_action('rss2_ns', 'wp_rss_img_adding_yahoo_media_tag');
function wp_rss_img_adding_yahoo_media_tag(){
echo 'xmlns:media="http://search.yahoo.com/mrss/"';
}
@tomharrigan
tomharrigan / gist:8a8c82064ef8ca948c67
Created May 29, 2015 19:03
Add image to RSS feed
add_action('rss_item', 'wp_rss_img_include');
add_action('rss2_item', 'wp_rss_img_include');
function wp_rss_img_include (){
global $post;
if( has_post_thumbnail( $post->ID ) ) {
$thumbnail_id = get_post_thumbnail_id( $post->ID );
'content' => new Fieldmanager_RichTextArea(
array(
'label' => __( 'Content', 'ev' ),
'sanitize' => 'wp_kses_post',
)
),
@tomharrigan
tomharrigan / gist:674d1e31d5a94d6cb5e0
Created January 9, 2015 05:32
Snippet for firing Facebook XFBML parsing function on post-load trigger
( function( $ ) {
$( document.body ).on( 'post-load', function () {
FB.XFBML.parse();
} );
} )( jQuery );
@tomharrigan
tomharrigan / gist:f093b89bbe2709273e6e
Created December 20, 2014 18:40
Infinite transporter config for hueman theme
function mytheme_infinite_transporter_init() {
add_theme_support( 'infinite-transporter', array(
'footer' => false, // boolean to enable or disable the infinite footer | string to provide an html id to derive footer width from
'google_analytics'=> true, // boolean if using google analytics, set to true
'render' => 'render_hueman',
) );
}
add_action( 'init', 'mytheme_infinite_transporter_init' );
function render_hueman() {