Skip to content

Instantly share code, notes, and snippets.

@vishalbasnet23
vishalbasnet23 / jquery.js
Created October 20, 2014 10:46
html-table-row-to-csv-javaScript
$('.export-csv').click(function(){
var nearestRow = $(this).closest('tr');
// console.log(nearestRow);
var allValue = [];
nearestRow.each(function() {
var eventDate = $(this).find('.event-date').text();
allValue.push(eventDate.trim().replace(/["~!@#$%^&*\(\)_+=`{}\[\]\|\\:;'<>,.\/?"\- \t\r\n]+/g, '-'));
var eventName = $(this).find('.event-name').text();
// console.log(eventName.trim().replace(/["~!@#$%^&*\(\)_+=`{}\[\]\|\\:;'<>,.\/?"\- \t\r\n]+/g, '-'));
@vishalbasnet23
vishalbasnet23 / redirect-after-successful-login-woocommerce.php
Last active August 29, 2015 14:08
Redirect to custom page url after successful Login WooCommerce
<?php add_filter('woocommerce_login_redirect', 'wc_login_redirect');
function wc_login_redirect( $redirect_to ) {
$page_slug = 'foo';
$redirect_to = get_permalink( get_page_by_path( $page_slug ) );
return $redirect_to;
}
@vishalbasnet23
vishalbasnet23 / woocommerce-remove-item-url-redirect.php
Last active August 29, 2015 14:08
Woocommerce remove item if that item is already is in cart.
<?php
global $woocommerce;
foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $cart_item ) {
if($cart_item['product_id'] == $current_package_id ){
$remove_url = $woocommerce->cart->get_remove_url( $cart_item_key );
echo '<a href="'.$remove_url.'class="remove-item">Remove</a>
<script>
jQuery('a.remove-item').trigger('click');
window.location.href = "'.home_url().'/foo/";
</script>';
@vishalbasnet23
vishalbasnet23 / clear-cart-button.html
Created October 28, 2014 09:08
WooCommerce Clear Cart Url
<a href="<?php echo home_url(); ?>/foo/?empty-cart">Clear Cart</a>
@vishalbasnet23
vishalbasnet23 / form-html.html
Created October 29, 2014 07:41
Custom CSV importer and insert into post WordPress
<form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">
Choose your file: <br />
<input name="csv" type="file" id="csv" />
<input type="submit" name="Submit" value="Submit" />
</form>
@vishalbasnet23
vishalbasnet23 / resolving-git-conflicts.txt
Created October 30, 2014 08:58
Resolving Git conflicts.
To checkout your own version you can use one of:
git checkout HEAD -- <filename>
git checkout --ours -- <filename>
git show :2:<filename> > <filename> # (stage 2 is ours)
To checkout the other version you can use one of:
git checkout test-branch -- <filename>
@vishalbasnet23
vishalbasnet23 / functions.php
Created October 31, 2014 08:57
User Registration Front End WordPress with Ajax
<?php
add_action('wp_ajax_register_user_front_end', 'register_user_front_end', 0);
add_action('wp_ajax_nopriv_register_user_front_end', 'register_user_front_end');
function register_user_front_end() {
$new_user_name = stripcslashes($_POST['new_user_name']);
$new_user_email = stripcslashes($_POST['new_user_email']);
$new_user_password = $_POST['new_user_password'];
$user_nice_name = strtolower($_POST['new_user_email']);
$user_data = array(
'user_login' => $new_user_name,
@vishalbasnet23
vishalbasnet23 / functions.php
Created October 31, 2014 09:16
User Login form Front End WordPress
<?php function login_form_frontend($args = array()) {
$defaults = array('echo' => true,
'redirect' => ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], // Default redirect is back to the current page
'form_id' => 'loginformfrontend',
'label_username' => __('Username'),
'label_password' => __('Password'),
'label_remember' => __('Remember Me'),
'label_log_in' => __('SIGN IN'),
'id_username' => 'user_login',
'id_password' => 'user_pass',
@vishalbasnet23
vishalbasnet23 / upcoming-event-calender.php
Last active August 29, 2015 14:08
Simple Event Calender using jQuery and PHP
<!-- Enqueue fullcalender.io --->
<style>
#calendar {
max-width: 900px;
margin: 0 auto;
}
</style>
<?php
for ( $upcoming_events as $upcoming_event ) {
$upcoming_event_object = array(
@vishalbasnet23
vishalbasnet23 / .gitignore
Last active May 16, 2017 04:23
git ignore for wordpress
*.log
.htaccess
sitemap.xml
sitemap.xml.gz
wp-config.php
wp-content/advanced-cache.php
wp-content/backup-db/
wp-content/backups/
wp-content/blogs.dir/
wp-content/cache/