copy_directory( AI1EC_PATH . '/' . AI1EC_THEMES_FOLDER, AI1EC_THEMES_ROOT ); if( @is_dir( AI1EC_THEMES_ROOT ) === false || @is_dir( AI1EC_DEFAULT_THEME_PATH ) === false ) return false; // Update installed core themes version. update_option( 'ai1ec_themes_version', AI1EC_THEMES_VERSION ); } return true; } /** * Returns whether core theme files need to be updated (only if core theme * files exist in the first place, checked using above function). * * @return bool */ public function are_themes_outdated() { if ( ! $this->are_themes_available() ) { return FALSE; } if ( get_option( 'ai1ec_themes_version', 1 ) >= AI1EC_THEMES_VERSION ) { return FALSE; } return TRUE; } /** * copy_directory function * * @return void **/ private function copy_directory( $source, $destination ) { if( is_dir( $source ) ) { @mkdir( $destination ); $directory = dir( $source ); while( FALSE !== ( $readdirectory = $directory->read() ) ) { if( $readdirectory == '.' || $readdirectory == '..' ) { continue; } $PathDir = $source . '/' . $readdirectory; if( is_dir( $PathDir ) ) { $this->copy_directory( $PathDir, $destination . '/' . $readdirectory ); continue; } copy( $PathDir, $destination . '/' . $readdirectory ); } $directory->close(); } else { copy( $source, $destination ); } } /** * Register Update Calendar Themes page in wp-admin. */ function register_theme_updater() { // Add menu item for theme update page, but without the actual menu item // by removing it again right away. add_submenu_page( 'themes.php', __( 'Update Core Calendar Files', AI1EC_PLUGIN_NAME ), __( 'Update Core Calendar Files', AI1EC_PLUGIN_NAME ), 'install_themes', AI1EC_PLUGIN_NAME . '-update-themes', array( &$this, 'update_core_themes' ) ); remove_submenu_page( 'themes.php', AI1EC_PLUGIN_NAME . '-update-themes' ); } /** * Called by the Update Calendar Themes page. Updates core themes with any * files that have changed since the last time a theme update has run. */ function update_core_themes() { global $ai1ec_view_helper; $src_dir = trailingslashit( AI1EC_PATH . '/' . AI1EC_THEMES_FOLDER . '/' ); $dest_dir = trailingslashit( AI1EC_THEMES_ROOT . '/' ); // Get previous version of core themes. $active_version = get_option( 'ai1ec_themes_version', 1 ); $files = array(); if ( $active_version < 2 ) { // Copy over files updated between AI1EC 1.6 and 1.7 RC1 $files[] = 'vortex/agenda.php'; $files[] = 'vortex/agenda-widget.php'; $files[] = 'vortex/js/bootstrap-dropdown.js'; $files[] = 'vortex/js/bootstrap-tooltip.js'; $files[] = 'vortex/js/general.min.js'; $files[] = 'vortex/css/calendar.css'; $files[] = 'vortex/css/event.css'; $files[] = 'vortex/css/general.css'; $files[] = 'vortex/css/print.css'; $files[] = 'vortex/less/build-css.sh'; $files[] = 'vortex/less/calendar.less'; $files[] = 'vortex/less/event.less'; $files[] = 'vortex/less/general.less'; $files[] = 'vortex/less/mixins-custom.less'; $files[] = 'vortex/less/variables.less'; $files[] = 'vortex/month.php'; $files[] = 'vortex/oneday.php'; $files[] = 'vortex/style.css'; $files[] = 'vortex/week.php'; } if ( $active_version < 3 ) { // Copy over files updated between AI1EC 1.7 RC1 and AI1EC 1.7 RC2 $files[] = 'vortex/js/calendar.min.js'; $files[] = 'vortex/js/calendar.js'; } if ( $active_version < 4 ) { // Copy over files updated between AI1EC 1.7 RC2 and AI1EC 1.7 RC3 $files[] = 'vortex/js/calendar.min.js'; $files[] = 'vortex/js/calendar.js'; } // Remove duplicates. $files = array_unique( $files ); $errors = array(); foreach ( $files as $file ) { if ( ! copy( $src_dir . $file, $dest_dir . $file ) ) { $errors[] = sprintf( __( '
There was an error updating one of the files. Please FTP to your web server and manually copy
%sto
%s
Please follow any instructions listed below or your calendar may malfunction: