Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * @package myplug
- */
- /*
- Plugin Name: myplug
- Plugin URI: myplug
- Description: myplug
- Domain Path: /lang
- Version: 0.1
- Author: myplug
- Author URI: myplug
- License: GPLv2 or later
- */
- if ( ! class_exists('myplug') )
- {
- class myplug
- {
- public function __construct()
- {
- add_action('admin_menu', array(&$this, 'myplug_adminmenu'));
- }
- public function myplug_upload_dir_inside()
- {
- return array(
- 'path' =>plugin_dir_path( __FILE__ ).'uploadtmp',
- 'url' => plugin_dir_url( __FILE__ ).'uploadtmp',
- 'subdir' => '',
- 'basedir' =>plugin_dir_path( __FILE__ ).'uploadtmp',
- 'baseurl' => plugin_dir_url( __FILE__ ).'uploadtmp',
- 'error' => false
- );
- }
- public function myplug_menu()
- {
- //Neither this call works
- // add_filter('upload_dir', array(&$this, 'myplug_upload_dir_inside'));
- //Nor this call either works !
- // add_filter('upload_dir', 'myplug_upload_dir_outside');
- echo '<pre>'; print_r(wp_upload_dir()); echo '</pre>';
- wp_enqueue_script('plupload-handlers');
- $form_class = 'media-upload-form type-form validate';
- echo '<form enctype="multipart/form-data" method="post" action="'.admin_url("media-upload.php?inline=&upload-page-form=").'" class="'.$form_class.'" id="file-form">';
- media_upload_form();
- echo '
- <script type="text/javascript">
- jQuery(function($){
- var preloaded = $(".media-item.preloaded");
- if ( preloaded.length > 0 ) {
- preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, "")},"");});
- }
- updateMediaForm();
- post_id = 0;
- shortform = 1;
- });
- </script>
- <input type="hidden" name="post_id" id="post_id" value="0" />';
- wp_nonce_field("media-form");
- echo '<div id="media-items" class="hide-if-no-js"></div>';
- submit_button( __( "Save all changes" ), "button savebutton hidden", "save" );
- echo '</form>';
- // remove_filter('upload_dir', 'manuland_upload_dir');
- }
- public function myplug_adminmenu()
- {
- add_menu_page('Myplugin', 'Myplugin', 'manage_options', 'myplug_menu', array(&$this, 'myplug_menu'));
- }
- }
- }
- $myplug = new myplug();
- function myplug_upload_dir_outside()
- {
- return array(
- 'path' =>plugin_dir_path( __FILE__ ).'uploadtmp',
- 'url' => plugin_dir_url( __FILE__ ).'uploadtmp',
- 'subdir' => '',
- 'basedir' =>plugin_dir_path( __FILE__ ).'uploadtmp',
- 'baseurl' => plugin_dir_url( __FILE__ ).'uploadtmp',
- 'error' => false
- );
- }
- //This call works though !
- //add_filter('upload_dir', 'myplug_upload_dir_outside');
- //BUT this filter can't be limited to this plugin : when i upload from library the upload dir is also filtered
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement