Skip to main content

Posts

Get Google Calendar Event List in WordPress

<a href="https://console.cloud.google.com/apis/credentials">Get Your Api Credentials Here</a> <a href="https://calendar.google.com/calendar">Get your Calender ID</a> <?php include_once("wp-load.php"); function  get_calender_events() { $params = array(); /*Get current date*/ $current_date  = date('Y-m-d H:i:s'); /*Convert it to google calendar's rfc_format */ $rfc_format = date("c", strtotime($current_date)); $params[] = 'orderBy=startTime'; $params[] ='maxResults=100'; $params[] = 'timeMin='.urlencode($rfc_format); $url_param = ''; foreach($params as $param) { $url_param.= '&'.$param; } $calender_id = "calender_id"; $client_key =  "client_key"; $url = "https://www.googleapis.com/calendar/v3/calendars/".$calender_id."/events?key=".$client_key."&singleEvents=true".$url_param; $list_events = wp_remote_post($url, ...

WordPress Custom Login Validation

function check_checkbox($user, $password) { $user_id = $user->ID;   $key = 'code';   $single = true;   $code = get_user_meta( $user_id, $key, $single );   if($invcode != "")   {     global $wpdb; $sql = "SELECT * FROM table where `code` = '$code' and status = '0';"; $pageposts = $wpdb->get_row($sql); if(!empty($pageposts)) {         remove_action('authenticate', 'wp_authenticate_username_password', 20);         $user = new WP_Error( 'denied', __("<strong>ERROR</strong>: Your license has expired.  Please contact us for help.$user_last") );     return $user;         }       }                     return $user; } add_filter( 'wp_authenticate_user', 'check_checkbox', 10, 3 );

Create Google reCAPTCHA v3 in PHP

<?php if(isset($_POST)){     //https://www.google.com/recaptcha/api/siteverify?secret=Secret_key&response=".$_POST['g-recaptcha-response']     $response = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=Secret-key&response=".$_POST['g-recaptcha-response']);    $result = json_decode($response);    print_r($result);    if($result->success == 1 && $result->score > 0.8){        echo "captch valid.";         }else{        echo "captch is not valid.";    } } ?> <form action="" method="post"> <input type="text" name="fname"> <input type="text" name="g-recaptcha-response" id="g-recaptcha-response"> <input type="submit"> </form> <script src='https://www.google.com/recaptcha/api.js?render=Site-key'></script> <script> grecaptcha.ready(f...

WooCommerce Mini cart With Ajax

WooCommerce Mini cart //MINI CART SECTION   <div class="productdiv rightcart">                                                         <?php if ( ! WC()->cart->is_empty() ) : ?>     <ul class="woocommerce-mini-cart cart_list product_list_widget <?php echo esc_attr( $args['list_class'] ); ?>">         <?php             do_action( 'woocommerce_before_mini_cart_contents' );             foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {                 $_product     = apply_filters( 'woocommerce_cart_item_pro...

Create custom menu in wordpress

<?php //add in function file function wpb_custom_new_menu() {   register_nav_menus(     array(       'my-custom-menu' => __( 'My Custom Menu' ),     )   ); } add_action( 'init', 'wpb_custom_new_menu' ); $menu_name = 'my-custom-menu'; $locations = get_nav_menu_locations(); $menu = wp_get_nav_menu_object( $locations[ $menu_name ] ); $menuitems = wp_get_nav_menu_items( $menu->term_id, array( 'order' => 'DESC' ) ); ?> <nav> <ul class="main-nav">     <?php     $count = 0;     $submenu = false;     foreach( $menuitems as $item ):         // set up title and url         $title = $item->title;         $link = $item->url;         // item does not have a parent so menu_item_parent equals 0 (false) ...

Mail send in Mailgun by using CURL

send_mail($emailadderss,$subject1,$message1); function send_mail($email,$subject,$msg) {   $api_key="";  $domain ="test.com";  /*  $ch = curl_init();  curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);  curl_setopt($ch, CURLOPT_USERPWD, 'api:'.$api_key);  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');  curl_setopt($ch, CURLOPT_URL, 'https://api.mailgun.net/v2/'.$domain.'/messages');  curl_setopt($ch, CURLOPT_POSTFIELDS, array(   'from' => 'test <test@test.com>',   'to' => $email,   'subject' => $subject,   'html' => $msg  ));  $result = curl_exec($ch);  curl_close($ch);  print_r($result);  */  $curl_post_data=array( 'from' => 'test <test@test.com>',     'to' => $email,     'subject' => $subject,     'html' => $msg ); $service...

Crurl in php in live server

global $product; $current_user = wp_get_current_user(); $useriid = $current_user->data->ID; $meta = get_user_meta( $useriid ); if($bpid == ""){ $productid = implode('-',$spid); $pdfcode = $spid[0]; }else{ $productid = $bpid; $pdfcode = $bpid; } $text = "demo".$order_id."-".$pdfcode."-1"; $url ='http://www.demo.in/wp-content/themes/wisdomstore/dompdf/barcode.php'; $fields = array( 'text'  => $text, ); //open connection $server = '103.195.184.60'; $host   = 'thewisdomstore.in'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $server); /* set the user agent - might help, doesn't hurt */ curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)'); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); /* try to follow redirects */ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); /* timeout after the specified number of seconds. as...

Create admin settings in wp

<?php /* Plugin Name: Demo SMS Plugin URI: http://myasa.net Description: This plugin will integrate Demo SMS API Author: Sheikh Aamir Wahid Version: 1.0 Author URI: https://github.com/aamirwahid5 */ ob_start(); //include "functions.php"; add_action('admin_menu', function() {     add_options_page( 'SMS Settings', 'Demo SMS', 'manage_options', 'mobi-sms-plugin', 'mobiSMS_plugin_page' ); }); add_action( 'woocommerce_order_status_pending', 'mysite_pending', 10, 1); add_action( 'woocommerce_order_status_failed', 'mysite_failed', 10, 1); add_action( 'woocommerce_order_status_on-hold', 'mysite_hold', 10, 1); // Note that it's woocommerce_order_status_on-hold, and NOT on_hold. add_action( 'woocommerce_order_status_processing', 'mysite_processing', 10, 1); add_action( 'woocommerce_order_status_completed', 'mysite_completed', 10, 1);...