/** * Return the current instance * * @access public * @since 1.4 * * @static * @return object */ public static function get_instance() { if ( empty( self::$instance ) ) self::$instance = new Envato_Backup_Mod(); return self::$instance; }
/** * Backup an Envato theme. * * This function requires the template/theme slug * to locate and backup that theme. * * @access private * @since 1.4 * * @param string Template slug * @return void */ protected function _backup_theme( $theme ) { $backup_errors = array(); $theme_backup = Envato_Backup_Mod::get_instance(); $theme_backup->path = EWPT_BACKUP_DIR_MOD; $theme_backup->root = get_theme_root() . '/' . $theme . '/'; $theme_backup->archive_filename = strtolower( sanitize_file_name( $theme . '.backup.' . date( 'Y-m-d-H-i-s', time() + ( current_time( 'timestamp' ) - time() ) ) . '.zip' ) ); if ( ( ! is_dir( $theme_backup->path() ) && ( ! is_writable( dirname( $theme_backup->path() ) ) || ! mkdir( $theme_backup->path() ) ) ) || ! is_writable( $theme_backup->path() ) ) { array_push( $backup_errors, 'Invalid backup path' ); return false; } if ( ! is_dir( $theme_backup->root() ) || ! is_readable( $theme_backup->root() ) ) { array_push( $backup_errors, 'Invalid root path' ); return false; } $theme_backup->backup(); if ( file_exists( Envato_Backup_Mod::get_instance()->archive_filepath() ) ) { return true; } else { return $backup_errors; } }