Ajax WordPress Login
We are happy to release “Ajax WordPress Login” a new WordPress This plugin allow you to display login widget in your WordPress. It’s useful for sites that would like to avoid the normal WordPress login pages. Login uses AJAX and jQuery effects.
http://wordpress.org/plugins/wp-ajax-login/
Features:
- Login Form.
- Register Form.
- Forgot Password Form.
- Error handling without refreshing your screen.
- Optional ReCaptcha verification for login and register forms.
- Control forgotten password request.
- Work with forced SSL logins.
- Specific option to show link to profile page and dashboard.
- Customizable redirect URL after log in or log out.
- Option to show or hide avatar and change it size.
- It’s responsive!
Understanding Regular Expression
Regular expression is the most important part in form validations and it is widely used for search, replace and web crawling systems. If you want to write a selector engine (used to find elements in a DOM), it should be possible with Regular Expressions. In this post we explained few tips that how to understand and write the Regular Expression in simple way.
Will discuss about basic regular expression in three stages.
Stage 1
Symbol Explanation
^ Start of string
$ End of string
. Any single character
+ One or more character
\ Escape Special characters
? Zero or more characters
Input exactly match with “abc”
var A = /^abc$/;
Input start with “abc”
var B = /^abc/;
Input end with “abc”
var C = /abc$/;
Input “abc” and one character allowed Eg. abcx
var D = /^abc.$/;
Input “abc” and more than one character allowed Eg. abcxy
var E = /^abc.+$/;
Input exactly match with “abc.def”, cause (.) escaped
var F = /^abc\.def$/;
Passes any characters followed or not by “abc” Eg. abcxyz12….
var G = /^abc.+?$/
Stage 2
Char Group Explanation
[abc] Should match any single of character
[^abc] Should not match any single character
[a-zA-Z0-9] Characters range lowercase a-z, uppercase A-Z and numbers
[a-z-._] Match against character range lowercase a-z and ._- special chats
(.*?) Capture everything enclosed with brackets
(com|info) Input should be “com” or “info”
{2} Exactly two characters
{2,3} Minimum 2 characters and Maximum 3 characters
{2,} More than 2 characters
Put together all in one URL validation.
var URL = /^(http|https|ftp):\/\/(www+\.)?[a-zA-Z0-9]+\.([a-zA-Z]{2,4})\/?/;
URL.test(“http://selvabalaji.com); // pass
URL.test(“http://www.selvabalaji.com”); // pass
URL.test(“https://selvabalaji.com/”); // pass
URL.test(“http://selvabalaji.com/index.php”); // pass
Stage 3
Short Form Equivalent Explanation
\d [0-9] Any numbers
\D [^0-9] Any non-digits
\w [a-zA-Z0-9_] Characters,numbers and underscore
\W [^a-zA-Z0-9_] Except any characters, numbers and underscore
\s – White space character
\S – Non white space character
var number = /^(\+\d{2,4})?\s?(\d{10})$/; // validating phone numbernumber.test(1111111111); //pass
number.test(+111111111111); //pass
number.test(+11 1111111111); //pass
number.test(11111111); //Fail
Magento Remove index.php from url
Magento by default added the index,php in url .So,As per the SEO page will not get indexed properly SO here we have try to Remove index.php in url from both End Access Magento URL without index.php
For example:
http://domain.com/index.php/category to
http://domain.com/categoryThen Just follow steps
1) Login to admin section by using the URL http://domain.com/index.php/admin
2) then go to “System >> Configuration >>Web >> Search Engines Optimization” Use Web Server Rewrites : YES
3) Go to “System >> Configuration >>Web >>Secure” Use secure URL Frontend: YES
4)Then create the .htaccess file under your the magento installed folder.
If the magento installed under document root ( /home/username/public_html) then add follogig rules into .htaccess file
RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] and If the magento installed under /shop or directory then add the following rules into ” /home/username/public_html/shop/.htaccess ” file. RewriteEngine On RewriteBase /shop/ RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /shop/index.php [L]Thst's it just refresh the cache .Hope this will help!
DownloadUrlContent from other site using Curl Method
function DownloadUrlContent($Url,$fields=array(”)){
if (!function_exists(‘curl_init’)){
die(‘CURL is not installed!’);
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $Url);
curl_setopt($ch, CURLOPT_REFERER, “http://www.google.com/”);
curl_setopt($ch, CURLOPT_USERAGENT,’Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.18) Gecko/20110614 Firefox/3.6.18′);
curl_setopt($ch, CURLOPT_HTTPHEADER,array(‘Expect:’));
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 0);
if(count($fields)>0){
foreach($fields as $key=>$value) { @$fields_string .= trim($key).’=’.trim($value).’&’; }rtrim(trim($fields_string),’&’);
$fields_string = substr($fields_string,0,strlen($fields_string)-1);curl_setopt($ch,CURLOPT_POST,count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
}
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
Related articles
- Lets begin curl scripting (ravidhavlesha.wordpress.com)
- Facebook like fetch url data using PHP Curl, Jquery and Ajax (itzurkarthi.com)
- Creating Custom Widgets for dashEE (christophermonnat.com)
- Intelligent (Pharma) Spam Decoded (sucuri.net)
- cURL how to make program continue after failing to connect to certain host (stackoverflow.com)
Share API
Share API
Reading and Creating Shares
Use the Share API to have a member share content with their network or with all of LinkedIn. This can be a simple short text update, similar to Twitter. Or a URL with a title and optional photo. Or both.
You can also forward the shared content to Twitter and reshare another member’s share.
Adding New Shares
To add a new share, you markup the content in XML and issue a HTTP POST to the following URL:
URL
To have LinkedIn pass the status message along to a member’s tethered Twitter account, if they have one, modify the URL to include a query string of twitter-post=true.
Fields for the XML Body
Node | Parent Node | Required? | Value | Notes |
---|---|---|---|---|
share | — | Yes | Child nodes of share | Parent node for all share content |
comment | share | Conditional | Text of member’s comment. (Similar to deprecated current-status field.) | Post must contain comment and/or (content/title and content/submitted-url). Max length is 700 characters. |
content | share | Conditional | Parent node for information on shared document | |
title | share/content | Conditional | Title of shared document | Post must contain comment and/or (content/title and content/submitted-url). Max length is 200 characters. |
submitted-url | share/content | Conditional | URL for shared content | Post must contain comment and/or (content/title and content/submitted-url). |
submitted-image-url | share/content | Optional | URL for image of shared content | Invalid without (content/title and content/submitted-url). |
description | share/content | Option | Description of shared content | Max length of 256 characters. |
visibility | share | Yes | Parent node for visibility information | |
code | share/visibility | Yes | One of anyone: all members or connections-only: connections only. |
Sample XML
Here is an example XML document:
<!--?xml version="1.0" encoding="UTF-8"?> 83% of employers will use social media to hire: 78% LinkedIn, 55% Facebook, 45% Twitter [SF Biz Times] -->http://bit.ly/cCpeOD Survey: Social networks top hiring tool - San Francisco Business Times http://sanfrancisco.bizjournals.com/sanfrancisco/stories/2010/06/28/daily34.html</submitted-url> <submitted-image-url>http://images.bizjournals.com/travel/cityscapes/thumbs/sm_sanfrancisco.jpg</submitted-image-url> </content> <visibility> <code>anyone</code> </visibility> </share>
Response
Returns 201 Created
on success. It will also provide a Location
HTTP header with a URL for the created resource. However, at this time, you cannot retrieve the Share from that location. It’s there for future compatibility.
Resharing An Existing Share
When a member does a reshare, they can pass along a previously shared item to their network. This can either be as-is, or they can annotate the share to provide their own thoughts. The process is similar to creating a new share, but you provide an attribution/id value instead of a content block.
You can only reshare a share with a content block. If this block is empty, you will get a 400 error saying “Specified share {s28311617} has no content”.
Read Retrieving Share Information for instructions to retrieve these value using the API.
URL
Fields for the XML Body
Node | Parent Node | Required? | Value | Notes |
---|---|---|---|---|
share | — | Yes | Child nodes of share | Parent node for all share content |
comment | share | No | Text of member’s comment. (Similar to deprecated current-status field.) | Max length is 700 characters. |
attribution | share | Yes | Parent node for information on reshared document | |
id | share/attribution/share | Yes | id of reshared document | Currently in the format of s12345678, so is not guaranteed to be an integer.Post must contain id if it does not contain content and id must be from a share with a content block. |
visibility | share | Yes | Parent node for visibility information | |
code | share/visibility | Yes | One of anyone: all members or connections-only: connections only. |
Sample XML
Here is an example XML document:
<!--?xml version="1.0" encoding="UTF-8"?> Check out this story! I can't believe it. s24681357 -->connections-only
Response
Returns 201 Created
on success. It will also provide a Location
HTTP header with a URL for the created resource. However, at this time, you cannot retrieve the Share from that location. It’s there for future compatibility.
Retrieving Share Information
A particular member’s current share is detailed in their Profile API, so you can get a member’s current share by requesting:
Use the ~, id, or public profile URL to identify the user.
To retrieve a stream of shares for the member or their member first degree network, use the Get Network Updates API resource requesting the SHAR update type.
For the specified member also use a query parameter of scope=self:
Omit the scope for their first degree network:
You will receive:
<!--?xml version="1.0" encoding="UTF-8"?> s12345678 1279577156654 83% of employers will use social media to hire: 78% LinkedIn, 55% Facebook, 45% Twitter [SF Biz Times] -->http://bit.ly/cCpeOD</comment> <content> <id>123456789</id> <title>Survey: Social networks top hiring tool - San Francisco Business Times</title> <submitted-url>http://sanfrancisco.bizjournals.com/sanfrancisco/stories/2010/06/28/daily34.html</submitted-url> <shortened-url>lnkd.in/abc123</shortened-url> <submitted-image-url>http://images.bizjournals.com/travel/cityscapes/thumbs/sm_sanfrancisco.jpg</submitted-image-url> <thumbnail-url>http://media.linkedin.com/media-proxy/ext...</thumbnail-url> </content> <visibility> <code>anyone</code> </visibility> <source> <service-provider> <name>LINKEDIN</name> </service-provider> <application> <name>Your Cool App</name> </application> </source> <current-share>
Fields for the XML Body
Beyond the fields listed above, you also receive:
Node | Parent Node | Value | Notes |
---|---|---|---|
id | share | Identifier for share. | |
timestamp | share | Time of posting in miliseconds since UTC. (Divide this number by 1000 to get the standard Unix timestamp.) | |
shortened-url | share/content | Short version of the submitted-url. If the submitted-url is generated via a URL shortener, this is the original URL and the submitted URL is the expanded version. Otherwise, this is a LinkedIn generated short URL using http://lnkd.in/. | |
resolved-url | share/content | The submitted-url unwound from any URL shortener services. | |
author | share/attribution/share | Information on the author of the original shared item. | Only appears when retrieving a reshare, not an original share. |
name | share/source/service-provider | Platform where the share came from, such as LINKEDIN or TWITTER. | |
name | share/source/application | Application where the share came from, such as the name of your application. |
Changing Backgrounds with body class()
The body_class()
WordPress function attaches a list of classes to the <body>
element according to what type of page is being displayed.
These classes can be used — in conjunction with your theme’s stylesheet — to display different backgrounds on different pages.
Let’s assume your header.php template file contains:
<body <?php body_class(); ?>>
And your current CSS for the background looks like:
body {background:#fff url(images/bg.jpg);}
In a single post, your body tag would look like:
postid-188 single-format-standard logged-in admin-bar">
A category page could have:
<body class="archive category category-cat-a category-9 logged-in admin-bar">
whilst a tag page might generate:
tag-tag1 tag-92 logged-in admin-bar">
The CSS
You can add some new rules to your theme’s CSS to target specific backgrounds at particular pages.
Default Single Post
body.single {background:#ccc url(images/bg-single.jpg);}
Single Post with an ID of 188
body.postid-188 {background:#999 url(images/bg-special.jpg);}
Default Category Background
body.category {background:#eee url(images/bg-cat.jpg);}
Category A Only
body.category-cat-a {background:#ddd url(images/bg-cat-a.jpg);}
The possibilities are almost endless.
You can find a full list of the classes generated by the body_class()
function in the WordPress Codex.
I’ve run into an error using an image resizing script by Victor Teixeira, which has worked wonderfully until I noticed an issue related to using the Featured Image uploader. If I a Featured Image, then attempt to re-insert a different image in its place I get this error:
function vt_resize( $attach_id = null, $img_url = null, $width, $height, $crop = false ) {
// this is an attachment, so we have the ID
if ( $attach_id ) {
$image_src = wp_get_attachment_image_src( $attach_id, 'full' );
$file_path = get_attached_file( $attach_id );
// this is not an attachment, let's use the image url
} else if ( $img_url ) {
$file_path = parse_url( $img_url );
$file_path = $_SERVER['DOCUMENT_ROOT'] . $file_path['path'];
//$file_path = ltrim( $file_path['path'], '/' );
//$file_path = rtrim( ABSPATH, '/' ).$file_path['path'];
$orig_size = getimagesize( $file_path );
$image_src[0] = $img_url;
$image_src[1] = $orig_size[0];
$image_src[2] = $orig_size[1];
}
$file_info = pathinfo( $file_path );
$extension = '.'. $file_info['extension'];
// the image path without the extension
$no_ext_path = $file_info['dirname'].'/'.$file_info['filename'];
$cropped_img_path = $no_ext_path.'-'.$width.'x'.$height.$extension;
// checking if the file size is larger than the target size
// if it is smaller or the same size, stop right here and return
if ( $image_src[1] > $width || $image_src[2] > $height ) {
// the file is larger, check if the resized version already exists (for $crop = true but will also work for $crop = false if the sizes match)
if ( file_exists( $cropped_img_path ) ) {
$cropped_img_url = str_replace( basename( $image_src[0] ), basename( $cropped_img_path ), $image_src[0] );
$vt_image = array (
'url' => $cropped_img_url,
'width' => $width,
'height' => $height
);
return $vt_image;
}
// $crop = false
if ( $crop == false ) {
// calculate the size proportionaly
$proportional_size = wp_constrain_dimensions( $image_src[1], $image_src[2], $width, $height );
$resized_img_path = $no_ext_path.'-'.$proportional_size[0].'x'.$proportional_size[1].$extension;
// checking if the file already exists
if ( file_exists( $resized_img_path ) ) {
$resized_img_url = str_replace( basename( $image_src[0] ), basename( $resized_img_path ), $image_src[0] );
$vt_image = array (
'url' => $resized_img_url,
'width' => $proportional_size[0],
'height' => $proportional_size[1]
);
return $vt_image;
}
}
// no cache files - let's finally resize it
$new_img_path = image_resize( $file_path, $width, $height, $crop );
$new_img_size = getimagesize( $new_img_path );
$new_img = str_replace( basename( $image_src[0] ), basename( $new_img_path ), $image_src[0] );
// resized output
$vt_image = array (
'url' => $new_img,
'width' => $new_img_size[0],
'height' => $new_img_size[1]
);
return $vt_image;
}
// default output - without resizing
$vt_image = array (
'url' => $image_src[0],
'width' => $image_src[1],
'height' => $image_src[2]
);
return $vt_image;
}
Quick tip: paths and URLs in WordPress
define(‘MY_WORDPRESS_FOLDER’,$_SERVER[‘DOCUMENT_ROOT’]);define(‘MY_THEME_FOLDER’,str_replace(“”,’/’,dirname(__FILE__)));define(‘MY_THEME_PATH’,‘/’ . substr(MY_THEME_FOLDER,stripos(MY_THEME_FOLDER,’wp-content’)
ABSPATH constant
TEMPLATEPATH constant
get_template_directory_uri()
/home/user/public_html/wp/wp-content/themes/example-theme
/wp-content/themes/example-theme
/wp-content/themes/example-theme/custom/book_panel.css
/wp/wp-content/themes/example-theme/custom/book_panel.css
wp_enqueue_style(‘my_meta_css’,get_template_directory_uri(). ‘/custom/book_panel.css’);
Conclusion
Related Articles
- How to Setup Multiuser in WordPress 3.0 (kimwoodbridge.com)
- 16 Vital Checks Before Releasing a WordPress Theme (net.tutsplus.com)
- How to Disable and Remove Shortlink Link Rel Hook in WordPress Header (mydigitallife.info)
- WordPress SEO Optimization: Enable Gzip Encoding and Caching (seochat.com)
- WordPress Fat-Loss Diet to Speed Up & Ease Load (line25.com)
Recent Comments