WordPress.org

Ready to get started?Download WordPress

Forums

RAD Dropbox Uploader
Upload Form always appears at top of page (5 posts)

  1. agumperz@gmail.com
    Member
    Posted 1 year ago #

    RAD-Dropbox version: 1.1.0

    When I use this plugin, no matter where I place the shortcode in the HTML for a post, the HTML form it generates is placed at the top of the corresponding HTML page on my WordPress site.

    This is not an HTML or a CSS issue. No matter how I embed the shortcode inside div's or use CSS to attempt to position it, the form is visually placed at the top of the HTML page under the post heading.

    In the WordPress developer documentation for shortcodes, I noticed this would be expected behavior if the shortcode handler function has no return. See: http://codex.wordpress.org/Shortcode_API look under the heading "output":

    The return value of a shortcode handler function is inserted into the post content output in place of the shortcode macro. Remember to use return and not echo - anything that is echoed will be output to the browser, but it won't appear in the correct place on the page.

    Could that be the problem? In any event, thank you for a nice and useful plug-in!

    http://wordpress.org/extend/plugins/rad-dropbox-uploader/

  2. agumperz@gmail.com
    Member
    Posted 1 year ago #

    Rad-dropbox version: 1.1.0

    Hello,

    I have had trouble uploading to a specific drop box directory.
    [rad-dropbox dir="/Path/To/Folder"]

    I am able to:
    1. upload to the root of my dropbox account
    2. upload to a /uploads directory when I specify that path under the settings.

    However when I try to upload to a different directory by specifying a dir attribut in my shortcode such as: [rad-dropbox dir="/folder1/folder2"] the files are instead uploaded to the default directory set under settings rather than to the correct folder.

    Thanks again for a nice plug-in. And please let me know if there is any further testing I can do.

  3. gaswirth
    Member
    Posted 1 year ago #

    Hi there,

    I'm having the same problems as agumperz. I've had to use a do_shortcode() template tag to properly position the plugin, and am unable to specify a directory via the shortcode, though it does work through the main settings page.

    Thanks for your help!! Terrific plugin! Any help would be greatly appreciated.

    Thanks,
    Nick

  4. agumperz@gmail.com
    Member
    Posted 1 year ago #

    I am no PHP programmer, but I have fixed this bug for myself. I did the following:

    In rad-dropbox-uploader/rad-dropbox-uploader.php

    On line 110, you declare the shortcode handler function:
    function rad_dropbox_shortcode( $atts )

    I added one line: return $var_sHTML;

    2. In your supporting file: rad-dropbox-uploader/inc/shortcode.php

    I defined a variable to hold the HTML form output:
    $var_sHTML = '';

    Then concatenated the HTML for the form to it:
    $var_sHTML .= <HTML form declaration here>

    The handler function now returns the HTML form to the WordPress engine, rather than simply echoing it to the browser. The HTML form code replaces the shortcode in your user's HTML and problem solved :-)

    Andrew

    PS Below I have pasted my edited code for your file:
    rad-dropbox-uploader/inc/shortcode.php

    <?php 
    
    extract(shortcode_atts(array("dir" => $directory, "button" => 'Upload To Dropbox!'), $atts));
    
    $rad_dropbox_settings = admin_url( 'admin.php?page=rad_dropbox_settings', '' );
    
    if (empty($wp_settings_check)) { echo '<div class="message-yellow">You must enter your Dropbox account details first! Please go to the <a href="'.$rad_dropbox_settings.'">settings</a> page!</div><br>'; } 
    
    echo $message; 
    
    //beginning of mods here
    $var_sHTML = '';
    
    // concatenates the string below (the def of the HTML form) to the null string declared above.
    // HTML below now concatenated with $variables instead of echoing their values 
    
    $var_sHTML .= '<form method="POST" enctype="multipart/form-data" class="rad-dropbox-uploader">
    <input type="hidden" name="dest" value="' . $dir . '" />
    <div class="rad-dropbox-file">
    <div style="margin-bottom:10px;"> <b>Upload Resume or Headshot</b> </div>
    <input type="file" name="file" class="rad-dropbox-file" />
    </div>
    <div class="rad-dropbox-button">
    <input type="submit" value="' . $button . '" class="rad-dropbox-button" />
    </div>
    </form>';
    
    ?>
  5. Aaron F.
    Member
    Plugin Author

    Posted 1 year ago #

    You guys are good. Thank you for the code snippet, can anyone else verify that this fixed the issue? I will implement it immediately if so.

    Thank you!

    PS - Andrew, can I offer a developer credit to your name?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic