migrate_award_templates()
Migrates meta data for achievement and certificate template posts.
Contents
Return Return
(bool) Returns true if more records need to be updated and false upon completion.
Source Source
File: includes/functions/updates/llms-functions-updates-600.php
function migrate_award_templates() {
$per_page = llms_update_util_get_items_per_page();
$query = new \WP_Query(
array(
'orderby' => array( 'ID' => 'ASC' ),
'post_status' => 'any',
'post_type' => array( 'llms_achievement', 'llms_certificate' ),
'posts_per_page' => $per_page,
'no_found_rows' => true, // We don't care about found rows since we'll run the query as many times as needed anyway.
'meta_query' => array(
'relation' => 'OR',
array(
'key' => '_llms_achievement_image',
'compare' => 'EXISTS',
),
array(
'key' => '_llms_certificate_image',
'compare' => 'EXISTS',
),
array(
'key' => '_llms_achievement_content',
'compare' => 'EXISTS',
),
),
)
);
$legacy_option_added['achievement'] = false;
$legacy_option_added['certificate'] = false;
foreach ( $query->posts as $post ) {
$type = llms_strip_prefixes( $post->post_type );
$image_migrated = _migrate_image( $post->ID, $type );
if ( 'achievement' === $type ) {
_migrate_achievement_content( $post->ID );
}
if ( ! $legacy_option_added[ $type ] && ! $image_migrated ) {
_add_legacy_opt( $type );
$legacy_option_added[ $type ] = true;
}
}
// If there was 50 results assume there's another page and run again, otherwise we're done.
return ( count( $query->posts ) === $per_page );
}
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 6.0.0 | Introduced. |