Posts

How to take a screenshot or make a image of current screen using php and javascript with jquery or make a pdf file of current scrren

For create a image of current screen using javascript add below script into your file <script type="text/javascript"> function printDiv() {     jQuery('.year_box').remove(); // add your container id for capcture screen here i write "main_panel_body" for example     html2canvas([document.getElementById('main_panel_body')], {           onrendered: function(canvas)          {             var img = canvas.toDataURL();             jQuery('.overlay_box').show(); // calling ajax method for create image from binary data             $.post("save.php", {data: img}, function (file) {                 jQuery('.overlay_box').hide();  ...

How to use ajax without jquery with pure javascript

Here is a snippet code for ajax request.. var ajax = {}; ajax.x = function() {     if (typeof XMLHttpRequest !== 'undefined') {         return new XMLHttpRequest();     }     var versions = [         "MSXML2.XmlHttp.6.0",         "MSXML2.XmlHttp.5.0",          "MSXML2.XmlHttp.4.0",         "MSXML2.XmlHttp.3.0",          "MSXML2.XmlHttp.2.0",         "Microsoft.XmlHttp"     ];     var xhr;     for(var i = 0; i < versions.length; i++) {         try {             xhr = new ActiveXObject(versions[i]);          ...

How to upload image to another server like amazon etc using php CURL

For upload an image or any file to external server using php curl just refer below code. and change it according to your need. $profile_image_string = '';             if ( isset($_FILES['profile_image']) )             {                 $tmpfile = $_FILES['profile_image']['tmp_name'];                 $filename = basename($_FILES['profile_image']['name']);                 $filetype = $_FILES['profile_image']['type'];                 $org_image_string =curl_file_create($tmpfile,$filetype,$filename);             }     $ch = curl_init();         ...

How to add a custom or new order status in woocommerce wordpress

For add a custom or new order status in woocommerce store. just copy and paste below code into your theme's functions.php or in your custom plugins file. For example i am add a shipping order status for order . // register post status wc-shipping add_action('init','register_shipping_post_status'); function register_shipping_post_status(){         register_post_status( 'wc-shipping', array(             'label'                     => 'Shipping',             'public'                    => true,             'exclude_from_search'       => false,          ...

How to allow html tags in the_excerpt post function in wordpress

Just copy and paste below code into your theme's functions.php file or in your custom plugin file. and change according to your need. function rj_wp_trim_excerpt($text) { $raw_excerpt = $text; if ( '' == $text ) {     $text = get_the_content('');     $text = strip_shortcodes( $text );     $text = apply_filters('the_content', $text);     $text = str_replace(']]>', ']]&gt;', $text);          $allowed_tags = '<p>,<a>'; // write your tags here for allow them in excerpt with comma seprated     $text = strip_tags($text, $allowed_tags);          $excerpt_word_count = 55; // change length of excerpt according to your need     $excerpt_length = apply_filters('excerpt_length', $excerpt_word_count);          $excerpt_end = '[...]';     $excerpt_more = apply_filters('ex...

How to add a shortcode button to wordpress page or post editor tinymce

Just copy and paste below code into your theme's functions.php file or your custom plugin's file and change according to your shortcode. add_action( 'init', 'rj_ctn_buttons' ); function rj_ctn_buttons() {     add_filter( "mce_external_plugins", "rj_add_ctn_buttons" );     add_filter( 'mce_buttons', 'rj_register_ctn_buttons' ); } function rj_add_ctn_buttons( $plugin_array ) {     $plugin_array['rj_ctn'] = get_stylesheet_directory_uri() . '/js/rj-ctn-plugin.js';  //include shortcode plugin js file in tinymce plugins     return $plugin_array; } function rj_register_ctn_buttons( $buttons ) {     array_push( $buttons, 'ctn' );  // add button to tinymce buttons     return $buttons; } and my rj-ctn-plugin.js file is as below (function() {     tinymce.create('tinymce.plugins.Rj_ctn', {         init : function(ed, url) {             ed.addButton...

How to change user id on checkout page for assign order to different user in woocommerce wordpress

Just copy and paste below code into your theme's functions.php file or in your custom plugin file function rj_replace_user_id_with_session_id(){     if(!session_id()){         session_start();     }     if(isset($_SESSION['order_replace_by_user_id'])){            return $_SESSION['order_replace_by_user_id']; // return user id you want to assign order     } } add_filter( 'woocommerce_checkout_customer_id', 'rj_replace_user_id_with_session_id' );