Skip to content

Instantly share code, notes, and snippets.

@stevelacey
Created August 29, 2013 11:52
Show Gist options
  • Save stevelacey/6377099 to your computer and use it in GitHub Desktop.
Save stevelacey/6377099 to your computer and use it in GitHub Desktop.
<?php
class Post extends \WPUF_Add_Post {
function __construct() {
remove_shortcode('wpuf_addpost');
add_shortcode('wpuf_addpost', array($this, 'shortcode'));
}
function post_form($post_type) {
$reflection = new \ReflectionMethod('WPUF_Add_Post', 'post_form');
$file = file($reflection->getFileName());
$content = implode(
'',
array_slice(
$file,
$reflection->getStartLine(),
$reflection->getEndLine() - $reflection->getStartLine() - 1
)
);
$content = preg_replace(
'#wp_dropdown_categories\( \'#',
'wp_dropdown_categories( \'selected=' . get_user_option('default_category'). '&',
$content
);
$content = str_replace('$this', '$that', $content);
$post_form = create_function('$that, $post_type', $content);
return $post_form($this, $post_type);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment