Use a separate upload folder for custom post attachment upload

I ended up solving it by completely bypassing the wp upload system, so this is how it looks now: /* * Define new upload paths */ $uploadfolder = WP_CONTENT_DIR . ‘/exames’; // Determine the server path to upload files $uploadurl = content_url() . ‘/exames/’; // Determine the absolute url to upload files define(RM_UPLOADDIR, $uploadfolder); define(RM_UPLOADURL, … Read more

How MUST the directory for a plugin be structured?

How does WordPress determine “the main plugin file” ? It is the file in your plugin that contains the plugin header comment /** * Plugin Name: A fresh example * Plugin URI: http://example.com * Description: Foo makes a bar * Version: 2012-06-14.1426 * Author: John Doe * Author URI: http://example.com * TextDomain: your_textdomain * License: … Read more

How to move page template files like page-{slug}.php to a sub-directory?

How Page Templates are loaded: According to the default WordPress Template Hierarchy, a page request loads a template based on the priority and naming as stated below: Custom Page Template: if defined in the page editor. page-{slug}.php page-{url-encoded-slug}.php: only for multi-byte characters. page-{id}.php page.php singular.php index.php Among these, singular.php and index.php are not actually page … Read more

Get a path to a different plugin

My best guess would be: if ( ! is_file( $dir = WPMU_PLUGIN_DIR . ‘/pluginb/pluginb.php’ ) ) { if ( ! is_file( $dir = WP_PLUGIN_DIR . ‘/pluginb/pluginb.php’ ) ) $dir = null; } return $dir; However, the danger here is still the assumption of the plugin’s “basename” – a well written plugin will still function even … Read more

Change upload directory for PDF files

Following Justice Is Cheap lead, I ended adapting the functions from this plugin: http://wordpress.org/extend/plugins/custom-upload-dir/ <?php /* * Change upload directory for PDF files * Only works in WordPress 3.3+ */ add_filter(‘wp_handle_upload_prefilter’, ‘wpse47415_pre_upload’); add_filter(‘wp_handle_upload’, ‘wpse47415_post_upload’); function wpse47415_pre_upload($file){ add_filter(‘upload_dir’, ‘wpse47415_custom_upload_dir’); return $file; } function wpse47415_post_upload($fileinfo){ remove_filter(‘upload_dir’, ‘wpse47415_custom_upload_dir’); return $fileinfo; } function wpse47415_custom_upload_dir($path){ $extension = substr(strrchr($_POST[‘name’],’.’),1); if(!empty($path[‘error’]) || … Read more

get_template_directory() vs bloginfo( ‘template_directory’ ) vs TEMPLATEPATH

To make a long story short: get_bloginfo( ‘template_directory’ ) and get_bloginfo( ‘template_url’ ) simply return get_template_directory_uri(). So, you can shortcut that second call simply by referring directly to the latter template tag. Refer to source for get_bloginfo(). A few others: ‘url’ => home_url() ‘wpurl’ => site_url() ‘stylesheet_url’ => get_stylesheet_uri() ‘stylesheet_directory’ => get_stylesheet_directory_uri() ‘locale’ => get_locale() … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)