I was asked what the advantage or disadvantage in the use of anonymous functions or inline (or onfly), and used a lot in JavaScript, now with 5.3, also in PHP.
An inline function, or anonymous because he did not - in fact - a name, is a quick way to write some procedures, indenting tree sequences such as the callback. Almost all languages support functions of this writing, each to the limit with its peculiarities and restrictions. They may also have different names and syntax details, such as the so-called Objective-C blocks.
Articles Tagged 'hook'
Anonymous functions
WordPress Snippet: The action save_post
When you add additional fields to the pages and post, or to get Custom Post Type ( CTP ), you have to record an action to save these new data. The implementation of this procedure is essentially always the same, changing only the fields and how to save, the extra data can reside in the 'custom field', ie after half the table, or tables of one or more personal.
WordPress Snippet: add styles and scripts to Custom Post Type
Now that WordPress allows you to create types of custom post (CPT), it becomes useful to be able to add our styles and our script when you view or edit our posts. The best way to do that is compatible with release 3.3 is the following:
1 2 3 4 5 6 7 | , function ( ) { add_action ('admin_enqueue_scripts', function () { ; global $ typenow; $typenow == 'id_custom_post' ) { if ($ typenow == 'id_custom_post') { , 'css/customstyle.css' ) ; wp_enqueue_style ('key_style', 'css / customstyle.css'); , 'js/customscript.js' ) ; wp_enqueue_script ('key_script', 'js / customscript.js'); } }); |
WordPress Delete Post
WordPress allows you to intercept when a post - even custom type - is being eliminated. . There are two action hooks that can be used: delete_post and deleted_post . In the first analysis, the former should be attributed to a "is being eliminated" the post, even if it does not seem to be, or better.
WordPress: use shortcodes
From version 2.5 of WordPress (preferably 2.5.1) are available so-called shortcodes , a procedure that allows the creation of callback hooks or rather, when the text of our post is found a string formatted with brackets like [id_shortcode] . Prior to the release of WordPress 2.5 shortcodes were implemented manually (see Napolux ), now you can exploit with more simplicity and for different uses.






Latest Comments
datrix : Thank you very much!
Robert : I rispsoto your questions with pleasure. The idea is really great. I am looking for a solution ...
Sting : @ Darius - you can see an example here: http://www.fight4fun.it/ clicking on: MAPS I hope ...
vik : Giustappunto I'm working on a project and the client asked me to show all the news (which are CPT) in ...
Giovambattista Fazioli : @ paso: absolutely. Simply identifying the field [cci] input [/ cci] you want to ...