开发者 | celloexpressions |
---|---|
更新时间 | 2023年9月18日 07:49 |
PHP版本: | 3.5 及以上 |
WordPress版本: | 6.3 |
版权: | GPLv2 |
[quickshare]
shortcode to display QuickShare wherever you'd like in any of your posts/pages. You can also exclude posts by id, or even use a custom output function in your templates, including the ability to override the default generated sharing data.
As a bonus, QuickShare includes several built-in CSS3 effects for hover state animations.
Please visit the plugin support forum for help with custom css snippets and/or feature requests!
Please note that QuickShare does not and will not support link tracking, because of its goal of being simple and lightweight. You can use a 3rd-party tool like Google Analytics to track shares as external links.
/wp-content/plugins/
directorywp_head()
action hook and uses the_content()
; this is where QuickShare hooks into. Alternately, add <?php do_quickshare_output(); ?>
to your template files.There are several ways to control where QuickShare is displayed:
the_content
for posts, pages, attachments, or all posts of any type, from the QuickShare Config settings page.[quickshare]
shortcode. This shortcode can be placed anywhere within a post or page, including in multiple places. You can use the shortcode with or without the automatic filtering of displaying on posts/pages/attachments, but be careful not to accidentally use the shortcode at the end of a post where the automatic filtering is turned on, because you'll get two instances of QuickShare right next to each other. To use the shortcode, simply add "[quickshare]
" to your posts/pages wherever you want QuickShare to display. It's that easy! REQUIRES VERSION 1.4+<?php do_quickshare_output( $url, $title, $source, $description, $imgurl ); ?>
in their template files wherever sharing is desired, with the optional parameters allowing custom share data to be provided (see details below, under "share bar doesn't display").Pinterest is image-centric, so any content to be shared via Pinterest should include an image. QuickShare attempts to find an image in each post by first looking for a featured image, then grabbing the first attached image, looking for a raw image tag, or finally falling beck to a site-wide default image that you can set. You can also hide Pinterest sharing if no post image is found. The post image will also be used for Facebook and Google+ sharing, by default (if open graph meta tags are enabled). For best results, always set a featured image in your post.
QuickShare provides many options for design customization, but if you want to go as far as changing the share images (if Genericons aren't working for you either), you can! Just throw in some custom CSS, based on the code in quickshare.css
. You could even use your own icon font in place of Genericons!
If you look at quickshare.css, you'll notice that the majority of the plugin's options are controlled through CSS. I recommend poking around in there to get some ideas, then adding your styles to the custom CSS field in the admin settings page. Placing the code here will ensure it overrides all plugin options. Depending on the share display type (icons/genericons/text), you can change icon and background colors and sizes, adjust shadows and borders, change how the plugin fits with your theme's layout (margins, padding, horizontal separations), add more CSS3 effects, and more! Unfortunately, it will be necessary to use !important
in some places.
An unfortunately large number of themes have not-fully-thought-out styling that interferes with QuickShare. Please post in the support forums with a link to your site and I can provide the appropriate custom CSS that will fix it for your site (I have seen themes do this in many, many different ways, so the steps QuickShare takes to resolve the issues are somethimes insufficient).
QuickShare can only display after posts use the_content()
. One example of where QuickShare can't display is in gallery post formats on index and archive (not single view) pages in the Twenty Thirteen theme. However, if you have a custom theme or a child theme, you can customize the QuickShare output by adding <?php do_quickshare_output(); ?>
to your template files somewhere within the loop.
For additional customization, you can use <?php do_quickshare_output( $url, $title, $source, $description, $imgurl ); ?>
, where $url
is the link to the content to share, $title
is the title, $source
is the name of your website/blog, $description
is a short description, and $imgurl
is the thumbnail image url. This version of the custom QuickShare output can be used anywhere in your templates, inside or outside of the loop, opening the door to many customization options. If any of the parameters are null, QuickShare will attempt to populate them with the default values (using the $post
global). Please remember to wrap this and all other plugin functions with <a href="http://bradblogging.com/coding/stop-breaking-your-wordpress-theme-with-plugins-use-the-if-function-exists-option/">if(function_exists())</a>
to avoid killing your site if/when the plugin is deactivated.
An example of a website using QuickShare in a custom context is Euclid's Muse, on app display pages.
QuickShare is designed for modern browsers. I do not (and will not make much effort to) support IE8 or below, and do not support features that aren't achievable with minimal CSS in other outdated browsers (including, now, IE9). That being said, if you find a compatibility issue with an easy fix, let me know on the support forums and I'll consider including it. In the meantime, you can always add any desired CSS to the custom CSS field without worrying about losing plugin edits to updates. For the most part, everything should fail gracefully; older browsers won't see special effects like rounded corners, transitions/animations, box shadows, and opacity filters, but will be functionally fine. Genericons do not work in several browsers (including IE7 and IE9 mobile, but not IE9 desktop), so don't use that display option if you need lots of browser support.
If you think QuickShare should support sharing to additional networks, please let me know in the support forums and I'll consider adding support. I don't intend to add any more networks that would be enabled by default (or automatically enabled after an update), though.
The one caveat to the bloat-less implementation and philosophy that QuickShare uses is that there is no good way to track shares. It is technically possible to track the number of times users take the initial action of pressing the share button on your site; however, there is no way to confirm that the action was completed without pulling in data from the various networks (typically via their javascripts). Furthermore, there is no clean way to store internal statistics (number of times each action was initiated) without polluting the database and making the sharing process more technically complex. Therefore, I don't plan on adding this functionality; if you find a possible alternative solution, please let me know and I will consider it. You should be able to track QuickShare shares as external links with analytics software such as Google Analytics if you're interested in tracking shares (versus displaying the data publicly).
QuickShare does not work in WordPress versions below 3.5 (it will probably throw a php fatal error when attempting to activate). For best results, always use the latest version of WordPress.
[quickshare]
anywhere in your posts/pages, even if QuickShare is disabled for that post type by default.the_excerpt
, which can get especially nasty if themes strip out html in a later filter. You can manually add QuickShare back to these places in your templates.<ul><a><li>
to <ul><li><a><span>
. This allows the output to be valid html (<a>
s aren't allowed as direct children of <ul>
s). Refactored plugin CSS accordingly and was able to remove much of the styling for the share text. Custom CSS will probably also require some minor refactoring.if_function_exists()
in conjunction with do_quickshare_output()
to the FAQ