Category icons for map marker != popular category widget
This topic contains 6 replies, has 3 voices, and was last updated by Stiofan O’Connor 6 years, 11 months ago.
We have moved to a support ticketing system and our forums are now closed.
Open Support TicketTagged: apply_filter, category, icon, iconurl, marker
-
AuthorPosts
-
January 4, 2018 at 9:58 am #411401
Hello,
I’ve searched the forum a bit and i think the closest one was this post: https://wpgeodirectory.com/support/topic/category-images-icons-listing-descriptions/ which is now closed due to inactivity.
What I need is something very similar, digging into the code:
File: wp-content/plugins/geodirectory/geodirectory-functions/general_functions.php
Function: geodir_helper_cat_list_output()This:
$term_icons = geodir_get_term_icon();
I saw that internally there’s an hook for that function: ‘geodir_get_term_icons’ and with that i could change the category icon url easily. The problem is that even the map marker uses the same function:
File: wp-content/plugins/geodirectory/geodirectory-functions/map-functions/get_markers.php
Function: get_markers()It would be really easy to add and practical for developers to use to make 2 very small, easy and quick changes that brings no problems at all.
For get_markers() you could make this:
$icon = !empty($geodir_cat_icons) && isset($geodir_cat_icons[$default_cat]) ? $geodir_cat_icons[$default_cat] : '';
Become this:
$icon = !empty($geodir_cat_icons) && isset($geodir_cat_icons[$default_cat]) ? $geodir_cat_icons[$default_cat] : ''; $icon = apply_filter('please_invent_one_name',$icon);
And for the geodir_helper_cat_list_output() make this:
$term_icon_url = ! empty( $term_icons ) && isset( $term_icons[ $cat->term_id ] ) ? $term_icons[ $cat->term_id ] : '';
Become this:
$term_icon_url = ! empty( $term_icons ) && isset( $term_icons[ $cat->term_id ] ) ? $term_icons[ $cat->term_id ] : ''; $term_icon_url = apply_filter('please_invent_another_name',$term_icon_url);
This way developers are free to change icons for map/popular category as they like.
Could it be possibile for you to add?
Thanks
January 4, 2018 at 1:01 pm #411412Hello!
Please take a look at this thread and see if it can be a foundation for what you want to do:
https://wpgeodirectory.com/support/topic/change-category-icons-on-detail-page/?view=all#post-411409That topic offers a snippet to swap out the category icons on the detail page.
Let us know
January 4, 2018 at 2:04 pm #411418I believe the map markers are called via ajax so you could prob wrap ay filters u want in a `if(!is_admin()){
//my filter here
}`Stiofan
January 4, 2018 at 2:17 pm #411419Thank you for the replies.
@alex: I’ve saw that already but that’s not helping. The filter is called everytime one element needs to fetch category icons, and map marker share the same function call with other elements.
@stiofan: Unfortunatly that doesn’t look the case, I’m inspecting the code with a debugger and when for example i load the detail page i never end inside admin-ajax.php.
If you check for example: wp-content/plugins/geodirectory/geodirectory_hooks_actions.php you will see:
if (!is_admin()) { .... add_action('the_post', 'create_marker_jason_of_posts'); // Add marker in json array, Map related filter }
That action is actually firing the geodir_get_term_icon() for the detail map marker.
What i suggest is to add more apply_filters that let developers the freedom to inject/modify the behaviour. I tried a dirty hack but the geodir_get_term_icon() function get called many times and there’s not always an easy way to detect whether it’s a Google Map marker call or other elements call.
January 4, 2018 at 6:42 pm #411436I am not entirely sure what you are trying to achieve? If you let me know then i will let you know how to do it.
Thanks,
Stiofan
January 5, 2018 at 9:04 am #411503Hello stiofan, my bad i didn’t explain the case i need. What i’m trying to achieve is to have “big” (90×90) custom images for popular category output and small image (30×30) for map marker. One of the way to do so is (since i can’t actually choose 2 images for one category in the back-end ) is to do the following:
1- Assign an image to the category choosing the small one (30×30), filename: myimg.png
2- Manually upload via Wp media library another image (same look as the other one but bigger size 90×90) with filename: myimg-big.pngNow i would need the filters i was speaking of to modify the icon url when rendering the popular category widget and append “-big” to the filename part.
If this can’t be done i guess i’ll just use big images directly in the backend and try to resize via css or gmap configs the marker icon size.
Please say if it’s not clear yet,
Cheers
January 5, 2018 at 10:49 am #411515There is no “easy” way to do this at the moment, and we might be changing this in v2 to i am hesitant to add new filters just now. It might be easier to copy the widget code and rename it to create a new widget and make the changes in ur new functions, or as u said try the CSS or JS route.
Thanks,
Stiofan
-
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket