response ) ){ $response = $obj->response; $key = eos_plugin_revision_key(); foreach( $response as $p => $arr ){ if( false !== strpos( $p,'pr-'.$key.'-' ) && isset( $response[$p] ) ){ unset( $response[$p] ); } } $obj->response = $response; } return $obj; } ); /** * Return revision key * * @since 0.0.1 */ function eos_plugin_revision_key(){ $opts = get_site_option( 'plugin_revisions' ); if( $opts && isset( $opts['time' ] ) ){ $key = substr( md5( sanitize_text_field( $opts['time' ] ) ),0,8 ); return $key; } else{ $time = time(); $opts['time'] = $time; update_site_option( 'plugin_revisions',$opts ); return substr( md5( $time ),0,8 ); } return false; } /** * Create zip pclzip. * * @since 0.0.6 * */ function eos_pv_create_zip_pclzip( $destination, $zip_dirname ) { if( file_exists( ABSPATH . 'wp-admin/includes/class-pclzip.php' ) ) { require_once( ABSPATH . 'wp-admin/includes/class-pclzip.php' ); if( class_exists( 'PclZip' ) ) { $files = eos_pv_get_files( $destination ); if( $files ) { $zip = new PclZip( str_replace( '/.zip', '.zip', $destination . '.zip' ) ); if ( defined( 'PCLZIP_OPT_REMOVE_PATH' ) ) { $zip_created = $zip->create( $files, PCLZIP_OPT_REMOVE_PATH, WP_PLUGIN_DIR ); if( 0 == $zip_created ) { return false; } return true; } } } return false; } } /** * Get files by path. * * @since 0.0.6 */ function eos_pv_get_files( $path ) { if( ! class_exists( 'RecursiveIteratorIterator' ) ) return false; $files = new RecursiveIteratorIterator( new RecursiveDirectoryIterator( $path ), RecursiveIteratorIterator::LEAVES_ONLY ); $files_paths = array(); foreach ( $files as $name => $file ) { if ( ! $file->isDir() ) { $file_path = str_replace( '\\', '/', $file->getRealPath() ); $files_paths[] = $file_path; } } return $files_paths; }