Very short snippet: Wordpress administrator?

Monday, November 3, 2008

Administrator or underwriter? Here's a quick way to understand this:

PHP:
  1. ; global $ user_ID;
  2. / /
  3. $user_ID , 'wp_capabilities' ) ; $ get_usermeta capabilities = ($ user_ID, 'wp_capabilities');
  4. / /
  5. is_array ( $capabilities ) ) { if (is_array ($ capabilities)) (
  6. $capabilities [ 'Administrator' ] == 1 || $capabilities [ 'administrator' ] == 1 ) { if ($ capabilities [ 'Administrator'] == 1 | | $ capabilities [ 'administrator'] == 1) (
  7. ; echo "You are an administrator";
  8. )
  9. )

Or, as "contracted"

PHP:
  1. ; global $ user_ID;
  2. / /
  3. $user_ID , 'wp_capabilities' ) ; $ get_usermeta capabilities = ($ user_ID, 'wp_capabilities');
  4. / / $ Admin is true if administrator
  5. $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

Wordpress: remove the menu

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:
  1. remove_menu_item function () (
  2. ; global $ menu;
  3. / / By label
  4. ( 'Design' , 'Impostazioni' , 'Plugins' ) ; $ removes = array ( 'Design', 'Settings',' Plugins');
  5. / / Through links
  6. / / $ Removes = array ( 'themes.php', 'options-general.php', 'plugins.php');
  7. $removes as $todel ) foreach ($ removes as $ todel)
  8. $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;)
  9. / / Through links
  10. / / Foreach ($ menu as $ key => $ sm) if ($ sm [2] == $ todel) (unset ($ menu [$ key]); break;)
  11. )
  12. / /
  13. , '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

Wordpress: write a personal logout

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:
  1. $user_ID != '' ) { // oppure if( is_user_logged_in() ) { if ($ user_ID! ='') (/ / or if (is_user_logged_in ()) (
  2. / / User is "logged" ...
  3. )

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:
  1. / **
  2. * Performs logout
  3. *
  4. * @ Author Giovambattista Fazioli
  5. * @ @ Email g.fazioli undolog.com
  6. * @ Web http://www.undolog.com
  7. * /
  8. / / Invoke WordPress bootstrap
  9. 'wp-config.php' ) ; @ Require_once ( 'wp-config.php');
  10. 'wp-includes/pluggable.php' ) ; @ Require_once ( 'wp-includes/pluggable.php');
  11. / / Wp logout
  12. wp_logout ();
  13. / / Load any other page
  14. "Location: /" ) ; header ( "Location: /");

And just then "link" to our page to provide a logout procedures:

PHP:
  1. $user_ID != '' ) { if ($ user_ID! ='') (
  2. ; echo 'Run the <a href="logout.php"> logout </ a>';
  3. )

Related Post

Wordpress: step by step how to create a login

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 : D

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:

  • mylogin
    • index.php
    • logon.php
    • css
      • layout.css
      • images
        • ajax-loader.gif

Continue reading ... "

Related Post

Wordpress: improving the list of comments

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:
  1. / / File comments.php
  2. $oddcomment ; ?>id= "comment-<?php comment_ID() ?>" > <li <? php echo $ oddcomment;?> id = "comment-<? php comment_ID ()?>>
  3. [...]
  4. / * Changes every other comment to a different class * /
  5. 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:

image

I, for example, I used the following code into the file comments.php:

PHP:
  1. <? php
  2. $comment -> user_id == 3 ) ? ' $ authcomment = ($ comment -> user_id == 3)? ' ; authcomment ':'';
  3. empty ( $classcomment ) ) ? ( ( $authcomment == '' ) ? ' alt' : '' ) : '' ; $ classcomment = (empty ($ classcomment)), (($ authcomment =='')? 'alt':''):'';
  4. >
  5. 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

Wordpress: modify AdminBigWidth for developers

Friday 17 October, 2008

AdminBigWidth is a Plugin for Wordpress able to set the working area of full-screen. It is a really simple plug and trivial, because the code does is change the CSS .wrap

PHP:
  1. AdminBigWidth function () (
  2. ; echo '<style type="text/css">. wrap (max-width: none) </ style>';
  3. )
  4. , 'AdminBigWidth' ) ; add_action ( 'admin_head', 'AdminBigWidth');

For those who like me use the Wordpress editor in HTML mode can be useful to set a fixed characters, such as Courier, rather than the proposed default font. In this way, at least for developers, it is easier to align source code. To do this simply add the style of AdminBigWidth, a new approach that is reflected CSS sull'editoria when in HTML mode. You could write a Plugin (two lines) to do this, but it is better exploit its code AdminBigWidth, so as to avoid a further burden due all'ennesimo Plugin:

PHP:
  1. AdminBigWidth function () (
  2. ; echo '<style type="text/css">. wrap (max-width: none) # # editorcontainer content (font-family: "Courier New, Courier, monospace) </ style>';
  3. )
  4. , 'AdminBigWidth' ) ; add_action ( 'admin_head', 'AdminBigWidth');

Related Post

Wordpress: how to write a reply to comment using jQuery

Friday October 3, 2008

Recently Cristiano Fino issued a profit Plugin for Wordpress can add two links to every comment by a post (perhaps you have installed a similar, given that the directory Wordpress.org I have a couple astray, but as an Italian software would be the event to honor the excellent work done by Cristiano). These Link (reply & shares), meet and / or quote the author of a commentary by running the boring operation to insert the character at (@) to indicate to whom it is addressed. In this tutorial I will explain - in the medium-expert users - how to add these two features "on hand", without any all'istallazione Plugin. Also exploit the capabilities of jQuery to the party in Javascript. The technique is exhibiting the same I used to introduce this feature in this blog.

Note: The use of a plug is the best solution for those who often tend to change their Wordpress template or at least, has in anticipation of doing so. This tutorial will only show how to perform targeted in the code Wordpress and is dedicated to the most curious.

Changing the file comments.php

The first change to make is to enter the link "reply" and "units" within each comment. To do this, edit the file comments.php located in the folder of our theme. This file contains all the instructions that allow you to view the comments at the end of a post. The section that interests us (which may vary slightly from issue to issue) is the loop creation of the various comments, recognizable by:

Continue reading ... "

Related Post

ABS-WP: Ver.1.11 on WordPress.org

Monday, September 8, 2008

Now you can download the plugin for Wordpress WP Add Browser Search directly from the site of Wordpress.org :)

ABS-WP

Related Post

ABS-WP: update release 1.1

Thursday 28 August, 2008
Update: latest

On the request of Yuri, who asked how to use the Plugin for WordPress WP Browser Add Search to add Google search AdSense for Search! So I released an update Plugin (downloadable here) that lets you set through a classic options panel, the parameters for the file descriptor XML standard OpenSearch.

Continue reading ... "

Related Post

ABS-WP: Add your blog to search browser

Thursday, August 21, 2008
Update: latest

OpenSearch is a standard that defines a set of formats for the sharing of search results. This standard is used, for example, from Social Network as Facebook, which have a system of research. One of the uses of this standard for browsers that support it, is the ability to automatically recognize and then add your own website or blog to the list of search engines in the drop-down menu of your browser:

image

If you visit (with Firefox or Flock) the search engine Divoogle, you can insert between the search engines on the menu.
This, however, could be done manually by selecting "Manage Search Engines ..." in Firefox, for example. But besides being a particular, each user should individually play. Latest browser, like Flock, thanks to allow standard OpenSearch to automate this function, reporting automatically to the website or blog offers its own search engine:

image

WordPress Plugin: Your Blog in the list of search engines

The procedure manual, useful to activate this feature everywhere, so we shall see below. In the meantime, if you have a Wordpress Blog, you can install this simple Plugin (wp-abs.zip) that does all the work for you. Once installed and activated will not have to configure anything! Loading your Wordpress Blog on Firefox or Flock, magically find your blog listed in the pulldown menu of search engines.
For the source see here.

Installation manual of standard OpenSearch

For those wishing to perform the installation of the OpenSearch standard in manual mode can follow the simple tutorial sample exposed below and / or refer to the documentation on this site OpenSearch.

To report the presence of a search engine the browser simply create an XML file on our website or blog. For example, here's the file of opensearch_desc.xml undolog.com:

XML:
  1. ? > <? Xml version = "1.0"?>
  2. <= Xmlns OpenSearchDescription "http://a9.com/-/spec/opensearch/1.1/"
  3. > xmlns: moz = "http://www.mozilla.org/2006/browser/search/">
  4. <ShortName> Undolog </ ShortName>
  5. <Description> Open Search Undolog.com </ Description>
  6. width = "16" type = "image/x-icon" > http://www.undolog.com/favicon.ico </Image > <image "16" Height = width = "16" type = "image/x-icon"> http://www.undolog.com/favicon.ico </ Image>
  7. method = "get" template = "http://www.undolog.com/?s={searchTerms}" /> <url Type = "text/html" method = "get" template = "http://www.undolog.com/?s={searchTerms}" />
  8. http://www.undolog.com/ </moz :SearchForm > <moz :SearchForm> http://www.undolog.com/ </ moz: SearchForm>
  9. </ OpenSearchDescription>

As you can see its format is fairly simple. The important point is the line 7:

XML:
  1. ...
  2. method = "get" template = "http://www.undolog.com/?s={searchTerms}" /> <url Type = "text/html" method = "get" template = "http://www.undolog.com/?s={searchTerms}" />
  3. ...

This tells the browser how and where to search. Usually, as in this case, using the standard Wordpress:

CODE:
  1. http://mioblog.com/?s=stringa to search

But according to need, as I did for Divoogle, this piece of code can vary. Once you create this file, simply insert a tag link head section of our home page:

HTML:
  1. <! - Opensearch ->
  2. type = "application/opensearchdescription+xml" href = "http://www.undolog.com/opensearch_desc.xml" title = "Undolog" / > <link rel = "search" type = "application/opensearchdescription+xml" href = "http://www.undolog.com/opensearch_desc.xml" title = "Undolog" />

Through the attribute rel="search" link will report to the browser (which supports it) to retrieve all information to add the search engine.

Related Post