We're growing into something new. Read More
omarabid

Abid Omar


Discussion

WordPress plugin boilerplate

I'm working on a WordPress plugin boilerplate. It's a set of classes that layout the basics and starting point of your WordPress plugin. What I'm trying to achieve: 1. Simplified structuring of the plugin files 2. Helper files (like readme.txt for wordpress.org, license...) 3. Object Oriented 4. Unit Testing integration 5. Scripts to automate some stuff (for example, generate the translation files...) It's obviously still under work but I'm looking for suggestions, ideas and maybe if someone is interested to contribute some code to it.

Discussion

Premium Themes Search Engine (Beta)

I built Premium Themes to make finding themes easier. The Web App offers a responsive interface that shows up the screenshots of the different themes and filters them based on the criteria you define. The app is still not quite polished yet, but I launched early to gather some reviews. Thanks for checking it out.

Discussion

Self-Hosted WordPress Plugin Repository

This class enabled you to create your own self-hosted WordPress Plugin repository. This enables automatic updates for plugins that are not hosted in the WordPress plugin repository. For more information about the implementation, usage and an explanation about the actual class, you can read my article on WPTuts wp.tutsplus.com/tutorials/plugins/a-guide-to-the-wordpress-http-api-automatic-plugin-updates/

Discussion

PayPal ExpressCheckout gateway for WordPress

This class enables easy implementation of PayPal payment for your WordPress Plugin. The class was implemented first here, but then I decided to give it another look. A full tutorial was written for the purpose. It explains how the class is made. A testing plugin is also available in Github to ease testing There is no licensing for this class. Feel free to use it in Free or Commercial projects. No attribution is required, but it'll be appreciated ;)

$gateway = array(
    'username' => your_account_username,
    'password' => your_account_password,
    'signature' => your_account_signature,
    'version' => '84.0',
    'payment_action' => 'Sale',
    'payment_amount' => '20.00',
    'currency' => 'USD',
    'return_url' => 'http://localhost/devpress/wp-admin/admin.php?page=adpress-paypal_redirect&action=success',
    'cancel_url' => 'http://localhost/devpress/wp-admin/admin.php?page=adpress-paypal_redirect&action=cancel'
);

// Create a new instance of the class
$paypal = new wp_adpress_paypal($gateway, true);

// Get the redirect URL
$redirect_url = $paypal->doExpressCheckout();

// Process the payment
$payment = $paypal->processPayment();

PayPal ExpressCheckout for WordPress

I have been working lately on a WordPress advertising plug-in. I implemented PayPal Express Checkout and thought of sharing the class I wrote for it in case it help someone. Get the settings. You'd better sign up for a sandbox account and create a merchant account their. You can enable the sandbox mode by settings the second parameter to "True". Redirect the user. You need to redirect the user to the payment page. It's not possible to do that with PHP since WordPress admin pages already send the headers, so JavaScript is the way to go. Process the payment. After the user permission is granted, the user is returned to the return_url specified in the gateway array. You can know invoke the process payment function. This class will only work with WordPress. If you want to make it work with PHP, just figure out an alternative to the wp_remote_post function. The Class code is available on Github.

$('a[href^=#]').click(function(){
        var target_id = $(this).attr('href');
        var target = $(target_id);
        if (target.length)
        {
            var top = target.offset().top;
            $('html,body').animate({scrollTop: top}, 1000);
            return false;
        }
    });

jQuery simple scroller

I wanted today to add a nice scrolling effect to all my in-page links. Unluckily, I didn't find the right Google term to find out a nice/short and simple solution for that. So, simply, I did it myself. The following piece of code will detect every link that starts with "#" and bind it to an element with the same ID. It'll add the default sliding effect (1 Second). You can change the easing effect and timing for more fun ;) Looking for your comments

function Myclass(param) {
/*
 * Use this variable to put default arguments.
 */
this.default = {
 default: 'default'
};
/*
 * The arguments object
 */
this.arg = {};
/*
 * Extending the argument object.
 */
$.extend (this.arg, this.default, param);
/*
 * Shared property
 */
this.property = 'string';
}

/*
 * Public Method
 */
Myclass.prototype.method = function () {

};

/*
 * Creating a new instance of our class
 */
var settings = {
 settings: 'settings'
};
var myobj = new Myclass(settings);
// Calling a public method
myobj.method();
// Using a public property
console.info(myobj.property);

Minimalist JavaScript Framework

This code features a minimalist JavaScript framework to create small application that size 3kb or less. The structure The framework is based on the ability of JavaScript to convert a function to an object with the new keyword. You class is constructed around this function. In our example, it's "Myclass". This gives us many advantages: Create as many objects as you wish: You can initiate as many instances of the Myclass function as you want. If you create a widget class, you are not limited to creating only one in the page. Share "this" across public methods: The "this" keyword is shared across all functions that are attached to the main class prototype. This means that the "this.arg" object is accessible through the public method "Myclass.method()". Public methods and the main class (function) itself can use the other public methods. To access them, use "this.method()". Arguments One thing that I do too frequently is passing arguments to my initiated class. Usually, you have default parameters that are optional to change. The code features an elegant and simple solution to mix the passed arguments with an object (this.default) containing the default parameters. The code uses the jQuery extend function. Be aware that this technique doesn't account for validation. So if you are looking to validate the passed parameters, you'd better try something else. That's all? Yes! This framework is useful if you want to build very small applications or add some JavaScript code to the page. It's useful to keep all your code in one place and have a nice architecture that can scale your application if needed. I used this structure for code up to 15kb, but more than that I don't recommend it.