{"id":85937,"date":"2010-10-22T08:00:00","date_gmt":"2010-10-22T08:00:00","guid":{"rendered":"https:\/\/www.weixiaoduo.com\/plugins\/2024\/02\/22\/hikari-tools\/"},"modified":"2010-10-23T03:27:00","modified_gmt":"2010-10-23T03:27:00","slug":"hikari-tools","status":"publish","type":"post","link":"https:\/\/www.weixiaoduo.com\/plugins\/hikari-tools\/","title":{"rendered":"Hikari Tools Framework"},"content":{"rendered":"<p><strong><a href=\"http:\/\/hikari.ws\/tools\/\" rel=\"nofollow ugc\">Hikari Tools Framework<\/a><\/strong> isn\u2019t a plugin with features for the end user. It\u2019s a development framework with tools to be used by other plugins, so that they don\u2019t need to duplicate the same code over and over again.<\/p>\n<p>It deeply decreases plugins development time, specially in building options pages. For that, instead of building the whole HTML for each plugin, we can just prepare an array and it\u2019s used to build the whole page.<\/p>\n<p>Another great feature this framework offers is options detection and reset. With the use of another simple array, in the bottom of options page it prints a table showing to plugin\u2019s users all kinds of options the plugins creates, being it wp_options, comment meta, post meta, and even network-wide options and user specific options (usermeta).<\/p>\n<p>Every kind of data your plugin stores in database is shown in a clear way, with its key so that users can easly search for them in database. But they don\u2019t need to, because together with each option it informs if there\u2019s any data of that type stored, and provides user-friendly command to reset them all, totally cleaning the user\u2019s database from any data created by the plugin. Very easy and practical to use, and instantly available to any plugin that consumes Hikari Tools Framework!<\/p>\n<h4>Features<\/h4>\n<p>There are really a bunch of features available, here are the most used ones.<\/p>\n<ul>\n<li><em>DRY<\/em>: Using the Don\u2019t Repeat Yourself principle, features are developed only once in the framework and are used anywhere you want! And once the framework is updated, the update is automatically replicated to all plugins that use it!<\/li>\n<li><em>Object Oriented<\/em>: it provides 2 classes, which you can expand to implement your code, and then call parent methods anywhere to use Framework\u2019s features. Also, if you wanna add special features to a specific method, just overwrite it in your class!<\/li>\n<li><em>Automatic \u2018plugins_loaded\u2019 and \u2018init\u2019 actions<\/em>: follows WordPress standards and runs the least code possible during plugins load time. Each object is instantiated and runs its <code>construct()<\/code> method during \u2018plugins_loaded\u2019 action, and its <code>startup()<\/code> method during \u2018init\u2019 action<\/li>\n<li><em>Data dump<\/em>: great for debugging, you can use the <code>HkTools::dump()<\/code> method to pass any kind of data and have it dumped, with a title above it, anywhere you want! And there\u2019s also the <code>HkTools::formatCode()<\/code> that receives a string and prints it using formatting plugins if available, or <em>pre<\/em> HTML element if needed.<\/li>\n<li><em>Strings search<\/em>: use <code>hasNeedle($haystack,$needle)<\/code> and <code>hasNeedleInsensitive($haystack,$needle)<\/code> methods to search inside strings. They use PHP\u2019s <code>stripos()<\/code> to do the search, but instead of returning numbers that are rarely used it returns ready-to-use boolean values to say if <code>$needle<\/code> was or wasn\u2019t found, and <code>$needle<\/code> can even be an array if you wanna search many strings at once!<\/li>\n<li><em>Version checks<\/em>: the Framework tests PHP and WordPress versions and doesn\u2019t load itself if requirements aren\u2019t fit, and plugins that consume it follow a standard of testing the Framework version too.<\/li>\n<li><em>Paths to plugin files<\/em>: it provides 2 variables for local path and URL for plugins root folder, for each plugin that consumes the Framework!<\/li>\n<\/ul>\n<p><strong>Full featured options page builder<\/strong>: This one deserves its own features list, so many they are! The <em>HkToolsOptions<\/em> class handles all your options data and options page building, including reseting data to default:<\/p>\n<ul>\n<li>Instead of having in each of your plugins a complete HTML page to allow your users to setup configs, just create an array with your options data and everything will be handled by the Framework, <strong>including handling default values and registering the options page and its menu item<\/strong>!<\/li>\n<li><em>Many types of data are supported<\/em>: text, textarea, select, radiobox, checkbox, and if neither of those are enough you can also specify custom areas where your special options (ex: complex data that requires custom HTML, JavaScript, etc) can be placed!<\/li>\n<li><em>Store multiple settings in a single option using arrays<\/em>: forget those dumb plugins that add dozens of wp_options rows, now you can use a single array to store all those settings, and place them all in a single options variable. And you don\u2019t have to deal with the complexity of setting them to use array, because the Framework handles it to you!<\/li>\n<li><strong>Use multiple sections<\/strong>: Does your plugin use so many settings that it becomes messy? Don\u2019t worry, create visually separated sections to organize your settings, each of them having a title and help text to explain what the section refers to. And multiple sections are still stored in a unique array\u2019ed wp_options row!<\/li>\n<li><em>Store your options in multiple places<\/em>: aside from the most known wp_options (which is specific for each site), you can also store Multisite \/ network-wide options (that are shared by all sites in a MultiSite network) and user specific options (which are stored together to current user and are valid only to him).<\/li>\n<li>Too many storage places make it hard for plugins users to delete them all when they are uninstalling the plugin? No! <em>Hikari Tools Framework easily resets them!<\/em>: it provides an <strong>uninstall form<\/strong> which is added in the bottom of default options page, listing all kinds of options (wp_options, sitemeta, usermeta, postmeta, commentmeta, \u2026) your plugin uses, informs for each of them if there\u2019s any data stored ATM, and provides a command to delete them all from database, followed by a command to directly uninstall the plugin! This feature can also be used to reset options to default.<\/li>\n<li><em>Default options aren\u2019t stored<\/em>: many plugins use to add default options to database when they find none, therefore storing data that didn\u2019t need to be there and blocking users from deleting those data before deactivating the plugin. With <strong>Hikari Tools Framework<\/strong> plugins that doesn\u2019t happen, because it doesn\u2019t save data automatically and uses default settings when options data isn\u2019t found in database. <em>And that\u2019s totally transparent for you while handling options in your code!<\/em><\/li>\n<li><em>Special debug feature<\/em>: There\u2019s a property named <code>HkTools::debug<\/code> that\u2019s set to false by default. In your plugin you can develop debugging code that will only be run if <code>$this->debug<\/code> is set to true. Then, it\u2019s just a matter of setting it in your extended class and all of a sudden all debug will be available to you! BTW, options pages have \u201chidden\u201d debug code, and when <code>HkToolsOptions::debug<\/code> is set to true they are automatically shown without you having to worry with anything!<\/li>\n<li><em>Automatic options loading<\/em>: Always load your options object first, because its <code>HkTools::loadAllOptions()<\/code> method automatically loads your options and stores them in <code>HkTools::optionsDBValue<\/code>, <em>regardless if it was indeed loaded from database or was built from options defaults<\/em>. The class by default handles a single wp_options variable, but you can create more objects and overwrite <code>loadAllOptions()<\/code> to load and provide them all.<\/li>\n<li><em>Options page customization<\/em>: if some part of default page doesn\u2019t fit your needs, you can change it by overwriting a <code>HkToolsOptions<\/code> method, instead of having to throw the whole class away and go back building full pages again.<\/li>\n<li><em><code>HkToolsOptions extends HkTools<\/code><\/em>: of course, all features available in HkTools are also available in HkToolsOptions to be used for handling your options.<\/li>\n<li>Reset and uninstall commands use JavaScript to alert user about data lost and ask confirmation before deleting<\/li>\n<\/ul>\n<p>I dedicate Hikari Tools Framework to Ju, my beloved frient ^-^<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A plugin development framework with a lot of reusable code and a nice settings page builder.<\/p>\n","protected":false},"author":65,"featured_media":289528,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"slim_seo":{"title":"Hikari Tools Framework - \u8587\u6653\u6735\u63d2\u4ef6\u76ee\u5f55","description":"A plugin development framework with a lot of reusable code and a nice settings page builder."},"footnotes":""},"categories":[1],"tags":[3836,2823,25225,2773],"class_list":["post-85937","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-dependancy","tag-framework","tag-hktoolsoptions","tag-tool"],"_links":{"self":[{"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/posts\/85937","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/users\/65"}],"replies":[{"embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/comments?post=85937"}],"version-history":[{"count":0,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/posts\/85937\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/media\/289528"}],"wp:attachment":[{"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/media?parent=85937"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/categories?post=85937"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/tags?post=85937"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}