bsf_update_all_product_version()
Updates all product versions.
Description
Return
(void)
Source
File: admin/bsf-core/auto-update/admin-functions.php
function bsf_update_all_product_version() { $brainstrom_products = get_option( 'brainstrom_products', array() ); $brainstrom_bundled_products = get_option( 'brainstrom_bundled_products', array() ); $bsf_product_themes = array(); if ( ! empty( $brainstrom_products ) ) : $bsf_product_plugins = ( isset( $brainstrom_products['plugins'] ) ) ? $brainstrom_products['plugins'] : array(); $bsf_product_themes = ( isset( $brainstrom_products['themes'] ) ) ? $brainstrom_products['themes'] : array(); endif; $bundled_product_updated = false; if ( ! empty( $bsf_product_plugins ) ) { foreach ( $bsf_product_plugins as $key => $plugin ) { if ( ! isset( $plugin['id'] ) || empty( $plugin['id'] ) ) { continue; } if ( ! isset( $plugin['template'] ) || empty( $plugin['template'] ) ) { continue; } if ( ! isset( $plugin['type'] ) || empty( $plugin['type'] ) ) { continue; } $version = ( isset( $plugin['version'] ) ) ? $plugin['version'] : ''; $current_version = bsf_get_current_version( $plugin['template'], $plugin['type'] ); $name = bsf_get_current_name( $plugin['template'], $plugin['type'] ); if ( '' !== $name ) { $brainstrom_products['plugins'][ $key ]['product_name'] = $name; } if ( '' !== $current_version ) { if ( version_compare( $version, $current_version ) === - 1 || 1 === version_compare( $version, $current_version ) ) { $brainstrom_products['plugins'][ $key ]['version'] = $current_version; } } } } if ( ! empty( $bsf_product_themes ) ) { foreach ( $bsf_product_themes as $key => $theme ) { if ( ! isset( $theme['id'] ) || empty( $theme['id'] ) ) { continue; } if ( ! isset( $theme['template'] ) || empty( $theme['template'] ) ) { continue; } if ( ! isset( $theme['type'] ) || empty( $theme['type'] ) ) { continue; } $version = ( isset( $theme['version'] ) ) ? $theme['version'] : ''; $current_version = bsf_get_current_version( $theme['template'], $theme['type'] ); $name = bsf_get_current_name( $theme['template'], $theme['type'] ); if ( '' !== $name ) { $brainstrom_products['themes'][ $key ]['product_name'] = $name; } if ( '' !== $current_version || false !== $current_version ) { if ( version_compare( $version, $current_version ) === - 1 || 1 === version_compare( $version, $current_version ) ) { $brainstrom_products['themes'][ $key ]['version'] = $current_version; } } } } if ( ! empty( $brainstrom_bundled_products ) ) { foreach ( $brainstrom_bundled_products as $keys => $bps ) { $version = ''; if ( strlen( $keys ) > 1 ) { foreach ( $bps as $key => $bp ) { if ( ! isset( $bp->id ) || '' === $bp->id ) { continue; } $version = $bp->version; $current_version = bsf_get_current_version( $bp->init, $bp->type ); if ( '' !== $current_version && false !== $current_version ) { if ( 1 === - version_compare( $version, $current_version ) || 1 === version_compare( $version, $current_version ) ) { if ( is_object( $brainstrom_bundled_products ) ) { $brainstrom_bundled_products = array( $brainstrom_bundled_products ); } $single_bp = $brainstrom_bundled_products[ $keys ]; $single_bp[ $key ]->version = $current_version; $bundled_product_updated = true; $brainstrom_bundled_products[ $keys ] = $single_bp; } } } } else { if ( ! isset( $bps->id ) || '' === $bps->id ) { continue; } $version = $bps->version; $current_version = bsf_get_current_version( $bps->init, $bps->type ); if ( '' !== $current_version || false !== $current_version ) { if ( - 1 === version_compare( $version, $current_version ) || 1 === version_compare( $version, $current_version ) ) { $brainstrom_bundled_products[ $keys ]->version = $current_version; $bundled_product_updated = true; } } } } } update_option( 'brainstrom_products', $brainstrom_products ); if ( $bundled_product_updated ) { update_option( 'brainstrom_bundled_products', $brainstrom_bundled_products ); } }
Expand full source code Collapse full source code View on Trac