• Hi
    i created sample plugin it’s work fine when activation my plugin it’s showing plugin content and media is not working when deactivate my plugin media will work fine what is the problem
    my plugin datepicker for booking enginee like checkin date and checkout

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    Can you put your plugin up on GitHub so we can see the code?

    Thread Starter dileepraja

    (@dileepraja)

    <?php
    /*
    *Plugin Name:Hs Booking engine
    *Description:Hs Booking Engine
    *Version:1.0
    *Author:Dileep
    *
    */
    
    //define('WP_DEBUG', true);
    
    register_activation_hook(__FILE__,'hs-activate-booking-engine');
    register_deactivation_hook(__FILE__,'hs-deactivation-booking-engine');
    
    add_action('init','hs_load_script');
    
    //loadind scripts and styles
    function hs_load_script()
    {
    
      echo '<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/themes/redmond/jquery-ui.min.css" />';
    
      echo '<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>';
    	echo '<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.0/jquery-ui.min.js"></script>';
    
      /*
        wp_register_style('mystyle',plugins_url('hs-booking engine/css/jquery.ui.css'));
        wp_enqueue_style('mystyle');
    
        wp_register_script('myscript',plugins_url('hs-booking engine/js/jquery.js',__FILE__),'1.11.1');
        wp_enqueue_script('myscript');
    
        wp_register_script('myplugin', plugins_url('hs-booking engine/js/cjquery-ui.min.js', __FILE__), '1.11.0');
        wp_enqueue_script('minjquery');*/
    
        //wp_register_script('minjquery',plugins_url('js/jquery.js'));
    
       //wp_enqueue_script('myplugin');
      //wp_enqueue_script('jquery');
      //wp_enqueue_script('jquery-ui-datepicker');
    
    	//wp_enqueue_script('custom-jquery-ui-datepicker',get_template_directory_uri().'/js/cjquery-ui.min.js',array(),'1.11.0',false);
    
      //wp_enqueue_script('custom-jquery-ui-datepicker',plugins_url('/js/cjquery-ui.min.js',__FILE__),array(),'1.11.0',false);
      //wp_register_style('custom-css',plugins_url('css/custom.css',__FILE__));
      ?>
    		<script type="text/javascript">
    
    			$(function() {
    
            //alert("Hello");
    
      $( "#sd" ).datepicker({
          dateFormat: "dd/mm/yy",
          //minDate: +1,
          showOn: "both",
          buttonImage: "https://jqueryui.com/resources/demos/datepicker/images/calendar.gif",
          buttonImageOnly: true,
          showAnim:"slide",
          changeMonth:true,
          changeYear:true,
          showButtonPanel:true,
          closeText:"Close",
          beforeShow: function(){
            // this gets today's date
            var theDate = new Date();
            theDate.setDate(<?php echo $checkin ?> + 2);
                    // set min date as 2 days from today
            $(this).datepicker('option','minDate',theDate);
          },
              // When datepicker for start date closes run this function
          onClose: function(){
            // this gets the selected start date
            var theDate = new Date($(this).datepicker('getDate'));
            // this sets "theDate" 1 day forward of start date
            theDate.setDate(theDate.getDate() + 1);
            // set min date for the end date as one day after start date
            $('#ed').datepicker('option','minDate',theDate);
          }
        });
    
        $('#ed').datepicker({
          dateFormat: "dd/mm/yy",
          showOn: "both",
          buttonImage:"https://jqueryui.com/resources/demos/datepicker/images/calendar.gif",
          buttonImageOnly: true,
          showAnim:"slide",
          changeYear:true,
          changeMonth:true,
          beforeShow: function(){
            // this gets today's date
            var theDate = new Date($( "#sd" ).datepicker('getDate'));
            // sets "theDate" 2 days ahead of today
            theDate.setDate(theDate.getDate() + 1);
            // set min date as 2 days from today
            $(this).datepicker('option','minDate',theDate);
          },
          onClose:function(){
    
          }  
    
        }); 
    
        $("#sd").datepicker("setDate", "<?php echo isset($_POST["check_in"]) ? $_POST["check_in"] : '0' ?>");
        $("#ed").datepicker("setDate", "<?php echo isset($_POST["check_in"]) ? $_POST["check_out"] : '1' ?>");
    
    });//.noConflict();
    
    		</script>
    		<style type="text/css">
    
          .cal
    			{
    				font-family: Arial, Helvetica, Sans-serif; font-size:13px;
    				border-radius: 15px;
    				width: 500px;
    				border: 1px solid #ccc;
    				margin-top: 20px;
    			}
    
    			img.ui-datepicker-trigger {
             		 position: relative;
              		left: -23px;
              		top: 3px;
        			}
    
        		.cal form
        		{
        			padding: 20px;
        		}
        		.cal .check-in
        		{
        			display: block;
        			padding: 0;
        			margin: 0;
        		}
    
        		.cal .check-out
        		{
        			display: block;
        			padding: 0;
        			margin: 0;
        		}
    
        		.cal .check-in input[type="text"]
        		{
        			padding: 8px;
        			margin-bottom: 15px
        		}
    
        		.cal .check-out input[type="text"]
        		{
        			padding: 8px;
        			margin-bottom: 15px
        		}
    
        		.cal .check-in label
        		{
        			padding: 15px;
        			width: 115px;
              float: left;
    
        		}
    
        		.cal .check-out label
        		{
        			padding: 15px;
        			width: 115px;
        			float: left;
        		}
    
        		.cal form button
        		{
        			margin: 15px;
        			margin-left: -21px;
        		}
    
            .showshortcode
            {
              position: relative;
              min-width: 255px;
              border: 1px solid #e5e5e5;
              -webkit-box-shadow: 0 1px 1px rgba(0,0,0,.04);
              box-shadow: 0 1px 1px rgba(0,0,0,.04);
              background: #fff;
            }
            .showshortcode h3{
              font-size: 14px;
              padding: 8px 12px;
              margin: 0;
              line-height: 1.4;
            }
    
            .showshortcode .inside{
              display: block;
            }
    
    		</style>
    	<?php
    }
    
    add_action('admin_menu','hs_booking_menu');
    
    //plugin menu
    function hs_booking_menu()
    {
    	add_menu_page('Booking Engine','Booking Engine','manage_options','hs-booking-engine','hs_booking_calender',plugins_url('hs-booking engine/images/calendar.gif'),99);
      add_submenu_page('hs-booking-engine','Form','Hs-Form-URL','manage_options','hs-form','hs_form_url');
      //add_submenu_page('hs-booking-engine','Settings','Hs-Settings','manage_options','hs-settings','hs_settings_shortcode');
    
    }
    
    //Provideing Function form url
    function hs_form_url(){
      add_option('formurl','https://www.google.com');
      $result=get_option('formurl');
      //echo $result;
      //update_option('formurl',$_REQUEST['formURL']);
      ?>
    
        <div class="cal">
          <form method="post">
             <p>Please Provide The Form URL</p>
            <label>Form Url:</label></label><input type="text" name="formURL" id="formURL1" value="<?=$result;?>"/>
            <input type="submit" name="submit" value="Save"/>
          </form>
        </div>
    
      <?php
     update_form_url();
     hs_settings_shortcode();
    
    }
    
    //Update form action url
    function update_form_url(){
    
      $result=get_option('formurl');
      if($_REQUEST['submit']){
    
        if($_REQUEST['formURL']){
    
          update_option('formurl',$_REQUEST['formURL']);
          echo "Updated";
          //hs_form_url();
        }
        else{
          echo "Not Updated";
        }
      }
    
    }
    
    //Displaying shortcode
    function hs_settings_shortcode()
    {
    
      ?>
    
          <div class="">
            <h3>Usage</h3>
    
            <div class="cal">
    
              <p class="">Copy & paste this code into a template file to include within your theme.</p>
    
    <pre> <?php echo do_shortcode("[hs_calender_shortcode]"); ?> </pre>
            </div>
              <p style="padding-left:210px">(OR)</p>
            <div class="cal">
              <p>Copy & paste the shortcode directly into any WordPress post or page.</p>
    
    <pre>[hs_calender_shortcode]</pre>
            </div>
          </div>
          <style type="text/css">
            .cal h4{
              padding: 15px;
            }
    
            .cal p{
              padding: 15px;
              color: #2ea2cc;
              font-weight: bold;
            }
            .cal pre{
              padding: 15px;
            }
          </style>  
    
      <?php
    }
    
    //Displaying Calender Widget
    function hs_booking_calender()
    {
      $result=get_option('formurl');
      global $title;
    	?>
    		<div class="cal">
    
    			<form action="<?php echo $result ?>" method="post" id="cal-from">
      				<?php echo $title;?>
    
      				<div class="check-in">
      					<label>From Date:</label><input type="text" id="sd" required/>
      				</div>
    
      				<div class="check-out">
      					<label>To Date:</label><input type="text" id="ed" value="" required/>
      				</div>
               <label>Select Location:</label>
              <select name="country" id="country" onchange="setStates();">
                  <option value="Alleppey">Alleppey</option>
                  <option value="Kumarakom">Kumarakom</option>
                  <option value="Kollam">Kollam</option>
                  <option value="Cochin">Cochin</option>
              </select>
    
              <label>Select Category:</label>
              <select name="state" id="state" onchange="setCities();">
                <option value="">Please select a Country</option>
              </select>
    
              <label>Select Category type:</label>
              <select name="city"  id="city">
                <option value="">Please select a Country</option>
              </select>
    
              <button>SUBMIT</button>
    			</form>
    		</div>
         <script type="text/javascript">
          var states = new Array();
    
          states['Alleppey'] = new Array('House Boat-Deluxe','House Boat-Premium Columbia','House Boat-Luxury','Shikara','Motor Boat','Speed Boat ');
          states['Kumarakom'] = new Array('House Boat-Deluxe','House Boat-Premium','House Boat-Luxury');
          states['Kollam'] = new Array('House Boat-Deluxe');
          states['Cochin']=new Array('House Boat-Deluxe ','Other Boat ');
    
          // City lists
          var cities = new Array();
    
          cities['Alleppey'] = new Array();
          cities['Alleppey']['House Boat-Deluxe'] = new Array('1Bed','2 Bed','3 Bed','5 Bed');
          cities['Alleppey']['House Boat-Premium Columbia'] = new Array('1Bed','2 Bed','3 Bed','5 Bed');
    
          cities['Alleppey']['House Boat-Luxury']          = new Array('1Bed','2 Bed','3 Bed','5 Bed');
          //cities['Alleppey']['Speed Boat']=new Array();
    
          cities['Kumarakom'] = new Array();
          cities['Kumarakom']['House Boat-Deluxe'] = new Array('1Bed','2 Bed','3 Bed','5 Bed');
          cities['Kumarakom']['House Boat-Premium']       = new Array('1Bed','2 Bed','3 Bed','5 Bed');
          cities['Kumarakom']['House Boat-Luxury']         = new Array('1Bed','2 Bed','3 Bed','5 Bed');
    
          cities['Kollam'] = new Array();
          cities['Kollam']['House Boat-Deluxe'] = new Array('Any');
    
          cities['Cochin']=new Array();
          cities['Cochin']['House Boat-Deluxe']    = new Array('Any');
          cities['Cochin']['Other Boat']   = new Array('Any');
    
          function setStates() {
            cntrySel = document.getElementById('country');
            stateList = states[cntrySel.value];
            changeSelect('state', stateList, stateList);
            setCities();
          }
    
          function setCities() {
            cntrySel = document.getElementById('country');
            stateSel = document.getElementById('state');
            cityList = cities[cntrySel.value][stateSel.value];
            changeSelect('city', cityList, cityList);
          }
    
          function changeSelect(fieldID, newOptions, newValues) {
            selectField = document.getElementById(fieldID);
            selectField.options.length = 0;
            for (i=0; i<newOptions.length; i++) {
              selectField.options[selectField.length] = new Option(newOptions[i], newValues[i]);
            }
          }
    
          function addLoadEvent(func) {
            var oldonload = window.onload;
            if (typeof window.onload != 'function') {
              window.onload = func;
            } else {
              window.onload = function() {
                if (oldonload) {
                  oldonload();
                }
                func();
              }
            }
          }
    
          addLoadEvent(function() {
            setStates();
          });
    
        </script>
    	<?php 
    
    }
    
    //Get Shortcode
    function hs_shortcode()
    {
    	ob_start();
    	hs_booking_calender();
    	return ob_get_clean();
    }
    
    add_shortcode('hs_calender_shortcode','hs_shortcode');
    
    add_filter('widget_text', 'do_shortcode');
    
    ?>

    this is my code please tell me validate or not thanx for respondin @ipstenu(Mike Epstein)

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘plugin effect’ is closed to new replies.