Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

New media upload page WordPress

I need new media upload and library pages the same as the standard ones found at /wp-admin/upload.php and /wp-admin/media-new.php, but which uses a different uploads folder.


Any ideas on the best way to implement this?


Added handy bonus feature I'd like if it's not too hard .... I'd like links for these new pages added in the "Appearance" menu rather than the "Media" menu.

Answers (2)

2011-10-29

Gabriel Reguly answers:

Hi Ryan,

I can do that for you for $35

Regards,
Gabriel


Gabriel Reguly comments:

Remember this code I have posted earlier? [[LINK href="http://wpquestions.com/question/show/id/2920"]]http://wpquestions.com/question/show/id/2920[[/LINK]]


add_filter( 'upload_dir', 'my_custom_upload_dir' );

function my_custom_upload_dir( $default_dir ){
/*
* On success, the returned array will have many indices:
* 'path' - base directory and sub directory or full path to upload directory.
* 'url' - base url and sub directory or absolute URL to upload directory.
* 'subdir' - sub directory if uploads use year/month folders option is on.
* 'basedir' - path without subdir.
* 'baseurl' - URL path without subdir.
* 'error' - set to false.
*/

// Adjust your settings here
$dir = '';
$url = '';
$subdir = '';
$bdir = '';
$burl = '';

$custom_dir = array(
'path' => $dir,
'url' => $url,
'subdir' => $subdir,
'basedir' => $bdir,
'baseurl' => $burl );
return shortcode_atts( $custom_dir, $default_dir );
}


Regards,
Gabriel

2011-10-29

Luis Cordova answers:

using this code into your functions.php can get you the custom directory:



add_filter( 'upload_dir', 'my_custom_upload_dir' );



function my_custom_upload_dir( $default_dir ){

/*

* On success, the returned array will have many indices:

* 'path' - base directory and sub directory or full path to upload directory.

* 'url' - base url and sub directory or absolute URL to upload directory.

* 'subdir' - sub directory if uploads use year/month folders option is on.

* 'basedir' - path without subdir.

* 'baseurl' - URL path without subdir.

* 'error' - set to false.

*/



// Adjust your settings here

$dir = '';

$url = '';

$subdir = '';

$bdir = '';

$burl = '';



$custom_dir = array(

'path' => $dir,

'url' => $url,

'subdir' => $subdir,

'basedir' => $bdir,

'baseurl' => $burl );

return shortcode_atts( $custom_dir, $default_dir );

}


and now in order to move the button then you will need to customize further the buttons in the dashboard. So here is how you get it http://codex.wordpress.org/Administration_Menus :

for appearance you will have to position it with: For Appearance:

add_submenu_page('themes.php',...)
or

<?php add_theme_page( $page_title, $menu_title, $capability, $menu_slug, $function); ?>



This is an example:


add_action('admin_menu', 'my_plugin_menu');

function my_plugin_menu() {
add_theme_page('My Plugin Theme', 'My Plugin', 'read', 'my-unique-identifier', 'my_plugin_function');
}


Take a look at the example in the link and you will find out how to adapt it exactly.

Thanks,