willfretwell
Forum Replies Created
-
Forum: Plugins
In reply to: [PDF Image Generator] Generated thumbnail not showingThanks for your response,
I’ve sent the files via the contact form as requested.
The theme I am using is Uncode by Undsgn.
Kind Regards,
WillForum: Plugins
In reply to: [SlimStat Analytics] Thumbnails of downloadsHi Jason,
That’s great news, I will get in contact about testing.
Thanks for your help,
Kind Regards,
WillForum: Plugins
In reply to: [SlimStat Analytics] Thumbnails of downloadsThanks Jason,
Kind Regards,
WillForum: Hacks
In reply to: Front End Custom Taxonomy EditingI’m not sure how I would do that. This isn’t my code so I’m not 100% with it.
And I’ll have a look around and see what I can find!
Forum: Hacks
In reply to: Front End Custom Taxonomy Editingadd_action('plugins_loaded','wpse_init_crowd_cats_class'); function wpse_init_crowd_cats_class(){ new WPSECrowdCatsClass(); } class WPSECrowdCatsClass { function __construct() { // APPEND THE FORM AUTOMATICALLY TO EVERY POST add_shortcode( 'editcamp', array( $this,'append_form' ) ); // TEMPLATE ACTION TAG TO BE USED IN THEME // Usage: do_action('wpse_crowd_cats_form'); // Usage: do_action('wpse_crowd_cats_form', $post_id, $taxonomy ); add_action( 'wpse_crowd_cats_form', array( $this,'wpse_crowd_cats_form' ), 10, 2 ); // FORM PROCESSING add_action( 'template_redirect', array( $this,'process_request' ) ); } function process_request(){ // check submission if ( ! isset($_POST['crowd-cat-radio']) || ! is_array($_POST['crowd-cat-radio']) ) return; //TODO: check nonce // sanitize and check the input $suggested_terms = array_map( 'absint', $_POST['crowd-cat-radio'] ); $post_id = absint( $_POST['crowd-cats-pid'] ); $tax = $_POST['crowd-cats-tax']; if ( ! taxonomy_exists($tax) ) return; // Allow only existing terms. Not sure if this is needed. $args = array( 'hide_empty' => false ); $args = apply_filters( 'mcc_allowed_terms_args', $args, $post_id, $tax ); $args['fields'] = 'ids'; $allowed_terms = get_terms( $tax, $args ); foreach ( $suggested_terms as $key => $term_id ) if ( ! in_array( $term_id, $allowed_terms ) ) unset( $suggested_terms[$key] ); // Add terms to taxonomy $affected_terms = wp_set_object_terms( $post_id, $suggested_terms, $tax, false ); update_term_cache($affected_terms); return $affected_terms; } function get_form( $post_id=null, $tax='campaigns' ) { if ( is_null($post_id) || ! taxonomy_exists($tax) ) return false; $args = array( 'hide_empty' => false ); $args = apply_filters( 'mcc_get_terms_args', $args, $post_id, $tax ); $all_terms = get_terms( $tax, $args ); if ( ! $all_terms ) return false; $post_terms = wp_get_object_terms( $post_id, $tax, array( 'fields' => 'ids' ) ); $permalink = get_permalink( $post_id ); $out = "<form id='crowd-cats' action='$permalink' method='POST' > <ul >"; foreach ( $all_terms as $t ) : $checked = in_array( $t->term_id, $post_terms) ? 'checked' : ''; $out .= " <input type='checkbox' id='crowd-cat-$t->term_id' name='crowd-cat-radio[]' value='$t->term_id' $checked /> <label for='crowd-cat-$t->term_id' >".esc_attr($t->name)."</label> - "; endforeach; $out .= "</ul> <input class='campeditcss' type='submit' value='Submit' name='crowd-cats-submit'/> <input type='hidden' value='".esc_attr($tax)."' name='crowd-cats-tax'/> <input type='hidden' value='$post_id' name='crowd-cats-pid'/>"; //TODO: set nonce $out .= "</form>"; return "<button class=accordion>Assign Campaigns</button> <div id=foo class=panel> $out <br /> </div>"; } function append_form($content){ global $post; if ( 'post' != $post->post_type ) return $content; $form = $this->get_form( $post->ID ); if ( ! $form ) return $content; return "$content \n $form"; } function wpse_crowd_cats_form( $post_id=null, $taxonomy='campaigns' ) { if ( is_null($post_id) ) { global $post; $post_id = $post->ID; } echo $this->get_form( $post_id, $taxonomy ); } } // end of classThis seems to work fine, a few issues such as once a Campaign has been assigned, it cannot be unassigned if it is the last Campaign Assigned to that post (basically there has to be one campaign assigned at least)
This shows an accordion which holds checkboxes of the Campaigns (to allow people to unassign a Campaign). Is there a way to convert this into a dropdown?
Forum: Hacks
In reply to: Front End Custom Taxonomy EditingSo I’ve figured out that the code was showing blank because the ‘Campaigns’ that were created aren’t assigned to a post, once they are assigned, they show up on the drop down.
This is great but a lot of the campaigns would be empty before they are originally assigned, and the drop down I am wanting to create is the only way to assign a campaign. So I need a way of showing all ‘Campaigns’ even if they are not assigned to a post yet.
Any ideas?
Forum: Hacks
In reply to: Front End Custom Taxonomy EditingThanks Morgy however this shows up blank, once again I tried some tweaks but no joy.
Thanks for clearing that up bcworkz! I think the autocomplete feature would really help as there will end up being a lot of campaigns (possibly hundreds eventually) and could be tedious to scroll through them.
I’ve seen a few plugins and tried them out but they’re either outdated and not working or don’t have the ability to use custom taxonomies, which is why I thought some custom coding might be need as you say.
Forum: Hacks
In reply to: Front End Custom Taxonomy EditingThanks for your help Morgy!
I have created a shortcode to apply this temporarily to the sidebar, the result is seen as a drop down menu that only contains one option called “campaigns” and not my campaigns taxonomy.
I’ve tried a couple of tweaks to get around this issue but my PHP knowledge is still in it’s early stages.
Do you know might be causing this problem?
Kind Regards,
WillForum: Plugins
In reply to: [SlimStat Analytics] Tracking DownloadsThanks Jason
Forum: Plugins
In reply to: [SlimStat Analytics] Ability to track users clicksHi Jason,
Thanks that worked great! Is there any way to see what page this click happened? as the link will be placed in the side bar of each post.
Kind Regards,
Will J FretwellForum: Plugins
In reply to: [SlimStat Analytics] Ability to track users clicksThanks for your reply Jason,
I’ve tried this and can’t seem to get it to work…
<tr style="border-bottom:1px solid white;"> <td class="tg-031e"><img style="padding:0px; margin:0px; vertical-align: middle;" src="/wp-content/uploads/2016/05/designlogo-upload.png"></td> <td class="tg-031e"><a onclick="SlimStat.ss_track(event, 100, jpeg_downloaded)" style="text-align:center;" class="download_image" target="_blank" href="<?php the_post_thumbnail_url( 'full' ); ?>" download><strong>DOWNLOAD</strong> as a jpeg</a></td> </tr><br>Is this correctly entered?
Kind Regards,
Will