Skip to content

include attachments and add filter#1

Open
steve1medix wants to merge 2 commits intohlashbrooke:masterfrom
steve1medix:master
Open

include attachments and add filter#1
steve1medix wants to merge 2 commits intohlashbrooke:masterfrom
steve1medix:master

Conversation

@steve1medix
Copy link
Copy Markdown

Include attachments in the export file and add a filter for others to change the list of post_ids

@hlashbrooke
Copy link
Copy Markdown
Owner

My apologies - I wasn't watching the repo so didn't get a notification about this PR. Will look into it this week - sorry for the delay.

@hlashbrooke
Copy link
Copy Markdown
Owner

@steve1medix If you're still keen for this PR to be merged could you please refresh it against the latest code in the master branch. If you're not going to work on it anymore then let me know and I'll close this PR then work on adding your updates myself.

@sc0ttkclark
Copy link
Copy Markdown
Contributor

The latest code utilizes WP_Query and query args and the loop to build the XML items. I'm thinking this as it is won't be easy to work into that as $post_ids variable is now only used for authors output at the top.

I think we could rework the WP_Query loop to use array_slice on the $post_ids to get 20 out at a time and run ->query( $args ) with post__in. This would replace the pagination it's doing with 'paged' / 'posts_per_page' and would mean the final query args for the loop itself would be simplistic and would be 'post_type' => 'any', it would only need the following:

$query_args = array(
    'post_type' => 'any',
    'post_status' => 'any',
    'post__in' => array_slice( $post_ids, 0, $posts_per_page )
);

and the post__in would get tweaked on each loop around to be:

$query_args[ 'post__in' ] = array_slice( $post_ids, ( $page - 1 ) * $posts_per_page, $posts_per_page );

I'll move forward with that and will let @steve1medix re-introduce his work via a PR against https://github.com/hlashbrooke/Export-Plus/blob/master/includes/class-export-plus.php to add post IDs to the $post_ids array via a new filter I will add in my PR:

$post_ids = apply_filters( 'export_wp_post_ids', $post_ids, $query_args, $args );

@sc0ttkclark
Copy link
Copy Markdown
Contributor

Code updated here: #4

So this PR only needs to hook into export_wp_post_ids and run it's thing. I would do it, but I'd rather @steve1medix get the GitHub contributor credit directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants