Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Custom Rating Images To Be Put In Themes Folder #36

Open
lesterchan opened this issue Jan 7, 2015 · 10 comments
Open

Allow Custom Rating Images To Be Put In Themes Folder #36

lesterchan opened this issue Jan 7, 2015 · 10 comments

Comments

@lesterchan
Copy link
Owner

https://wordpress.org/support/topic/custom-rating-images-lost-on-plugin-upgrade?replies=1#post-6404160

@ramiy
Copy link
Contributor

ramiy commented Nov 24, 2015

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.

@ramiy
Copy link
Contributor

ramiy commented Dec 26, 2015

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.

@ramiy
Copy link
Contributor

ramiy commented Dec 26, 2015

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.

@lesterchan
Copy link
Owner Author

I like the second idea!

@likwrk
Copy link

likwrk commented May 9, 2016

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/') ) );
}

@msxpro
Copy link
Contributor

msxpro commented Jun 30, 2017

lesterchan, you have plans to merge this to branch?

@lesterchan
Copy link
Owner Author

@msxpro this is not a pull request, so there is nothing to merge.

@msxpro
Copy link
Contributor

msxpro commented Jun 30, 2017

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.

@lesterchan
Copy link
Owner Author

As of now, I have no plans because I have no time to do it. Feel free to submit a Pull Request =)

@aparentMMS
Copy link

ability to upload images would be great, save a step for our administrator to re-ftp images over and over after updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants