This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form id="form-id"> | |
<div class="span6 form-table"> | |
<label for="usr">First Name <b>*</b></label> | |
<input name="first_name" type="text" class="form-control" id="usr" data-required="yes"> | |
<div class="cus-validation-error" style="display:none;"> | |
Please Enter Your First Name. | |
</div> | |
</div> | |
<div class="span6 form-table"> | |
<label for="">E-mail address<b>*</b></label> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. cmd+shift+p | |
2. Type phpcs and install it | |
3. Preferences > Package Settings > Php Code Sniffer > User settings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Programmatically logs a user in | |
* | |
* @param string $username | |
* @return bool True if the login was successful; false if it wasn't | |
*/ | |
function programmatic_login( $username ) { | |
if ( is_user_logged_in() ) { | |
wp_logout(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function change_pass_frontend() { | |
require_once( ABSPATH . 'wp-includes/class-phpass.php'); | |
$old_pass = $_POST['old_pass']; | |
$new_pass = $_POST['new_pass']; | |
$user_id = $_POST['user_id']; | |
$user_data = get_userdata( $user_id ); | |
$wp_hasher = new PasswordHash(8, TRUE); | |
$password_hashed = $user_data->user_pass; | |
if($wp_hasher->CheckPassword($old_pass, $password_hashed)) { | |
wp_set_password( $new_pass, $user_id ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"always_show_minimap_viewport": true, | |
"bold_folder_labels": true, | |
"caret_extra_bottom": 3, | |
"caret_extra_top": 3, | |
"caret_extra_width": 2, | |
"enable_tab_scrolling": false, | |
"font_face": "Ubuntu Mono", | |
"font_options": | |
[ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'wp_login_failed', 'code_login_failed' ); | |
function code_login_failed( $user ) { | |
// check what page the login attempt is coming from | |
$referrer = $_SERVER['HTTP_REFERER']; | |
// check that were not on the default login page | |
if ( !empty($referrer) && !strstr($referrer,'wp-login') && !strstr($referrer,'wp-admin') && $user!=null ) { | |
// make sure we don't already have a failed login attempt | |
if ( !strstr($referrer, '?login=failed' )) { | |
// Redirect to the login page and append a querystring of login failed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
remove_filter('authenticate', 'wp_authenticate_username_password', 20); | |
add_filter('authenticate', 'login_with_email', 20, 3); | |
function login_with_email($user, $email, $password) { | |
//Check for empty fields | |
if(filter_var($email, FILTER_VALIDATE_EMAIL) ){ | |
if(empty($email) || empty ($password)){ | |
//create new error object and add errors to it. | |
$error = new WP_Error(); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Post view Count | |
*/ | |
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0); | |
function wpb_set_post_views($postID) { | |
$count_key = 'wpb_post_views_count'; | |
$count = get_post_meta($postID, $count_key, true); | |
if($count==''){ | |
$count = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action('wp_ajax_infinite_scroll_home', 'infinite_scroll_home', 0); | |
add_action('wp_ajax_nopriv_infinite_scroll_home', 'infinite_scroll_home'); | |
function infinite_scroll_home() { | |
$exclude_posts_json = $_POST['exclude_posts']; | |
$exclude_posts = json_decode($exclude_posts_json); | |
$post_offset = $_POST['post_offset']; | |
$infinite_scroll_args = array( 'post_type'=>'post', 'posts_per_page'=> 2,'post__not_in' => $exclude_posts, 'offset' => $post_offset); | |
$infinite_scroll_query = new WP_Query( $infinite_scroll_args ); | |
while( $infinite_scroll_query->have_posts() ) : $infinite_scroll_query->the_post(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'pa_color_add_form_fields', array( $this, 'pa_attr_taxonomy_columns' ) ); | |
add_filter( 'pa_color_edit_form_fields', array( $this, 'edit_pa_attr_taxonomy_column' ), 10 ); | |
add_action( 'created_pa_color', array( $this, 'pa_attr_save_taxonomy_fields' ), 10, 2 ); | |
add_action( 'edit_pa_color', array( $this, 'pa_attr_save_taxonomy_fields' ), 10, 2 ); | |
/** | |
* Add Fields | |
* | |
*/ |