Skip to content

Instantly share code, notes, and snippets.

@blupu
blupu / add-custom-data.php
Last active March 10, 2018 14:59
WP-AppKit - Custom template if post has a specific category
<?php
/*
* @desc Add custom data to what is returned by the web services. All custom data will be available to the JS API.
* @param $post_data
* @param $post
* @param $component
*/
function wpak_add_custom_data( $post_data, $post, $component ) {
$taxonomy = 'category'; // We search for categories
@blupu
blupu / wpak-allow-all-embeds-in-apps
Last active August 29, 2015 14:21
WP-AppKit: allow embeds (notably iframes) in apps
<?php
/*
* Applies to: since WP-AppKit 0.1
* Goal: By default, embeds are stripped from post content when send to WP-AppKit apps.
* We'd like to display embeds in apps (such as YouTube, Vimeo, SlideShare...).
* Usage: In the app's theme PHP folder or a separate plugin.
*/
add_filter( 'wpak_post_content_format', 'wpak_post_content_with_embeds', 10, 2);
function wpak_post_content_with_embeds( $content, $post ) {
@blupu
blupu / wpak-allow-oembed-iframes-in-app
Last active August 29, 2015 14:21
WP-AppKit: allow oEmbed iframes in apps
<?php
/*
* Applies to: since WP-AppKit 0.1
* Goal: By default, iframes are stripped from post content when send to WP-AppKit apps.
* It removes iframes inserted by WordPress through the oEmbed mechanism like videos (https://codex.wordpress.org/Embeds).
* We'd like to let iframes pass to the app to display video embeds in apps.
* Usage: in the app's theme PHP folder or a separate plugin.
*/
add_filter( 'wpak_post_content_allowed_tags', 'wpak_allow_iframe_tag', 10, 2);
function wpak_allow_iframe_tag( $allowed_tags, $post ) {