Top Questions

  • 2.9 Years

    • Category : Php
    • Location : Chandigarh
    • Posted On : Nov 19, 2016

    split time interval in 15 min slot using php

    $array_of_time = array ();
    $start_time    = strtotime ("2013-08-28 17:45:00");
    $end_time      = strtotime ("2013-08-28 22:15:00");
    
    $fifteen_mins  = 15 * 60;
    
    while ($start_time <= $end_time)
    {
       $array_of_time[] = date ("Y-m-d H:i:s", $start_time);
       $start_time  = $fifteen_mins;
    }
    
    print_r ($array_of_time);
     
  • 2.11 Years

    • Category : Wordpress
    • Location : Chandigarh, India
    • Posted On : Feb 13, 2019

    Disable default wp-cron.php behavior We can easily tell WordPress to let us handle the execution of wp-cron.php with the wp-config.php file.

    Open your wp-config.php file with the cPanel File Manager Code Editor
    
    Go to the bottom of the database settings in wp-config.php.
    define( 'AUTOSAVE_INTERVAL',    3600 );     // autosave 1x per hour
    define( 'WP_POST_REVISIONS',    false );    // no revisions
    define( 'DISABLE_WP_CRON',      true );
    define( 'EMPTY_TRASH_DAYS',     7 );        // one week
    
    Now WordPress will not automatically run the wp-cron.php script each time your site gets a new visitor.
  • 5.11 Years

    • Category : Php
    • Location : Mohali
    • Posted On : Sep 9, 2018

    Customer session does not work except some pages

    Method 1.  To check if customer is logged: (best way)Create helper file like Data.phphow to create custom helper or module https://www.dorcode.com/blog/52/how-to-create-and-use-helpers-in-magento-2


    <?php
    namespace Magento\Mytheme\Helper;
    
    class Data extends \Magento\Framework\App\Helper\AbstractHelper
    {
        protected $_customerSession;
        protected $_customerSessionn;
    
        public function __construct(\Magento\Framework\App\Helper\Context $context,
                \Magento\Framework\App\Request\Http $request,
                \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository,
                \Magento\Customer\Model\SessionFactory $customerSession,
                \Magento\Customer\Model\Session $customerSessionn
            ) 
        {
            $this->request = $request;
            $this->customerRepository = $customerRepository;
            $this->_customerSession = $customerSession;
            $this->_customerSessionn = $customerSessionn;
            parent::__construct($context);
        }
        public function getCustomerName(){
            $customer = $this->_customerSession->create();
            return $customer->getCustomer()->getName();
        }
        public function isLoggedIn()
        {
            return $this->_customerSessionn->isLoggedIn();
        }
    }
    ?>
    
    Call to your template :
    
    <?php
    $myhelper = $this->helper('Magento\Mytheme\Helper\Data');
    $cname=$myhelper->getCustomerName();
    $isLoggedIn=$myhelper->isLoggedIn();
    
    if ($isLoggedIn):
    	   echo 'login';
    else : 
    	  echo 'not login';
    endif;
    ?>
  • 5.11 Years

    • Category : Wordpress
    • Location : Mohali
    • Posted On : Feb 9, 2017

    I have below code here. It's display that I want categories names with all details as well. This code to display top post categories first show.

    <?php
    $GLOBALS['uname'] = get_categories();
    define(_SYSTEM_, 'uname');
    class get_all_category_by_top_post {
        public function show() {
            $categories = $this->{_SYSTEM_};
            usort($categories,array($this,'sortByOrder'));
            return $categories;
        }
      public function sortByOrder($a, $b) {
         return $a->count < $b->count;
      }
        public function __get($d) {
            return $GLOBALS[$d];  
        }
    }
    $categories = new get_all_category_by_top_post();
    echo "<pre>";
    print_r($categories->show());
    ?>
  • 5.11 Years

    • Category : Php
    • Location : Mohali
    • Posted On : Nov 23, 2017

    There's a bug in Wordpress 4.9, I discovered this temporary super code. I plan on uninstalling it once they fix the bug, but it works great in the meantime!

    global $wpdb;
    $wpdb->query( "DELETE FROM `$wpdb->options` WHERE `option_name` LIKE '_transient_files_%' LIMIT 1" );
     
  • 2.9 Years

    • Category : Php
    • Location : Chandigarh
    • Posted On : Jan 4, 2017

    Easy Multiple Image Using Codeigniter.

    if($_FILES['filename']['name']!='')
     {
           $image=array();
           $counts = count($_FILES['filename']['name']);
           $config['upload_path'] = APPPATH.'uploads/'; //create upload folder in application
                                                        // Give permission -R 777 to upload folder 
           $config['allowed_types'] = '*';
           $files = $_FILES;
           for($i=0; $i<$counts; $i  )
            {       
               if($_FILES['filename']['name'][$i]!='')
     { 
           $_FILES['filename']['name']= time().$files['filename']['name'][$i];
           $_FILES['filename']['type']= $files['filename']['type'][$i];
           $_FILES['filename']['tmp_name']= $files['filename']['tmp_name'][$i];
           $_FILES['filename']['error']= $files['filename']['error'][$i];
           $_FILES['filename']['size']= $files['filename']['size'][$i];
           $this->load->library('upload', $config);
           $this->upload->initialize($config);
           $upload= $this->upload->do_upload('familypicture');
           if($upload){
          $uu=$this->upload->data();
                $image[] =$uu['file_name'];
       }
             }
             }
       $fileToUpload = implode('|',$image);
    }
     
  • 2.9 Years

    • Category : Jquery
    • Location : Chandigarh
    • Posted On : Feb 4, 2017

    you can copy text to clipboard and paste where you want

    <button class="btn btn-success" id="copyButton" onclick="copyToClipboard('testing')">Copy</button>
    
    <script type="text/javascript">
    function copyToClipboard(elementId) {
    
      // Create a "hidden" input
      var aux = document.createElement("input");
    
      // Assign it the value of the specified element
      aux.setAttribute("value", elementId);
    
      // Append it to the body
      document.body.appendChild(aux);
    
      // Highlight its content
      aux.select();
    
      // Copy the highlighted text
      document.execCommand("copy");
    
      // Remove it from the body
      document.body.removeChild(aux);
    
    }
    </script>
  • 2.9 Years

    • Category : Jquery
    • Location : Chandigarh
    • Posted On : Jun 25, 2016

    you can make td editable using this code

    Note: Add Table Class editableTable
    <script>
    $(function () {
        $(".qty").dblclick(function () {
            var OriginalContent = $(this).text();
            var Originalid = $(this).attr('id');
            $(this).addClass("cellEditing");
              $(this).html("<input type='text' class='qty' value='"   OriginalContent   "' />");
            $(this).children().first().focus();
            $(this).children().first().focusout(function (e) {
                    var newContent = $(this).val();
                    $(this).parent().text(newContent);
                    $(this).parent().removeClass("cellEditing");
            });
             
        $(this).children().first().blur(function(){
            $(this).parent().text(OriginalContent);
            $(this).parent().removeClass("cellEditing");
        });
        });
    });
     </script>
  • 5.11 Years

    • Category : Java
    • Location : Mohali
    • Posted On : Jul 9, 2016

    URL — The new history entry's URL is given by this parameter. Note that the browser won't attempt to load this URL after a call to pushState(), but it might attempt to load the URL later, for instance after the user restarts the browser. The new URL does not need to be absolute; if it's relative, it's resolved relative to the current URL. The new URL must be of the same origin as the current URL; otherwise, pushState() will throw an exception. This parameter is optional; if it isn't specified, it's set to the document's current URL.

    // modify history
    window.history.pushState(obj, title, url);
    window.history.pushState("", "", 'www.dorcode.com');  
  • 2.9 Years

    • Category : Php
    • Location : Chandigarh
    • Posted On : Dec 23, 2015
    <form action="" method="post" enctype="multipart/form-data" class="upload_bus"> 
    div class="btn-group col-lg-3 col-md-3 col-sm-6 col-xs-12 rightgp-btns">
      <input class="create-doc" id="upbuss"  type="file" name="upbus" >
    </div>
    </form>
    <center><div id="loader-icon" style="display:none;"><img src="images/loader-time.gif" height="100px" width="100px" /></div></center>
    <script>
    $('input#upbill').change(function(){
    $('form.upload_b').submit();
    })
    $('form.upload_b').submit(function(e){
      var formData = new FormData(this);
      $('#loader-icon').show();
    $.ajax({
    url: "upload_file.php",            
    type: "POST",
    data:  formData,
    mimeType:"multipart/form-data",
    contentType: false,
    cache: false,
    processData:false,
    success: function(data)
    {
      $('#loader-icon').hide();
       window.location.href="example.php";
    }
    });
    return false;
    });
    </script>