Android & Wordpress Help center

Archive for the month “June, 2012”

Add custom font type in Android

Adding custom font type other than the default – ‘sans’, ‘serif’, ‘monospace’ & ‘normal’ font types is pretty easier than one can think of!

We can start by creating an xml file to place our TextView :

<?xml version=”1.0″ encoding=”utf-8″?>

<LinearLayout xmlns:android=”;

android:text=”This is the Chantelli Antiqua font.”


Here we have a TextView with id ‘custom_font_text’, this has been added as we need to add custom font to this TextView programmatically. Now here is what has to be done next –

1) Download a custom font of your choice- the file will be of the format ttf or otf. For instance here we have used ‘HelveticaNeue-Roman.otf’.

2) Put this file in assets folder of your current project.

3) Use the below mentioned code to use this font in your activity –

TextView myText = (TextView) findViewById(;
Typeface font = Typeface.createFromAsset(getAssets(), “.HelveticaNeue-Roman.otf”);

The above code will set the font typeface for this particular TextView to HelveticaNeue-Roman.


WordPress : Add administration/settings menu for plugins

To add an administration menu, you must do three things:

  1. Create a function that contains the menu-building code
  2. Register the above function using the “admin_menu” action hook (if you are adding an admin menu for the Network, use “network_admin_menu” instead)
  3. Create the HTML output for the page (screen) displayed when the menu item is clicked

It is that second step that is often overlooked by new developers. You cannot simply call the menu code described; you must put it inside a function, and then register the function.

Here is a very simple example of the three steps just described. This plugin will add a sub-level menu item under the Settings top-level menu, and when selected, that menu item will cause a very basic screen to display. Note: this code should be added to a main plugin PHP file or a separate PHP include file.

add_action( 'admin_menu', 'my_plugin_menu' ); 
function my_plugin_menu() { 

// My Plugin Options => Page title
// My Plugin => Label in sub-menu
// manage_options => capability
// my-unique-identifier => page identifier 
// my_plugin_options => call back function name

add_options_page( 'My Plugin Options', 
'My Plugin', 
'my_plugin_options' ); 

function my_plugin_options() { 
if ( !current_user_can( 'manage_options' ) ) { 
 wp_die( __( 'You do not have sufficient permissions to access this page.' ) ); 

echo '<div>'; echo '<p>Here is where the form would go if I actually had options.</p>'; 
echo '</div>'; 


In this example, the function, my_plugin_menu(), adds a new item to the Administration menu via the add_options_page function. Note: more complicated multiple menu items can be added, but that will be described later. Notice the add_action line–that invokes the hook which “registers” the function, my_plugin_menu(). Without that add_action, a PHP error for “undefined function” will be thrown when attempting to activate the plugin. Finally, the add_options_page code refers to the my_plugin_options() function which contains the actual page to be displayed (and PHP code to be processed) when someone clicks the menu item.

The actual detail of these processes is described in more detail in the sections below. Remember to enclose creation of the menu and the html page in functions, and invoke the admin_menu hook to get the whole process started!

The above code will create a sub-menu under the Settings tab with the name “My Plugin”

References :

Post Navigation