https://github.com/xwp/wp-better-find-posts
Better Find Posts WordPress plugin
https://github.com/xwp/wp-better-find-posts
Last synced: 3 months ago
JSON representation
Better Find Posts WordPress plugin
- Host: GitHub
- URL: https://github.com/xwp/wp-better-find-posts
- Owner: xwp
- Created: 2014-08-29T09:19:50.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2014-08-29T22:03:14.000Z (over 11 years ago)
- Last Synced: 2025-06-03T14:42:39.013Z (7 months ago)
- Language: PHP
- Homepage:
- Size: 152 KB
- Stars: 2
- Watchers: 66
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Better Find Posts
Extensible JavaScript-centric replacement for the WordPress 3.1 `find_posts_div()`/`findPosts`
API. Add to page via `\Better_Find_Posts::instance()->enqueue()` then create
a control via `BetterFindPosts.create()`.
Example code:
```php
add_action( 'add_meta_boxes', function () {
$id = 'linked-post-metabox';
$title = __( 'Linked Post' );
$post_type = 'post';
$context = 'normal';
$priority = 'high';
$callback = 'linked_post_metabox';
add_meta_box( $id, $title, $callback, $post_type, $context, $priority );
} );
function linked_post_metabox() {
\Better_Find_Posts::instance()->enqueue();
?>
BetterFindPosts.ready.done( function () {
var control = BetterFindPosts.create( {
searchFormContainer: '#linked-post-metabox .search-form',
resultsTableContainer: '#linked-post-metabox .results-table',
defaultQueryArgs: {
'post_type': 'post',
'post_status': 'publish'
},
hiddenColumns: [ 'type', 'status', 'time' ]
} );
// @todo Need some built-in events here
control.resultsTableContainer.on( 'click', 'input', function () {
var post_id = jQuery( this ).val();
// Do something with this
} );
} );