- This topic is empty.
-
AuthorPosts
-
October 15, 2014 at 11:00 am #186324
sbertrand
ParticipantIs there any way to add a copy link link/button to the share portion of this? (Currently using the QuickShare plug in). So that instead of routing to email or other social media they have the direct option of copying (and/or pasting) the link? Thanks!
October 15, 2014 at 4:24 pm #186334drose379
Participant$_SESSION['url'] = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
Will get you the link and save it in a session.October 15, 2014 at 4:27 pm #186335sbertrand
ParticipantWhere would I put this in? The plug in folder file for quickshare and that php file?
October 15, 2014 at 4:28 pm #186336drose379
ParticipantMaybe, I’ve never used a plugin before. Do you have any code to show? Maybe I could help you that way.
October 15, 2014 at 4:34 pm #186337sbertrand
Participant$class .= '-color'; } } else { $class = 'quickshare-text'; if(cxnh_quickshare_getOption('text_icons',$options)) $class .= ' qs-genericons'; } //effects if(cxnh_quickshare_getOption('effect-spin',$options)) $class .= ' quickshare-effect-spin'; if(cxnh_quickshare_getOption('effect-round',$options)) $class .= ' quickshare-effect-round'; if(cxnh_quickshare_getOption('effect-glow',$options)) $class .= ' quickshare-effect-glow'; if(cxnh_quickshare_getOption('effect-expand',$options)) $class .= ' quickshare-effect-expand'; if(cxnh_quickshare_getOption('effect-contract',$options)) $class .= ' quickshare-effect-contract'; //size if(cxnh_quickshare_getOption('size',$options)) // ie, if not "normal" $class .= ' quickshare-' . cxnh_quickshare_getOption('size',$options); return $class; } function cxnh_quickshare_get_post_image() { global $post; $imgdata; // if there's a featured image, use it if(has_post_thumbnail()) $imgdata = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'medium' ); elseif(is_attachment()) $imgdata = wp_get_attachment_image_src( $post->ID, 'medium' ); // attachment post type, so post id is attachment id else { // next, try grabbing first attached image $args = array( 'numberposts' => 1, 'post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image' ); $attachments = get_children( $args ); //array is keyed by attachment id if(!empty($attachments)) { $rekeyed_array = array_values($attachments); $imgdata = wp_get_attachment_image_src( $rekeyed_array[0]->ID , 'medium' ); } else { //finally, look for the first img tag brute-force. Presumably if there's a caption or it's a gallery or anything it should have come up as an attachment $result = preg_match_all( '/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches ); // find imag tags, grab srcs if($result > 0) return $matches[1][0]; // return first img src, no way to select size if we've gotten this deep } } if(!empty($imgdata)) return $imgdata[0]; //image url else return cxnh_quickshare_getOption('image'); } function cxnh_quickshare_get_post_description() { // essentially a summary of get_the_excerpt(), but avoiding most filters other than custom ones (otherwise results in infinite loop) $post = get_post(); $excerpt = $post->post_excerpt; if($excerpt == '') $excerpt = $post->post_content; $excerpt = wp_trim_words($excerpt, 40); //do this first so we aren't processing a ton of data $excerpt = strip_shortcodes( $excerpt ); $excerpt = strip_tags($excerpt); $excerpt = str_replace(']]>', ']]>', $excerpt); return $excerpt; }
<–This is the quickshare php file code.
October 15, 2014 at 4:37 pm #186338drose379
ParticipantDo you know how to create functions? I would add a property to the class there called ‘url’ and create a method (function) that gets the url of the page using the code I pasted above.
$this->url = $url
and have the method return $this->url. You can then use that value whenever you need it as long as an instance of the class is created.October 15, 2014 at 4:40 pm #186339drose379
ParticipantI actually have something the exact same as what you want on a site I have.
October 15, 2014 at 4:51 pm #186340sbertrand
ParticipantIt’s been a long long time since I’ve had to write a function…I happen to lean more designer and less coder, but apparently it’s time I learned a bit more, sigh…so something like this?
function url () {
$this->url = $url;
$_SESSION['url'] = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
}
<code></code>
And then would I insert it somewhere else besides my main function.php file?October 15, 2014 at 4:59 pm #186342drose379
ParticipantOctober 15, 2014 at 5:45 pm #186343sbertrand
ParticipantWell, I inserted what you sent over and it gave me a lot of error messages…and to clarify – I am not inserting to a single page, but to the plug in because this needs to be included on all the pages, lightboxes, post pages, etc.
BTW – thank you for all your help. If I knew who you were or where you were at, I’d invite you to share a nice beverage with me. :)
October 16, 2014 at 11:32 am #186405drose379
ParticipantSorry, what I sent was not ready to be thrown right into code. It would have to be tailored to how you set up your code in order to work.
-
AuthorPosts
- The forum ‘Back End’ is closed to new topics and replies.