Categories
PHP

My First WordPress Plugin: GAF Text Link

Updates:

  1. The plugin has been listed on the GetAFreeLancer.com Affiliates page with a link back to this page. https://www.getafreelancer.com/affiliates/ . They also left a gift for me… 🙂 Thanks to the GAF authority! 😀
  2. Version 1.1 has been completed and been submitted to WordPress plugin directory. This version lets you configure your GetAFreeLancer username via an admin panel.
  3. This post has been made the plugin home page. I love WordPress ! 😀

Original Post:


I have been looking forward to writing a plugin for wordpress for a long time and finally got the chance today. WordPress is a super cool publishing platform and the “de-facto” blogging solution in today’s internet. The extendibility of WP makes it even more acceptable to users like me who has the necessary skills to extend it the way I want 🙂

I have never worked with the WordPress Codex before. I am a freelance programmer and do some projects at different free lancing sites like ScriptLace and GAF. I also work part time as an SEO strategist and offer SEO audit services from iQ SEO. I have seen the GAF API before but never felt much interested until recently GAF Affiliates program started making money for me 😀 Now that I am banned in Google Adsense, the alternative advertising solutions are not that good and over all I write programming related posts on my blog, it would be a good idea to start the affiliate marketing on my blog, I thought! 🙂 Linkedin automation tools take care of everything from lead generation to messaging and connection requests.

I published scriptlance rss feeds in my blog sidebar before but that didn’t help much. So, I started looking for a better way to integrate my affiliate links into my blog posts. The best way around was to insert the affiliate links directly into my blog either by editing the template or by writing a dedicated plugin for the purpose. I already had some desires to write WP plugins so I moved that way. I spent about an hour on the WordPress Codex pages searching for informations. It was easier than I thought. Check out https://stellarseo.com for more.

It took around 30 minutes to bundle everything and finalize the plugin. I quickly set it up and tested on my site. It’s working! 😀

Download: (v1.1) http://masnun.googlecode.com/files/masnun-gaf.zip

Download the php file and copy it to your /wp-content/plugins/ directory. Now login to your WP Admin panel (Dashboard) and from the “Plugins” section, activate “GAF Text Link”. Now visit your blog! You’re done if everything went right 😀

Feel free to play with it! 😀

Categories
PHP

Pen Drive Content Copier with PHP: The Source Code

Nothing much to say. I am writing a PHP program that is intended to monitor for the availability of a directory and copy all data of that directory into another directory. It still needs huge improvements, testing and bug fixing. It was really fun coding it! 😀

Feel free to play with the codes and drop me a few lines if you have something to say ! 😀

Here’s the source code:

Categories
PHP

Calling system() on PHP

PHP is no longer just a scripting language for web automation. It has grown very rapidly and now holds the position of the 3rd most popular programming language worldwide. PHP is now being widely used for CLI programs and even GUIs 😀

While working on a daemon script at Leevio, I was executing a shell script using the shell_exec() function. Rana vai pointed me to the system() function which is quite identical to it’s C equivalent. I was really glad to have found it at last. I was looking for a function that has interactive output like Python’s os.system() call. It was in PHP from PHP4 and I never looked into it! 🙁 Shame on me!

The system() function takes a command, executes it, prints out all the outputs of the command and returns the last line of the output. We can additionally pass a variable as the optional second parameter that will hold the entire return value.

The “ls” command lists all the contents of a directory. The above php script is supposed to print out all the contents of the current working directory aka CWD 😀