Articles Tagged 'Snippe'


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.

Continued ...

WordPress Snippet: is_page () Custom Post Type

If you recorded your own Custom Post Type ( CPT ), especially if you type 'page', you could serve to determine if you are viewing that particular page, the 'single' so to speak. . In this case it is useless to try is_page() or is_page_template() . The clean solution is as follows:

1
2
3
4
5
6
is_singular ( 'cpt_key' ) ) { if (is_singular ('cpt_key')) {
; global $ post;
$post -> post_name == 'slug_pagina' ) { if ($ post -> post_name == 'slug_pagina') {
/ / Your code here ... type add_action (), wp_enqueue_scripts (), etc ...
}
}

Continued ...

WordPress 3.3: now all jQuery

With WordPress 3.3 also jQuery and all its modules have been aligned. Now it is possible to access the new list of the modules of the latest release 3.3, such as the autocomplete. Here is a snippet for a good inclusion:

1
2
3
4
5
6
/ / Load modules that WordPress for us preparatory to the script "MyScript.js"
array ( 'jquery-ui-slider' , $ Deps = array ('jquery-ui-slider',
'Jquery-ui-datepicker',
'Jquery-ui-autocomplete'
);
, 'js/myscript.js' , $deps , 1 . 3 . 4 , true ) ; wp_enqueue_script ('key', 'js / MyScript.js', $ deps, 1 3.. 4, true);

Continued ...

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');
}
});

Continued ...

WordPress Snippet: Remove the admin bar

The latest version of WordPress has added a new toolbar frontend side when the administrator is logged. If you want to disable this code included in the file functions.php of your theme:

1
2
3
4
/ / Check to see if the filter show_admin_bar
has_filter ( 'show_admin_bar' ) ) { if (has_filter ('show_admin_bar')) {
, '__return_false' ) ; add_filter ('show_admin_bar', '__return_false');
}

Continued ...

Very short snippet: NSConnection POST with parameters

che in modalità POST . The object NSMutableURLRequest can be used in either GET mode in POST . . The parameters, however, must be formatted as if they were in GET , ie in the sequence nome_campo1=valore1&nome_campo2=valore2&... . Here's a useful snippet to simplify the construction of fields:

Continued ...

Very short snippet: the UIView to display an image

Working with Interface Builder can be spontaneously use an object UIImageView to set the background of our view controller. Alternatively, you can delete this object, thus saving a little 'memory, and take advantage of the view associated with the view controller. Just plug in our view controller:

Continued ...

jQuery snippets

Verify the existence of an element in the DOM

There will ever need to check the existence of an element of the DOM. With jQuery could be spontaneously try:

Continued ...

Very short snippet: increment a field in SQL

The latest release of WP Bannerize I introduced a new field in the table shows how many times a banner is "clicked". To perform the operation valore = valore +1 I used in SQL:

1
`campo` = `campo` + 1 WHERE id = id_record; UPDATE table SET `field` = `the` + 1 WHERE id = id_record;

Continued ...

10 useful snippets Objective-C

Move the double-tap on the simulator

The simulator iPhones / iPad Xcode allows you to simulate the double tap the Alt key is pressed. This is useful to simulate the function of Pinch, that used to enlarge or scroll Keep away content in the view with objects or UIWebView . Well, some of you have noticed that the simulation of the "two fingers" proceeds in a symmetrical manner always starting from the center of the screen. To move this "center" is also just hold down the SHIFT key.

Continued ...