Library Viewer

Description

Library Viewer 2.0.0 has introduced many hooks and alter some functionality on how it uses hooks.
If you have used some hooks of 1.x.x plugin version, please see the changelog and documentation.

With Library Viewer, you can display the containing files and the containing folders of a “specific folder” of your (FTP) server to your users in the front-end.

The significant difference from other similar plugins is that:
1. You can allow users to view that the files exist, but cannot open them if they are not logged in (or if they are not administrators, or authors etc…).
2. You can allow users to view files in a custom viewer or redirect them through a RESTful web service of your choice(examples exists below).

DEMO

For this plugin (the free version), the “specific folder” is the folder “library” of your httpdocs(yoursite.com/library).
If you want to display other folder (and its files) that isn’t contained in yoursite.com/library , you need to buy the Library Viewer Pro.
You can buy Library Viewer Pro from this link: www.pexlechris.dev/library-viewer-pro

This plugin adds the [library-viewer] shortcode in your WordPress site!
So the only thing that you must do to display the folders and files in the front-end is to add this shortcode in a post, or page etc.

The [library-viewer] shortcode get optional parameters that extend the functionality of plugin:

PARAMETERS DOCUMENTATION AND USE CASES

  • have_file_access (have_file_access parameter determines which user have access to view the files.)
  • my_doc_viewer (my_doc_viewer parameter determines in which viewer the file will be opened.)
  • login_page (login_page parameter defines the login page that user will be redirected -if need it-, to log in.)
  • path [ONLY IN PRO] (path parameter allow us to choose what folder we want to display in the Library in the front-end. When we say, folder, we mean folder’s contents i.e. containing folders and files of this folder.)
  • waiting_seconds [ONLY IN PRO] (waiting_seconds parameter sets the seconds of user is waiting the redirection to login and see the file (0: for instant redirect).)
  • breadcrumb [ONLY IN PRO] (breadcrumb parameter determines if breadcrumb will be displayed in the Library in front-end.)
  • hidden_folders [ONLY IN PRO] (hidden_folders determines which folders will not be displayed and will not be accessible by Library in the front-end.)
  • shown_folders [ONLY IN PRO] (shown_folders parameter determines which folders will be displayed and will be accessible by Library in the front-end.)
  • hidden_files [ONLY IN PRO] (hidden_files determines which files will not be displayed and will not be accessible by Library in the front-end.)
  • shown_files [ONLY IN PRO] (shown_files parameter determines which files will be displayed and will be accessible by Library in the front-end.)

PARAMETERS DOCUMENTATION AND USE CASES

Hooks Documentation

From 2.0.0 version and then, there are many hooks that you can customize the functionality of this plugin.
You can read more in HOOKS DOCUMENTATION

Other Details

  • The algorithm does not show in the front-end folders that contains in their name the string “hidden-folder”.
    Also does not show .php , .ini files and files that contains in their name the string “hidden-file”.
    So if you don’t want to displaying an existing folder or file, you can rename it appropriately!
    If you want to display these folders/files and restrict access to others folders/files, you need to buy Library Viewer Pro (See below)!
  • There are some hooks that you can customize the URls. If you want more info ask in the support forum of plugin.
  • If have_file_access is NOT in the DEFAULT state, files open with plugin viewer.
    All the files that are supported by WordPress Core opens in new tab of browser, all others are downloaded (this from PC, from smartphone pdf files are downloaded).
    If you want to add support for others files (that browser can open) or make the files to be downloaded, use the lv_mime_types wp filter. See FAQs for details.
  • If you want to add text above the front-end folders or below the front-end files, you can create via FTP a file with name “include.php” in the FTP folder that you want texts to be shown in front-end.
    HTML tags are allowed!
    Your texts must be values of php variables ($text_at_beginning , $text_at_end respectively) as you can see below:

    <?php
    $text_at_beginning = "My text above front-end folders";
    $text_at_end = "My text below front-end files";
    

     
    Also, you can use the hooks lv_folder_text_at_beginning and lv_folder_text_at_end respectively

 

Library Viewer Pro

  • With Library Viewer Pro you can display folders & files of a directory (in FTP) of your choice, not only library directory (yoursite.com/library)
  • In the Library Viewer Pro you can set the seconds of user is waiting the redirection, as you like (0: for instant redirect).
    (With Library Viewer when user clicks to open a file and is not logged in, he/she wait for 5 seconds to redirect in the login page.)
  • If a folder or file contains a space character (” “) in its name, in the url the space is replaced by “–” for beauty reasons.
    It is much prettier this link: …LV/library/my–file.pdf than this: …LV/library/my%20file.pdf
    With Library Viewer Pro you can set the character of your choice to replace the spaces in the urls.
  • The algorithm of Library Viewer does not show in the front-end folders with name that contains in their name the string “hidden-folder”.
    Also does not show .php and .ini files and the files with name that contains in their name the string “hidden-file”.
    With Library Viewer Pro you can set the names that you don’t (and you do) want to displaying in the front-end.
  • With Library Viewer Pro you can hide the breadcrumb with a shortcode parameter.
  • Library Viewer Pro supports comments
  • Buy Library Viewer Pro in this link: www.pexlechris.dev/library-viewer-pro

Screenshots

  • library folder must be located in the root of your FTP server
  • Not all files and folders are displaying in the front-end Library Viewer because of their special names (hidden-folder, hidden-file, .php etc.)
  • The string-value of the $text_at_beginning variable is displayed between the breadcrumb and the folders, the string-value of the $text_at_end variable is displayed below the folders & files.

Installation

  1. Download the plugin from Official WP Plugin Repository
  2. Upload Plugin from your WP Dashboard ( Plugins>Add New>Upload Plugin ) the library-viewer.zip file.
  3. Activate the plugin through the ‘Plugins’ menu in WordPress Dashboard
  4. Add to a new or existing page/post (or widget etc.) the shortcodes [library-viewer] with the parameters of your choice.

FAQ

Can I forbid the direct access in the files of the library? I want only via library files can be accessible.

With Library Viewer Pro, you can! See this support topic: wordpress.org/support/topic/executable-pdf-file

I have put the shortcode in a page but it doesn’t work when I click in a folder or a file. Why?

PLAIN PERMALINKS ARE NOT SUPPORTED. Please change your permalink from /wp-admin/options-permalink.php to something else.
The problem is with the get parameters. Get parameters are not fully supported at all. Maybe this is the reason that doesn’t work efficiently

Are there shortcode examples?

You can test your own use cases in the DEMO

The plugin says me that a folder or a file doesn’t exists, but it exists! Why?

This is because maybe some special characters are not supported as names of folders and files.
In this case, contact me via email or via support forum to find a solution!
In addition, if you use the plugin Remove Uppercase Ascents and a CSS code like .library-viewer–folder{text-transform: uppercase;} maybe this cause the problem. The solution in this case is to use instead this CSS code: .library-viewer–folder h3 a{text-transform: uppercase;}

With which Page Builders the Library Viewer are compatible?

Library Viewer have been tested with TinyMCE (Classic Editor) , Gutenberg , WPBakery, Visual Composer, Elementor and works fine!

Can I change the colors or the fonts that plugin uses?

Yes. But only with plain CSS at the moment. So you can add your custom css from WP customizer (from Additional CSS)

When a comment is added under a folder-page, this comment is displayed in another folder-page too. Why?

This happens because Library Viewer does not support comments. So if you want to displaying different comments in different folders/pages you need to buy Library Viewer Pro!

Can I hide an existing folder or file of FTP folder from the front-end library?

Yes. Please read carefully the section “Other Details” of plugin.

Can I add my custom text inside a folder of front-end library viewer?

Yes. Please read carefully the section “Other Details” of plugin.

How to upload files and create new folders?

You can do this via FTP or from the File Manager of your cPanel/Plesk etc

How can I deny users to execute php files in folders of my library?

You need to add the following code in the .htaccess file of the folder that you want to deny users execute php files

  <Files *.php>
  deny from all
  </Files>

Is Library Viewer’ file viewer supports all mime types?

From 1.1.2, the Library Viewer’ file viewer supports all mime types that wordpress supports.
These that included in the function: wp_get_mime_types()
If you want to add support for mime types that are not included, use the WP filter: lv_mime_types to include them.
Read more in HOOkS DOCUMENTATION

I want all files to be downloaded. Is that possible?

Yes, you need to use the Library Viewer’ file viewer (my_doc_viewer=”library-viewer”) and to add the following hook in your function.php

  add_filter('lv_mime_types', function(){
    return array();
  });

I have a proposal for a new functionality of this plugin. Can I suggest it to you?

Yes. I need new ideas to improve my plugin. Send it to me via email or via support forum

Reviews

27 March 2021
This plugin do exactly all that says with easy setup and work very fast.
15 September 2020
I implemented this plugin as a way to create text files for our own employee use. Each time one of our products is changed, it writes the changes to a text file creating a log for each individual product. The logs are stored in the folder the plugin uses and it creates a quick and easy way for employees to check product changes. I love the ease of use and the customization which allows for only logged in users of a certain role to access the files as well. Side note: After an update, the plugin was throwing an error, so I reverted to the old version and informed the creator of the plugin. He / she responded almost immediately and had a patch for the error in just a few hours.
13 September 2019
Very good plugin, it works as expected. Also, it has great and fast support!
Read all 5 reviews

Contributors and Developers

“Library Viewer” is open source software. The following people have contributed to this plugin.

Contributors

Translate “Library Viewer” into your language.

Interested in development?

Browse the code, check out the SVN repository, or subscribe to the development log by RSS.

Change Log

2.0.1

  • [Bug Fix]: Fix bug of Library Viewer Pro. Files weren’t opened…

2.0.0

  • Tested up to WP 5.7
  • [Enhancement]: Add compatibility for symbols #, ? for file names and folder names of your library
  • [Enhancement]: Security update: Hidden folders (that have in their name the string ‘hidden-folder’) and hidden-files (that have in their name the string ‘hidden-ile’), now,
    are not accessible, if you know the full path of the hidden folder/file.
  • [Enhancement]: Now the file link is being encoded and then is appended to the my_doc_viewer parameter. If you don’t want to be encoded use lv_my_doc_viewer_file_encoded filter.
  • [Deprecated]: library-viewer--current-breadcrumb-item class removed from breadcrumb current item. Replaced with the CSS rule .library-viewer--breadcrumb-item:last-of-type
    Hooks:
  • [Deprecated]: LV__folder_was_viewed action replaced with lv_folder_was_viewed action.
  • [Deprecated]: LV__array_replace_to__in_foldernames filter replaced with lv_folder_fake_path_symbols filter.
  • [Deprecated]: LV__array_replace_from__in_foldernames filter replaced with lv_folder_real_path_symbols filter.
  • [Deprecated]: LV__array_replace_to__in_filenames filter replaced with lv_file_fake_path_symbols filter.
  • [Deprecated]: LV__array_replace_from__in_filenames filter replaced with lv_file_real_path_symbols filter.
  • [Deprecated]: LV__folder_html filter replaced with lv_folder_html filter.
  • [Deprecated]: LV__file_html filter replaced with lv_file_html filter.
  • [Deprecated]: LV__file_was_viewed filter replaced with lv_file_was_viewed filter.
  • [New]: lv_file_identifier filter introduced. With this you can change the ‘/LV/’ that is the part of URL of a file.
  • [New]: lv_before_breadcrumb_start action introduced.
  • [New]: lv_after_breadcrumb_start action introduced.
  • [New]: lv_breadcrumb_folder_delimiter_html action introduced. You can change the delimiter of folders of breadcrumb.
  • [New]: lv_breadcrumb_items action introduced. With this filter, you can alter the breadcrumb items, for example the folder name and folder fake link.
  • [New]: lv_before_breadcrumb_end action introduced.
  • [New]: lv_after_breadcrumb_end action introduced.
  • [New]: lv_empty_folder_html filter introduced. If the current folder contains neither files nor folders, an equivalent message will be displayed an with filter. With this filter you can change it.
  • [New]: lv_folder_text_at_beginning filter introduced. This filter allow us to add or change the text at beginning of the folder, i.e. the text before the first containing folder.
  • [New]: lv_containing_folders filter introduced. Containing folders of current folder filter.
  • [New]: lv_folder_icon_html filter introduced. Used to filter the html of folder icon.
  • [New]: lv_folder_html filter introduced. Used to filter the html output of printed folder.
  • [New]: lv_before_folder action introduced.
  • [New]: lv_after_folder action introduced.
  • [New]: lv_containing_files filter introduced. Containing files of current folder filter.
  • [New]: lv_file_icon_html filter introduced. Used to set a file icon using php.
  • [New]: lv_file_html filter introduced. Used to filter the html output of printed file.
  • [New]: lv_before_file action introduced.
  • [New]: lv_after_file action introduced.
  • [New]: lv_folder_text_at_end filter introduced. This filter allow us to add or change the text at end of the folder, i.e. the text after the last containing file.
  • [New]: lv_folder_was_viewed action introduced. Do some actions if a folder was accessed/viewed.
  • [New]: lv_file_was_viewed action introduced. Do some actions if a file was accessed/viewed.
  • [New]: Filter lv_my_doc_viewer_file_encoded introduced. With this filter you can determine if the file will be appended to my_doc_viewer as encoded or not default is true (encoded).
  • [New]: Filter lv_mime_types introduced. If you want to add support for mime types that are not included, use this filter.

1.2.3

  • Tested up to WP 5.6
  • [Enhancement]: In filter LV__folder_html introduced the $attributes parameter
  • [New]: filter LV__file_html introduced

1.2.2

  • Tested up to WP 5.5.3
  • [Enhancement]: Change Library Viewer Pro URL in plugins’ page on dashboard

1.2.1

  • [Bug Fix]: False Positive: shortcode [library-viewer] seams to be used more than 1 times in the same page, but not

1.2.0

  • Tested up to WP 5.5.1
  • [New]: LV__folder_was_viewed wordpress action was added in the code
  • [Enhancement]: From 1.2.0, the shortcode settings are saved in database, not in files. Also, the folder /wp-content/uploads/library-viewer will be deleted!
  • [Bug Fix]: Now Library Viewer’ shortcode is supported in the homepage too
  • [New]: library-viewer has been added to the available values that my_doc_viewer can get
  • [Bug Fix in PRO]: The shortcode [library-viewer] cannot be used more than 1 times in the same page. This feature is available in Library Viewer Pro

1.1.2

  • LV__mime_types wordpress filter was added in the code
  • LV__file_was_viewed wordpress action was added in the code
  • Tested up to WP 5.4.2

1.1.1

  • Some errors has been fixed!

1.1.0

  • now is possible to restrict users from open files by a capability using the have_file_access parameter
  • php die() replaced by wp_die() for more pretty messages
  • enhancement in code
  • delete folder library-viewer of your uploads folder on uninstall
  • now you can more easily add an icon in the front of a file using CSS

1.0.7

  • Library Viewer has been tested up to WP 5.3.2
  • PHP Notices fixed

1.0.6

  • Folders icons NOW are printed by css background-image attribute
  • Compatibility with sites that exist in a subdirectory fixed

1.0.5

  • SECURITY PATCH (Please update NOW)

1.0.3

  • Library Viewer has been tested up to WP 5.2.3
  • readme file was translated in Greek
  • Compatibility with Visual Composer have been tested and works fine
  • Instruction to fix the conflict with Remove Uppercase Ascents Plugin added in FAQ
  • Go Back button have been added in error messages

1.0.2

  • Library Viewer has been tested up to WP 5.2.2
  • Link notice for Library Viewer Pro has been added in the backend (WP Plugins Page)
  • Plugin URI has been fixed
  • A screenshot has been added in the Official WP Page of Library Viewer Plugin
  • Minor typo fixes in the readme file and Official WP Page of Library Viewer Plugin

1.0.1

  • Compatibility have added for most common special characters(+ , & , , .)
  • Redirect waiting time to login is now 5 seconds (if you want to change this you need to buy the Library Viewer Pro)
  • The ability of encryption of the real path of your folder (with hash technique) moved to Library Viewer Pro

1.0.0

  • Initial Release.