Make WordPress Core

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#26774 closed enhancement (wontfix)

Move wp_star_rating() to be more accessible on the front end

Reported by: dgwyer's profile dgwyer Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.8
Component: Formatting Keywords:
Focuses: Cc:

Description

This is a great little function that would be useful on the front end for all sorts of things. There are many star rating Plugins out there but I'd prefer to use the core WordPress function.

At the moment wp_star_rating() is in /wp-admin/includes/template.php which is a pretty big file to include on every front end page (73 KB) and contains mostly functions that would never conceivably be used on the front end.

Is there a better location for wp_star_rating() that would make it more accessible for front end for developers?

BTW - I noticed the Codex page needs updating as the source file link incorrectly points to wp-admin/includes/formatting.php, which makes the guide for using wp_star_rating() on the front end invalid.

http://codex.wordpress.org/Function_Reference/wp_star_rating

Change History (7)

#1 @markoheijnen
11 years ago

  • Version changed from trunk to 3.8

I can see why you would love to have this on the front end but unsure if we should do it. It's a small function that doesn't load the styling now. I do believe we should replace our custom classes like star-full with dashicons-star-filled. We could even do a wp_enqueue_style('dashicons'); inside wp_star_rating(). That would make including this function a bit easier.

I do have to say that this isn't a star rating plugin but just the display function.

#3 @dgwyer
11 years ago

@kpdesign Thanks for the speedy correction Kim.

@markoheijnen:

It would be nice to use it on the front end if possible but I'm aware there are some considerations. It also depends on if we want to force usage of dashicons with wp_star_rating()?

If we want to give users flexibility to use their own font icons then I'm thinking the CSS selectors should remain generic. Also, dashicons could be enqueued by default inside wp_star_rating() as you suggested, but optionally turned off via an argument if needed.

That would make the function both easier to include and flexible at the same time.

#4 @markoheijnen
11 years ago

It it's only the HTML then I don't really see the point of moving this function. I would say that it's better to copy/paste the function if you really like it.

#5 @helen
11 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

I am not a fan of the idea of having to maintain this function to work properly and with back-compat across the front-end rather than just the admin. The more complexity we introduce, the more impossible it will be to change it later.

#6 follow-up: @markoheijnen
11 years ago

What about the non dashicons class naming? Should that be changed?

#7 in reply to: ↑ 6 @helen
11 years ago

Replying to markoheijnen:

What about the non dashicons class naming? Should that be changed?

I wouldn't remove the existing classes, as they are descriptive, but if adding existing classes means we can remove some CSS, might be worth looking at. New ticket, though.

Note: See TracTickets for help on using tickets.