public static function execute($force = false)
 {
     $data = (require SLN_PLUGIN_DIR . '/_install_data.php');
     $ids = array();
     foreach ($data['posts'] as $label => $post) {
         if (!self::checkPost($post['post']['post_title'], $post['post']['post_type'])) {
             $id = wp_insert_post($post['post']);
             if (isset($post['meta'])) {
                 foreach ($post['meta'] as $k => $v) {
                     add_post_meta($id, $k, $v);
                 }
             }
             $ids[$label] = $id;
         }
     }
     if (!get_option(SLN_Settings::KEY)) {
         if (isset($ids['thankyou'])) {
             $data['settings']['thankyou'] = $ids['thankyou'];
         }
         if (isset($ids['booking'])) {
             $data['settings']['booking'] = $ids['booking'];
         }
         update_option(SLN_Settings::KEY, $data['settings']);
     }
     new SLN_UserRole_SalonStaff(SLN_Plugin::getInstance(), SLN_Plugin::USER_ROLE_STAFF, __('Salon staff', 'sln'));
 }
 private function buildBookings()
 {
     $args = array('post_type' => SLN_Plugin::POST_TYPE_BOOKING, 'nopaging' => true, 'meta_query' => array(array('key' => '_sln_booking_date', 'value' => $this->date->format('Y-m-d'), 'compare' => '=')));
     $query = new WP_Query($args);
     $ret = array();
     foreach ($query->get_posts() as $p) {
         $ret[] = SLN_Plugin::getInstance()->createBooking($p);
     }
     wp_reset_query();
     wp_reset_postdata();
     SLN_Plugin::addLog(__CLASS__ . ' - buildBookings(' . $this->date->format('Y-m-d') . ')');
     foreach ($ret as $b) {
         SLN_Plugin::addLog(' - ' . $b->getId());
     }
     return $ret;
 }
 public function setDatetime(DateTime $date)
 {
     if ($timezone = get_option('timezone_string')) {
         date_default_timezone_set($timezone);
     }
     $this->initialDate = $this->bindInitialDate($date);
     $ah = $this->availabilityHelper;
     $times = $ah->getTimes($date);
     $i = 0;
     while (empty($times) && $i < 100) {
         $date->modify('+1 days');
         $times = $ah->getTimes($date);
         $i++;
     }
     if (empty($times)) {
         $date->modify('-99 days');
         while (empty($times) && $i > 0) {
             $date->modify('-1 days');
             $times = $ah->getTimes($date);
             $i--;
         }
     }
     $this->times = $times;
     $suggestedTime = $date->format('H:i');
     $i = SLN_Plugin::getInstance()->getSettings()->getInterval();
     $timeout = 0;
     while ($timeout < 86400 && !isset($times[$suggestedTime])) {
         $date->modify("+{$i} minutes");
         $suggestedTime = $date->format('H:i');
         $timeout++;
     }
     $this->suggestedDate = $date;
     $this->bindDates($ah->getDays());
     ksort($this->times);
     ksort($this->years);
     ksort($this->days);
     ksort($this->months);
     if ($timezone = get_option('timezone_string')) {
         date_default_timezone_set('UTC');
     }
 }
 public static function create($attrs)
 {
     $obj = new self(SLN_Plugin::getInstance(), $attrs);
     return $obj->execute();
 }
Ejemplo n.º 5
0
 public static function getMinutesIntervals($interval = null, $maxItems = null)
 {
     $start = "00:00";
     $curr = strtotime($start);
     $interval = isset($interval) ? $interval : SLN_Plugin::getInstance()->getSettings()->getInterval();
     $maxItems = isset($maxItems) ? $maxItems : 1440;
     $items = array();
     do {
         $items[] = date("H:i", $curr);
         $curr = strtotime('+' . $interval . ' minutes', $curr);
         $maxItems--;
     } while (date("H:i", $curr) != $start && $maxItems > 0);
     return $items;
 }
/*
Plugin Name: Salon Booking Wordpress Plugin - Free Version
Description: Let your customers book you services through your website. Perfect for hairdressing salons, barber shops and beauty centers.
Version: 1.0.6
Plugin URI: http://salon.wpchef.it/
Author: Wordpress Chef / Plugins 
Author URI: http://plugins.wpchef.it/
Text Domain: sln
*/
define('SLN_PLUGIN_BASENAME', plugin_basename(__FILE__));
define('SLN_PLUGIN_DIR', untrailingslashit(dirname(__FILE__)));
define('SLN_PLUGIN_URL', untrailingslashit(plugins_url('', __FILE__)));
define('SLN_VERSION', '1.0.6');
function sln_autoload($className)
{
    if (strpos($className, 'SLN_') === 0) {
        include_once SLN_PLUGIN_DIR . "/src/" . str_replace("_", "/", $className) . '.php';
    }
}
function my_update_notice()
{
    $info = __('ATTENTION! Back-up your translations files before update.', 'sln');
    echo '<span class="spam">' . strip_tags($info, '<br><a><b><i><span>') . '</span>';
}
if (is_admin()) {
    add_action('in_plugin_update_message-' . plugin_basename(__FILE__), 'my_update_notice');
}
spl_autoload_register('sln_autoload');
SLN_Plugin::getInstance();
ob_start();