PluginProbe
WP Ultimate Post Grid / 1.9
WP Ultimate Post Grid v1.9
4.1.1 trunk 1.5 1.6 1.7 1.7.1 1.7.2 1.8 1.9 2.0 2.1 2.2 2.3 2.4.0 2.5.0 2.6.0 2.7.0 2.8.0 2.8.2 3.0.0 3.3.0 3.4.0 3.5.0 3.6.0 3.7.0 All 32 releases
wp-ultimate-post-grid / helpers / migration.php

migration.php in WP Ultimate Post Grid 1.9, at helpers/migration.php

53 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class WPUPG_Migration {
4
5 public function __construct()
6 {
7 add_action( 'admin_init', array( $this, 'migrate_if_needed' ) );
8 }
9
10 public function migrate_if_needed()
11 {
12 // Get current migrated to version
13 $migrate_version = get_option( 'wpupg_migrate_version', false );
14
15 if( !$migrate_version ) {
16 $notices = false;
17 $migrate_version = '0.0.1';
18 } else {
19 $notices = true;
20 }
21
22 $migrate_special = '';
23 if( isset( $_GET['wpupg_migrate'] ) ) {
24 $migrate_special = $_GET['wpupg_migrate'];
25 }
26
27 if( $migrate_version < '1.2' ) require_once( WPUltimatePostGrid::get()->coreDir . '/helpers/migration/1_2_active_colors.php');
28
29 // Each version update once
30 if( $migrate_version < WPUPG_VERSION ) {
31 WPUltimatePostGrid::addon( 'custom-templates' )->default_templates( true ); // Reset default templates
32
33 // Update all grid caches
34 $args = array(
35 'post_type' => WPUPG_POST_TYPE,
36 'post_status' => 'any',
37 'posts_per_page' => -1,
38 'nopaging' => true,
39 'fields' => 'ids',
40 );
41
42 $query = new WP_Query( $args );
43 $posts = $query->have_posts() ? $query->posts : array();
44 $grid_ids = array_map( 'intval', $posts );
45
46 if( count( $grid_ids ) > 0 ) {
47 update_option( 'wpupg_regenerate_grids_check', $grid_ids );
48 }
49
50 update_option( 'wpupg_migrate_version', WPUPG_VERSION );
51 }
52 }
53 }