Category Archives: Uncategorized

How to get value from url after question mark in php?

How to PHP Request uri get string parts after question mark?

$url = explode(“?”, $_SERVER[REQUEST_URI]);
echo $url[1];

The post How to get value from url after question mark in php? appeared first on wpcodekit.

How to create custom popup in html, css and jQuery?

Create custom popup in html, css and jQuery

body{
margin:0px;
padding:0px;
}
.outer_quick_view_box {
width: 100%;
height: 100vh;
background: rgba(0, 0, 0, 0.46);
justify-content: center;
display: none;
align-items: center;
position: fixed;
top: 0px;
right: 0px;
left: 0px;
bottom: 0px;
}
.quick_view_box{
width:70%;
height:70vh;
background:white;
}
.quick_view_close_bt {
color: #565454;
position: absolute;
top: 0px;
right: 0;
background: white;
border: 1px solid #8a8a8a;
border-radius: 50%;
padding: 11px;
margin: 40px;
cursor: pointer;
}
.quick_view_half_sec{
width:50%;
height:auto;
float:left;
}
jQuery(document).ready(function($){
$(‘.quick_view_close_bt’).click(function(){
$(‘.outer_quick_view_box’).hide();
});
$(‘.show_quick_view_bt’).click(function(){
$(‘.outer_quick_view_box’).show();
$(‘.outer_quick_view_box’).css(‘display’,’flex’);
});
});
X

The post How to create custom popup in html, css and jQuery? appeared first on wpcodekit.

How to use PHP session in wordpress

Use PHP session in wordpress.

add_action(‘init’, ‘myStartSession’, 1);
function myStartSession() {
if(!session_id()) {
session_start();
}
}

The post How to use PHP session in wordpress appeared first on wpcodekit.

How to add button next to add button in shop page in woo-commerce?

Add button next to add button in shop page in woo-commerce.

add_action( ‘woocommerce_after_shop_loop_item’, ‘view_product_button_shop’, 10 );

function view_product_button_shop() {

global $product;

$link = $product->get_permalink();

echo ‘View Product‘;

}

The post How to add button next to add button in shop page in woo-commerce? appeared first on wpcodekit.

How to add new file type to upload in wordpress?

Add new file type to upload in wordpress

function add_file_types_to_uploads($file_types){
$new_filetypes = array();
$new_filetypes[‘svg’] = ‘image/svg+xml’;
$file_types = array_merge($file_types, $new_filetypes );
return $file_types;
}
add_filter(‘upload_mimes’, ‘add_file_types_to_uploads’);

The post How to add new file type to upload in wordpress? appeared first on wpcodekit.

How to create custom wordpress logout button(wp_logout_url) in wordpress?

custom wordpress logout button(wp_logout_url) in wordpress

  • <a class="colorbox" href=””>Logout
  • Or
    <li class="signOut"><?php wp_logout(); ?></li>

    add_action( 'wp_logout', 'auto_redirect_external_after_logout');
    function auto_redirect_external_after_logout(){
    wp_redirect
    ( 'http://redirect-url' );
    exit();
    }



    The post How to create custom wordpress logout button(wp_logout_url) in wordpress? appeared first on wpcodekit.

    How to redirect user on different page accounding to user (Customer, editor, admin, subscriber and etc)?

    How to redirect user on different page accounding to user (Customer, editor, admin, subscriber and etc)?

    function wc_custom_user_redirect( $redirect, $user ) {
    // Get the first of all the roles assigned to the user
    $role = $user->roles[0];
    $dashboard = admin_url();
    $myaccount = get_permalink( wc_get_page_id( ‘myaccount’ ) );
    if( $role == ‘administrator’ ) {
    //Redirect administrators to the dashboard
    $redirect = $dashboard;
    } elseif ( $role == ‘shop-manager’ ) {
    //Redirect shop managers to the dashboard
    $redirect = $dashboard;
    } elseif ( $role == ‘editor’ ) {
    //Redirect editors to the dashboard
    $redirect = $dashboard;
    } elseif ( $role == ‘author’ ) {
    //Redirect authors to the dashboard
    $redirect = $dashboard;
    } elseif ( $role == ‘customer’ || $role == ‘subscriber’ ) {
    //Redirect customers and subscribers to the “My Account” page
    if(has_active_subscription($user->ID) || wc_customer_bought_product( $current_user->user_email, $current_user->ID,’9011′)){
    $redirect = home_url(‘/start-deal/’);
    }
    else
    {
    $redirect = home_url(‘/pricing/’);
    }
    } else {
    //Redirect any other role to the previous visited page or, if not available, to the home
    $redirect = wp_get_referer() ? wp_get_referer() : home_url();
    }
    return $redirect;
    }

    add_filter( ‘woocommerce_login_redirect’, ‘wc_custom_user_redirect’, 10, 2 );

    The post How to redirect user on different page accounding to user (Customer, editor, admin, subscriber and etc)? appeared first on wpcodekit.

    Check if User Has Already Purchased Product in woo-commerce?

    WooCommerce: Check if User Has Already Purchased Product

    function start_deal_button(){
    ob_start();
    global $user;

    global $product;
    $current_user = wp_get_current_user();

    if(!is_user_logged_in())
    {
    echo “Start Deal ”;
    }

    if((has_active_subscription() || wc_customer_bought_product( $current_user->user_email, $current_user->ID,’9011′)) && (is_user_logged_in())){
    echo “Start Deal ”;;
    }

    if(!(has_active_subscription() || wc_customer_bought_product( $current_user->user_email, $current_user->ID,’9011′)) && (is_user_logged_in())){
    echo “Start Deal ”;

    }

    $obc = ob_get_contents();
    ob_end_clean();
    return $obc;
    }
    add_shortcode(“startdeal”,”start_deal_button”);

    The post Check if User Has Already Purchased Product in woo-commerce? appeared first on wpcodekit.

    How to remove and unremove options(Download, Account Detail, Payment methods) from my account in woo-commerce?

    How to remove and keep options(Download, Account Detail, Payment methods) from my account in woo-commerce?

    add_filter ( ‘woocommerce_account_menu_items’, ‘misha_remove_my_account_links’ );
    function misha_remove_my_account_links( $menu_links ){

    //unset( $menu_links[‘edit-address’] ); // Addresses

    unset( $menu_links[‘dashboard’] ); // Remove Dashboard
    //unset( $menu_links[‘payment-methods’] ); // Remove Payment Methods
    unset( $menu_links[‘orders’] ); // Remove Orders
    //unset( $menu_links[‘downloads’] ); // Disable Downloads
    //unset( $menu_links[‘edit-account’] ); // Remove Account details tab
    //unset( $menu_links[‘customer-logout’] ); // Remove Logout link

    return $menu_links;

    }

    The post How to remove and unremove options(Download, Account Detail, Payment methods) from my account in woo-commerce? appeared first on wpcodekit.

    How to use WP_Query with have_posts()?

    How to use WP_Query with have_posts()?

    global $wp_query;
    $original_query = $wp_query;
    $wp_query
    = null;
    $wp_query
    = new WP_Query( $args );
    if ( have_posts() ) :
    while ( have_posts() ) : the_post();
    the_title
    ();
    the_excerpt
    ();
    endwhile
    ;
    else:
    echo
    'no posts found';
    endif
    ;
    $wp_query
    = null;
    $wp_query
    = $original_query;
    wp_reset_postdata
    ();
    Get more detail from here

    The post How to use WP_Query with have_posts()? appeared first on wpcodekit.