- Premium Data
- Getting Started
- 51Degrees.php Config
- Using the Detector
- Advanced Usage
- Accessing Metadata
- Image Optimiser
- Client Side Overrides
- Passing Properties To Client Side
- User Performance Monitoring
- Usage Sharing
- Automatic Data Updates
- Advanced Suggestions
Using 51Degrees Properties within a Theme
- With the plugin installed and activated, login as a user account with sufficient permissions to customise a themes PHP code.
- In the editor screen look on the right hand side menu and find the file name that reads "Main Index Template (index.php)" and click it.
- Within this file find the following lines of code.
Navigate to the theme editor by clicking on "Appearance" and then "Editor" (in the left hand menu). This will display the code of the current theme.
For this tutorial the default theme, "Twenty Eleven", is in use.
The main screen will change to show all the PHP code contained within this file.
<div id="content" role="main">
They are located near the beginning of the file after the file description comments.
As the $_51d variable is declared in global scope, you will need to use the global keyword to use it.
Also note that that all properties are given as strings, even if the property is boolean. This is to ensure data consistency.
Add the following code after the lines found above.
echo "Welcome Mobile Visitor";
echo "Welcome Non-Mobile Visitor";
The changes should be similar to the following screen shot.
The addition of this small piece of code within the Wordpress theme will print a message on the main index page of your Wordpress site. The message will change depending on whether the visitor is using a mobile device or a non-mobile device.
All the properties exposed by the plugin are accessible via the
array. You could use
to easily see all the properties and values available. See the
for more information.
The paid for versions of the plugin contain more properties and features. Learn more .
51Degrees.mobi paid for device data can be distributed under licence with 3rd party skins or plugins. Please contact us for more information.
To disable redirection (eg, to have a link to the desktop site) you will need to 'NO_SWITCH' to true:
$SESSION['NO_SWITCH'] = true;
This needs to be set before the desktop page is loaded. Redirection can be re enabled by