' . __('Settings Saved.', 'aparg-watermark-and-resize') . '
'; } ?> blogid; if($apwr_logo['type'] == 'image/jpeg') $apwr_ext = '.jpg'; if($apwr_logo['type'] == 'image/png') $apwr_ext = '.png'; $apwr_logo["name"] = $apwr_blogid . $apwr_ext; add_filter('upload_dir', 'apwr_upload_dir'); $movefile = wp_handle_upload($apwr_logo, array('test_form' => false)); if ($movefile && !isset($movefile['error'])) { return $movefile; } else { return $movefile['error']; } } return ''; } /** * Set upload image dir and empty this folder */ function apwr_upload_dir($movefile) { $movefile['subdir'] = '/img'; $movefile['path'] = plugin_dir_path(__FILE__) . $movefile['subdir']; $movefile['url'] = plugins_url('aparg-watermark-and-resize') . $movefile['subdir']; global $wpdb; $apwr_blogid = $wpdb->blogid; array_map('unlink', glob($movefile['path'] ."/". $apwr_blogid .".*")); return $movefile; }