Automattic / WP-Job-Manager

Manage job listings from the WordPress admin panel, and allow users to post jobs directly to your site.
https://wpjobmanager.com
GNU General Public License v3.0
900 stars 368 forks source link

Add possibility to force sync the WPCOM license #2812

Closed fjorgemota closed 5 months ago

fjorgemota commented 5 months ago

Fixes https://github.com/Automattic/wpjobmanager.com/issues/721

Changes Proposed in this Pull Request

Testing Instructions

  1. Checkout https://github.com/Automattic/wpjobmanager.com/pull/724.
  2. Make sure your site is pointing to your test env of wpjobmanager.com. You can do by setting the constant JOB_MANAGER_DEV_API_BASE_URL to the base URL of your local WPJMCOM instance in your wp-config.php. For instance:
    define( "JOB_MANAGER_DEV_API_BASE_URL", "http://wpjobmanager.local" );
  3. Using the Code Snippets plugin, add a filter to make WPJM think that an addon was actually provided by WPCOM. This is the code of the filter to add:
    add_filter("default_option_wpcom_active_subscriptions", function( $value ) {
    $value["wp-job-manager-applications"] = true;
    return $value;
    } );

    (you can change the slug of the addon if you want, but please change it as well in the next steps)

  4. In the wpjobmanager.com's class-flush-wpcom-activation-endpoint.php (added in the PR linked above): 5.1. Update the access token as described in the step 8 in https://github.com/Automattic/wpjobmanager.com/pull/724 5.2. Comment this line because your local site won't exist on WPCOM: https://github.com/Automattic/wpjobmanager.com/pull/724/files#diff-a4f394b8eec10682db698affd6bffeab207386eb4581b0eb937a69568284c861R167 5.3. Create an ownership as described from steps 1 to step 5 in https://github.com/Automattic/wpjobmanager.com/pull/724, and hard-code the value of $wpcom_marketplace_ownership_id to match the ownership ID you just created.
  5. Make sure you don't have a license activated in your local WPJM site. You can always reset all the WPJM licenses in a site by using wp option delete job_manager_helper.
  6. Navigate to the Licenses page: /wp-admin/edit.php?post_type=job_listing&page=job-manager-marketplace&section=helper. It should show you something like this: Deactivated WPCOM product
  7. Click on the "Activate License" button to initiate the process
  8. If: 9.1. There's an error, you should see this: Activation error 9.2. If the process was successful, you should see this: Activation Successful

Also make sure the normal license activation and deactivation continue working properly.

  1. Revert the changes above
  2. Buy a WPJM Addon on your local wpjobmanager.com site.
  3. Try to activate and deactivate the license through your WPJM site, and make sure it works properly.

Context

This is akin to the PR in https://github.com/Automattic/sensei-pro/pull/2529


Plugin build for 67ffb319bce5b0d3d1c1fbb4e8a155857bd808db
📦 Download plugin zip
▶️ Open in playground