Skip to content

Instantly share code, notes, and snippets.

@ekandreas
Created August 25, 2015 14:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ekandreas/0e8636898ae6784dfc4f to your computer and use it in GitHub Desktop.
Save ekandreas/0e8636898ae6784dfc4f to your computer and use it in GitHub Desktop.
Plugin example of UM Activity wall for a post. Place this file in the plugin folder and activate the plugin. Then place the shortcode [ultimatemember_activity_page] inside a post or page. Requires UM and UM Activity.
<?php
/*
Plugin Name: UM - Social Activity Page
Description: Page example of UM Social Activity
Version: 0.1
Author: EkAndreas
Author URI: http://www.andreasek.se/
*/
class UM_Activity_Page {
function __construct()
{
add_action( 'um_activity_post_insert_tools', array( &$this, 'insert_post_parent' ) );
add_filter( 'um_activity_insert_post_args', array( &$this, 'insert_post_args' ) );
add_shortcode( 'ultimatemember_activity_page', array( &$this, 'shortcode' ) );
}
static function insert_post_parent( $args )
{
global $um_activity;
if (isset( $um_activity->shortcode->args['post_parent'] )) {
$post_parent = (int) $um_activity->shortcode->args['post_parent'];
echo '<input type="hidden" name="post_parent" value="' . $post_parent . '" />';
}
}
static function insert_post_args( $args )
{
if (isset( $_POST['post_parent'] )) {
$args['post_parent'] = (int) $_POST['post_parent'];
}
return $args;
}
static function shortcode( $atts ) {
add_filter( 'um_activity_wall_args', function( $args ) { $args['post_parent'] = get_the_ID(); return $args; } );
return do_shortcode( '[ultimatemember_activity post_parent=' . get_the_ID() . ']' );
}
}
new UM_Activity_Page();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment