{"id":152,"date":"2005-02-28T07:56:58","date_gmt":"2005-02-28T07:56:58","guid":{"rendered":"http:\/\/wordpress.org\/development\/2005\/02\/wordpress-15-developers-primer\/"},"modified":"2021-06-04T11:58:33","modified_gmt":"2021-06-04T11:58:33","slug":"developers-primer","status":"publish","type":"post","link":"https:\/\/wordpress.org\/news\/2005\/02\/developers-primer\/","title":{"rendered":"WordPress 1.5 Developers' Primer"},"content":{"rendered":"
WordPress 1.5 is not just cool and suave on the outside, there are quite a few programming enhancements and added features for coders, hackers, plugin developers and enthusiasts. Some of these are obvious while others are more difficult to track down without digging through the code. This is a highly technical post, so feel free to skip it if that’s not your bag.<\/p>\n
<\/p>\n
\n$this = array(array(), blah, blah, blah);
\nupdate_option('xfnbl_data', $this);
\n$newthis = get_option('xfnbl_data');
\n<\/code>
\nThe update_option function will transparently serialize the data. If you save an option as an array, the option is returned as an array.\n<\/li>\n- If you update_option an option that doesn’t exist, it’ll create it<\/em>: If the option did not exist when it was updated, it is created transparently. If the option did not exist when it was requested using get_option, the code degrades gracefully and does not error out, returning an empty variable.<\/li>\n
- Lots of hooks, including these tasty ones<\/em>\n
\n- You can dynamically modify any option returned without changing the option in the DB: There are two new hooks to help with this.
\n
\nadd_filter('pre_option_' . $option_name, 'function_name');
\nadd_filter('all_options', 'function_name');
\n<\/code>\n<\/li>\n- You can create and modify any XML-RPC call through the xmlrpc.php interface<\/em>: Another cool new tool. If you need to add functions to the xmlrpc class (IXR) and then handle them as you like, just do something like the following:
\n
\nadd_filter('xmlrpc_methods', 'Add_XBN_Stuff');
\nfunction Add_XBN_stuff($args) {
\n\t\t$args['demo.somefunction'] = 'somefunction';
\n\t\treturn $args;
\n\t}
\nfunction somefunction($stuff) {
\n\tdo_stuff($stuff)
\n}
\n<\/code>
\nFor a better look at a plugin developed with this functionality, look at this plugin<\/a>.\n<\/li>\n<\/ul>\n<\/li>\n- You can create pages in the admin interface<\/em>: There are a bunch of functions that allow manipulation of the managment menus and create new pages.
\n
\nadd_menu_page('Page Title', 'Menu Title', $access_level, 'PHP_File_to_Display')
\nadd_submenu_page('Parent_Page', 'Page Title', 'Menu Title', $access_level, 'PHP_File_to_Display', 'function_name')
\nadd_options_page('Page Title', 'Menu Title', $access_level, 'PHP_File_to_Display','function_name')
\nadd_management_page('Page Title', 'Menu Title', $access_level, 'PHP_File_to_Display','function_name')
\n<\/code>
\nFor an example see cache-images: http:\/\/svn.wp-plugins.org\/cache-images\/trunk\/<\/a>:<\/li>\n- There’s a new hook for caching plugins that is called before everything is loaded, though you do have to edit wp-config.php to activate it.<\/em><\/li>\n
- A whole bunch of hooks to help plugin developers get more creative<\/em>: Some of these are new, some have existed through 1.2. There are too many hooks to list here. Just do a search within the wordpress folder for the data item you are dealing with and ‘apply_filter’ or ‘do_action’. You are sure to find something that works for you.\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"
WordPress 1.5 is not just cool and suave on the outside, there are quite a few programming enhancements and added features for coders, hackers, plugin developers and enthusiasts. Some of these are obvious while others are more difficult to track down without digging through the code. This is a highly technical post, so feel free […]<\/p>\n","protected":false},"author":330,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"episode_type":"","audio_file":"","cover_image":"","cover_image_id":"","duration":"","filesize":"","date_recorded":"","explicit":"","block":"","filesize_raw":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[6],"tags":[],"class_list":["post-152","post","type-post","status-publish","format-standard","hentry","category-documentation"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pZhYe-2s","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/news\/wp-json\/wp\/v2\/posts\/152","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/news\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wordpress.org\/news\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.org\/news\/wp-json\/wp\/v2\/users\/330"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.org\/news\/wp-json\/wp\/v2\/comments?post=152"}],"version-history":[{"count":1,"href":"https:\/\/wordpress.org\/news\/wp-json\/wp\/v2\/posts\/152\/revisions"}],"predecessor-version":[{"id":2869,"href":"https:\/\/wordpress.org\/news\/wp-json\/wp\/v2\/posts\/152\/revisions\/2869"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/news\/wp-json\/wp\/v2\/media?parent=152"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wordpress.org\/news\/wp-json\/wp\/v2\/categories?post=152"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wordpress.org\/news\/wp-json\/wp\/v2\/tags?post=152"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}