Open lesterchan opened 9 years ago
Actually, moving the custom images from the plugin folder to the theme folder is not so hard to develop.
The only issue that I see here is backward-compatibility.
We can do I by introducing a registration mechanism to register images folder:
function add_custom_postratings_images_folder( $folders ) {
$folders['stars_crystal'] = WP_PLUGIN_DIR.'/wp-postratings/images/stars_crystal';
$folders['stars_dark'] = WP_PLUGIN_DIR.'/wp-postratings/images/stars_dark';
return $folders;
}
add_filter( 'wp_postratings_images', 'add_custom_postratings_images_folder' );
This way, the plugin will register all the default images in a single function and external developers will be able to register custom images located in themes on extended plugins.
We can also extend this method to deprecate the 'wp_postratings_image_extension' filter and register all kinds of image extensions using an array:
function add_custom_postratings_images_folder( $folders ) {
$folders['stars(png)'] = array( WP_PLUGIN_DIR.'/wp-postratings/images/stars(png)', 'png' );
$folders['stars_crystal'] = array( WP_PLUGIN_DIR.'/wp-postratings/images/stars_crystal', 'gif' );
$folders['stars_dark'] = array( WP_PLUGIN_DIR.'/wp-postratings/images/stars_dark', 'gif' );
return $folders;
}
add_filter( 'wp_postratings_images', 'add_custom_postratings_images_folder' );
This way we don't lose backwards compatibility.
I like the second idea!
Why not just define image path
if( ! defined( 'RATINGS_IMG_DIR' ) ) {
define( 'RATINGS_IMG_DIR', apply_filters( 'wp_postratings_image_dir', plugins_url('wp-postratings/images/') ) );
}
lesterchan, you have plans to merge this to branch?
@msxpro this is not a pull request, so there is nothing to merge.
Erhhh ... sorry, asking the question better, are there plans to implement this in pluguin? Because this was also a request I made a few times, when I posted that modification on the links in the list of ratings.
As of now, I have no plans because I have no time to do it. Feel free to submit a Pull Request =)
ability to upload images would be great, save a step for our administrator to re-ftp images over and over after updates.
https://wordpress.org/support/topic/custom-rating-images-lost-on-plugin-upgrade?replies=1#post-6404160