are_themes_available() ) { return FALSE; } if ( get_option( 'ai1ec_themes_version', 1 ) >= AI1EC_THEMES_VERSION ) { return FALSE; } return TRUE; } /** * Returns a notice informing admin to update the core theme files if core * theme files are determined to be out of date. Else returns '' (evaluates * to false). If $echo is true, outputs the notice. Else outputs nothing. * * @see Ai1ec_Themes_Controller::are_themes_outdated() * * @param boolean $echo Whether to output the message or just return it. * @return boolean Whether core theme files are out of date. */ public function frontend_outdated_themes_notice( $echo = true ) { $output = ''; if ( $this->are_themes_outdated() ) { $output .= '

'; $output .= __( 'The All-in-One Event Calendar core theme files are out of date and the calendar has been temporarily disabled.', AI1EC_PLUGIN_NAME ); $output .= ' '; if ( current_user_can( 'install_themes' ) ) { $output .= sprintf( __( 'To enable the calendar, please log into the WordPress dashboard and follow the instructions.', AI1EC_PLUGIN_NAME ), esc_attr( admin_url() ) ); } else { $output .= __( 'To enable the calendar, an administrator must log into the WordPress dashboard and follow the instructions.', AI1EC_PLUGIN_NAME ); } $output .= '

'; } if ( $echo ) { echo $output; } return $output; } /** * 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 ); } } /** * install_themes function * * @return void **/ function install_themes() { ?>

wp_content_dir() . AI1EC_THEMES_FOLDER; $result = $wp_filesystem->mkdir( $themes_root ); if( $result === false ) { ?>

wp_plugins_dir() . AI1EC_PLUGIN_NAME . DIRECTORY_SEPARATOR . AI1EC_THEMES_FOLDER; $result = copy_dir( $plugin_themes_dir, $themes_root ); if( is_wp_error( $result ) ) { ?>

.

get_error_message() ), AI1EC_PLUGIN_NAME ) ?>

.

is_dir( $folder ) ) { // Try to delete it recusively. if ( false === $wp_filesystem->delete( $folder, true ) ) { // If delete failed, chmod folder recursively to 0644 and try again. $wp_filesystem->chmod( $folder, 0644, $recursive ); if ( false === $wp_filesystem->delete( $folder, true ) ) { // We were not able to remove the folder; notify the user. $delete_errors[] = $folder; } } } } // 2. Copy fresh versions of folders. foreach ( $folders as $folder ) { $src_folder = $src_dir . $folder; $dest_folder = $dest_dir . $folder; // Try to copy the folder. $result = copy_dir( $src_dir, $dest_dir ); if ( is_wp_error( $result ) ) { // We were not able to copy the folder; notify the user. $copy_errors[] = $src_folder; } } $errors = array(); if ( $delete_errors ) { $error = '

'; $error .= __( 'There was an error while removing outdated core themes from your themes folder.', AI1EC_PLUGIN_NAME ); $error .= ' '; $error .= __( 'Please FTP to your web server and manually delete:', AI1EC_PLUGIN_NAME ); $error .= '

'; $error .= implode( '
', $delete_errors ); $error .= '
'; $errors[] = $error; } if ( $copy_errors ) { $error = '

'; $error .= __( 'There was an error while copying core themes from the plugin into the themes folder.', AI1EC_PLUGIN_NAME ); $error .= ' '; $error .= __( 'Please FTP to your web server and manually copy the folders:', AI1EC_PLUGIN_NAME ); $error .= '

'; $error .= implode( '
', $copy_errors ); $error .= '
'; $error .= '

' . __( 'to', AI1EC_PLUGIN_NAME ) . ' ' . $dest_dir . '

'; $errors[] = $error; } // Unsuccessful core theme file update. if ( $errors ) { array_unshift( $errors, __( '

Errors occurred while we tried to update your core Calendar Themes

Please follow any instructions listed below or your calendar may malfunction:

', AI1EC_PLUGIN_NAME ) ); } // Successful core theme file update. else { // Update theme version update_option( 'ai1ec_themes_version', AI1EC_THEMES_VERSION ); $msg = '

'; $msg .= __( 'Your core Calendar Themes were updated successfully', AI1EC_PLUGIN_NAME ); $msg .= '

'; $msg .= __( 'Be sure to reload your browser when viewing your site to make sure the most current scripts are used.', AI1EC_PLUGIN_NAME ); $msg .= '

'; } $args = array( 'msg' => $msg, 'errors' => $errors, ); $ai1ec_view_helper->display_admin( 'themes-updated.php', $args ); } /** * Called immediately after WP theme's functions.php is loaded. Load our own * theme's functions.php at this time, and the default theme's functions.php. */ function setup_theme() { $functions_files = array( $this->active_template_path() . '/functions.php', AI1EC_DEFAULT_THEME_PATH . '/functions.php', ); $functions_files = array_unique( $functions_files ); foreach( $functions_files as $file ) { if ( file_exists( $file ) ) { include( $file ); } } } } // END class