sterner-stuff / private-wordpress-plugin-composer-provider

A starter template for a self-updating GitHub mirror of a private WordPress library for use via Composer.
40 stars 6 forks source link

Easy Digital Downloads (SearchWP and others) example #13

Closed MWDelaney closed 1 year ago

MWDelaney commented 1 year ago

This example uses the documentation found in #11, but doesn't successfully download the latest version of SearchWP yet, because I don't yet have a method of retrieving the EDD id for the download.

@ethanclevenger91 suggested hitting EDD's REST endpoints looking for IDs, but I wasn't able to find anything at https://searchwp.com/wp-json/wp/v2/ using the default slug of downloads.

So, we could reach out to SearchWP (and other providers of popular EDD-distributed plugins) and ask for the missing details, or keep digging at APIs or guessing names?

Closes #11

ethanclevenger91 commented 1 year ago

Using Postman, I hit FacetWP with my license key and item ID 24 (which I pulled from the links on their purchase page), but that simply returned the FacetWP homepage - I think they have EDD's licensing feature completely disabled.

I don't have a valid SearchWP license, but when I tossed in my expired license and item_id 8, which I got from the renewal URL in my dashboard, I got a valid response:

{
    "new_version": "3.1.16",
    "stable_version": "3.1.16",
    "name": "SearchWP",
    "slug": "searchwp",
    "url": "https://searchwp.com/downloads/searchwp/?changelog=1",
    "last_updated": "2022-07-05 12:42:40",
    "homepage": "https://searchwp.com/downloads/searchwp/",
    "package": "[download link]",
    "download_link": "[download link]",
    "sections": "a:2:{s:11:\"description\";s:0:\"\";s:9:\"changelog\";s:6962:\"<p><strong>Note:</strong> SearchWP 4 is available! Automatic upgrade <em>is not available</em>. <a href=\"https://searchwp.com/?p= 289887\" target=\"_blank\" rel=\"noopener\">View details</a>.</p>\n<p>3.1.16</p>\n<ul>\n<li><strong>[Update]</strong> Updated updater</li>\n</ul>\n<p>3.1.15</p>\n<ul>\n<li><strong>[Fix]</strong> Updates deprecated jQuery function</li>\n</ul>\n<p>3.1.14</p>\n<ul>\n<li><strong>[Fix]</strong> Character encoding issue in PDF parsing in some cases</li>\n</ul>\n<p>3.1.13</p>\n<ul>\n<li><strong>[Fix]</strong> Issue with PDF parsing in some cases</li>\n<li><strong>[Update]</strong> Updated updater</li>\n</ul>\n<p>3.1.12</p>\n<ul>\n<li><strong>[Fix]</strong> Issue with partial match return values in some cases</li>\n<li><strong>[Fix]</strong> Notice about Deprecated array syntax</li>\n<li><strong>[Update]</strong> Dependencies</li>\n</ul>\n<p>3.1.11</p>\n<ul>\n<li><strong>[Fix]</strong> Issue with synonym partial matching not working as expected in some cases</li>\n</ul>\n<p>3.1.10</p>\n<ul>\n<li><strong>[Fix]</strong> Issue with supported post type attributes not appearing in all cases</li>\n<li><strong>[Change]</strong> Template conflict detection is now opt-in</li>\n<li><strong>[Update]</strong> Updated dependencies</li>\n</ul>\n<p>3.1.9</p>\n<ul>\n<li><strong>[Fix]</strong> Logic issue with one of the query limiters in some cases</li>\n</ul>\n<p>3.1.8</p>\n<ul>\n<li><strong>[New]</strong> searchwp_query_strict_limiters filter allowing you to <em>opt out</em> of some search query limiters</li>\n<li><strong>[Change]</strong> Some private properties/methods have been made public</li>\n</ul>\n<p>3.1.7</p>\n<ul>\n<li><strong>[Fix]</strong> Issue with finding partial matches in some cases</li>\n<li><strong>[Improvement]</strong> PHP 7.4 compatibility</li>\n<li><strong>[Update]</strong> Adds class reference to some hooks</li>\n<li><strong>[Update]</strong> Dependencies</li>\n</ul>\n<p>3.1.6</p>\n<ul>\n<li><strong>[Change]</strong> Default partial match minimum length updated to 3</li>\n<li><strong>[Improvement]</strong> Handling of quoted searches when highlighting</li>\n<li><strong>[Improvement]</strong> Integration with WordPress 5.3</li>\n<li><strong>[Improvement]</strong> Exact matches given more weight when finding partial matches</li>\n<li><strong>[Fix]</strong> SWP_Query quoted search handling in some cases</li>\n</ul>\n<p>3.1.5</p>\n<ul>\n<li><strong>[Improvement]</strong> Performance when considering document processing</li>\n<li><strong>[Fix]</strong> Partial matches resource usage</li>\n</ul>\n<p>3.1.4</p>\n<ul>\n<li><strong>[Fix]</strong> Regression introduced when debugging is enabled and FS_METHOD = ftpext is imposed</li>\n<li><strong>[Fix]</strong> Custom built admin searches not working as expected in some cases</li>\n<li><strong>[Improvement]</strong> Search query performance</li>\n<li><strong>[Improvement]</strong> Handling of AND logic when considering partial matches and synonyms</li>\n<li><strong>[Improvement]</strong> Improve performance of partial match handling</li>\n<li><strong>[Improvement]</strong> Prevention of redundant queries in some cases</li>\n<li><strong>[New]</strong> New filter searchwp_th_excerpt_consider_comments to consider Comments when generating global excerpts if no highlight is found</li>\n</ul>\n<p>3.1.3</p>\n<ul>\n<li><strong>[Fix]</strong> Issue with tokenizing during searches in some cases</li>\n<li><strong>[Fix]</strong> Fixes a regression in synonym processing introduced in 3.1</li>\n<li><strong>[Improvement]</strong> Performance improvement when performing searches</li>\n</ul>\n<p>3.1.2</p>\n<ul>\n<li><strong>[Fix]</strong> Indexer performance regression introduced in 3.1</li>\n<li><strong>[Fix]</strong> Inaccurate notice displayed when searching in the admin in some cases</li>\n</ul>\n<p>3.1.1</p>\n<ul>\n<li><strong>[Fix]</strong> JavaScript error when adding Custom Fields to engines</li>\n</ul>\n<p>3.1</p>\n<ul>\n<li><strong>[Change]</strong> Partial term matching now requires PHP 5.4+</li>\n<li><strong>[Change]</strong> Synonym handling has been improved, for full explanation see <a href=\"https://searchwp.com/?p=193232\">https://searchwp.com/?p=193232</a></li>\n<li><strong>[New]</strong> Support (with caveats) for quoted/phrase/sentence searches, for more information see <a href=\"https://searchwp.com/?p=190759\">https://searchwp.com/?p=190759</a></li>\n<li><strong>[New]</strong> Automatic \"Did you mean\" handling for misspelled searches, for more information see <a href=\"https://searchwp.com/?p=190545\">https://searchwp.com/?p=190545</a></li>\n<li><strong>[New]</strong> Adds core support for keyword stemming for these language codes: EN, DA, NL, FR, DE, IT, NB, NN, PT, RO, RU, ES, SV (if you are using an Extension you can remove it)</li>\n<li><strong>[New]</strong> New filter searchwp_query_collate_override to override table COLLATE</li>\n<li><strong>[New]</strong> New filter searchwp_th_minimum_word_length to control highlighter minimum word length</li>\n<li><strong>[New]</strong> New filter searchwp_persist_extra_metadata to control whether Extra Metadata is persisted (e.g. to support quoted searches for that data)</li>\n<li><strong>[New]</strong> Detection for background indexer communication failure in some cases</li>\n<li><strong>[Improvement]</strong> Global excerpts now implement WordPress' excerpt_more output where applicable</li>\n<li><strong>[Improvement]</strong> Partial match highlighting is more accurate</li>\n<li><strong>[Improvement]</strong> JavaScript bundlers have been reconfigured and optimized</li>\n<li><strong>[Fix]</strong> Account for AND logic refinement being too aggressive in some cases</li>\n<li><strong>[Fix]</strong> Trigger index when scheduled posts are published</li>\n<li><strong>[Fix]</strong> Delta updates when editing via Quick Edit</li>\n<li><strong>[Fix]</strong> Better checks against index when evaluating partial matches</li>\n<li><strong>[Fix]</strong> SWP_Query results are no longer incorrectly overridden with subsequent calls to SWP_Query-&gt;get_posts()</li>\n<li><strong>[Fix]</strong> Highlighter partial match setting now defaults to core partial match setting</li>\n<li><strong>[Fix]</strong> Warning when processing purge queue in some cases</li>\n<li><strong>[Fix]</strong> Parent weight transfer for Media is no longer enabled by default</li>\n<li><strong>[Fix]</strong> Global highlight functions are now initialized in a more accessible way</li>\n<li><strong>[Fix]</strong> z-index problem when adding a Post Type to an engine</li>\n<li><strong>[Fix]</strong> More consistent handling of internal metadata types</li>\n<li><strong>[Fix]</strong> Prevent inapplicable post types from being considered for search when in the WordPress Dashboard</li>\n<li><strong>[Fix]</strong> Take exclusive regex matches into consideration when tokenizing</li>\n<li><strong>[Update]</strong> Translation source</li>\n</ul>\n<p>For older versions please see <a href=\"https://searchwp.com/docs/changelog-archive/\" target=\"_blank\" rel=\"noopener\">the changelog archive</a></p>\n\";}",
    "banners": "a:2:{s:4:\"high\";s:0:\"\";s:3:\"low\";s:0:\"\";}",
    "icons": "a:0:{}",
    "requires_php": "5.6.0"
}

Old version of SearchWP, which is odd, because my license expired in October 2022, long after the release of 4.0, so I should have access to 4.0.

It's possible their teams may be willing to provide more info. Dunno.

FWIW, the EDD registered REST endpoint is edd-downloads. But both sites appear to have disabled that endpoint. Tested successfully on my own site running EDD.

MWDelaney commented 1 year ago

That's the same result I'm getting; the "last" release of version 3 (complete with a note to upgrade to 4), rather than the "current" release of version 4. I guess it can't hurt to hit up support!

ethanclevenger91 commented 1 year ago

@MWDelaney FacetWP appears to not use EDD's license mechanism for their updater. Instead, it wants a POST request to api.facetwp.com:

$request = wp_remote_post( 'https://api.facetwp.com', [
                'body' => [
                    'action'    => 'check_plugins',
                    'slugs'     => array_keys( $plugins ), // 'facetwp' works, though you can pass the extensions as well
                    'license'   => FWP()->helper->get_license_key(), // this would be a secret
                    'host'      => FWP()->helper->get_http_host(), // doesn't seem to be required
                    'wp_v'      => get_bloginfo( 'version' ), // doesn't seem to be required
                    'fwp_v'     => FACETWP_VERSION, // doesn't seem to be required
                    'php_v'     => phpversion(), // doesn't seem to be required
                ]
            ] );

Easy enough to replicate via a GitHub action. The response is:

{
    "activation": {
        "status": "success",
        "message": "All done, thanks for activating!",
        "expiration": "2023-05-31 01:07:08",
        "payment_id": 161067,
        "price_id": 1
    },
    "slugs": {
        "facetwp": {
            "name": "FacetWP",
            "slug": "facetwp",
            "version": "4.1.6",
            "requires": "5.0",
            "tested": "6.1.1",
            "downloaded": 0,
            "last_updated": "2023-03-06 05:54:25",
            "sections": { "description": "", "changelog": "..." },
            "url": "https://facetwp.com",
            "package": "[ a downloadable zip]",
            "homepage": "https://facetwp.com/",
            "contributors": {
                "mgibbs189": {
                    "profile": "https://twitter.com/mgibbs189",
                    "avatar": "https://secure.gravatar.com/avatar/ce6607d5fb834cbfc538bce124e8ddd3?s=96&d=monsterid",
                    "display_name": "Matt Gibbs"
                }
            }
        }
    }
}

Probably worthy of its own PR.

ethanclevenger91 commented 1 year ago

@MWDelaney SearchWP's item ID is 216029. Don't know why I didn't think to look in the plugin's source code first.

That response also includes a minimum PHP version, which could be parsed and dropped into the composer.json file as a dependency, if you wanted to be really thorough.

MWDelaney commented 1 year ago

Hah! I looked at Facet's source and found that API stuff but didn't look at SearchWP's. I'll test that item ID and update this PR!

MWDelaney commented 1 year ago

Works. Ready to merge!

ethanclevenger91 commented 1 year ago

@MWDelaney Since SearchWP is using EDD's licensing API, why not make this example a configurable open-ended EDD example? Configure the base domain and item_id in the env section of the action, change the secret to something more generic (like LICENSE_KEY), and rename it to something simply like edd.yml. It could be annotated with some comments if necessary.

ethanclevenger91 commented 1 year ago

@MWDelaney can you roll back that latest commit? That change is well outside the scope of this PR and should be submitted separately. There are also some merge comments left in it.

MWDelaney commented 1 year ago

@ethanclevenger91 definitely. I updated a bunch of stuff not thinking about these PRs. I'll re-do them all!