Thursday, 10 November 2016

Onclick javascript to make browser go back to previous page

1. First Method

 <a href="javascript: history.go(-1)">Go Back</a></div>

2. Second Method

<a href="##" onClick="history.go(-1); return false;">Go back</a> \

3.Third Method

<input name="action" type="submit" value="Cancel" onclick="window.history.back();"/>

if we want to more than one step back then increase

For going 2 steps back history.go(-2)
For going 3 steps back history.go(-3)
For going 4 steps back history.go(-4)
and so on.......

Friday, 4 November 2016

Jquery validation Rule List

Rule Format

To add rules to your input elements follow this format:
data-rule-[rule name separate by dashes]="true" 
Here are some examples:
  • Required - data-rule-required="true"
  • Email - data-rule-email="true"
  • Minimum Length = data-rule-minlength="6"

Message Format

By default the jQuery Validation Plugin will add it’s owne messages, but you can customize them to be whatever you want using another data attribute. To specify messages for each rule with data attributes follow this format:
data-msg-[rule name separate by dashes]="The message you want."
Here are some examples:
  • Required - data-msg-required="Madam/sir, this field is required."
  • Email - data-msg-email="Let us spam you, enter a valid email address."

Rule List:

If you want to know exactly what the validators are available and what they do look at the code for the validators in core or browse the additional validators.
Here is a list of them that I compiled by looking at the source on GitHub. I marked them with what part of the framework they’re from, and whether or not I tested them:
(Tested, core)
  • data-rule-required=”true”
  • data-rule-email=”true”
(Untested, core, but should work)
  • data-rule-url=”true”
  • data-rule-date=”true”
  • data-rule-dateISO=”true”
  • data-rule-number=”true”
  • data-rule-digits=”true”
  • data-rule-creditcard=”true”
  • data-rule-minlength=”6”
  • data-rule-maxlength=”24”
  • data-rule-rangelength=”5,10”
  • data-rule-min=”5”
  • data-rule-max=”10”
  • data-rule-range=”5,10”
  • data-rule-equalto=”#password”
  • data-rule-remote=”custom-validatation-endpoint.aspx”
(Untested, additional, but should work)
  • data-rule-accept=””
  • data-rule-bankaccountNL=”true”
  • data-rule-bankorgiroaccountNL=”true”
  • data-rule-bic=””
  • data-rule-cifES=””
  • data-rule-creditcardtypes=””
  • data-rule-currency=””
  • data-rule-dateITA=””
  • data-rule-dateNL=””
  • data-rule-extension=””
  • data-rule-giroaccountNL=””
  • data-rule-iban=””
  • data-rule-integer=”true”
  • data-rule-ipv4=”true”
  • data-rule-ipv6=”true”
  • data-rule-mobileNL=””
  • data-rule-mobileUK=””
  • data-rule-lettersonly=”true”
  • data-rule-nieES=””
  • data-rule-nifES=””
  • data-rule-nowhitespace=”true”
  • data-rule-pattern=””
  • data-rule-phoneNL=”true”
  • data-rule-phoneUK=”true”
  • data-rule-phoneUS=”true”
  • data-rule-phonesUK=”true”
  • data-rule-postalcodeNL=”true”
  • data-rule-postcodeUK=”true”
  • data-rule-require_from_group=””
  • data-rule-skip_or_fill_minimum=””
  • data-rule-strippedminlength=””
  • data-rule-time=””
  • data-rule-time12h=””
  • data-rule-url2=””
  • data-rule-vinUS=””
  • data-rule-zipcodeUS=”true”
  • data-rule-ziprange=””

Facebook Meta tag for Sharing ........

Basic Metadata

To turn your web pages into graph objects, you need to add basic metadata to your page. We've based the initial version of the protocol on RDFa which means that you'll place additional <meta> tags in the <head> of your web page. The four required properties for every page are:

og:title - The title of your object as it should appear within the graph, e.g., "The Rock".
og:type - The type of your object, e.g., "video.movie". Depending on the type you specify, other properties may also be required.
og:image - An image URL which should represent your object within the graph.
og:url - The canonical URL of your object that will be used as its permanent ID in the graph, e.g., "http://www.imdb.com/title/tt0117500/".
As an example, the following is the Open Graph protocol markup for The Rock on IMDB:

<html prefix="og: http://ogp.me/ns#">
<head>
<title>Welcome to my Blog</title>
<meta property="og:title" content="The Rock" />
<meta property="og:type" content="video.movie" />
<meta property="og:url" content="http://www.imdb.com/title/tt0117500/" />
<meta property="og:image" content="http://ia.media-imdb.com/images/rock.jpg" />
...
</head>
...
</html>

Optional Metadata

The following properties are optional for any object and are generally recommended:

og:audio - A URL to an audio file to accompany this object.
og:description - A one to two sentence description of your object.
og:determiner - The word that appears before this object's title in a sentence. An enum of (a, an, the, "", auto). If auto is chosen, the consumer of your data should chose between "a" or "an". Default is "" (blank).
og:locale - The locale these tags are marked up in. Of the format language_TERRITORY. Default is en_US.
og:locale:alternate - An array of other locales this page is available in.
og:site_name - If your object is part of a larger web site, the name which should be displayed for the overall site. e.g., "IMDb".
og:video - A URL to a video file that complements this object.

For example (line-break solely for display purposes):


<meta property="og:audio" content="http://example.com/bond/theme.mp3" />

<meta property="og:description"   content="Sean Connery found fame and fortune as the           suave, sophisticated British agent, James Bond." />

<meta property="og:determiner" content="the" />

<meta property="og:locale" content="en_GB" />

<meta property="og:locale:alternate" content="fr_FR" />

<meta property="og:locale:alternate" content="es_ES" />

<meta property="og:site_name" content="IMDb" />

<meta property="og:video" content="http://example.com/bond/trailer.swf" />


The RDF schema (in Turtle) can be found at ogp.me/ns.


Structured Properties

Some properties can have extra metadata attached to them. These are specified in the same way as other metadata with property and content, but the property will have extra :.

The og:image property has some optional structured properties:

og:image:url - Identical to og:image.
og:image:secure_url - An alternate url to use if the webpage requires HTTPS.
og:image:type - A MIME type for this image.
og:image:width - The number of pixels wide.
og:image:height - The number of pixels high.
A full image example:

<meta property="og:image" content="http://example.com/ogp.jpg" />

<meta property="og:image:secure_url" content="https://secure.example.com/ogp.jpg" />

<meta property="og:image:type" content="image/jpeg" />

<meta property="og:image:width" content="400" />

<meta property="og:image:height" content="300" />

The og:video tag has the identical tags as og:image. Here is an example:


<meta property="og:video" content="http://example.com/movie.swf" />

<meta property="og:video:secure_url" content="https://secure.example.com/movie.swf" />

<meta property="og:video:type" content="application/x-shockwave-flash" />

<meta property="og:video:width" content="400" />

<meta property="og:video:height" content="300" />

The og:audio tag only has the first 3 properties available (since size doesn't make sense for sound):

<meta property="og:audio" content="http://example.com/sound.mp3" />


<meta property="og:audio:secure_url" content="https://secure.example.com/sound.mp3" />


<meta property="og:audio:type" content="audio/mpeg" />

Arrays

If a tag can have multiple values, just put multiple versions of the same <meta> tag on your page. The first tag (from top to bottom) is given preference during conflicts.

<meta property="og:image" content="http://example.com/rock.jpg" />
<meta property="og:image" content="http://example.com/rock2.jpg" />
Put structured properties after you declare their root tag. Whenever another root element is parsed, that structured property is considered to be done and another one is started.

For example:


<meta property="og:image" content="http://example.com/rock.jpg" />


<meta property="og:image:width" content="300" />


<meta property="og:image:height" content="300" />


<meta property="og:image" content="http://example.com/rock2.jpg" />


<meta property="og:image" content="http://example.com/rock3.jpg" />


<meta property="og:image:height" content="1000" />

Friday, 12 February 2016

HTML CODE FOR FORM IN CENTER (FROM ALL SIDE )

<html>
<head><title>Hello Gaurav</title></head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%">
<tr><td align="center" valign="middle">
<table border="1" width="300">
<tr><td>Hey look at me! I'm in the middle!</td></tr>
</table>
</td></tr>
</table>
</body>
</html>

Saturday, 6 February 2016

What are the differences between %f, %e and %g format specifiers in C language? Explain with examples in which these format specifiers are emplyed.

  1. %f prints the corresponding number as a decimal floating point number (e.g. 321.65),
  2.  %e prints the number in scientific notation (e.g. 3.2165e+2), 
  3. %g prints the number in the shortest of these two representations (using the same number, the decimal floating point is shorter and hence 321.65 would be printed.  An example where %g would print the scientific notation is when the number is 6000000000.  In scientific notation, this would 6e+9 which is shorter and hence, 6e+9 would be printed.)
  4. The only difference between the lower case %e, %g and the upper case versions %E, %G is that printing scientific notation will use an upper case E instead of a lower case e to indicate the exponent.  E.g.  %E produces 3.2165E+2 when %e produces 3.2165e+2.

Friday, 5 February 2016

Right program of goto keyword

int main()
{
   int age;
   

   printf("Enter you age:");
   scanf("%d", &age);
   if(age>=18)
        goto Vote;
   else
        goto NoVote;
Vote:
     printf("you are eligible for voting");
     exit();
   NoVote:
     printf("you are not eligible to vote");
    exit();
return 0; }

Best example of goto keyword

Program to Print whether the number is even or odd 

#include<stdio.h> 
main(){
int n;
printf(''Enter the number :");
scanf("%d",&n);
if(n%2= = 0){
goto even;
}
else{
goto odd;

}

even  : 
printf("Number is even");

goto end;

odd : 
printf("Number is odd ");
goto end;

end: 
printf("\n");

getch();
return 0;


}

Sunday, 17 January 2016

wordpress Most important Links

Creating new page template


Copy and paste page.php from in your theame ,
and in top, just add :
Template Name: Home page
Eg:
* The template for displaying pages
* Template Name: Home page
* This is the template that displays all pages by default.
* Please note that this is the WordPress construct of pages and that
* other "pages" on your WordPress site will use a different template.
*
* @package WordPress
* @subpackage Twenty_Fifteen
* @since Twenty Fifteen 1.0
https://codex.wordpress.org/Page_Templates


Get Wordpress links

WordPress Directories:
home_url()
Home URL
http://www.example.com
site_url()
Site directory URL
http://www.example.com or http://www.example.com/wordpress
admin_url()
Admin directory URL
http://www.example.com/wp-admin
includes_url()
Includes directory URL
http://www.example.com/wp-includes
content_url()
Content directory URL
http://www.example.com/wp-content
plugins_url()
Plugins directory URL
http://www.example.com/wp-content/plugins
theme_url()
Themes directory URL (#18302)
http://www.example.com/wp-content/themes
wp_upload_dir()
Upload directory URL (returns an array)
http://www.example.com/wp-content/uploads

Creating More Menu

https://codex.wordpress.org/Navigation_Menus
Navigation Menus
. WordPress includes an easy to use mechanism for introducing customised navigation menus into a theme. In order to incorporate menu support into your theme, you need to add a few code segments to your theme files.
Function Reference
Register Navigation Menu
register_nav_menus()
register_nav_menu()
unregister_nav_menu()
Show Navigation Menu
has_nav_menu()
wp_nav_menu()
Contents
1 Function Reference
2 Register Menus
3 Display Menus on Theme
4 Menus Panel
5 External Resources
6 Related
Register Menus
Firstly, in your theme's functions.php, you need to write a function to register the names of your menus. (This is how they will appear in the Appearance -> Menus admin screen.) As an example, this menu would appear in the "Theme Locations" box as "Header Menu".
function register_my_menu() {
  register_nav_menu('header-menu',__( 'Header Menu' ));  }

 add_action( 'init', 'register_my_menu' );
And this would make two menu options appear, header menu and extra menu -
function register_my_menus() {  

 register_nav_menus(      array(  
    'header-menu' => __( 'Header Menu' ),  

    'extra-menu' => __( 'Extra Menu' )      )    );  }
add_action( 'init', 'register_my_menus' );

Get specific Pages

https://codex.wordpress.org/Function_Reference/is_front_page
<?php is_front_page(); ?>
<?php if(is_front_page() || is_home() ) { ?>
<?php } ?>

Contact 7 page redirect url

put the code in
on_sent_ok: "location.replace('http://errorfound.in/significance/?page_id=9');"
Nivo slider Defect
    Warning : The permissions to the directory /home/username/sitename//wp-content/uploads/nivoslider4wp_files/ are invalid. Set them to 777 to be able to upload files.
First, the path is wrong on line 7 of file nivoslider4wp-panel.php. I changed it from:
$ns4wp_filesdir = ABSPATH.'/wp-content/uploads/nivoslider4wp_files/';
to:
$ns4wp_filesdir = ABSPATH.'wp-content/uploads/nivoslider4wp_files/';
Second, line 274 requires permissions 777 on the folder which is a MAJOR security issue. I changed it from:
<?php if (substr(decoct(fileperms($ns4wp_filesdir)),2) != '777') : ?>
to:
<?php if (substr(decoct(fileperms($ns4wp_filesdir)),2) < '755') : ?>
In my opinion these things need to be changed in the plugin core.

Create Dynamic Sidebar

Paste this code where you want to show..
  <?php // if ( dynamic_sidebar('sidebar-3') ) : else : endif; ?>
Paste this code in function.php
register_sidebar( array(
        'name'          => __( 'Secondary Widget Area', 'twentythirteen' ),
        'id'            => 'sidebar-2',
        'description'   => __( 'Appears on posts and pages in the sidebar.', 'twentythirteen' ),
        'before_widget' => '<aside id="%1$s" class="widget %2$s">',
        'after_widget'  => '</aside>',
        'before_title'  => '<h3 class="widget-title">',
        'after_title'   => '</h3>',
    ) );
Theme My Admin
FOR LOGIN PAGE
[theme-my-login default_action=login login_template=tml-login-form.php]
FOR REGISTER PAGE
[theme-my-login show_title=0 default_action=register register_template=tml-register-form.php]

FOR LOST PASSWORD PAGE

[theme-my-login show_title=0 default_action=lostpassword lostpassword_template=tml-lostpassword-form.php]
But now I'm not able to replicate this strategy for the profile page.
I've created a WP page for the themed profile and I've putted this shortcode in it's content:
[theme-my-login default_action=profile profile_template=tml-profile-form.php]

Woo Commerce Shortcode

    [woocommerce_cart] – shows the cart page
    [woocommerce_checkout] – shows the checkout page
    [woocommerce_pay] – shows the checkout pay page
    [woocommerce_thankyou] – shows the order received page
    [woocommerce_order_tracking] – shows the order tracking form
    [woocommerce_my_account] – shows the user account page
    [woocommerce_edit_address] – shows the user account edit address page
    [woocommerce_view_order] – shows the user account view order page
    [woocommerce_change_password] – shows the change password page
    [woocommerce_lost_password] – shows the lost password page
    [woocommerce_logout] – shows the logout page
open link in a new window
click on Screen Options (top right), and check the box labelled Link Target under the Show advanced menu properties heading.
Now select the appropriate target for your custom link.

API's

Wonderfull API's

In computer programming, an application programming interface (API) is a set of routines, protocols, and tools for building software applications. An API expresses a software component in terms of its operations, inputs, outputs, and underlying types.

Paypal API

<!-----<!-----------Paypal Button Api Start----------------->
<script src="<?php echo $this->baseUrl() . "/"; ?>assets/myaccount/js/paypal-button.min.js?merchant=MERCHENT ID"
data-button="buynow"
data-name="My product"
data-amount="1.00"
async
></script>
<!-----------Paypal Button Api Ends----------------->
------Paypal Button Api Start----------------->
<script src="<?php echo $this->baseUrl() . "/"; ?>assets/myaccount/js/paypal-button.min.js?merchant=MERCHENT ID"
data-button="buynow"
data-name="My product"
data-amount="1.00"
async
></script>
<!-----------Paypal Button Api Ends----------------->

Login with facebook API

<!-----------Facebook Lofin with Facebook Start----------------->
<!-- Paste in header Starts ---->
<script>
// This is called with the results from from FB.getLoginStatus().
function statusChangeCallback(response) {
console.log('statusChangeCallback');
console.log(response);
// The response object is returned with a status field that lets the
// app know the current login status of the person.
// Full docs on the response object can be found in the documentation
// for FB.getLoginStatus().
if (response.status === 'connected') {
// Logged into your app and Facebook.
testAPI();
} else if (response.status === 'not_authorized') {
// The person is logged into Facebook, but not your app.
document.getElementById('status').innerHTML = 'Please log ' +
'into this app.';
} else {
// The person is not logged into Facebook, so we're not sure if
// they are logged into this app or not.
document.getElementById('status').innerHTML = 'Please log ' +
'into Facebook.';
}
}
// This function is called when someone finishes with the Login
// Button. See the onlogin handler attached to it in the sample
// code below.
function checkLoginState() {
FB.getLoginStatus(function(response) {
statusChangeCallback(response);
});
}
window.fbAsyncInit = function() {
FB.init({
appId : 434485136717218,
cookie : true, // enable cookies to allow the server to access
// the session
xfbml : true, // parse social plugins on this page
version : 'v2.2' // use version 2.2
});
// Now that we've initialized the JavaScript SDK, we call
// FB.getLoginStatus(). This function gets the state of the
// person visiting this page and can return one of three states to
// the callback you provide. They can be:
//
// 1. Logged into your app ('connected')
// 2. Logged into Facebook, but not your app ('not_authorized')
// 3. Not logged into Facebook and can't tell if they are logged into
// your app or not.
//
// These three cases are handled in the callback function.
FB.getLoginStatus(function(response) {
statusChangeCallback(response);
});
};
// Load the SDK asynchronously
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
// Here we run a very simple test of the Graph API after login is
// successful. See statusChangeCallback() for when this call is made.
function testAPI() {
console.log('Welcome! Fetching your information.... ');
FB.api('/me', function(response) {
console.log('Successful login for: ' + response.name);
document.getElementById('status').innerHTML =
'Thanks for logging in, ' + response.name + '!';
});
}
</script>
<!-- Paste in header Ends ---->
<!-- Paste where you want to call button Starts ---->
<fb:login-button scope="public_profile,email" onlogin="checkLoginState();">
</fb:login-button>
<!-- Paste where you want to call button Ends ---->
<!-----------Facebook Lofin with Facebook Ends----------------->