{"id":4262,"date":"2017-10-21T12:44:54","date_gmt":"2017-10-21T10:44:54","guid":{"rendered":"https:\/\/florianbrinkmann.com\/en\/?p=4262"},"modified":"2020-02-09T10:59:43","modified_gmt":"2020-02-09T09:59:43","slug":"create-code-reference","status":"publish","type":"post","link":"https:\/\/florianbrinkmann.com\/en\/create-code-reference-4262\/","title":{"rendered":"Create code reference \u00e0 la developer.wordpress.org"},"content":{"rendered":"\n
In the code reference under developer.wordpress.org\/reference<\/a> you can find all functions, hooks, classes and methods of WordPress. For example, an entry for a function displays which parameters it expects, what return value there is and what the code looks like. Here I describe briefly how something similar can be done.<\/p>\n\n\n\n\n\n\n\n Some time ago I came up with the idea to provide a code reference for my themes, which provides similar information like the official one from WordPress (you can see the result here at the example of the Photographus theme<\/a>). The corresponding plugin WP-Parser<\/a><\/em>, which parses the WordPress code for the code reference and creates custom post types from it, is located on GitHub and is not very difficult to use. In addition to PHP 5.4+, Composer and WP-CLI are required.<\/p>\n\n\n\n After the plugin has been installed and activated, it can be executed with the following command:<\/p>\n\n\n This parses the files and inline documentation and creates corresponding CPT entries (there are the CPTs Functions<\/em>, Methods<\/em>, Classes<\/em> and Hooks<\/em>).<\/p>\n\n\n\nwp parser create \/path\/to\/source\/code --user=<id|login<\/span>><\/span><\/code><\/div>Code language:<\/span> HTML, XML<\/span> (<\/span>xml<\/span>)<\/span><\/small><\/pre>\n\n\n