Monday, November 3, 2008 Administrator or underwriter? Here's a quick way to understand this:
PHP: / /
$user_ID , 'wp_capabilities' ) ; $ get_usermeta capabilities = ($ user_ID, 'wp_capabilities');
/ /
$capabilities [ 'Administrator' ] == 1 || $capabilities [ 'administrator' ] == 1 ) { if ($ capabilities [ 'Administrator'] == 1 | | $ capabilities [ 'administrator'] == 1) (
; echo "You are an administrator"; )
)
Or, as "contracted"
PHP: / /
$user_ID , 'wp_capabilities' ) ; $ get_usermeta capabilities = ($ user_ID, 'wp_capabilities');
/ / $ Admin is true if administrator
$capabilities [ 'Administrator' ] == 1 || $capabilities [ 'administrator' ] == 1 ) ; $ admin = ($ capabilities [ 'Administrator'] == 1 | | $ capabilities [ 'administrator'] == 1);
You can of course check all levels made available by Wordpress, as subscriber for example.
Related Post
Saturday, November 1, 2008 It may be useful, sometimes, "obscure" some of the menu of Wordpress, especially if you developed a website / blog for a client and do not want to allow access to sensitive features. There Plugin already performing this function, but to have a personal and complete control, we see in detail how this feature.
As always exploit the useful Action made available by Wordpress, in this case admin_menu Through the global variable $menu can access the list of the menu. We can find the menu to "remove" in two ways: through the label or via the link that it points (see commented shares in the example below). The proposal is "obscured" menu items Design, Settings and Plugins:
PHP: remove_menu_item function () (
/ / By label
( 'Design' , 'Impostazioni' , 'Plugins' ) ; $ removes =
array ( 'Design', 'Settings',' Plugins'); / / Through links
/ / $ Removes = array ( 'themes.php', 'options-general.php', 'plugins.php');
$removes as $todel ) foreach ($ removes as $ todel)
$menu as $key => $sm ) if ( $sm [ 0 ] == $todel ) { unset ( $menu [ $key ] ) ; break ; } foreach ($ menu as $ key => $
sm) if ($ sm [0] ==
$ todel) (unset ($ menu [$ key]); break;) / / Through links
/ / Foreach ($ menu as $ key => $ sm) if ($ sm [2] == $ todel) (unset ($ menu [$ key]); break;)
)
/ /
, 'remove_menu_item' ) ; add_action ( 'admin_menu', 'remove_menu_item');
Using the links as key to the removal $sm[2] in parts commented code surprise here), is useful when there is certainty of language - location - with which you installed Wordpress. With this technique, however, the menu is removed only at the interface, so you can still access the page via a direct link.
Related Post
Friday 31 October, 2008 Converts a date format yyyy-mm-dd hh:mm:ss to yyyymmddhhmmss Useful to be able to exploit the functions of law; type asort()
PHP: / **
* Format from "yyyy-mm-dd hh: mm: ss" to "yyyymmddhhmmss"
* /
$d ) { plainDate function ($ d) (
)
Better than this:
PHP: $d ) { plainDate function ($ d) (
str_replace ( ' ' , '' , str_replace ( '-' , '' , str_replace ( ':' , '' , $d ) ) ) ) ; return (str_replace ( '','', str_replace ( '-','', str_replace ( ':','', $
d)))); )
Or even this:
PHP: $d ) { plainDate function ($ d) (
( ' ' , $d ) ; $ pd =
explode ( '', $
d); ( '-' , $pd [ 0 ] ) ; $ dd =
explode ( '-', $ pd [0]); ( ':' , $pd [ 1 ] ) ; $ hp =
explode ( ':', $
pd [1]); $dd [ 0 ] . $dd [ 1 ] . $dd [ 2 ] . $hp [ 0 ] . $hp [ 1 ] . $hp [ 2 ] ) ; return ($ dd [0]. $ dd [1]. $ dd [2]. $ hp [0]. $ hp [1]. $ hp [2]);
)
Related Post
Thursday, October 30, 2008 Because of the different rendering between different browser, which certainly see Microsoft Internet Explorer in mind, we must always resort to apply for artifizi effects that now should be a standard. The multi-discussed rounded edges are a classic example of the "disaster" produced by the complete inability to achieve a standard seriously on page rendering HTML / CSS. There are numerous networking solutions that allow you to have "effects" (effects exempting dall'HTML present as rounded edges, shadow effects, reflections, etc ...) with patches on the sheets of styles, special tricks using div grafted , Javascript libraries, use of canvas etc ...
For purely educational I would explain further technical (cross-browser) to apply to the rounded edges of images:
Demos and sources
Continue reading ... "
Related Post
Tuesday, October 28, 2008 Chrome Google allows you to create Desktop applications from a Web page? In fact, as shown in the menu item, is simply allowed to create a shortcut to a shortcut that - in turn - opens a window without the address bar without all the frills of the browser. With this does not mean that we have created a Desktop, and we have just created a link to the same Google Chrome mode - so to speak-chrome-less.
Feature Simla, but more ambitious, had already been proposed by the Mozilla Foundation in 2007 through the Prism. This is certainly the most versatile and articulate, accompanied by a useful extension that allows you to create desktop applications menu of FireFox, like Google Chrome.
However, both solutions are far away from technology Adobe AIR. Before someone is confusing the good stress the substantial differences between a shortcut on the desktop, which opens a window without menus, and a desktop application true and proper.
Adobe AIR, in fact, unlike the solutions proposed by Google Chrome and Prism allows:
- Virtually complete access to the system running the application with the ability to read and write files. Opportunity to extend its functionality through a DLL (dynamic link library), extensions and third-party products as SHU Player (see Distribute Adobe AIR: AIR Badge by a SHU Player)
- It manages the application like any other system applications: installation and uninstallation
Related Post
Monday, October 27, 2008 Starting from post Wordpress: step by step how to create a login, performed the login procedure could be useful to indicate in our blog a link to the disconnection, or logout. We will not use again the standard procedures of Wordpress, but we'll see how to log out low level. First of all we must understand whether a user is logged on or not. This is possible simply querying the variable $user_ID of Wordpress. For example:
PHP: $user_ID != '' ) { // oppure if( is_user_logged_in() ) { if ($ user_ID! ='') (/ / or if (is_user_logged_in ()) (
/ / User is "logged" ...
)
Once we know that a user is logged in the system, we can insert a simple link to our page logout. Then we create a page, for example logout.php and inserting the following code:
PHP: / **
* Performs logout
*
* @ Author Giovambattista Fazioli
* @ @ Email g.fazioli undolog.com
* @ Http://www.undolog.com web
* /
/ / Invoke WordPress bootstrap
'wp-config.php' ) ; @ Require_once ( 'wp-config.php');
'wp-includes/pluggable.php' ) ; @ Require_once ( 'wp-includes/pluggable.php');
/ / Wp logout
wp_logout ();
/ / Load any other page
"Location: /" ) ; header ( "Location: /");
And just then "link" to our page to provide a logout procedures:
PHP: $user_ID != '' ) { if ($ user_ID! ='') (
; echo 'Run the <a href="logout.php"> logout </ a>'; )
Related Post
Friday 24 October, 2008 In this tutorial we'll see how to create a personal login procedure, using Ajax functionality via jQuery. There are several ways to customize the login Wordpress, for example through the use of hooks and filters add_action() add_filter() We use a more low-level, although we still interfaces to the kernel Wordpress. Also make sure to validate a user through the double email / password.
Why create a login?
- In some contexts can return uitle have the most control over the login page, to propose a custom layout to our registered users. You can also enrich the page with information, a logo from the classic "Password Forgotten?"
- To allow access via email (as shown here Treaty) instead of
user_login standard Wordpress - To be able to enter a login panel in the sidebar of our Blog
- And finally, to have a skeleton - and an idea - for a good Plugin

Environment
In our example / tutorial work on the root of Wordpress inside a folder mylogin I created two php files within this folder: index.php and logon.php The first contains the interface of our login, with all functions Javascript / jQuery which we serve. The second file, logon.php will contain the code to validate the user. Then we create a folder css and inside this file layout.css and a folder images Inside the folder images include a classic Ajax loader: create it online at AjaxLoad.info. At the end you should have:
Continue reading ... "
Related Post
Thursday, October 23, 2008 Mozilla Firefox lets you manage multiple profiles, features useful to those who, like me, develops Web sites and requires a series of extensions dedicated to debug and analysis of Web pages. Through the use of profiles you can configure different settings FireFox:
Firefox save your personal information such as bookmarks, passwords and preferences in a file called profile in a different location than the program files for Firefox.
On Windows Vista (see here for other operating systems) allows access to management profiles from Esegui command using:
One of the advantages in the use of profiles is to have a FireFox to navigate, without any toolbar and extensions for debugging and FireFox to develop, together with Firebug and all other development tools.
Related Post
Wednesday, 22 October, 2008 There is an abbreviated form for assigning "in flight" a value to a variable if another is not defined (undefined), using the logical OR operator (| |) - Double-pipe:
JavaScript: / / Pluto is undefined
var pluto;
; var foo = pluto | |'5 ';
pippo ) ; alert (foo);
/ / Result: 5
This technique is useful for writing functions with parameters:
JavaScript: param ) { miaFunc function (param) (
; var p1 = param | | 'benchmark';
/ / ...
)
But we must be careful to use this form as zero values such as 0 false are misinterpreted, because of "guilt" of the OR logic used:
JavaScript: ; pluto var = 0;
; var foo = pluto | |'5 ';
pippo ) ; alert (foo);
/ / Result: 5
; pluto var = false;
; var foo = pluto | |'5 ';
pippo ) ; alert (foo);
/ / Result: 5
; pluto var = 1;
; var foo = pluto | |'5 ';
pippo ) ; alert (foo);
/ / Result: 1
Related Post
Wednesday, 22 October, 2008 The standard template for Wordpress (like others) usually provide an alternate layout for the list of comments. In the standard template for example is set to a class css alt according to the logic:
PHP: / / File comments.php
$oddcomment ; ?>id= "comment-<?php comment_ID() ?>" > <li
<? php echo $ oddcomment;?> id =
"comment-<? php comment_ID ()?>> [...]
/ * Changes every other comment to a different class * /
empty ( $oddcomment ) ) ? 'class="alt" ' : '' ; $ oddcomment = (empty ($ oddcomment))? 'class = "alt"':'';
This causes the tag li $oddcomment is set once a blank ( "" and once class="alt" class class="alt" An amendment could be useful to introduce an additional class when is the author of the blog to post a comment:

I, for example, I used the following code into the file comments.php:
PHP: <? php
$comment -> user_id == 3 ) ? ' $ authcomment = ($ comment -> user_id == 3)? ' ; authcomment ':'';
empty ( $classcomment ) ) ? ( ( $authcomment == '' ) ? ' alt' : '' ) : '' ; $ classcomment = (empty ($ classcomment)), (($ authcomment =='')? 'alt':''):''; >
id= "comment-<?php comment_ID() ?>" > <li class = "<?=$ classcomment ?><?=$ authcomment?> "id =" comment-<? php comment_ID ()?>>
The row $comment->user_id==3 vary according to ID of your user. I would not use the administrator to respond to the blog, but I have my user ID=3 Normally l ID administrator 1 1, if you use this user can $comment->user_id==1 $ $comment->user_id==1 In this way besides having alternating layout on the comments left by visitors, is immediately recognizable response of the author of the blog.
Related Post