Plugin Directory

Changeset 636253


Ignore:
Timestamp:
12/09/2012 07:33:52 PM (13 years ago)
Author:
WebsiteBakery
Message:

1.4 release

Location:
shopp-seo-glue
Files:
1 added
1 edited
4 moved

Legend:

Unmodified
Added
Removed
  • shopp-seo-glue/tags/1.4/readme.txt

    r625773 r636253  
    55Requires at least: 3.4.1
    66Tested up to: 3.4.2
    7 Stable tag: 1.3
     7Stable tag: 1.4
    88License: GPL3 or later
    99License URI: http://www.gnu.org/licenses/gpl.html
     
    2121
    2222*   WordPress 3.4.2
    23 *   Shopp 1.2.3 (right now I also *expect* it to work on the planned 1.2.4 and 1.3 future releases)
    24 *   WordPress SEO 1.2.8.7
     23*   Shopp 1.2.5
     24*   WordPress SEO 1.3.1.1
    2525
    26 No other configurations have been tested and this plugin will not work (and anyway should not be required) if you are using the old 1.1 branch
    27 of Shopp.
     26No other configurations have been tested and this plugin will not work (and anyway should not be required) if you are using
     27the old 1.1 branch of Shopp.
    2828
    29 This plugin was written by [Barry Hughes](http://freshlybakedwebsites.net/ "WordPress developer and designer, Vancouver Island") ... if you want to support this plugin or are in need of some positive karma then feel free to [buy Barry a beer](http://freshlybakedwebsites.net/say-thanks-with-a-beer/) - contributions also by [Lars Koudal](http://cleverwp.com/).
     29This plugin was written by [Barry Hughes](http://freshlybakedwebsites.net/ "WordPress developer and designer, Vancouver Island")
     30... if you want to support this plugin or are in need of some positive karma then feel free to
     31[buy Barry a beer](http://freshlybakedwebsites.net/say-thanks-with-a-beer/) - contributions also by
     32[Lars Koudal](http://cleverwp.com/).
    3033
    3134== Installation ==
     
    3336It's just like any other plugin!
    3437
    35 Either upload the zipped plugin archive using the Add New Plugin screen in WordPress, or unzip and upload the _shoppseoglue_ directory so that
    36 it resides within your wp-content/plugins directory ... then activate!
     38Either upload the zipped plugin archive using the Add New Plugin screen in WordPress, or unzip and upload the _shoppseoglue_ directory
     39so that it resides within your wp-content/plugins directory ... then activate!
    3740
    38 This plugin does not generate any new admin screens or anything else - it simply mediates between Shopp and WordPress SEO - both of which must of
    39 course be installed and activated first of all. Otherwise Shopp SEO Glue will sit and do nothing at all.
     41This plugin does not generate any new admin screens or anything else - it simply mediates between Shopp and WordPress SEO - both of
     42which must of course be installed and activated first of all. Otherwise Shopp SEO Glue will sit and do nothing at all.
    4043
    4144== Frequently Asked Questions ==
    4245
    43 = Why can't I customize product categories? =
     46= Why do I need this? =
    4447
    45 You can! This has been available as of version 1.2.
     48Shopp uses custom post types and custom taxonomies, it's true, but it does not use the standard WordPress-generated post and
     49taxonomy editors. For that reason, WordPress SEO has a hard time integrating with Shopp.
    4650
    47 = The snippet preview URL is wrong! =
    48 
    49 This was a known issue that has been addressed in Shopp SEO Glue 1.1. So if you were one of the first people to test out Shopp SEO Glue then please
    50 ensure you have updated to the latest stable version and try again. If it is still a problem then you may simply *need to save your product* to
    51 refresh the Snippet Preview.
     51This plugin aims to solve that problem by doing the legwork needed to make these plugins play nicely with one another.
    5252
    5353= How about All in One SEO Pack? =
    5454
    5555To the best of my knowledge All in One SEO Pack works with Shopp 1.2 without any problems. Consequently, this plugin does not integrate with
    56 AIOSEOP in any way whatsoever (there's no need!).
     56AIOSEOP in any way whatsoever (there's no need).
    5757
    5858= Is this actively maintained ... what's next on the roadmap? =
    5959
    60 It's not really actively maintained insofar as the plugin author rarely uses it - that said, any solid contributions are gratefully received and may be incorporated for the benefit of those who still use it. If you desperately need some new feature then you could also consider sponsoring a solution.
    61 
    62 With all that said, adding further controls to offer up WPSEO style functionality for Shopp's virtual pages (those which aren't "housed" in a regular page, post or custom post type - the checkout, storefront homepage etc are all examples of this) is one possible avenue we could follow, dependent on interest.
     60Don't depend upon it! That said, I'm happy to add in new features and make minor changes if they are supported by a solid argument and,
     61even better, if even a little bit of the code to make it happen is contributed.
    6362
    6463== Screenshots ==
     
    7170== Changelog ==
    7271
    73 = 1.0 =
    74 * Initial commit (targeting WP 3.4.1, Shopp 1.2.3, WPSEO 1.2.5)
     72= 1.4 =
     73* Cleans up more effectively after modifying WP Query (necessary to cause category meta descriptions to be output) - should
     74improve compatibilty across themes
     75* Shopp-generated description is now removed from category pages
     76(thanks: [dencreativeltd](http://wordpress.org/support/profile/dencreativeltd))
     77so only the WPSEO description tag will be output by default
     78* Tested with WP 3.4.2, Shopp 1.2.5 and WPSEO 1.3.1.1
     79
     80= 1.3 =
     81* Changes to improve compatibility with other plugins including Advanced Custom Fields
     82(thanks to [Lars](http://profiles.wordpress.org/lkoudal))
     83* Tested with WP 3.4.2, Shopp 1.2.3 and WPSEO 1.2.8.7 - also tested concurrently with ACF 3.5.0
     84
     85= 1.2 =
     86* Added product category support
    7587
    7688= 1.1 =
    7789* Fix put in place to address issue with the Snippet Preview URL
    7890
    79 = 1.2 =
    80 * Added product category support
    81 
    82 = 1.3 =
    83 * Changes to improve compatibility with other plugins including Advanced Custom Fields (thanks to [Lars](http://profiles.wordpress.org/lkoudal))
    84 * Tested with WP 3.4.2, Shopp 1.2.3 and WPSEO 1.2.8.7 - also tested concurrently with ACF 3.5.0
     91= 1.0 =
     92* Initial commit (targeting WP 3.4.1, Shopp 1.2.3, WPSEO 1.2.5)
    8593
    8694== Upgrade Notice ==
  • shopp-seo-glue/tags/1.4/shoppseoglue.php

    r625773 r636253  
    44Plugin URI: http://freshlybakedwebsites.net/wordpress/shopp/wordpress-seo-compatibility/
    55Description: Aims to reconcile the popular Shopp and WordPress SEO plugins so that Shopp products can benefit from WordPress SEO's feature set. Currently experimental, this plugin was built against Shopp 1.2.3 and WordPress SEO 1.2.8.7: it may not work with earlier or later versions of either plugin.
    6 Version: 1.3
     6Version: 1.4
    77Author: Barry Hughes
    88Author URI: http://freshlybakedwebsites.net/
     
    2828
    2929
     30/**
     31 * Facilitates integration of Shopp and WordPress SEO.
     32 */
    3033class ShoppSEOGlueLayer {
    31     public $wpseoMetabox;
     34    /**
     35     * Holds a reference to the WordPress SEO metabox object or is (bool) false
     36     * if it has not been loaded.
     37     *
     38     * @var mixed
     39     */
     40    public $wpseoMetabox = false;
     41
     42    /**
     43     * Holds a reference to the WordPress SEO taxonomy object or is (bool) false
     44     * if it has not been loaded.
     45     *
     46     * @var mixed
     47     */
    3248    public $wpseoTaxonomy;
    3349
    34 
     50    /**
     51     * Contains the original values for any WP Query properties that might be
     52     * modified, so they can be restored again at a later point in the request.
     53     *
     54     * @var array
     55     */
     56    protected $queryBackup = array();
     57
     58
     59    /**
     60     * Safely creates a new ShoppSEOGlueLayer object (having first checked that
     61     * Shopp and WPSEO are active.
     62     */
    3563    public static function init() {
    3664        if (defined('SHOPP_VERSION') and defined('WPSEO_VERSION'))
     
    3967
    4068
     69    /**
     70     * Glues Shopp and WordPress SEO together. Handled in 3 steps:
     71     *
     72     *  - The WPSEO metaboxes are glued to the Shopp product editor
     73     *  - The same is done for the Shopp category editor
     74     *  - We make it so Shopp category pagesa are detectable by WPSEO
     75     *
     76     * @return ShoppSEOGlueLayer
     77     */
    4178    public function __construct() {
    4279        $this->glueProductEditor();
     
    4683
    4784
     85    /**
     86     * If the Shopp product editor has been requested then pull in the WPSEO
     87     * metaboxes and repair the URL preview feature.
     88     */
    4889    protected function glueProductEditor() {
    4990        if ($this->onShoppEditorPage('products')) {
     
    5596
    5697
     98    /**
     99     * If this is the Shopp category editor then pull in the WPSEO metaboxes
     100     * (not the same as those used in the product editor/on posts generally).
     101     */
    57102    protected function glueCategoryEditor() {
    58103        if ($this->onShoppEditorPage('categories')) {
     
    63108
    64109
     110    /**
     111     * Detects if we are on the specified type of Shopp editor page (possible
     112     * values for $slug could be "products" or "categories").
     113     *
     114     * @param string $slug
     115     * @return bool
     116     */
    65117    protected function onShoppEditorPage($slug) {
    66118        return ($this->pageAndIDQuerySet() and
     
    69121
    70122
     123    /**
     124     * Checks if the URL query contains "id" and "page" keys; this is intended
     125     * as an additional check before making any changes within the editor
     126     * environment.
     127     *
     128     * @return bool
     129     */
    71130    protected function pageAndIDQuerySet() {
    72131        return (array_key_exists('id', $_GET) and
     
    75134
    76135
     136    /**
     137     * Loads the WPSEO code responsible for generating the post editor metabox
     138     * and ensures any scripts/styles it depends upon are enqueued.
     139     */
    77140    public function pullInWPSEOMetabox() {
    78141        $this->loadSEOMetaboxClass();
     
    82145
    83146
     147    /**
     148     * Tries to load the WPSEO metabox code and sets the $this->wpseoMetabox
     149     * flag if successful.
     150     */
    84151    public function loadSEOMetaboxClass() {
    85152        if (defined('WPSEO_PATH') and class_exists('WPSEO_Metabox') === false) {
     
    91158
    92159
     160    /**
     161     * Forces WPSEO to set up the scrips/styles it needs, and also hooks in a
     162     * handler for when posts (products in this case) are saved.
     163     */
    93164    public function reattachWPSEOBehaviours() {
    94165        add_action('admin_print_styles',
     
    100171
    101172
     173    /**
     174     * Expects to be called when shopp_product_saved fires: ensures the WPSEO
     175     * saves any data from its metabox along with any other changes that may
     176     * have been made to the product.
     177     */
    102178    public function wpseoSavePostData() {
    103179        global $post_id;
     
    110186
    111187
     188    /**
     189     * The JS code that powers the neat URL preview will not work by itself in
     190     * the Shopp product editor, so we'll replace it with a modified version
     191     * that does work.
     192     */
    112193    protected function repairURLPreview() {
    113194        add_action('admin_print_footer_scripts',
     
    117198
    118199
     200    /**
     201     * Injects the replacement WPSEO URL preview code.
     202     */
    119203    public function insertURLPreviewScript() {
    120204        echo '<script type="text/javascript">';
     
    124208
    125209
     210    /**
     211     * Tries to load the WPSEO taxomonomy code and sets $this->wpseoTaxonomy
     212     * appropriately.
     213     *
     214     * @return bool
     215     */
    126216    public function loadSEOTaxonomyClass() {
    127217        if (defined('WPSEO_PATH') and class_exists('WPSEO_Metabox') === false) {
     
    135225
    136226
     227    /**
     228     * Adds the category metabox from WPSEO to the Shopp category editor.
     229     * Positioning can be tweaked if necessary by filtering:
     230     *
     231     *  - shoppseoglue_catmb_context
     232     *  - shoppseoglue_catmb_priority
     233     *
     234     * Which correspond to the context and priority params normally used when
     235     * working with metaboxes.
     236     */
    137237    public function categoryMetabox() {
    138238        $context = apply_filters('shoppseoglue_catmb_context', 'advanced');
     
    146246
    147247
     248    /**
     249     * Actually causes the WPSEO category metaboxes to be rendered. A Shopp
     250     * category object is expected to be passed in here and will be used to
     251     * get term data for WPSEO to use.
     252     *
     253     * @param $category
     254     */
    148255    public function drawCategoryMetabox($category) {
    149256        $term = get_term($category->term_taxonomy_id, ProductCategory::$taxon);
     
    152259
    153260
     261    /**
     262     * WPSEO does not know when Shopp category pages are being viewed so we need
     263     * to listen out for them.
     264     */
    154265    protected function glueShoppCategories() {
    155266        if (is_admin() === false)
     
    158269
    159270
     271    /**
     272     * If the request is for a Shopp taxonomy page then lets alter some of the
     273     * WP Query flags to "trick" WPSEO into doing it's thing.
     274     *
     275     * On the basis that if we are using WPSEO for category descriptions we have
     276     * no need for Shopp's own descriptions we will also remove the default
     277     * Shopp generated description tag ... this behaviour may not always be
     278     * desirable however and so can be turned off by filtering:
     279     *
     280     *  - shoppseoglue_remove_default_description
     281     *
     282     * And setting it to false.
     283     */
    160284    public function waitForCategories() {
    161285        if (is_shopp_taxonomy()) $this->modifyQueryFlags();
    162     }
    163 
    164 
     286        if (apply_filters('shoppseoglue_remove_default_description', true))
     287            add_filter('shopp_meta_description', array($this, 'removeDefaultDescription'));
     288    }
     289
     290
     291    /**
     292     * Changes a number of WP Query flags to make it clear to WPSEO that this is
     293     * a category page and it should work its magic.
     294     */
    165295    protected function modifyQueryFlags() {
     296        $this->safelyModifyQuery(array(
     297            'is_archive' => true,
     298            'is_category' => true,
     299            'is_singular' => false ));
     300    }
     301
     302
     303    /**
     304     * Takes an array of key:value pairs and changes the matching WP Query
     305     * properties. A record of the original values is retained in order to
     306     * restore them at a later point in the request.
     307     *
     308     * @param array $propertyValuesMap
     309     */
     310    protected function safelyModifyQuery(array $propertyValuesMap) {
    166311        global $wp_query;
    167         $wp_query->is_archive = true;
    168         $wp_query->is_category = true;
    169         $wp_query->is_singular = false;
     312
     313        foreach ($propertyValuesMap as $property => $value)
     314            if (property_exists($wp_query, $property)) {
     315                $this->queryBackup[$property] = $wp_query->$property;
     316                $wp_query->$property = $value;
     317            }
     318
     319        if (count($this->queryBackup) > 0)
     320            add_action('wp_head', array($this, 'restoreQueryProperties'), 11);
     321    }
     322
     323
     324    /**
     325     * Restores the original values of any WP Query properties which were
     326     * altered by Shopp SEO Glue earlier in the request.
     327     */
     328    protected function restoreQueryProperties() {
     329        global $wp_query;
     330
     331        foreach ($this->queryBackup as $property => $value)
     332            $wp_query->$property = $value;
     333    }
     334
     335
     336    /**
     337     * Filter for shopp_meta_description: returns an empty string which should
     338     * stop Shopp from generating its default description meta tag.
     339     *
     340     * Props to dencreativeltd on wordpress.org/support for suggesting this.
     341     */
     342    public function removeDefaultDescription() {
     343        return '';
    170344    }
    171345}
    172346
    173347
     348// Let the glueing commence
    174349add_action('plugins_loaded', array('ShoppSEOGlueLayer', 'init'), 80);
  • shopp-seo-glue/trunk/readme.txt

    r621263 r636253  
    55Requires at least: 3.4.1
    66Tested up to: 3.4.1
    7 Stable tag: 1.3
     7Stable tag: 1.4
    88License: GPL3 or later
    99License URI: http://www.gnu.org/licenses/gpl.html
Note: See TracChangeset for help on using the changeset viewer.