Plugin Directory

Changeset 2251865


Ignore:
Timestamp:
02/28/2020 09:54:22 AM (6 years ago)
Author:
jakeob
Message:

adding support for defining path directly in shortcode, thus allowing multiple different listings across website

Location:
simple-ftp-directory-lister
Files:
28 added
3 edited

Legend:

Unmodified
Added
Removed
  • simple-ftp-directory-lister/trunk/assets/sfdl-options.php

    r2245864 r2251865  
    127127    {
    128128        print '<div>Plugin register path to folder within wordpress upload folder, therefore add only relative path to the folder you want to list. <br> When the path to folder is properly set, just copy the shortcode and past it anywhere to the page where you want to show the listing. </div><div style="color: red; margin-top:10px;">Please keep in mind that this plugin is not suitable for listing thousands of items since it loads all the information at once.</div>';
     129        print '<br><b>You can also define path within the shortcode to use the plugin in serveral places and listing different folders: [simple-ftp-directory-lister path="/path-to-folder"]</b>';
    129130    }
    130131
     
    137138        global $full_safe_dir_path;
    138139        $pathcheck = "<br>Set directory for listing: " . $full_safe_dir_path . "<br><br>";
    139         global $full_safe_dir_path;
     140
    140141        if (! file_exists($full_safe_dir_path)) {
    141142                $pathcheck .= '<div style="color:red;font-size:20px;font-weight:600;"> ERROR --> Set path does not exist.</div>';
  • simple-ftp-directory-lister/trunk/readme.txt

    r2245864 r2251865  
    66Tested up to: 5.2
    77Requires PHP: 7.2
    8 Stable tag: 1.0
     8Stable tag: 1.1
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    2121
    2222Please keep in mind that this plugin is not suitable for listing thousands of items since it loads all the information at once.
     23
     24You can also define path within the shortcode to use the plugin in serveral places and listing different folders: [simple-ftp-directory-lister path="/path-to-folder"]
    2325 
    2426== Installation ==
    2527 
    26 1. Upload`simple-ftp-directory-lister folder` to the `/wp-content/plugins/` directory
     281. Upload simple-ftp-directory-lister folder` to the `/wp-content/plugins/` directory
    27292. Activate the plugin through the 'Plugins' menu in WordPress
    28303. Go to settings -> Simple FTP Directory Lister Settings
     
    4042= Can I list multiple folders? =
    4143 
    42 Not at the moment, SFDL supports only one folder to list.
     44Yes, you can define path within the shortcode to use the plugin in serveral places and listing different folders: [simple-ftp-directory-lister path="/path-to-folder"]
    4345 
    4446== Screenshots ==
    45 screenshot-1.png`
    46 screenshot-2.png`
    47 screenshot-3.png`
     47screenshot-1.png
     48screenshot-2.png
     49screenshot-3.png
    4850 
    4951== Changelog ==
     52= 1.1 =
     53* adding support for defining path directly in shortcode, thus allowing multiple different listings across website
    5054
    5155= 1.0 =
  • simple-ftp-directory-lister/trunk/simple-ftp-directory-lister.php

    r2245864 r2251865  
    33 * Plugin Name:       Simple FTP Directory Lister
    44 * Description:       Choose folder from FTP - WP UPLOAD DIRECTORY - and display all its files and subfolders. Easy integration.
    5  * Version:           1.0
     5 * Version:           1.1
    66 * Requires at least: 5.2
    77 * Requires PHP:      7.2
     
    2222add_shortcode( 'simple-ftp-directory-lister', 'sfdl_main_function');
    2323
    24 // set directory
    2524$directory = get_option( 'simple_file_directory_lister_option_name');
    2625$user_input_path = $directory["id_path_to_folder"];
     26
     27
    2728/* set full path and remove all dot dot slashes from the path */
    2829$upload_dir = wp_upload_dir();
     
    4142$full_safe_dir_path = realpath($full_dir_path);
    4243
     44
    4345/* functions declaration */
    44 
    4546if (!function_exists('array_key_first')) {
    4647    function array_key_first(array $arr) {
     
    109110
    110111/*main function of the lister */
    111 function sfdl_main_function(){
     112function sfdl_main_function($path){
     113
     114
    112115    global $full_safe_dir_path;
    113116  global $full_dir_path;
    114117  global $upload_dir;
     118  global $directory;
     119  global $id_path_to_folder;
    115120  global $user_input_path;
     121
     122  // set directory
     123  if (isset($path['path'])){
     124      $directory = $path['path'];
     125      $user_input_path = $path['path'];
     126  }
     127
     128  // add / to beginning of user input path if missing
     129  if (substr($user_input_path, 0, 1) !== '/' && substr($user_input_path, 0, 1) !== '\\' && substr($user_input_path, 0, 1) !== '.') {
     130        $user_input_path =   "/" . $user_input_path;
     131        }
     132
     133  // change all \ to / within user input path
     134  elseif (substr($user_input_path, 0, 1) === '\\') {
     135  $user_input_path = str_replace("\\", "/", $user_input_path);
     136  }
     137
     138  $full_dir_path = $upload_dir['basedir'] . $user_input_path;
     139  $full_safe_dir_path = realpath($full_dir_path);
     140
     141
    116142
    117143/*dont run in admin area */
Note: See TracChangeset for help on using the changeset viewer.