Travis Ballard
Forum Replies Created
-
Forum: Plugins
In reply to: [TBTestimonials] [Plugin: TBTestimonials] Return the categoryTryin cat=”technology” just for giggles
here’s a little example page template I put together that will let users add a new testimonial as a draft. To make it a little prettier, you could move the add_testimonial_from_form() function to your functions.php
<?php function add_testimonial_from_form( $post_array ) { $required_fields = array( 'name', 'email', 'testimonial' ); foreach( $required_fields as $field_name ){ if( ! array_key_exists( $field_name, $post_array ) || empty( $post_array[ $field_name ] ) ) return new wp_error( $field_name, 'Required field is missing.' ); } # check email if( ! filter_var( $post_array['email'], FILTER_VALIDATE_EMAIL ) ) return new wp_error( 'email', 'Email is invalid.' ); # check url if it's set, it's not required if( isset( $post_array['url'] ) && ! empty( $post_array['url'] ) ){ if( ! filter_var( $post_array['url'], FILTER_VALIDATE_URL ) ) return new wp_error( 'URL', 'URL is invalid.' ); else $url = $post_array['url']; } else $url = false; $new_post = array(); $new_post['post_title'] = esc_attr( $post_array['name'] ); $new_post['post_content'] = esc_attr( $post_array['testimonial'] ); $new_post['post_status'] = 'draft'; $new_post['post_type'] = 'testimonial'; if( ! is_wp_error( $new_post_id = wp_insert_post( $new_post ) ) ) { # insert meta ## email add_post_meta( $new_post_id, 'tbtestimonial_company_email', $post_array['email'] ); ## company if( isset( $post_array['company'] ) && ! empty( $post_array['company'] ) ) add_post_meta( $new_post_id, 'tbtestimonial_company', esc_attr( $post_array['company'] ) ); ## url if( $url ) add_post_meta( $new_post_id, 'tbtestimonial_company_url', $url ); # show user notice printf( '<div class="updated">Testimonial Added and is awaiting review</div>' ); } } # template name: add testimonial get_header(); # check for new testimonail and add it if present. if( isset( $_POST['new_testimonial'] ) && is_array( $_POST['new_testimonial'] ) && count( $_POST['new_testimonial'] ) > 0 ){ if( is_wp_error( $error = add_testimonial_from_form( $_POST['new_testimonial'] ) ) ) printf( '<pre class="debug">%s</pre>', print_r( $error, 1 ) ); # dump error message } ?> <section id="content-wrap"> <form action="" method="post"> <p> <label for="author-name">Your Name</label> <input name="new_testimonial[name]" id="author-name" size="40"> </p> <p> <label for="author-email">Email Address</label> <input name="new_testimonial[email]" id="author-email" size="40"> </p> <p> <label for="author-company">Company</label> <input name="new_testimonial[company]" id="author-company" size="40"> </p> <p> <label for="author-url">Website URL</label> <input name="new_testimonial[url]" id="author-url" size="40"> </p> <p> <label for="author-testimonial">Testimonial</label> <textarea name="new_testimonial[testimonial]" id="author-testimonial" cols="100" rows="5"></textarea> </p> <p> <input type="submit" value="Submit" /> </p> </form> </section> <?php get_footer();Forum: Plugins
In reply to: [TBTestimonials] [Plugin: TBTestimonials] HTTPS BugCan any of you let me know if this is fixed in 1.6.0? Thanks.
Eric this should be fixed now. If not email me directly and I’ll make sure it gets fixed. Didn’t see this post until now, apologies.
Forum: Plugins
In reply to: [TBTestimonials] [Plugin: TBTestimonials] Return the categoryor you could return $categories ( wp_get_object_terms() call ) and then do a loop in the template to display more than 1 category.
Template Example:
{% if category %} Categories: {% for cat in category %} <span class="category">{{ cat.name }}</span> {% endfor %} {% endif %}New my_category_func for functions.php that returns array
/** * callback for category tag * */ function my_category_func(){ return wp_get_object_terms( get_the_ID(), 'tbtestimonial_category' ); }Forum: Plugins
In reply to: [TBTestimonials] [Plugin: TBTestimonials] Return the categoryI just added an update with a new template api. you can add the tag yourself by adding this to your functions.php. after that you can use it however you like.
add_action( 'tbt_template_functions', 'add_category_to_tbtestimonials' ); /** * add a 'category' variable to tbt * * @param mixed $twig */ function add_category_to_tbtestimonials( $twig ){ $twig->addGlobal( 'category', call_user_func( 'my_category_func' ) ); } /** * callback for category tag * */ function my_category_func() { $categories = wp_get_object_terms( get_the_ID(), 'tbtestimonial_category' ); if( isset( $categories[0]->name ) ) return $categories[0]->name; }Forum: Plugins
In reply to: [TBTestimonials] [Plugin: TBTestimonials] Return the categorycan you explain a little further? I added in stuff the other day for it to show a listing a based on a category. Haven’t tagged it to a new version yet as I’m working on other goodies before I do.
Good catch Ryan. That will be fixed in the next update which will probably be tomorrow or later tonight depending on when i finish these enhancements.
Jan Van Dank, maybe this will resolve it for you finally as well.
Just fixed this in my trunk version, I’ll release an update here soon. Going to work on a couple other things before pushing the update.
Forum: Plugins
In reply to: [TBTestimonials] [Plugin: TBTestimonials] jQuery Conflict with other pluginsYeah it’s nice and that’s why I did it like that to begin with. Don’t exactly recall the issue but I was having a problem getting the bundled jQuery to work correctly in the footer, so I unregistered it and used google’s version.
It’s been causing issues for a while though so I think best solution is just to remove the option to load it in the footer or come up with a better way to go about doing it. I’ll see about keeping it as I really don’t want to remove existing functionality. Though it does appear to have an undefined index for js_in_footer that I’m about to release an update for soon.
Wondering if a wp_reset_query will fix this or not. anyone still having this issue? email me, junk@ansimation.net and I’ll see what I can do.
Forum: Plugins
In reply to: [TBTestimonials] [Plugin: TBTestimonials] jQuery Conflict with other pluginsIf you disable loading jQuery in the footer under the General Settings tab it should resolve your issue. In the next version I’m going to do away with the loading the footer all together.Seems to cause a lot of issues and even though I have a work around it seems like a better idea to just do it that way and maybe help reduce some confusion.
Forum: Plugins
In reply to: [Facebook Page Publish] [Plugin: Facebook Page Publish] It is brokenwhoops, also changes line 594 to
preg_match('/access_token=(.[^&]+).*/', $access_token_url, $matches);Forum: Plugins
In reply to: [Facebook Page Publish] [Plugin: Facebook Page Publish] It is brokenIt looks like Facebook removed Offline Access from their permissions and that’s why it’s failing. https://developers.facebook.com/roadmap/offline-access-removal/
To fix this, just remove offline_access from the array on line 663 of fpp_index.php http://plugins.trac.wordpress.org/browser/facebook-page-publish/trunk/fpp_index.php#L663
It should now look like: $permissions = array(‘share_item’);
Alright, 1.5.9 was committed, you should get an update notice here shortly. Sorry I didn’t get it to you on Friday, the weekend got in the way.