Alias ‘wp-content’ directory to something shorter (framework?)
Alias ‘wp-content’ directory to something shorter (framework?)
Alias ‘wp-content’ directory to something shorter (framework?)
According to me, Copy the “images” folder to your root directory. That will help you. And for future upload, place this code to your wp-config.php define( ‘UPLOADS’, ”.’images’ );
This is kind of a hacky way to do this; but unfortunately, there is not a WP function that will do both (theme and/or plugin). It’s only an either/or proposition. On the surface, you’d think it wouldn’t be difficult. You could just get the path and compare it with the site URL or something like … Read more
wp_upload_dir() is perfect. It is the only place where you can expect write permissions. Store the attachment ID, not a path. Then you get the image with: wp_get_attachment_url( $attach_id ) Sometimes a user may have deleted the image per media library. To avoid problems with missing files check the return value from wp_get_attachment_url() first. Excerpt … Read more
The idea is just to programmatically create a path/url in a plugin for a WordPress site (like, “[mysite]/mypath”), and then load an arbitrary html or php file. In case anyone else is looking for something similar, this works for me (in my main plugin function file): register_activation_hook(__FILE__, ‘myplugin_activate’); function myplugin_activate () { create_custom_page(‘mytestpath’); } function … Read more
Turns out the problem was with WP_CONTENT_URL, defined inside wp-config.php: define( ‘WP_CONTENT_URL’, ‘http://’ . $_SERVER[‘HTTP_HOST’] . ‘/lab/WordPress-Skeleton/content’ ); It seems that $_SERVER[‘HTTP_HOST’] is returning an incomplete path (only localhost without the folder). Since I’m using version control and using a local-config.php to define some local dev variables (like database credentials), I also placed this on … Read more
I think you are looking for plugin_dir_url: $url = plugin_dir_url(__FILE__); $imageurl = $url.’images/someimage.png’; EDIT: Sorry I misread the question… that is only an answer to the linked question. You could check the parent directory recursively until you find the right one: function base_plugin_dir($dirpath) { if (substr(dirname($dir),-7) == ‘plugins’) {return $dirpath;} else {$dirpath = base_plugin_dir($dirpath);} return … Read more
If you just need that class included, and your script is located in the plugin directory, like /wp-content/plugins/pluginName/script.php, then you can do: require realpath(‘../../../wp-includes/class-phpass.php’);
The function plugin_dir_path has an misleading name, it doesn’t include a file from plugin directory, it just include a file from the same directory of the file passed as argument. When you call include( plugin_dir_path( __FILE__ ) . ‘test-plugin/needed_file.php’); from a file in theme directory, you are just trying to include a file from theme … Read more
The forward slash works on every operating system supported by PHP. Yes, on Windows too. It is also more readable and easier to type, so there is no need to use the constant. See the tickets #20849 and #15598 for related discussion on Trac.