{"id":19023886,"date":"2026-09-19T00:37:41","date_gmt":"2026-09-19T00:37:41","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/add-a-code-library-for-use-in-multiple-modules\/"},"modified":"2026-09-19T11:23:24","modified_gmt":"2026-09-19T11:23:24","slug":"add-a-code-library-for-use-in-multiple-modules","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/add-a-code-library-for-use-in-multiple-modules\/","title":{"rendered":"Add a code library for use in multiple modules?"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">I have tow libraries of code for use in more than one module I want to develop. Can I create an add on module that makes the library available to other modules or do I have to add the code to every module?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Both libraries have a base bit of code to create autoloading for that library. Directory example contains example.php and sets up autoloading for the example directory. Every file in the directory is a class named example_* in file example_*.php.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The modules using the Example library would list the Example module as a prerequisite and need only a way to load example.php then all the classes in example would be autoloaded.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I just need a pointer to a module already doing this or a documentation page. I have experience creating WordPress modules. For this task, my Internet searches have not produced a starting point.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If sharing a library across modules is not legal, what is the recommended way to add the library unmodified so I can maintain the library in Github and just download the updated library direct into the module code as is?<\/p>\n","protected":false},"template":"","class_list":["post-19023886","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/19023886","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":1,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/19023886\/revisions"}],"predecessor-version":[{"id":19024061,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/19023886\/revisions\/19024061"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=19023886"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}