{"id":16630358,"date":"2023-04-05T17:47:07","date_gmt":"2023-04-05T17:47:07","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/using-jetpack-autoloader\/"},"modified":"2023-04-05T17:47:07","modified_gmt":"2023-04-05T17:47:07","slug":"using-jetpack-autoloader","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/using-jetpack-autoloader\/","title":{"rendered":"Using Jetpack Autoloader"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Hi there!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I worked on the Jetpack team, and recently noticed that you&#8217;re using 2 Jetpack Composer packages in your plugin:<\/p>\n\n\n\n<ul>\n<li>Jetpack Assets<\/li>\n\n\n\n<li>Jetpack Constants<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">First of all, I&#8217;m happy to see that, I hope you&#8217;re finding those 2 packages useful! \ud83d\ude42<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I am reaching out to make a suggestion, so your plugin can be fully compatible with other plugins that rely on those 2 packages.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When using packages that are also used by other plugins on the same site, it is recommended to use the <a href=\"https:\/\/packagist.org\/packages\/automattic\/jetpack-autoloader\">Jetpack Autoloader Composer package<\/a> as well; it would ensure that when your plugin is installed alongside another plugin that also loads Jetpack Assets or Jetpack Constants, there are no conflicts between the 2 versions.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you&#8217;d like to implement that on your site, you&#8217;d have to do 2 things:<\/p>\n\n\n\n<ol>\n<li>Require <code>automattic\/jetpack-autoloader<\/code> in your plugin&#8217;s <code>composer.json<\/code>.<\/li>\n\n\n\n<li>Load the Autoloader in your plugin&#8217;s main file: <code>require_once <strong>DIR<\/strong> . '\/vendor\/autoload_packages.php';<\/code><\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">Things should then work just like before, but your plugin&#8217;s users should never run into conflicts with other sites that use those packages.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you&#8217;d like to implement that in your plugin and need some more help, do not hesitate to reach out by creating a GitHub issue <a href=\"https:\/\/github.com\/Automattic\/jetpack\/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc\">here<\/a>, or <a href=\"https:\/\/jetpack.com\/contact-support\/?rel=support&amp;hpi=1\">contact us via  email<\/a> and mention this forum thread; I&#8217;ll be happy to help you with this!<\/p>\n","protected":false},"template":"","class_list":["post-16630358","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/16630358","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/16630358\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=16630358"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}