• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP birch_ns函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中birch_ns函数的典型用法代码示例。如果您正苦于以下问题:PHP birch_ns函数的具体用法?PHP birch_ns怎么用?PHP birch_ns使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了birch_ns函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: birch_ns

birch_ns('birchschedule.model.cpt.staff', function ($ns) {
    global $birchschedule;
    $ns->init = function () use($ns, $birchschedule) {
        $birchschedule->model->pre_save->when($ns->is_model_staff, $ns->pre_save);
        $birchschedule->model->post_get->when($ns->is_model_staff, $ns->post_get);
    };
    $ns->is_model_staff = function ($model) {
        return $model['post_type'] === 'birs_staff';
    };
    $ns->pre_save = function ($staff, $config) {
        birch_assert(is_array($staff) && isset($staff['post_type']));
        if (isset($staff['_birs_assigned_services'])) {
            $staff['_birs_assigned_services'] = serialize($staff['_birs_assigned_services']);
        }
        if (isset($staff['_birs_staff_schedule'])) {
            $staff['_birs_staff_schedule'] = serialize($staff['_birs_staff_schedule']);
        }
        return $staff;
    };
    $ns->post_get = function ($staff) {
        birch_assert(is_array($staff) && isset($staff['post_type']));
        if (isset($staff['post_title'])) {
            $staff['_birs_staff_name'] = $staff['post_title'];
        }
        if (isset($staff['_birs_assigned_services'])) {
            $assigned_services = $staff['_birs_assigned_services'];
            $assigned_services = unserialize($assigned_services);
            $assigned_services = $assigned_services ? $assigned_services : array();
            $staff['_birs_assigned_services'] = $assigned_services;
        }
        if (isset($staff['_birs_staff_schedule'])) {
            $schedule = $staff['_birs_staff_schedule'];
            if (!isset($schedule)) {
                $schedule = array();
            } else {
                $schedule = unserialize($schedule);
            }
            $schedule = $schedule ? $schedule : array();
            $staff['_birs_staff_schedule'] = $schedule;
        }
        if (isset($staff['post_content'])) {
            $staff['_birs_staff_description'] = $staff['post_content'];
        }
        return $staff;
    };
});
开发者ID:stanislav-chechun,项目名称:campus-rize,代码行数:46,代码来源:package.php


示例2: birch_ns

<?php

birch_ns('birchschedule.model.cpt.payment', function ($ns) {
    global $birchschedule;
    birch_defn($ns, 'init', function () use($ns, $birchschedule) {
        birch_defmethod($birchschedule->model, 'pre_save', 'birs_payment', $ns->pre_save);
        birch_defmethod($birchschedule->model, 'post_get', 'birs_payment', $ns->post_get);
    });
    birch_defn($ns, 'pre_save', function ($payment, $config) {
        birch_assert(is_array($payment) && isset($payment['post_type']));
        if (isset($payment['_birs_payment_amount'])) {
            $payment['_birs_payment_amount'] = floatval($payment['_birs_payment_amount']);
        }
        return $payment;
    });
    birch_defn($ns, 'post_get', function ($payment) {
        birch_assert(is_array($payment) && isset($payment['post_type']));
        $payment['_birs_payment_amount'] = floatval($payment['_birs_payment_amount']);
        return $payment;
    });
});
开发者ID:JonathanAJ,项目名称:Seara-da-Ciencia-UFC,代码行数:21,代码来源:package.php


示例3: birch_ns

birch_ns('birchschedule.view.appointments.edit', function ($ns) {
    global $birchschedule;
    birch_defn($ns, 'init', function () use($ns, $birchschedule) {
        add_action('admin_init', array($ns, 'wp_admin_init'));
        add_action('init', array($ns, 'wp_init'));
        add_action('birchschedule_view_register_common_scripts_after', array($ns, 'register_scripts'));
        birch_defmethod($birchschedule->view, 'load_post_edit', 'birs_appointment', $ns->load_post_edit);
        birch_defmethod($birchschedule->view, 'enqueue_scripts_post_edit', 'birs_appointment', $ns->enqueue_scripts_post_edit);
    });
    birch_defn($ns, 'wp_init', function () use($ns) {
        global $birchschedule;
        $birchschedule->view->register_script_data_fn('birchschedule_view_appointments_edit', 'birchschedule_view_appointments_edit', array($ns, 'get_script_data_fn_view_appointments_edit'));
    });
    birch_defn($ns, 'wp_admin_init', function () use($ns) {
    });
    birch_defn($ns, 'get_script_data_fn_view_appointments_edit', function () use($ns) {
        return array('services_staff_map' => $ns->get_services_staff_map(), 'locations_map' => $ns->get_locations_map(), 'services_map' => $ns->get_services_map(), 'locations_staff_map' => $ns->get_locations_staff_map(), 'locations_services_map' => $ns->get_locations_services_map(), 'locations_order' => $ns->get_locations_listing_order(), 'staff_order' => $ns->get_staff_listing_order(), 'services_order' => $ns->get_services_listing_order());
    });
    birch_defn($ns, 'register_scripts', function () use($ns) {
        global $birchschedule;
        $version = $birchschedule->get_product_version();
        wp_register_script('birchschedule_view_appointments_edit', $birchschedule->plugin_url() . '/assets/js/view/appointments/edit/base.js', array('birchschedule_view_admincommon', 'birchschedule_view', 'jquery-ui-datepicker'), "{$version}");
    });
    birch_defn($ns, 'get_locations_map', function () {
        global $birchschedule;
        return $birchschedule->model->get_locations_map();
    });
    birch_defn($ns, 'get_services_map', function () {
        global $birchschedule;
        return $birchschedule->model->get_services_map();
    });
    birch_defn($ns, 'get_locations_staff_map', function () {
        global $birchschedule;
        return $birchschedule->model->get_locations_staff_map();
    });
    birch_defn($ns, 'get_locations_services_map', function () {
        global $birchschedule;
        return $birchschedule->model->get_locations_services_map();
    });
    birch_defn($ns, 'get_services_staff_map', function () {
        global $birchschedule;
        return $birchschedule->model->get_services_staff_map();
    });
    birch_defn($ns, 'get_services_locations_map', function () {
        global $birchschedule;
        return $birchschedule->model->get_services_locations_map();
    });
    birch_defn($ns, 'get_locations_listing_order', function () {
        global $birchschedule;
        return $birchschedule->model->get_locations_listing_order();
    });
    birch_defn($ns, 'get_staff_listing_order', function () {
        global $birchschedule;
        return $birchschedule->model->get_staff_listing_order();
    });
    birch_defn($ns, 'get_services_listing_order', function () {
        global $birchschedule;
        return $birchschedule->model->get_services_listing_order();
    });
    birch_defn($ns, 'load_post_edit', function ($arg) use($ns) {
        add_action('add_meta_boxes', array($ns, 'add_meta_boxes'));
    });
    birch_defn($ns, 'enqueue_scripts_post_edit', function ($arg) {
        global $birchschedule;
        $birchschedule->view->register_3rd_scripts();
        $birchschedule->view->register_3rd_styles();
        $birchschedule->view->enqueue_scripts(array('birchschedule_view_appointments_edit'));
        $birchschedule->view->enqueue_styles(array('birchschedule_appointments_edit'));
    });
    birch_defn($ns, 'add_meta_boxes', function () use($ns) {
        add_meta_box('meta_box_birs_appointment_edit_info', __('Appointment Info', 'birchschedule'), array($ns, 'render_appointment_info'), 'birs_appointment', 'normal', 'high');
        add_meta_box('meta_box_birs_appointment_edit_actions', __('Actions', 'birchschedule'), array($ns, 'render_actions'), 'birs_appointment', 'side', 'high');
    });
    birch_defn($ns, 'get_back_to_calendar_url', function () use($ns) {
        global $birchschedule;
        $back_url = admin_url('admin.php?page=birchschedule_calendar');
        $hash_string = $birchschedule->view->get_query_string($_GET, array('calview', 'locationid', 'staffid', 'currentdate'));
        if ($hash_string) {
            $back_url = $back_url . '#' . $hash_string;
        }
        return $back_url;
    });
    birch_defn($ns, 'render_actions', function ($post) use($ns) {
        $back_url = $ns->get_back_to_calendar_url();
        ?>
                <div class="submitbox">
                    <div style="float:left;">
                        <a href="<?php 
        echo $back_url;
        ?>
">
                            <?php 
        _e('Back to Calendar', 'birchschedule');
        ?>
                        </a>
                    </div>
                    <div class="clear"></div>
                </div>
<?php 
    });
//.........这里部分代码省略.........
开发者ID:JonathanAJ,项目名称:Seara-da-Ciencia-UFC,代码行数:101,代码来源:package.php


示例4: birch_ns

birch_ns('birchpress.view', function ($ns) {
    $scripts_data = array();
    $enqueued_scripts = array();
    $localized_scripts = array();
    $printed_scripts = array();
    birch_defn($ns, 'init', function () use($ns) {
        add_action('init', array($ns, 'wp_init'));
        add_action('admin_init', array($ns, 'wp_admin_init'));
    });
    birch_defn($ns, 'wp_init', function () use($ns) {
        if (!defined('DOING_AJAX')) {
            $ns->register_core_scripts();
            add_action('wp_print_scripts', array($ns, 'localize_scripts'));
            if (is_admin()) {
                add_action('admin_print_footer_scripts', array($ns, 'localize_scripts'), 9);
                add_action('admin_print_footer_scripts', array($ns, 'post_print_scripts'), 11);
            } else {
                add_action('wp_print_footer_scripts', array($ns, 'localize_scripts'), 9);
                add_action('wp_print_footer_scripts', array($ns, 'post_print_scripts'), 11);
            }
        }
    });
    birch_defn($ns, 'wp_admin_init', function () use($ns) {
        add_action('load-post.php', function () use($ns) {
            $post_type = $ns->get_current_post_type();
            $ns->load_post_edit(array('post_type' => $post_type));
        });
        add_action('load-post-new.php', function () use($ns) {
            $post_type = $ns->get_current_post_type();
            $ns->load_post_new(array('post_type' => $post_type));
        });
        add_action('admin_enqueue_scripts', function ($hook) use($ns) {
            $post_type = $ns->get_current_post_type();
            if ($hook == 'post-new.php') {
                $ns->enqueue_scripts_post_new(array('post_type' => $post_type));
            }
            if ($hook == 'post.php') {
                $ns->enqueue_scripts_post_edit(array('post_type' => $post_type));
            }
            if ($hook == 'edit.php' && isset($_GET['post_type'])) {
                $post_type = $_GET['post_type'];
                $ns->enqueue_scripts_post_list(array('post_type' => $post_type));
            }
        });
        add_action('save_post', function ($post_id, $post) use($ns) {
            if (!isset($_POST['action']) || $_POST['action'] !== 'editpost') {
                return;
            }
            if (empty($post_id) || empty($post) || empty($_POST)) {
                return;
            }
            if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
                return;
            }
            if (is_int(wp_is_post_revision($post))) {
                return;
            }
            if (is_int(wp_is_post_autosave($post))) {
                return;
            }
            $post_a = (array) $post;
            $ns->save_post($post_a);
        }, 10, 2);
        add_filter('wp_insert_post_data', function ($post_data, $post_attr) use($ns) {
            if (!isset($_POST['action']) || $_POST['action'] !== 'editpost') {
                return $post_data;
            }
            if ($post_data['post_status'] == 'auto-draft') {
                return $post_data;
            }
            return $ns->pre_save_post($post_data, $post_attr);
        }, 10, 2);
    });
    birch_defn($ns, 'get_post_type_lookup_config', function () {
        return array('key' => 'post_type', 'lookup_table' => array());
    });
    birch_defmulti($ns, 'enqueue_scripts_post_new', $ns->get_post_type_lookup_config, function ($arg) {
    });
    birch_defmulti($ns, 'enqueue_scripts_post_edit', $ns->get_post_type_lookup_config, function ($arg) {
    });
    birch_defmulti($ns, 'enqueue_scripts_post_list', $ns->get_post_type_lookup_config, function ($arg) {
    });
    birch_defmulti($ns, 'load_post_edit', $ns->get_post_type_lookup_config, function ($arg) {
    });
    birch_defmulti($ns, 'load_post_new', $ns->get_post_type_lookup_config, function ($arg) {
    });
    birch_defmulti($ns, 'save_post', $ns->get_post_type_lookup_config, function ($post_a) {
    });
    birch_defmulti($ns, 'pre_save_post', $ns->get_post_type_lookup_config, function ($post_data, $post_attr) {
        return $post_data;
    });
    birch_defn($ns, 'get_wp_screen', function ($hook_name) use($ns) {
        if (substr($hook_name, -4) !== '.php') {
            $hook_name = $hook_name . '.php';
        }
        $screen = WP_Screen::get($hook_name);
        return $screen;
    });
    birch_defn($ns, 'register_3rd_scripts', function () use($ns) {
        global $birchpress;
//.........这里部分代码省略.........
开发者ID:JonathanAJ,项目名称:Seara-da-Ciencia-UFC,代码行数:101,代码来源:package.php


示例5: birch_ns

birch_ns('birchschedule.model.schedule', function ($ns) {
    $_ns_data = new stdClass();
    $ns->init = function () use($ns, $_ns_data) {
        $_ns_data->step_length = 5;
    };
    $ns->get_staff_calculated_schedule_by_location = function ($staff_id, $location_id) use($ns) {
        global $birchschedule;
        $location_schedule = $birchschedule->model->get_staff_schedule_by_location($staff_id, $location_id);
        $new_schedules = array();
        if (isset($location_schedule['schedules'])) {
            $schedules = $location_schedule['schedules'];
            for ($week_day = 0; $week_day < 7; $week_day++) {
                $new_schedules[] = array();
            }
            foreach ($schedules as $schedule_id => $schedule) {
                $schedule_date_start = $birchschedule->model->schedule->get_staff_schedule_date_start($staff_id, $location_id, $schedule_id);
                $schedule_date_end = $birchschedule->model->schedule->get_staff_schedule_date_end($staff_id, $location_id, $schedule_id);
                foreach ($new_schedules as $week_day => $new_schedule) {
                    if (isset($schedule['weeks'][$week_day])) {
                        $new_schedules[$week_day][] = array('minutes_start' => $schedule['minutes_start'], 'minutes_end' => $schedule['minutes_end'], 'date_start' => $schedule_date_start, 'date_end' => $schedule_date_end);
                    }
                }
            }
        }
        $location_schedule['schedules'] = $new_schedules;
        return $location_schedule;
    };
    $ns->get_staff_calculated_schedule = function ($staff_id) use($ns) {
        global $birchschedule;
        $staff = $birchschedule->model->get($staff_id, array('base_keys' => array(), 'meta_keys' => array('_birs_staff_schedule')));
        $staff_schedule = $staff['_birs_staff_schedule'];
        $new_all_schedule = array();
        foreach ($staff_schedule as $location_id => $schedule) {
            $new_all_schedule[$location_id] = $birchschedule->model->schedule->get_staff_calculated_schedule_by_location($staff_id, $location_id);
        }
        return $new_all_schedule;
    };
    $ns->get_all_calculated_schedule = function () use($ns) {
        global $birchschedule;
        $staff = $birchschedule->model->query(array('post_type' => 'birs_staff'));
        $allschedule = array();
        foreach ($staff as $thestaff) {
            $schedule = $birchschedule->model->schedule->get_staff_calculated_schedule($thestaff['ID']);
            $allschedule[$thestaff['ID']] = $schedule;
        }
        return $allschedule;
    };
    $ns->get_staff_schedule_date_start = function ($staff_id, $location_id, $schedule_id) {
        return '';
    };
    $ns->get_staff_schedule_date_end = function ($staff_id, $location_id, $schedule_id) {
        return '';
    };
    $ns->get_staff_exception_date_start = function ($staff_id, $location_id, $exception_id) {
        return '';
    };
    $ns->get_staff_exception_date_end = function ($staff_id, $location_id, $exception_id) {
        return '';
    };
    $ns->get_avaliable_schedules_by_date = function ($schedules, $date) use($ns) {
        global $birchpress;
        $new_schedules = array();
        $mysql_format = 'Y-m-d';
        foreach ($schedules as $schedule) {
            if ($schedule['date_start']) {
                $date_start = $birchpress->util->get_wp_datetime(array('date' => $schedule['date_start'], 'time' => 0))->format($mysql_format);
            } else {
                $date_start = "";
            }
            if ($schedule['date_end']) {
                $date_end = $birchpress->util->get_wp_datetime(array('date' => $schedule['date_end'], 'time' => 0))->format($mysql_format);
            } else {
                $date_end = 'a';
            }
            $current_date = $date->format($mysql_format);
            if ($date_start <= $current_date && $date_end >= $current_date) {
                $new_schedules[] = array('minutes_start' => $schedule['minutes_start'], 'minutes_end' => $schedule['minutes_end']);
            }
        }
        return $new_schedules;
    };
    $ns->get_exceptions_blocks = function ($exceptions) use($ns, $_ns_data) {
        $exceptions_blocks = array();
        $min_blocks = array();
        foreach ($exceptions as $exception) {
            $start = $exception['minutes_start'];
            $end = $exception['minutes_end'];
            if ($end - $start === $_ns_data->step_length) {
                $min_blocks[] = $start;
            } else {
                $exception_blocks = array();
                for ($i = $start + $_ns_data->step_length; $i < $end; $i += $_ns_data->step_length) {
                    $exception_blocks[] = $i;
                }
                $exceptions_blocks = array_unique(array_merge($exceptions_blocks, $exception_blocks));
            }
        }
        sort($exceptions_blocks);
        $new_min_blocks = array();
        foreach ($min_blocks as $min_block) {
//.........这里部分代码省略.........
开发者ID:stanislav-chechun,项目名称:campus-rize,代码行数:101,代码来源:package.php


示例6: birch_ns

birch_ns('birchpress.util', function ($ns) {
    $_ns_data = new stdClass();
    $ns->init = function () use($ns, $_ns_data) {
        $_ns_data->request_actions = array();
        add_filter('http_api_transports', array($ns, 'http_api_transports'), 20);
        add_action('init', array($ns, 'call_request_function'), 100);
    };
    $ns->http_api_transports = function ($transports) {
        return array('streams', 'curl');
    };
    $ns->call_request_function = function () use($ns, $_ns_data) {
        $action = empty($_GET['birchpress_action']) ? '' : $_GET['birchpress_action'];
        if (!empty($action)) {
            $args = empty($_REQUEST['args']) ? '[]' : $_REQUEST['args'];
            $args = json_decode(stripslashes_deep($args), true);
            if (isset($_ns_data->request_actions[$action])) {
                $fn = $_ns_data->request_actions[$action];
                call_user_func_array($fn, $args);
            }
            die;
        }
    };
    $ns->get_remote_call_url = function ($action) use($ns) {
        $url = add_query_arg(array('birchpress_action' => $action), home_url('/index.php'));
        return $url;
    };
    $ns->async_run_task = function ($task) use($ns) {
        $url = $ns->get_remote_call_url($task['action']);
        wp_remote_post($url, array('timeout' => 0.01, 'blocking' => false, 'sslverify' => apply_filters('https_local_ssl_verify', true), 'body' => array('args' => json_encode($task['args']))));
    };
    $ns->enable_remote_call = function ($fn) use($ns, $_ns_data) {
        if (!is_a($fn, 'Birch_Fn')) {
            return;
        }
        $fn_name = $fn->get_full_name();
        $_ns_data->request_actions[$fn_name] = $fn;
    };
    $ns->get_wp_screen = function ($hook_name) use($ns) {
        if (substr($hook_name, -4) !== '.php') {
            $hook_name = $hook_name . '.php';
        }
        $screen = WP_Screen::get($hook_name);
        return $screen;
    };
    $ns->has_shortcode = function ($shortcode = NULL) use($ns) {
        $post_to_check = get_post(get_the_ID());
        $found = false;
        if (!$shortcode) {
            return $found;
        }
        if (stripos($post_to_check->post_content, '[' . $shortcode) !== FALSE && stripos($post_to_check->post_content, '[[' . $shortcode) == FALSE) {
            $found = TRUE;
        }
        return $found;
    };
    $ns->render_html_options = function ($options, $selection = false, $default = false) use($ns) {
        if ($selection == false && $default != false) {
            $selection = $default;
        }
        foreach ($options as $val => $text) {
            if ($selection == $val) {
                $selected = ' selected="selected" ';
            } else {
                $selected = '';
            }
            echo "<option value='{$val}' {$selected}>{$text}</option>";
        }
    };
    $ns->get_first_day_of_week = function () use($ns) {
        return get_option('start_of_week', 0);
    };
    $ns->starts_with = function ($haystack, $needle) {
        return !strncmp($haystack, $needle, strlen($needle));
    };
    $ns->ends_with = function ($haystack, $needle) {
        $length = strlen($needle);
        if ($length == 0) {
            return true;
        }
        return substr($haystack, -$length) === $needle;
    };
    $ns->current_page_url = function () use($ns) {
        $pageURL = 'http';
        if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") {
            $pageURL .= "s";
        }
        $pageURL .= "://";
        if ($_SERVER["SERVER_PORT"] != "80") {
            $pageURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
        } else {
            $pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
        }
        return $pageURL;
    };
    $ns->new_error = function ($code = '', $message = '', $data = '') use($ns) {
        return new WP_Error($code, $message, $data);
    };
    $ns->add_error_item = function ($errors, $code, $message, $data = '') use($ns) {
        $errors->add($code, $message, $data);
        return $errors;
//.........这里部分代码省略.........
开发者ID:stanislav-chechun,项目名称:campus-rize,代码行数:101,代码来源:package.php


示例7: birch_ns

birch_ns('birchschedule.view.appointments.edit.clientlist.edit', function ($ns) {
    global $birchschedule;
    birch_defn($ns, 'init', function () use($ns) {
        add_action('admin_init', array($ns, 'wp_admin_init'));
        add_action('birchschedule_view_register_common_scripts_after', array($ns, 'register_scripts'));
    });
    birch_defn($ns, 'wp_admin_init', function () use($ns, $birchschedule) {
        add_action('wp_ajax_birchschedule_view_appointments_edit_clientlist_edit_save', array($ns, 'ajax_save'));
        add_action('birchschedule_view_enqueue_scripts_post_edit_after', array($ns, 'enqueue_scripts_post_edit'));
        add_action('birchschedule_view_appointments_edit_clientlist_render_more_rows_after', array($ns, 'render_row'), 20, 3);
        add_filter('birchschedule_view_appointments_edit_clientlist_get_item_actions', array($ns, 'add_item_action'), 20, 2);
    });
    birch_defn($ns, 'register_scripts', function () use($birchschedule) {
        $version = $birchschedule->get_product_version();
        wp_register_script('birchschedule_view_appointments_edit_clientlist_edit', $birchschedule->plugin_url() . '/assets/js/view/appointments/edit/clientlist/edit/base.js', array('birchschedule_view_admincommon', 'birchschedule_view'), "{$version}");
    });
    birch_defn($ns, 'enqueue_scripts_post_edit', function ($arg) {
        if ($arg['post_type'] != 'birs_appointment') {
            return;
        }
        global $birchschedule;
        $birchschedule->view->register_3rd_scripts();
        $birchschedule->view->register_3rd_styles();
        $birchschedule->view->enqueue_scripts(array('birchschedule_view_appointments_edit_clientlist_edit'));
    });
    birch_defn($ns, 'add_item_action', function ($item_actions, $item) {
        $action_html = '<a href="javascript:void(0);" data-item-id="%s">%s</a>';
        $item_actions['edit'] = sprintf($action_html, $item['ID'], __('Edit', 'birchschedule'));
        return $item_actions;
    });
    birch_defn($ns, 'render_row', function ($wp_list_table, $item, $row_class) use($ns) {
        $client_id = $item['ID'];
        $appointment_id = $wp_list_table->appointment_id;
        $column_count = $wp_list_table->get_column_count();
        $edit_html = $ns->get_client_edit_html($appointment_id, $client_id);
        ?>
                <tr class="<?php 
        echo $row_class;
        ?>
 birs_row_edit"
                    id="birs_client_list_row_edit_<?php 
        echo $client_id;
        ?>
"
                    data-item-id = "<?php 
        echo $client_id;
        ?>
"
                    data-edit-html = "<?php 
        echo esc_attr($edit_html);
        ?>
">

                    <td colspan = "<?php 
        echo $column_count;
        ?>
">
                    </td>
                </tr>
<?php 
    });
    birch_defn($ns, 'ajax_save', function () use($ns) {
        global $birchpress, $birchschedule;
        $appointment1on1_errors = $ns->validate_appointment1on1_info();
        $client_errors = $ns->validate_client_info();
        $email_errors = $ns->validate_duplicated_email();
        $errors = array_merge($appointment1on1_errors, $client_errors, $email_errors);
        if ($errors) {
            $birchschedule->view->render_ajax_error_messages($errors);
        }
        $client_config = array('base_keys' => array(), 'meta_keys' => $_POST['birs_client_fields']);
        $client_info = $birchschedule->view->merge_request(array(), $client_config, $_POST);
        $client_info['ID'] = $_POST['birs_client_id'];
        $client_id = $birchschedule->model->booking->save_client($client_info);
        if (isset($_POST['birs_appointment_fields'])) {
            $appointment1on1s_fields = $_POST['birs_appointment_fields'];
        } else {
            $appointment1on1s_fields = array();
        }
        $appointment1on1s_config = array('base_keys' => array(), 'meta_keys' => $appointment1on1s_fields);
        $appointment1on1s_info = $birchschedule->view->merge_request(array(), $appointment1on1s_config, $_POST);
        $appointment1on1s_info['_birs_client_id'] = $_POST['birs_client_id'];
        $appointment1on1s_info['_birs_appointment_id'] = $_POST['birs_appointment_id'];
        $appointment1on1s_info['_birs_appointment_fields'] = $appointment1on1s_fields;
        $birchschedule->model->booking->change_appointment1on1_custom_info($appointment1on1s_info);
        $birchschedule->view->render_ajax_success_message(array('code' => 'success', 'message' => ''));
    });
    birch_defn($ns, 'validate_duplicated_email', function () {
        global $birchschedule;
        $errors = array();
        $client_id = $_POST['birs_client_id'];
        if (!isset($_POST['birs_client_email'])) {
            return $errors;
        }
        $email = $_POST['birs_client_email'];
        if ($birchschedule->model->booking->if_email_duplicated($client_id, $email)) {
            $errors['birs_client_email'] = __('Email already exists.', 'birchschedule') . ' (' . $email . ')';
        }
        return $errors;
    });
//.........这里部分代码省略.........
开发者ID:JonathanAJ,项目名称:Seara-da-Ciencia-UFC,代码行数:101,代码来源:package.php


示例8: birch_ns

birch_ns('birchschedule.view.help', function ($ns) {
    global $birchschedule;
    $_ns_data = new stdClass();
    birch_defn($ns, 'init', function () use($ns, $_ns_data) {
        $_ns_data->RUN_ACTION_NAME = "birchschedule_help_action_run";
        add_action('admin_init', array($ns, 'wp_admin_init'));
    });
    birch_defn($ns, 'wp_admin_init', function () use($ns, $_ns_data) {
        if (isset($_REQUEST['page']) && $_REQUEST['page'] == 'birchschedule_help') {
            $php_code = get_transient('birchschedule_help_php_code');
            $ns->run_php_code($php_code);
            delete_transient('birchschedule_help_php_code');
            $ns->load_page();
        }
        add_action('birchschedule_view_render_help_page_after', array($ns, 'render_admin_page'));
        add_action('admin_post_' . $_ns_data->RUN_ACTION_NAME, array($ns, 'cache_code'));
    });
    birch_defn($ns, 'run_php_code', function ($code) {
        if (!$code) {
            return;
        } else {
            ob_start();
            eval($code);
            ob_end_clean();
        }
    });
    birch_defn($ns, 'get_screen', function () use($ns) {
        global $birchschedule;
        $hook_name = $birchschedule->view->get_page_hook('help');
        $screen = $birchschedule->view->get_screen($hook_name);
        return $screen;
    });
    birch_defn($ns, 'load_page', function () use($ns) {
        $screen = $ns->get_screen();
        add_meta_box('birs_help_general', __('Help and Support', 'birchschedule'), array($ns, 'render_help_general'), $screen, 'main', 'default');
        add_meta_box('birs_help_version', __('Versions', 'birchschedule'), array($ns, 'render_help_version'), $screen, 'main', 'default');
        if (current_user_can('manage_options')) {
            add_meta_box('birs_help_run_scripts', __('Tools', 'birchschedule'), array($ns, 'render_run_scripts'), $screen, 'main', 'default');
        }
    });
    birch_defn($ns, 'render_help_version', function () use($ns) {
        global $birchschedule, $wp_version, $wpdb;
        $version = $birchschedule->get_product_version();
        $product_name = $birchschedule->get_product_name();
        ?>
                <div class="wrap">
                    <table class="form-table">
                        <tbody>
                            <tr>
                                <th><?php 
        echo "{$product_name}";
        ?>
</th>
                                <td><?php 
        echo "{$version}";
        ?>
</td>
                            </tr>
                            <tr>
                                <th><?php 
        echo "WordPress";
        ?>
</th>
                                <td><?php 
        echo "{$wp_version}";
        ?>
</td>
                            </tr>
                            <tr>
                                <th><?php 
        echo "PHP";
        ?>
</th>
                                <td><?php 
        echo phpversion();
        ?>
</td>
                            </tr>
                            <tr>
                                <th><?php 
        echo "MySQL";
        ?>
</th>
                                <td><?php 
        echo $wpdb->db_version();
        ?>
</td>
                            </tr>
                        </tbody>
                    </table>
                </div>
<?php 
    });
    birch_defn($ns, 'render_help_general', function () {
        ?>
                <div class="padding">
                    <p>If you have any questions, please refer to <a target="_blank" href="http://www.birchpress.com/support/documentation">documentation</a> first.</p>
                    <p>If you are using a <a target="_blank" href="http://www.birchpress.com/">premium edition</a>, please submit a ticket <a target="_blank" href="http://www.birchpress.com/support/submit-a-ticket/">here</a>.</p>
                    <p>If you are using a free version, please submit your question through our <a target="_blank" href="http://www.birchpress.com/support/forums">support forum</a>.</p>
                    <p>If you find our product helpful, please <a target="_blank" href="http://wordpress.org/extend/plugins/birchschedule">rate it!</a></p>
//.........这里部分代码省略.........
开发者ID:JonathanAJ,项目名称:Seara-da-Ciencia-UFC,代码行数:101,代码来源:package.php


示例9: birch_ns

birch_ns('birchschedule.model.booking', function ($ns) {
    global $birchschedule;
    birch_defn($ns, 'init', function () use($ns, $birchschedule) {
        add_action('birchschedule_model_schedule_get_staff_avaliable_time_after', array($ns, 'record_fully_booked_day'), 20, 5);
        add_action('admin_post_birchschedule_model_booking_recheck_fully_booked_days', array($ns, 'admin_post_recheck_fully_booked_days'), 20);
        add_action('admin_post_nopriv_birchschedule_model_booking_recheck_fully_booked_days', array($ns, 'admin_post_recheck_fully_booked_days'), 20);
        add_action('birchschedule_model_booking_actions_check_if_fully_booked_for', array($ns, 'check_if_fully_booked_for'), 20, 1);
        add_action('birchschedule_model_booking_do_change_appointment1on1_status_after', array($ns, 'enqueue_checking_if_fully_booked'), 20, 1);
        add_action('birchschedule_model_booking_do_reschedule_appointment1on1_after', array($ns, 'enqueue_checking_if_fully_booked'), 20, 1);
        add_action('birchschedule_model_booking_cancel_appointment1on1_after', array($ns, 'enqueue_checking_if_fully_booked'), 20, 1);
        add_action('birchschedule_model_booking_do_change_appointment1on1_status_after', array($birchschedule, 'spawn_cron'), 200);
        add_action('birchschedule_model_booking_do_reschedule_appointment1on1_after', array($birchschedule, 'spawn_cron'), 200);
        add_action('birchschedule_model_booking_cancel_appointment1on1_after', array($birchschedule, 'spawn_cron'), 200);
    });
    birch_defn($ns, 'get_appointment_title', function ($appointment) use($ns) {
        global $birchschedule;
        $service = $birchschedule->model->get($appointment['_birs_appointment_service'], array('base_keys' => array('post_title'), 'meta_keys' => array()));
        $appointment1on1s = $appointment['appointment1on1s'];
        if (sizeof($appointment1on1s) > 1) {
            $title = $service['post_title'] . ' - ' . sprintf(__('%s Clients', 'birchschedule'), sizeof($appointment1on1s));
        } else {
            if (sizeof($appointment1on1s) == 1) {
                $appointment1on1s = array_values($appointment1on1s);
                $appointment1on1 = $appointment1on1s[0];
                $title = $service['post_title'] . ' - ' . $appointment1on1['_birs_client_name'];
            } else {
                $title = $service['post_title'];
            }
        }
        return $title;
    });
    birch_defn($ns, 'get_appointment1on1s_by_appointment', function ($appointment_id, $config = array()) use($ns) {
        $config = array_merge(array('status' => 'any'), $config);
        $appointments = $ns->query_appointments(array('status' => $config['status'], 'appointment_id' => $appointment_id), $config);
        if ($appointments) {
            $appointment1on1s = $appointments[$appointment_id]['appointment1on1s'];
        } else {
            $appointment1on1s = array();
        }
        return $appointment1on1s;
    });
    birch_defn($ns, 'get_appointment1on1', function ($appointment_id, $client_id, $config = array()) use($ns) {
        global $birchschedule;
        if (!$config) {
            $fields = $birchschedule->model->get_appointment1on1_custom_fields();
            $fields = array_merge($fields, array('_birs_client_id', '_birs_appointment_id', 'post_status'));
            $config = array('appointment1on1_keys' => $fields);
        }
        $config = array_merge(array('status' => 'any'), $config);
        $appointments = $ns->query_appointments(array('client_id' => $client_id, 'appointment_id' => $appointment_id, 'status' => $config['status']), $config);
        if ($appointments) {
            $appointment1on1s = $appointments[$appointment_id]['appointment1on1s'];
            $appointment1on1s = array_values($appointment1on1s);
            return $appointment1on1s[0];
        } else {
            return false;
        }
    });
    birch_defn($ns, 'query_appointments', function ($criteria, $config = array()) use($ns) {
        global $birchschedule;
        if (!is_array($criteria)) {
            $criteria = array();
        }
        $default = array('appointment_id' => -1, 'client_id' => -1, 'start' => time(), 'end' => time() + 24 * 60 * 60, 'location_id' => -1, 'staff_id' => -1, 'service_id' => -1, 'status' => 'publish', 'cache_results' => false);
        $criteria = array_merge($default, $criteria);
        $start = $criteria['start'];
        $end = $criteria['end'];
        $location_id = $criteria['location_id'];
        $staff_id = $criteria['staff_id'];
        $service_id = $criteria['service_id'];
        $status = $criteria['status'];
        $cache_results = $criteria['cache_results'];
        if (!is_array($config) || !$config) {
            $config = array();
        }
        if (isset($config['appointment_keys'])) {
            $appointment_keys = $config['appointment_keys'];
        } else {
            $appointment_keys = array();
        }
        if (isset($config['appointment1on1_keys'])) {
            $appointment1on1_keys = $config['appointment1on1_keys'];
        } else {
            $appointment1on1_keys = array();
        }
        if (isset($config['client_keys'])) {
            $client_keys = $config['client_keys'];
        } else {
            $client_keys = array();
        }
        $appointments_criteria = array('post_type' => 'birs_appointment', 'post_status' => 'publish', 'meta_query' => array(array('key' => '_birs_appointment_timestamp', 'value' => $start, 'compare' => '>=', 'type' => 'SIGNED'), array('key' => '_birs_appointment_timestamp', 'value' => $end, 'compare' => '<=', 'type' => 'SIGNED')), 'cache_results' => $cache_results);
        if ($location_id != -1) {
            if (!is_array($location_id)) {
                $appointments_criteria['meta_query'][] = array('key' => '_birs_appointment_location', 'value' => $location_id, 'type' => 'UNSIGNED');
            } else {
                $appointments_criteria['meta_query'][] = array('key' => '_birs_appointment_location', 'value' => $location_id, 'compare' => 'IN', 'type' => 'UNSIGNED');
            }
        }
        if ($staff_id != -1) {
            if (!is_array($staff_id)) {
//.........这里部分代码省略.........
开发者ID:JonathanAJ,项目名称:Seara-da-Ciencia-UFC,代码行数:101,代码来源:package.php


示例10: birch_ns

birch_ns('birchschedule.view.calendar', function ($ns) {
    $ns->init = function () use($ns) {
        global $birchschedule;
        add_action('admin_init', array($ns, 'wp_admin_init'));
        $birchschedule->view->register_script_data_fn('birchschedule_view_calendar', 'birchschedule_view_calendar', array($ns, 'get_script_data_fn_view_calendar'));
    };
    $ns->wp_admin_init = function () use($ns) {
        global $birchschedule;
        add_action('admin_enqueue_scripts', function ($hook) {
            global $birchschedule;
            if ($birchschedule->view->get_page_hook('calendar') !== $hook) {
                return;
            }
            $birchschedule->view->calendar->enqueue_scripts();
        });
        add_action('wp_ajax_birchschedule_view_calendar_query_appointments', array($ns, 'ajax_query_appointments'));
        add_action('birchschedule_view_render_calendar_page_after', array($ns, 'render_admin_page'));
    };
    $ns->get_script_data_fn_view_calendar = function () use($ns) {
        return array('default_calendar_view' => $ns->get_default_view(), 'location_map' => $ns->get_locations_map(), 'location_staff_map' => $ns->get_locations_staff_map(), 'location_order' => $ns->get_locations_listing_order(), 'staff_order' => $ns->get_staff_listing_order(), 'slot_minutes' => 15, 'first_hour' => 9);
    };
    $ns->enqueue_scripts = function () use($ns) {
        global $birchschedule;
        $birchschedule->view->register_3rd_scripts();
        $birchschedule->view->register_3rd_styles();
        $birchschedule->view->enqueue_scripts(array('birchschedule_view_calendar', 'birchschedule_view', 'birchschedule_view_admincommon', 'birchschedule_model'));
        $birchschedule->view->enqueue_styles(array('fullcalendar_birchpress', 'birchschedule_admincommon', 'birchschedule_calendar', 'select2', 'jgrowl'));
    };
    $ns->get_default_view = function () {
        return 'agendaWeek';
    };
    $ns->query_appointments = function ($start, $end, $location_id, $staff_id) use($ns) {
        global $birchschedule, $birchpress;
        $criteria = array('start' => $start, 'end' => $end, 'location_id' => $location_id, 'staff_id' => $staff_id);
        $appointments = $birchschedule->model->booking->query_appointments($criteria, array('appointment_keys' => array('_birs_appointment_duration', '_birs_appointment_price', '_birs_appointment_timestamp', '_birs_appointment_service'), 'client_keys' => array('post_title')));
        $apmts = array();
        foreach ($appointments as $appointment) {
            $title = $birchschedule->model->booking->get_appointment_title($appointment);
            $appointment['post_title'] = $title;
            $duration = intval($appointment['_birs_appointment_duration']);
            $price = $appointment['_birs_appointment_price'];
            $time_start = $appointment['_birs_appointment_timestamp'];
            $time_end = $time_start + $duration * 60;
            $time_start = $birchpress->util->get_wp_datetime($time_start)->format('c');
            $time_end = $birchpress->util->get_wp_datetime($time_end)->format('c');
            $apmt = array('id' => $appointment['ID'], 'title' => $appointment['post_title'], 'start' => $time_start, 'end' => $time_end, 'allDay' => false, 'editable' => true);
            $apmts[] = $apmt;
        }
        return $apmts;
    };
    $ns->get_locations_map = function () use($ns) {
        global $birchschedule;
        $i18n_msgs = $birchschedule->view->get_frontend_i18n_messages();
        $locations_map = $birchschedule->model->get_locations_map();
        $locations_map[-1] = array('post_title' => $i18n_msgs['All Locations']);
        return $locations_map;
    };
    $ns->get_locations_staff_map = function () use($ns) {
        global $birchschedule;
        $i18n_msgs = $birchschedule->view->get_frontend_i18n_messages();
        $map = $birchschedule->model->get_locations_staff_map();
        $allstaff = $birchschedule->model->query(array('post_type' => 'birs_staff'), array('meta_keys' => array(), 'base_keys' => array('post_title')));
        $new_allstaff = array('-1' => $i18n_msgs['All Providers']);
        foreach ($allstaff as $staff_id => $staff) {
            $new_allstaff[$staff_id] = $staff['post_title'];
        }
        $map[-1] = $new_allstaff;
        return $map;
    };
    $ns->get_locations_services_map = function () {
        global $birchschedule;
        return $birchschedule->model->get_locations_services_map();
    };
    $ns->get_services_staff_map = function () {
        global $birchschedule;
        return $birchschedule->model->get_services_staff_map();
    };
    $ns->get_locations_listing_order = function () {
        global $birchschedule;
        $locations = $birchschedule->model->get_locations_listing_order();
        $locations = array_merge(array(-1), $locations);
        return $locations;
    };
    $ns->get_staff_listing_order = function () {
        global $birchschedule;
        return $birchschedule->model->get_staff_listing_order();
    };
    $ns->get_services_listing_order = function () {
        global $birchschedule;
        return $birchschedule->model->get_services_listing_order();
    };
    $ns->get_services_prices_map = function () {
        global $birchschedule;
        return $birchschedule->model->get_services_prices_map();
    };
    $ns->get_services_duration_map = function () {
        global $birchschedule;
        return $birchschedule->model->get_services_duration_map();
    };
    $ns->ajax_query_appointments = function () use($ns) {
//.........这里部分代码省略.........
开发者ID:stanislav-chechun,项目名称:campus-rize,代码行数:101,代码来源:package.php


示例11: birch_ns

birch_ns('birchschedule.model', function ($ns) {
    global $birchschedule;
    $ns->init = function () use($ns) {
        add_filter('birchbase_db_get_essential_post_columns', array($ns, 'add_more_essential_columns'), 20, 2);
    };
    $ns->save = function ($model, $config = false) {
        global $birchschedule, $birchpress;
        $model = $birchschedule->model->pre_save($model, $config);
        return $birchpress->db->save($model, $config);
    };
    $ns->pre_save = function ($model, $config) {
        return $model;
    };
    $ns->post_get = function ($model) {
        return $model;
    };
    $ns->is_valid_id = function ($id) {
        global $birchpress;
        return $birchpress->db->is_valid_id($id);
    };
    $ns->add_more_essential_columns = function ($columns, $post_type) {
        if ($post_type == 'birs_staff') {
            $columns[] = 'post_title';
            $columns[] = 'post_content';
        }
        if ($post_type == 'birs_service') {
            $columns[] = 'post_title';
            $columns[] = 'post_content';
        }
        return $columns;
    };
    $ns->get_service_pre_payment_fee = function ($service_id) {
        global $birchschedule;
        if (!$birchschedule->model->is_valid_id($service_id)) {
            return 0;
        }
        $service = $birchschedule->model->get($service_id, array('base_keys' => array(), 'meta_keys' => array('_birs_service_pre_payment_fee', '_birs_service_price')));
        $is_prepayment_enabled = $birchschedule->model->is_prepayment_enabled($service_id);
        if (!$is_prepayment_enabled) {
            return 0;
        }
        $service_pre_payment_fee = $service['_birs_service_pre_payment_fee'];
        if ($service_pre_payment_fee) {
            if ($service_pre_payment_fee['pre_payment_type'] == 'fixed') {
                return floatval($service_pre_payment_fee['fixed']);
            } else {
                if ($service_pre_payment_fee['pre_payment_type'] == 'percent') {
                    return $service_pre_payment_fee['percent'] * 0.01 * $service['_birs_service_price'];
                } else {
                    return 0;
                }
            }
        } else {
            return 0;
        }
    };
    $ns->get_service_padding = function ($service_id, $type) {
        global $birchschedule;
        birch_assert($birchschedule->model->is_valid_id($service_id));
        birch_assert($type === 'before' || $type === 'after');
        $service = $birchschedule->model->get($service_id, array('meta_keys' => array('_birs_service_padding', '_birs_service_padding_type'), 'base_keys' => array()));
        $padding_type = $service['_birs_service_padding_type'];
        if ($padding_type === 'before-and-after' || $padding_type === $type) {
            $padding = $service['_birs_service_padding'];
        } else {
            $padding = 0;
        }
        return $padding;
    };
    $ns->get_service_padding_before = function ($service_id) use($ns) {
        return $ns->get_service_padding($service_id, 'before');
    };
    $ns->get_service_padding_after = function ($service_id) use($ns) {
        return $ns->get_service_padding($service_id, 'after');
    };
    $ns->get_service 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP bit_redirect函数代码示例发布时间:2022-05-24
下一篇:
PHP bindtextdomain函数代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap