jasonkadlec
Forum Replies Created
-
Forum: Plugins
In reply to: [SearchWP Live Ajax Search] Add link to view all results?Ah so easy!
I’m using a search form, and so I updated the button to say “view all results” – when clicked, it submits the form / page redirects to the .com/?search=etc-etc
No need to put a link at the bottom, just use a button next to the input field which will submit the form.
Forum: Plugins
In reply to: [SearchWP Live Ajax Search] Add link to view all results?Update ( not solved yet) — it looks like search-results.php should just work like whatever would be used on search.php in a default theme… however
the_search_query();
as well as
get_search_query()
are both NULL….
Maybe javascript really is the way to go since once the search is open…the user can keep typing which keeps interacting with the search, so the “view all” link should be keeping track of/live updating itself to whatever is actually getting typed in… hmmm.
OOPS! Note the above code will break!! I forgot that if the achievement is not yet earned, the code that normally renders the achievement breaks as several things rely on $achievement being a post object… so you need to be sure to add:
$achievement = get_post($achievement_ID);
Here is the full code again
add_filter( 'badgeos_render_achievement', 'learnCMS_render_badge', 10, 2 ); function learnCMS_render_badge ($output, $achievement_ID) { wp_enqueue_script( 'badgeos-achievements' ); wp_enqueue_style( 'badgeos-widget' ); // check if user has earned this Achievement, and add an 'earned' class $earned_status = badgeos_get_user_achievements( array( 'user_id' => $user_ID, 'achievement_id' => absint( $achievement_ID ) ) ) ? 'user-has-earned' : 'user-has-not-earned'; // Setup our credly classes $credly_class = ''; $credly_ID = ''; // If the achievement is earned and givable, override our credly classes if ( 'user-has-earned' == $earned_status && $giveable = credly_is_achievement_giveable( $achievement_ID, $user_ID ) ) { $credly_class = ' share-credly addCredly'; $credly_ID = 'data-credlyid="'. absint( $achievement_ID ) .'"'; } $achievement = get_post($achievement_ID); // Each Achievement $output = ''; $output .= '<div id="badgeos-achievements-list-item-' . $achievement_ID . '" class="badgeos-achievements-list-item '. $earned_status . $credly_class .'"'. $credly_ID .'>'; // Achievement Image $output .= '<div class="badgeos-item-image">'; $output .= '<a href="' . get_permalink( $achievement_ID ) . '">' . badgeos_get_achievement_post_thumbnail( $achievement_ID ) . '</a>'; $output .= '</div><!-- .badgeos-item-image -->'; // Achievement Content $output .= '<div class="badgeos-item-description">'; // Achievement Title $output .= '<h2 class="badgeos-item-title"><a href="' . get_permalink( $achievement_ID ) . '">' . get_the_title( $achievement_ID ) .'</a></h2>'; // Achievement Short Description $output .= '<div class="badgeos-item-excerpt">'; $output .= badgeos_achievement_points_markup( $achievement_ID ); if ('user-has-earned' == $earned_status) { $excerpt = badgeos_render_earned_achievement_text($achievement_ID, get_current_user_id()); } else { $excerpt = !empty( $achievement->post_excerpt ) ? $achievement->post_excerpt : $achievement->post_content; } $output .= wpautop( apply_filters( 'get_the_excerpt', $excerpt ) ); $output .= '</div><!-- .badgeos-item-excerpt -->'; // Render our Steps if ( $steps = badgeos_get_required_achievements_for_achievement( $achievement_ID ) ) { $output.='<div class="badgeos-item-attached">'; $output.='<div id="show-more-'.$achievement_ID.'" class="badgeos-open-close-switch"><a class="show-hide-open" data-badgeid="'. $achievement_ID .'" data-action="open" href="#">' . __( 'Show Details', 'badgeos' ) . '</a></div>'; $output.='<div id="badgeos_toggle_more_window_'.$achievement_ID.'" class="badgeos-extras-window">'. badgeos_get_required_achievements_for_achievement_list_markup( $steps, $achievement_ID ) .'</div><!-- .badgeos-extras-window -->'; $output.= '</div><!-- .badgeos-item-attached -->'; } $output .= '</div><!-- .badgeos-item-description -->'; $output .= '</div><!-- .badgeos-achievements-list-item -->'; return $output; }
thanks Michael!
oops – I see you answered my follow up question already.
Anyway for anyone wanted to show the Congrats text instead of the normal text when using the single achievment shortcode, add this to your functions.php
add_filter( 'badgeos_render_achievement', 'learnCMS_render_badge', 10, 2 ); function learnCMS_render_badge ($output, $achievement_ID) { wp_enqueue_script( 'badgeos-achievements' ); wp_enqueue_style( 'badgeos-widget' ); // check if user has earned this Achievement, and add an 'earned' class $earned_status = badgeos_get_user_achievements( array( 'user_id' => $user_ID, 'achievement_id' => absint( $achievement_ID ) ) ) ? 'user-has-earned' : 'user-has-not-earned'; // Setup our credly classes $credly_class = ''; $credly_ID = ''; // If the achievement is earned and givable, override our credly classes if ( 'user-has-earned' == $earned_status && $giveable = credly_is_achievement_giveable( $achievement_ID, $user_ID ) ) { $credly_class = ' share-credly addCredly'; $credly_ID = 'data-credlyid="'. absint( $achievement_ID ) .'"'; } // Each Achievement $output = ''; $output .= '<div id="badgeos-achievements-list-item-' . $achievement_ID . '" class="badgeos-achievements-list-item '. $earned_status . $credly_class .'"'. $credly_ID .'>'; // Achievement Image $output .= '<div class="badgeos-item-image">'; $output .= '<a href="' . get_permalink( $achievement_ID ) . '">' . badgeos_get_achievement_post_thumbnail( $achievement_ID ) . '</a>'; $output .= '</div><!-- .badgeos-item-image -->'; // Achievement Content $output .= '<div class="badgeos-item-description">'; // Achievement Title $output .= '<h2 class="badgeos-item-title"><a href="' . get_permalink( $achievement_ID ) . '">' . get_the_title( $achievement_ID ) .'</a></h2>'; // Achievement Short Description $output .= '<div class="badgeos-item-excerpt">'; $output .= badgeos_achievement_points_markup( $achievement_ID ); if ('user-has-earned' == $earned_status) { $excerpt = badgeos_render_earned_achievement_text($achievement_ID, get_current_user_id()); } else { $excerpt = !empty( $achievement->post_excerpt ) ? $achievement->post_excerpt : $achievement->post_content; } $output .= wpautop( apply_filters( 'get_the_excerpt', $excerpt ) ); $output .= '</div><!-- .badgeos-item-excerpt -->'; // Render our Steps if ( $steps = badgeos_get_required_achievements_for_achievement( $achievement_ID ) ) { $output.='<div class="badgeos-item-attached">'; $output.='<div id="show-more-'.$achievement_ID.'" class="badgeos-open-close-switch"><a class="show-hide-open" data-badgeid="'. $achievement_ID .'" data-action="open" href="#">' . __( 'Show Details', 'badgeos' ) . '</a></div>'; $output.='<div id="badgeos_toggle_more_window_'.$achievement_ID.'" class="badgeos-extras-window">'. badgeos_get_required_achievements_for_achievement_list_markup( $steps, $achievement_ID ) .'</div><!-- .badgeos-extras-window -->'; $output.= '</div><!-- .badgeos-item-attached -->'; } $output .= '</div><!-- .badgeos-item-description -->'; $output .= '</div><!-- .badgeos-achievements-list-item -->'; return $output; }
Oops – replied to the wrong thread…
I’ll update to 3.03 and see if it persists, & if I can get a window, will make a screen cast of it happening.
J
Forum: Plugins
In reply to: [Comments - wpDiscuz] Enable Pagination instead of "Load More"Awesome!!!!
Forum: Plugins
In reply to: [Comments - wpDiscuz] Get a list of deep links to comments by user_id?Nevermind… I’ve reposted this as a different question:
Will WPDiscuz offer pagination in addition to the “Load more” button.
Pagination would create the ability to link directly to a comment that is buried on the Nth page.
Forum: Plugins
In reply to: [BadgeOS] Achievement Categories / How to solve this req. ?Michael:
Thanks! It’s a huge time saver when someone who knows the plugin better can point the way to useful functions.
With badgeos_get_children_of_achievement and badgeos_get_parent_of_achievement, I think I can turn the sketch into code and make it work.
Forum: Plugins
In reply to: [BadgeOS] Achievement Categories / How to solve this req. ?Of course – I’d not leave edits in rules-engine.php, I’m just trying to figure out what does what.
By default WordPress, I meant things like leaving a comment, logging in vs. specific achievements.
I wouldn’t need to check how many times a step is required… what I want is as simple as:
Trigger = Achievement has been Awarded… OK so look and see if that Achievement was a required Step of some other Achievement.
If it was, go see what other steps that Achievement has, and also see if there is a number set in that Achievement’s custom posts.
So let’s say that I was just awarded the Achievement “Thing One.”
Thing One is a required step of the Achievement “Lesson 1.” Lesson 1 also has steps Thing 2 and Thing 3, Thing 4 and has that custom field value set at 3.
Now look at the User’s Achievements — look for Thing 2, Thing 3, Thing 4 in the achievements awarded so far, and count up how many were found.
Compare the Count with the custom field value.
If the count is equal to or greater than the value of the custom field, then Award the Achievement Lesson 1.
… Thus overriding the default behavior which requires that the user must have ALL the steps Thing 1, Thing 2, Thing 3 and Thing 4 in order to earn the Lesson 1 badge.
So it is just a matter of figuring out:
How do I figure out if an Achievement is a required step of another Achievement?
How do I figure out all the required steps of a given Achievement, and further more get the ID’s of the actual Achievements that are the steps.
Sounds like Steps are a private post type serving as a linking table between Achievements.
Anything I’m not understanding that would prevent what I’ve sketched out from working?
Forum: Plugins
In reply to: [BadgeOS] Achievement Categories / How to solve this req. ?I’m a bit confused as to how function badgeos_user_deserves_step works?
It seems like that’s the thing I need to emulate/filter?
I successfully got a custom field added to the Achievement so I can set my “step override.”
Again – here is what I’m looking to do:
I have an Achievement that is earned by completing steps:
https://cl.ly/image/3F3E0H0Y1V2O
I’ve created 3 such steps, of specific Achievement Type, and then selected the specific Achievement within that type:
https://cl.ly/image/3e2z1b423u0n
I now have a custom field added to the Achievement (the main one, that has the required steps):
https://cl.ly/image/1y313y45291H
Just to see if I could understand what does what… I tried this:
function badgeos_user_deserves_step( $return = false, $user_id = 0, $step_id = 0 ) { // Only override the $return data if we're working on a step if ( 'step' == get_post_type( $step_id ) ) { if (!empty(get_post_meta( $step_id, 'wpcf-how-many-steps', true ))) { $minimum_activity_count = absint( get_post_meta( $step_id, 'wpcf-how-many-steps', true ) ); } else { $minimum_activity_count = absint( get_post_meta( $step_id, '_badgeos_count', true ) ); } // Grab the relevent activity for this step $relevant_count = absint( badgeos_get_step_activity_count( $user_id, $step_id ) ); // If we meet or exceed the required number of checkins, they deserve the step if ( $relevant_count >= $minimum_activity_count ) $return = true; else $return = false; } return $return; } add_filter( 'user_deserves_achievement', 'badgeos_user_deserves_step', 10, 3 );
— meaning I directly edited rules-engine.php at line 401.
Where wpcf-how-many-steps — is my custom field… I even just tried hard setting
$minimum_activity_count = 2;
Just to see if that is what is being checked… and it doesn’t appear to be the thing.
So need your help a little bit more…
It seems like if the Achievement is set to “require steps” — this is the only rule in the rules-engine.php that would seem to apply?
It looks like this rule calls the function badgeos_get_step_activity_count at the bottom there… which is where we total up how many steps for that achievement have been awarded?
Do these functions only pertain to steps that are the default WordPress kind of steps?
Thanks for your help! I’d love to get this to work and then you could check it into a future update ha ha!
Forum: Plugins
In reply to: [BadgeOS] Achievement Categories / How to solve this req. ?Interesting — can you confirm 1 thing and then let me know if you’d consider the 2nd:
1st:
I can create a new function – like the points — that says if the achievement type is required steps — then get the total number of steps, and if the user has at least total number -1, then achieve the award.
This would mean that 3 out of 4 steps, 9 out of 10 steps etc would always get the badge… but I’d always be locked into Total – 1.
2nd:
Would you consider making it a feature so that when “required steps” is chosen, that we can also set in that screen the number of those specific steps would be required to earn the Achievement?
OR
Can you point me towards how I could add in such an additional field so it surfaces in the admin, but only when the user as selected Requires Steps – so it loads with the rest of that UI where they select the steps.
And/or — I suppose I could use the Custom Fields / Types style plugin (or write into functions) to add a custom field to the created Achievement Post Type and then go looking for a value in that field instead of just the Total – 1 idea above…
OK that’s what I’m going to do for now… but I think it would be a super useful feature to allow the require at least _____ steps to be available in BOTH the way it is now (require ____ number of steps of (select achievement type).
AND also when setting a “Require Steps” — make it so that it either requires all the steps, or allows the end user to specify how may of those steps specified would be required to earn the achievement.
Thanks for considering.
Thanks for answering so fast!
Thanks for answering with useful link straight to the thing I need.
YO. You da man.
Forum: Plugins
In reply to: [BadgeOS] Points Per Achievement?Thanks!
Forum: Plugins
In reply to: [BadgeOS] badgeos_achievements_list include= param gives unexpected resultsit was never a problem.
Forum: Plugins
In reply to: [BadgeOS] Submissions loading comments on the confirm pageYep, that does the trick. Thanks!