This article will guide you in to create a simple firefox extension . There are three different techniques you can use to build extensions: Add-on SDK-based extensions, manually bootstrapped restartless extensions, and legacy extensions. This tutorial will take you through the steps required to build a very basic extension – one which adds a action button . SDK Installation Prerequisites To develop add-ons using the current Add-on SDK, you’ll need:
- Python 2.5, 2.6 or 2.7. Note that versions 3.x of Python are not supported on any platform.
- Firefox Browser.
- The SDK itself: you can obtain the latest stable version of the SDK as a tarballor azip file.
Steps to Create firefox extension
Extract the file contents wherever you choose, and navigate to the root directory of the SDK with a shell/command prompt. For example: tar -xf addon-sdk.tar.gz cd addon-sdk
Then, if you’re a Bash user, run: source bin/activate
Your command prompt should now have a new prefix containing the name of the SDK’s root directory: (addon-sdk)user@user-Lenovo-B570e:~/addon-sdk$
The activate command sets some environment variables that are needed for the SDK. It sets the variables for the current command prompt only. If you open a new command prompt, the SDK will not be active in the new prompt until you type activate again. Initializing an empty add-on In the command prompt, create a new directory. The directory doesn’t have to be under the SDK root: you can create it anywhere you like. Navigate to it, type cfx init, and hit enter: mkdir my-addon cd my-addon cfx init
Folder structure of the add-on From the command cfx init automatically folders will be created their structure will be like my-addon/
- data/
- lib/ main.js
- test/
- package.json
Data This folder contain images and all the other javascript,html etc files. At the creation of the folder this folder is empty. Lib This folder contain and is created at the time of initialization main.js file. this the the main file from where the the program start from here you can refer other file for functionality in the data folder. Test This folder contain a test.js file which test that add-on . you can use this command to test . cfx test
- package.json
The package.json file contains manifest data for your add-on, providing not only descriptive information about the add-on for presentation in the Add-ons Manager, but other metadata required of add-ons. Some of its entries, such as icon, name, and description, have direct analogues in the install manifest format, and entries from package.json are written into the install manifest when the add-on is built using command cfx xpi
. Others, such as lib, permissions, and preferences, represent instructions to the cfx tool itself to generate and include particular code and data structures in your add-on.
Implementing the add-on Now you can write the add-on’s code, which goes in the “main.js” file in your “lib” directory. This file was created for you in the previous step. Open it and add the following code: var buttons = require('sdk/ui/button/action'); var tabs = require("sdk/tabs");
var button = buttons.ActionButton( id: “mangocoders”, label: “Visit mangocoders”, icon: { “16”: “./icon-16.png”, “32”: “./icon-32.png”, “64”: “./icon-64.png” }, onClick: handleClick }); function handleClick(state) { tabs.open(“http://www.mangocoders.com/”); } To run and try the add-on use : cfx run
Packaging add-on :
When you’ve finished the add-on and are ready to distribute it, you’ll need to package it as an XPI file (xpi is like a zip file). This is the installable file format for Firefox add-ons. You can distribute XPI files yourself or publish them to https://addons.mozilla.org so other users can download and install them. To build an XPI, just execute the command : cfx xpi
[4:30:26 رات] Adil Gulzar: http://i1.wp.com/www.mangocoders.com/wp-content/uploads/2015/06/ff.jpg?w=220 [4:31:03 رات] Adil Gulzar: Add super admin user of wordpress via database [4:31:19 رات] Adil Gulzar: This tutorial will guide you to add super admin user . There can be times when you seem to be locked out of your account. This can happen via a code error, a hack, accidental admin account deletion, or a malicious site partner changing information on you. If this happens, you will need to create a new admin account in order to regain access to the administration interface. You will need to do this by interacting directly with the database. Below is a step by step guide to add super admin user just that in your WordPressinstallation.
Steps To Add super Admin User
Step 1: Login into your database (i have used Adminer you can use your own datebase interface like PHPMyAdmin,mysql etc.) You can insert the below query to add super admin user in wp_users table. INSERT INTO `wp_users` (`user_login`, `user_pass`, `user_nicename`, `user_email`,
`user_url`, `user_registered`, `user_activation_key`, `user_status`, `display_name`)
VALUES ('demo', MD5('demo'), 'Your Name', 'test@yourdomain.com', 'http://www.test.com/',
'2011-06-07 00:00:00','', '0', 'Your Name');
Or you can insert it by the table ,click the wp_users table then click the new item to insert a new admin user. In the insert form, add the following :
- ID –It will be incremented automatically (As shown in the figure) .
- user_login – Insert the user name with which you will login the WordPressDashbaord.
- user_pass – Add a password for this username. Make sure to select MD5 in the functions menu (Refer to the screenshot above).
- user_nicename – Put a nickname or something else that you would like to refer yourself as
- user_email – Add an email address with which you can associate with this account.
- user_url – This would be the url to your website.
- user_registered – Select the date/time for when this user is registered.
- user_status – Set this to 0.
- display_name – Put the name you like to display for this user on the site (it can be your user_nicename value as well).
- Click the Save button .
Step 2: Next we are going to have to add the values to wp_usermeta table. you can add this SQL query command . INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`,
`meta_value`)
VALUES (NULL, (Select max(id) FROM wp_users), 'wp_capabilities',
'a:1:{s:13:"administrator";s:1:"1";}');
Or Click on the wp_usermeta table and then click on the New Item just like the previous step. Then add the following information to the insert form:
- umeta_id – Leave this blank (it will be auto-generated).
- user_id – This will be the id of the user you created in the previous step. Since it was auto incremented so take a look at the wp_users table and select the last userid since it will be the one that was recently added .
- meta_key –Its Value should be wp_capabilities
- meta_value – Insert this: a:1:{s:13:”administrator”;s:1:”1″;}
- Click the Save button.
Step 3: Insert another row with the following information: use the SQL command. INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, (Select max(id) FROM wp_users), 'wp_user_level', '10');
Or Click on the wp_usermeta table and then click on the New Item just like the previous step. Then add the following information to the insert form:
- umeta_id – Leave this blank (it will be auto-generated).
- user_id – This will be the id of the user you created in the previous step. Since it was auto incremented so take a look at the wp_users table and select the last userid since it will be the one that was recently added .
- meta_key – Its Value should be wp_user_level
- meta_value – Insert this : 10
Then click on the Save button, and you have created a new super admin user. Now you should be able to login to your wp-admin with the username and password you specified for this super user. Once logged in, click on Users and edit the username you just created. Go down and click on the Save button (you don’t have to change anything). This will allow WordPressto go through and add some more information and clean-up the user we just added.