Archive

Posts Tagged ‘wordpress’

WordPress plugin hack to display a post with thumbnail

August 11th, 2011 No comments

amtyThumb plugin provides best way to generate thumbnail of an image. It can extract first image from any post. It provides you a single function to do this.

Now just edit your any plugin to display thumbnail along with post list.

Go to setting page of WP-PostViews page. You will find following text in Most Viewed Template:

<li><a href="%POST_URL%"  title="%POST_TITLE%">%POST_TITLE%</a> - %VIEW_COUNT% views</li>

Add %THUMBNAIL% option to above text

<li><img src="%THUMBNAIL%" /><a href="%POST_URL%"  title="%POST_TITLE%">%POST_TITLE%</a> - %VIEW_COUNT% views</li>

Modify wp-postviews/wp-postviews.php
search for “$output .= $temp;”. Add below line just before the searched test.

$temp = str_replace("%THUMBNAIL%", amty_lead_img(75,75,1,'','','zoom',$post->ID);, $temp);

You can edit plugin in the same manner. Otherwise wait for coming version of amty Thumb Post which has capability to display mostly, recently, rarely …. posts with thumbnail and with any style.

Read more about using amtyThumb here. This article will guide you more about amty_lead_img() function & to insert a thumbnail in your post using shortcode.

WordPress Multi Select Category Box

April 8th, 2011 4 comments

While developing some pages of my new site thinkzarahatke, I faced problem to display a multiple select category box. WordPress provides wp_dropdown_categories() function which display you a combo(select) box of categories. You can select only one category at a time.

Since I dint found any other function which can help me and I was not willing to use any plug in for the same so I set multiple attribute to select box at run time using jquery.

$(function() {
           $(".multiselect").attr( 'multiple', 'multiple' );
});

Using the above code you can make multi select category box easily.

Really Simplest CAPTCHA integration

March 13th, 2011 No comments

CATCHA is required for humanity check. So you can save your site from any script attack. If you are running a site on wordpress platform then implementing CAPTCHA would be so much easier. The same script you can use to integrate in any PHP site.

1

Write a function to display CAPTCHA somewhere on your site.

function Display_captcha(){
	$common_captcha = new ReallySimpleCaptcha();
	$common_captcha_defaults = array(
			'chars' =&gt; 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789',
			'char_length' =&gt; '4',
			'img_size' =&gt; array( '72', '24' ),
			'fg' =&gt; array( '0', '0', '0' ),
			'bg' =&gt; array( '255', '255', '255' ),
			'font_size' =&gt; '16',
			'font_char_width' =&gt; '15',
			'img_type' =&gt; 'png',
			'base' =&gt; array( '6', '18'),
			);

	/**************************************
	* All configurable options are below  *
	***************************************/

	// Set Really Simple CAPTCHA Options
	$common_captcha-&gt;chars = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789amty';
	$common_captcha-&gt;char_length = '4';
	$common_captcha-&gt;img_size = array( '72', '24' );
	$common_captcha-&gt;fg = array( '0', '0', '0' );
	$common_captcha-&gt;bg = array( '255', '255', '255' );
	$common_captcha-&gt;font_size = '16';
	$common_captcha-&gt;font_char_width = '15';
	$common_captcha-&gt;img_type = 'png';
	$common_captcha-&gt;base = array( '6', '18' );

	// Set common Form Options

	// Generate random word and image prefix
	$common_captcha_word = $common_captcha-&gt;generate_random_word();
	$common_captcha_prefix = mt_rand();
	// Generate CAPTCHA image
	$common_captcha_image_name = $common_captcha-&gt;generate_image($common_captcha_prefix, $common_captcha_word);
	// Define values for common form CAPTCHA fields
	$common_captcha_image_url =  get_bloginfo('wpurl') . '/wp-content/plugins/really-simple-captcha/tmp/';
	$common_captcha_image_src = $common_captcha_image_url . $common_captcha_image_name;
	$common_captcha_image_width = $common_captcha-&gt;img_size[0];
	$common_captcha_image_height = $common_captcha-&gt;img_size[1];
	$common_captcha_field_size = $common_captcha-&gt;char_length;
	// Output the common form CAPTCHA fields
	$common_captcha_arr = array(
		array ( 'img',$common_captcha_image_src,$common_captcha_image_width, $common_captcha_image_height),
		array ( 'text',$common_captcha_field_size),
		array ( 'hidden',$common_captcha_prefix),

	);
	return $common_captcha_arr;
}

2

Write a function to verify CAPTCHA.

function Verify_captcha($prefix,$code)
{
	$question_captcha = new ReallySimpleCaptcha();
		$question_captcha_prefix = $prefix;
		$question_captcha_code = $code;
		$question_captcha_correct = false;
		$question_captcha_check = $question_captcha-&gt;check( $question_captcha_prefix, $question_captcha_code );
		$question_captcha_correct = $question_captcha_check;
		$question_captcha-&gt;remove($question_captcha_prefix);
		$question_captcha-&gt;cleanup();
		if ( ! $question_captcha_correct ) {
			return false;
		}
		return true;
}

3

Display it somewhere on your form.

&lt; form
&lt; ?php $common_captcha_arr = Display_captcha(); ?&gt;
&lt; p class=&quot;common-form-captcha&quot;&gt;
&lt; img src=&quot;&lt;?php echo $common_captcha_arr[0][1]; ?&gt;&quot; alt=&quot;captcha&quot; width=&quot;&lt;?php echo $common_captcha_arr[0][2]; ?&gt;&quot; height=&quot;&lt;?php echo $common_captcha_arr[0][3]; ?&gt;&quot; /&gt;
&lt; input id=&quot;common_captcha_code&quot; name=&quot;common_captcha_code&quot; size=&quot;&lt;?php echo $common_captcha_arr[1][1]; ?&gt;&quot; type=&quot;text&quot; class=&quot;textfield2&quot; /&gt;
&lt; input id=&quot;common_captcha_prefix&quot; name=&quot;common_captcha_prefix&quot; type=&quot;hidden&quot; value=&quot;&lt;?php echo $common_captcha_arr[2][1]; ?&gt;&quot; /&gt;
&lt; /p&gt;
&lt; /form&gt;

4

Verify it.

if(! Verify_captcha($_POST['common_captcha_prefix'],$_POST['common_captcha_code'])){
  :
}

* You would have to download & Install really-simple-captcha

Embed Everything

December 13th, 2010 No comments

Many visitors are never interested to download the contents first then check them. They want to take snapshot about the contents from your site/article/post itself. You must help them to view documents online instead of downloading any document to their local PC or to installing any plugin. It’ll remove an overhead from your visitor and will increase hits on your site.


noticeboard embed everything to a webpage

What you need to embed

  1. Word document
  2. Power point presentation
  3. Excel worksheet
  4. PDF documents
  5. Video

I already had suggested about how to embed documents using google . But if you want to avoid any manual intervention then TGN plugin (for wordpress users) would be a good option.

How to use TGN

While writing an article, you can use short code to embed any document on your page. TGN must be installed in advance.

YouTube
[ youtube article-stack]

VideoReadr
[ videoreadr article-stack]

PDF
[ pdf article-stack]

PowerPoint
[ powerpoint article-stack]

Microsoft Word
[ word article-stack]

Note that: remember to replace “article-stack” keyword with valid link for your documents or video ID.

Let visitors read documents without downloading

December 13th, 2010 No comments

There is a very simple solution to display word documents , presentations, excel files etc on your own webpage itself. So people can read them directly without downloading the article and installing any plugin. You can take the help of google for this purpose.

noticeboard embed

For this,

  1. Either upload the documentation file on your server or arrange a link of any other server
  2. Place your link after the given link
    http://docs.google.com/viewer?url=

    For example;

    http://docs.google.com/viewer?url=http%3A%2F%2Fwww.jvds.nl%2Fclimateuncertaintyethics.ppt&embedded=true

Definitely, you would have to use “iframe” tag for this purpose. Read article Highly searched keywords in year 2010 for live demo.


Tip

Instead, if you are willing to display a website, document etc in a popup like thickbox then read the power of wordpress inbuilt thickbox. You can do it without installing any extra plugin.

Use the power of wordpress inbuilt thickbox

December 12th, 2010 No comments

Many people search for plugins to add support of jquery based thickbox. But do you know this is already included in your wordpress bundle. Let’s try
article-stack in wordpress inbuilt jquery thickbox

Suppose you want to open a webpage into thickbox. Just add following code at the end of last link we made above

&amp;embedded=true&amp;KeepThis=true&amp;TB_iframe=true&amp;height=400&amp;width=650

And add following code to your anchor tag.

  class=&quot;thickbox&quot;

For Example

For more guidance, refer jquery thickbox

WordPress security hack

September 16th, 2010 No comments

Do you avoid people to get registered on your site? …… Many people do this because they afraid.

There is common thinking in everyone’s mind that if you want to secure your wordpress blog then you must disable users to get registered on your site.


amty wordpress security hack logo

Registration on a site always attracts hackers. Many plug-ins may secure your blog. But some of them might be proved as a powerful & useful tool for hackers.

Here I am discussing about a plug-in which is very useful in point of security. But I used this to hack my own site.

Let’s do it.

1
Install wp file monitor plug-in. This plug-in monitors all files on your site. It prompts you if any file is manipulated by any hacker, virus or by any other utility. It prompts you even if you do any changes. It also can mail summary of changes.
2
Now register at your own site. And login as a subscriber. Remember that below steps shall not work until you log in.
If you are testing this hack on your localhost then you must know, how to register users on local machine?
3
Now this is the time to hack your own site. Put following URL in address bar of any internet browser like Epic.


http://localhost/wp-admin/options-general.php?page=WordPressFileMonitor&display=alertDesc

or
< your blog url >/wp-admin/options-general.php?page=WordPressFileMonitor&display=alertDesc

My aim behind writing this post is not to improve hacking but to aware people.

Here you’ll get a page informing you last modified files. You also can remove this information without any administrator permission. So the next time when owner of that site logins to dashboard, shall not be prompt for any modification. Only the problem is that if mail service for this plug-in is already enabled then the owner would be prompted via mails.

This hack will help you to collect more information about the site like latest changes, posts in draft, plug-in recently installed, theme, and various path along with file name.

WordPress security plugins for complete security, only 4

September 15th, 2010 No comments
wordpress army helmet

You’ll find many posts over wordpress security plug-ins. But I had excluded all plug-ins which do less work that you can do by changing some settings. Like creating .htaccess file etc.

I also not mentioned plug-ins related to SSL. SSL certificates let you connect to your server with encrypted channel which is very secure. You need to buy SSL certificate. You can use shared or private certificates. But in both cases you need to payment. Since most of the bloggers doesn’t go for buying SSL certificates. So I avoided them.

Try to use plug-ins as less as possible for the sake of performance. Some plugins may lead security hack

Moreover, I don’t consider a plug-in for database operation or backup procedure in security category. So all those plug-ins I’ll discuss in other article later.

You can achieve full security by using very less number of plug-ins. Some of them are;

Akismet - It helps you to protect from SPAM. In simple words you can say. If someone comments on a post just for advertisement or uses offensive word then Akismet can stop them.

Block Bad Queries (BBQ) - I hope all of you are aware with SQL injection. SQL injections are nothing but some complex SQL queries written with the aim of breaking your site security. And to get internal information of your site database as much as possible. This plug-in can control SQL injection & base64 attacks till some extension.

Login LockDown - Login LockDown controls number of unsuccessful login attempts. So you ever be safe from brute force & dictionary attack.

WordPress File Monitor - As its name suggest, it monitors all files on your server. This plug-in tells you about what files are changed on your server. So that you can identify whether the mentioned files are changed by you or by some script.

How to upload wordpress theme or plugin after development

September 2nd, 2010 1 comment
wordpress theme & plugin upload
Developing a plugin or theme is not as difficult as uploading this to WordPress server. right? at least it was true for me in starting.
After developing a plugin i uploaded it into wordpress database after 1 month. But when i started to update it, i took only some minutes to understand the complete process.

Let’s start

Develop your plugin and test it locally.

Notify WordPress team about your work

a. Create you account on wordpress .
b. Select “Add your plugin” from left menu. Fil basic information about your plugin or theme. So that wordpress team can access it and test it.

Wait for mail
Once your plugin is submitted to and tested by wordpress team you will get a mail. like this

    Your plugin hosting request has been approved.
    Within one hour, you will have access to your SVN repository at 

http://plugins.svn.wordpress.org/YOUR-PLUGIN-NAME/

    with your WordPress.org/bbPress.org username and password (the same one you use on the forums).
    Here's some handy links to help you get started.
    Using Subversion with the WordPress Plugins Directory 

http://wordpress.org/extend/plugins/about/svn/

    FAQ about the WordPress Plugins Directory 

http://wordpress.org/extend/plugins/about/faq/

    WordPress Plugins Directory readme.txt standard 

http://wordpress.org/extend/plugins/about/readme.txt

    readme.txt validator: 

http://wordpress.org/extend/plugins/about/validator/

    Enjoy!

It may confuse you little bit. But forget it

4. Download “Tortoise SVN” from http://subversion.tigris.org/. [you may have to login to download it]

5. Once the installation is done.

  1. Create a folder somewhere on your hard disk.
  2. Right click on the folder. And select “Create repository here”.
  3. Some folders will be created inside the folder you opted for repository.
  4. Again right click on the same folder. And select “SVN Checkout”. [To know more in detail you may visit wordpress]
  5. It will ask for login ID & Password. Use the id you use to login on wordpress plugin site.

tortoise SVN menu screen shot

6. Inside your plugin directory you will get three more folders

  1. trunk
  2. tags
  3. branches

7. Copy your plugin files in “trunk” folder.(dont archive them)

8. Make a readme.txt to tell something about your plugin or theme. refer its format.

Note
To check whether contents of your readme.txt are valid or not. Go to read me validator. Here you can paste contents of readme.txt. And can validate it.

Extra files
Providing screenshots to viewers of your plugin is really a good idea. It may fascinate users to use your plugin. Take some screenshot. And place them into “tags” folder of your repository folder. And specify their path into readme.txt.

Note
tags folder contain a version folder like “/2.0/”. All files are placed only inside version folder. This version must be similar to the version specified in you readme.txt

Save your work

What else. Just right click on your repository folder and select “SVN Commit”. Your work will be uploaded to wordpress server. You may check it by following http://plugins.svn.wordpress.org/YOUR-PLUGIN-NAME/

You may also refer my repository directory structure for further help.

CSS: PNG fix

September 2nd, 2010 No comments

I never suggest using PNG images since they are bigger in size and not compatible with many browsers. Although you can fix their appearance so their transparency can persist. But sometimes they are needful for web designers. So here I am mentioning some PNG fixes as per my experience.

These fixes may fix transparency of a PNG image. But you would have to test it with various version of internet browsers like IE 5,6,7 etc, various internet browsers like chrome, Firefox, epic, IE etc. And on various platform like Mac , Windows, Linux, Mobile OS.

Testing a page against so many browsers is really a tough job. Specially when you asked to test it on various platforms. You can use one click solution for this. It’ll not only save your time but money as well.

If you are wrodpress blogger then HITS- IE6 PNGFix might help you to fix PNG transparency in IE6. You may try it to other browsers as well. But author claims to fix in IE6 only.

1

andreaseberhard jquery png fix

This fix, based on jquery, is ultimate. It supports all version of IE above than 5.5 (including). Click on the image for online demo and how to use guide. You can directly download it from andreaseberhard.


2

twinhelix ie png fix

twinhelix PNG fix claims to fix transparency problem of any PNG file as well as ALPHA problem. It supports all the images inserted on the HTML page using < img > or background images. Click on the image to visit their demo page and how to use guide. I am not sure this fix is compatible with CSS3. But I had tested it against EPIC and firefox. And found it effective.
You can download this fix directly from twinhelix.

Please report me if you find any link broken.

PNG transparency is not only the problem for web designers. There are some more problems related to margin, floats etc. These problems always make me worry. But I have cure for margin Fix and floating fix. Please let me know if you are facing any other CSS related issue. Moreover, CSS compatibility charts can help you giving an idea about what part or browser you are missing from testing your webpage. I would like to find out more effective solutions as well as improving my knowledge.

Xampp : How to Run & Test WordPress locally

September 2nd, 2010 No comments

If you are planning to edit/create your own wordpress theme, XAMPP will be a best option to test it. Although creating WP themes using Artisteer is too easy and editing existing themes using ThemeDreamer is very simple. But how would they look in various browser is important. And at this point you need some platform where you can run wordpress.

Xampp will let you test your wordpress blog or any other PHP, JSP etc site locally. This tutorial will tell you about how to configure xampp and about how to configure wordpress on xampp.

1
Setup XAMPP

  1. Download xampp lite. It is free, smaller in size & direct run.
  2. Extract it to C drive. Now you will have a folder on C drive with name XAMPPLITE.
  3. Open setup_xampp.bat resides in XAMPPLITE folder.

    xampp folder
  4. Once you get success message, open “xampp-control.exe”
  5. Start Apache & MySql from the opened window.

    xampp controler
  6. To check whether XAMPP is working fine. Open following link in any Internet browser.
    
    http://localhost/xampp/splash.php
    
    or 
    
    http://localhost/xampp/
    

2
Setup WordPress

  1. Download wordpress. It is also smaller in size & free to use.
  2. Extract it to C:/XAMPPLITE/HTDOCS
  3. Open http://localhost/xampp/splash.php in any internet browser. Click on phpMyAdmin (under Tools in left sidebar).
  4. You will get a window given in below image. Copy the text exact which is marked in red in below image & click on CREATE button. This is the database name which will be used by wordpress. You are free to give your desirable name.
    xampp phpMyAdmin
  5. Open wordpress directory (C:/XAMPPLITE/HTDOCS/WORDPRESS/).
  6. Rename wp-config-sample.php to wp-config.php. And Open this file.
  7. You will find following code in starting of the file.
/** The name of the database for WordPress */
define('DB_NAME', 'putyourdbnamehere');
/** MySQL database username */
define('DB_USER', 'usernamehere');
/** MySQL database password */
define('DB_PASSWORD', 'yourpasswordhere');
/** MySQL hostname */
define('DB_HOST', 'localhost');

Replace the above code with below code.

/** The name of the database for WordPress */
define('DB_NAME', 'wordpress');
/** MySQL database username */
define('DB_USER', 'root');
/** MySQL database password */
define('DB_PASSWORD', '');
/** MySQL hostname */
define('DB_HOST', 'localhost');
3
setup your blog

Open;


http://localhost/wordpress/wp-admin/install.php

or 

http://localhost/wordpress/wp-admin/.

This is one time process to setup your blog. This will provide you id & password that you can change after login. Note it down somewhere because it’ll not display it again and you can not. Use the same above link to login to dashboard (like a control panel of your blog).

To run your blog type http://localhost/wordpress/ in any internet browser like epic.

Finally, your local server is ready to run your blog. Now the turn is to install some themes and plug-ins. You may also need some sample posts if you want to save your time while testing.
You can try my plug-in initially. It’ll give you more options to test. Read other articles over wordpress. And remember to make a user locally to complete your testing.
If you had published your site and want to test its appearance on various browsers and platform the browsershots can help you.

Please leave your feed backs, suggestions and ideas for another easy setup of any blog.

How to get the path of wordpress installation directory

August 1st, 2010 No comments

I seen many people asking site owners about their CMS platform.
It is easier to know it yourself. There is a fixed path pattern of every CMS. If a site is using wordpress CMS then path pattern should be like,

Domain Name/wp-admin

If you get wordpress login page by entering above path then you surely can say that site is built on wordpress CMS. But wordpress provides an easier way to change the path of wordpress installation directory. This option is available in wordpress dashboard under settings option. If a user had changed the path then it is really difficult to guess the path. Specially when site owner restricts crawler to index their site contents. In this case below google search will not help you

inurl:wp-admin site:article-stack.com

Well! it is pretty easy to know wordpress installation directory path. Use the below path

Domain Name/robots.txt

You’ll get a text file containing path as follow

Sitemap: Domain Name/sitemap-web.xml

User-Agent: *
Disallow: /wp/wp-admin/
:
Disallow: /go/
Disallow: /forums/profile/

If robots.txt revealing the path you are trying to hide then you must know why robots.txt is imported for your site.

In case of above example, wordpress installation directory is Domain Name/wp/

Please note this
This hack is not to attract hackers. But to improve security only.

amty thumb recent is now amty thumb posts

June 28th, 2010 68 comments

Well!! I had updated this article and deleted blah blah detail about this plugin. It makes me bore. Even though you can visit amtyThumb Post for more detail, features, FAQ, how to use it etc.

Why I deleted details from here?

With the version 7.0, amty thumb post has been changed a lot. You must have been read enough about it on wordpress plugin repository. If you miss something there, comment here. I’ll solve your problems

Why do you like this plugin?

Fully customizable plugin to show Recently written, Recently viewed, Random, Mostly & Rarely Viewd, Mostly Commented posts with thumbnail.

You can customize it in whatever way you want. It’s appearance depends on your imagination. Even if there is something which limits you, just comment here. I’ll add that feature ASAP.
download

Supportable plugin: amtyThumb

Screen Shots:

amty thumb post screenshotamty thumb post screenshot

amty thumb post screen shotamty thumb post screen shot

amty thumb post screenshotamty thumb post screen shotamty thumb post screen shot

More images