Function Reference: geodir_get_export_posts
Summary
Retrieves the posts for the current post type.
Global Values
- $wpdb
- (object) (required) WordPress Database object.
- Default: None
- $plugin_prefix
- (string) (required) Geodirectory plugin table prefix.
- Default: None
Package
GeoDirectory
Parameters
- $post_type
- (string) (required) Post type.
- Default: None
- $per_page
- (int) (required) Per page limit.
- Default: 0
- $page_no
- (int) (required) Page number.
- Default: 0
Return Values
- (array)
- Array of posts data.
Change Log
Since: 1.4.6
1.5.7 $per_page & $page_no parameters added.
Filters
‘geodir_get_export_posts’ [Line: 5487]
‘geodir_imex_export_posts_query’ [Line: 5499]
‘geodir_export_posts’ [Line: 5511]
Source File
geodir_get_export_posts() is located in geodirectory-admin/admin_functions.php [Line: 5453]
Source Code
function geodir_get_export_posts( $post_type, $per_page = 0, $page_no = 0 ) {
global $wpdb, $plugin_prefix;
if ( ! post_type_exists( $post_type ) )
return new stdClass;
$table = $plugin_prefix . $post_type . '_detail';
$limit = '';
if ( $per_page > 0 && $page_no > 0 ) {
$offset = ( $page_no - 1 ) * $per_page;
if ( $offset > 0 ) {
$limit = " LIMIT " . $offset . "," . $per_page;
} else {
$limit = " LIMIT " . $per_page;
}
}
// Skip listing with statuses trash, auto-draft etc...
$skip_statuses = geodir_imex_export_skip_statuses();
$where_statuses = '';
if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
$where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
}
/**
* Filter the SQL where clause part to filter posts in import/export.
*
* @since 1.6.4
* @package GeoDirectory
*
* @param string $where SQL where clause part.
*/
$where_statuses = apply_filters( 'geodir_get_export_posts', $where_statuses, $post_type );
$query = $wpdb->prepare( "SELECT {$wpdb->posts}.ID FROM {$wpdb->posts} INNER JOIN {$table} ON {$table}.post_id = {$wpdb->posts}.ID WHERE {$wpdb->posts}.post_type = %s " . $where_statuses . " ORDER BY {$wpdb->posts}.ID ASC" . $limit, $post_type );
/**
* Modify returned posts SQL query for the current post type.
*
* @since 1.4.6
* @package GeoDirectory
*
* @param int $query The SQL query.
* @param string $post_type Post type.
*/
$query = apply_filters( 'geodir_imex_export_posts_query', $query, $post_type );
$results = (array)$wpdb->get_results( $query, ARRAY_A );
/**
* Modify returned post results for the current post type.
*
* @since 1.4.6
* @package GeoDirectory
*
* @param object $results An object containing all post ids.
* @param string $post_type Post type.
*/
return apply_filters( 'geodir_export_posts', $results, $post_type );
}