本文整理汇总了PHP中wp_car_manager函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_car_manager函数的具体用法?PHP wp_car_manager怎么用?PHP wp_car_manager使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_car_manager函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: run
/**
* AJAX callback method
*
* @return void
*/
public function run()
{
// check nonce
$this->check_nonce();
// @todo set filters
$filters = array();
// get filters from get vars
foreach ($_GET as $get_key => $get_var) {
if (0 === strpos($get_key, 'filter_')) {
$filters[str_ireplace('filter_', '', $get_key)] = absint($get_var);
}
}
// get vehicles
$vehicle_manager = new Vehicle\Manager();
$vehicles = $vehicle_manager->get_vehicles($filters);
// check & loop
if (count($vehicles) > 0) {
foreach ($vehicles as $vehicle) {
// title
$title = get_the_title($vehicle->get_id());
// get image
$image = get_the_post_thumbnail($vehicle->get_id(), apply_filters('wpcm_listings_vehicle_thumbnail_size', 'wpcm_vehicle_listings_item'), array('title' => $title, 'alt' => $title, 'class' => 'wpcm-listings-item-image'));
// load template
wp_car_manager()->service('template_manager')->get_template_part('listings/item', '', array('url' => get_permalink($vehicle->get_id()), 'title' => $title, 'image' => $image, 'description' => $vehicle->get_short_description(), 'price' => $vehicle->get_formatted_price(), 'mileage' => $vehicle->get_formatted_mileage(), 'frdate' => $vehicle->get_formatted_frdate()));
}
} else {
wp_car_manager()->service('template_manager')->get_template_part('listings/no-results', '', array());
}
// bye
exit;
}
开发者ID:valeriosouza,项目名称:wp-car-manager,代码行数:36,代码来源:GetVehicleResults.php
示例2: run
/**
* AJAX callback method
*
* @return void
*/
public function run()
{
// check nonce
$this->check_nonce();
// check if make is set
if (!isset($_GET['make'])) {
return;
}
// make
$make = absint($_GET['make']);
// models array
$models = array();
// get raw models
$models_raw = wp_car_manager()->service('make_model_manager')->get_models($make);
// check & loop
if (count($models_raw) > 0) {
foreach ($models_raw as $model_raw) {
// add to $models array
$models[] = array('id' => $model_raw['id'], 'name' => $model_raw['name']);
}
}
// send JSON
wp_send_json($models);
// bye
exit;
}
开发者ID:valeriosouza,项目名称:wp-car-manager,代码行数:31,代码来源:GetModels.php
示例3: ajax_get_models
/**
* AJAX 'get_models' callback
*/
public function ajax_get_models()
{
// check nonce
check_ajax_referer('wpcm-dat-ajax-nonce', 'nonce');
// check if make is set
if (!isset($_POST['make'])) {
return;
}
// make
$make = absint($_POST['make']);
// models array
$models = array();
// get raw models
$models_raw = wp_car_manager()->service('make_model_manager')->get_models($make);
// check & loop
if (count($models_raw) > 0) {
foreach ($models_raw as $model_raw) {
// add to $models array
$models[] = array('id' => $model_raw['id'], 'name' => $model_raw['name']);
}
}
// send JSON
wp_send_json($models);
// bye
exit;
}
开发者ID:valeriosouza,项目名称:wp-car-manager,代码行数:29,代码来源:CarData.php
示例4: mileage
/**
* Formats mileage
*
* @param $mileage
*
* @return string
*/
public static function mileage($mileage)
{
/** @var Settings $settings */
$settings = wp_car_manager()->service('settings');
// translated distance units
$translated_distance_units = array('miles' => __('miles', 'wp-car-manager'), 'km' => __('km', 'wp-car-manager'));
return number_format($mileage ? $mileage : 0, 0, $settings->get_option('decimal_separator'), $settings->get_option('thousand_separator')) . ' ' . $translated_distance_units[$settings->get_option('distance_unit')];
}
开发者ID:barrykooij,项目名称:wp-car-manager,代码行数:15,代码来源:Format.php
示例5: output
/**
* @param array $atts
*
* @return string
*/
public function output($atts)
{
// JS
WPCarManager\Assets::enqueue_shortcode_submit_car_form();
// start output buffer
ob_start();
wp_car_manager()->service('submit_car_handler')->display_next_step();
return ob_get_clean();
}
开发者ID:barrykooij,项目名称:wp-car-manager,代码行数:14,代码来源:SubmitCarForm.php
示例6: meta_box_output
/**
* Actual meta box output
*
* @param \WP_Post $post
*/
public function meta_box_output($post)
{
// nonce
$this->output_nonce();
// vehicle
$vehicle = wp_car_manager()->service('vehicle_factory')->make($post->ID);
// load view
wp_car_manager()->service('view_manager')->display('meta-box/mb-data', array('mb_prefix' => 'wpcm-ld', 'vehicle' => $vehicle, 'fields' => array('condition' => array('type' => 'date', 'label' => __('Expiry Date:', 'wp-car-manager'), 'key' => 'expiration', 'required' => false), 'sold' => array('type' => 'checkbox', 'label' => __('Sold?', 'wp-car-manager'), 'key' => 'sold', 'required' => false))));
}
开发者ID:barrykooij,项目名称:wp-car-manager,代码行数:14,代码来源:ListingData.php
示例7: column_data
/**
* Custom column data
*
* @param string $column
*/
public function column_data($column)
{
global $post;
/** @var \Never5\WPCarManager\Vehicle\Vehicle $vehicle */
$vehicle = wp_car_manager()->service('vehicle_factory')->make($post->ID);
// val
$val = '';
// set correct column val
switch ($column) {
case 'image':
// title
$title = get_the_title($vehicle->get_id());
// check if there's a thumbnail
if (has_post_thumbnail($vehicle->get_id())) {
// get image
$val = get_the_post_thumbnail($vehicle->get_id(), apply_filters('wpcm_listings_vehicle_thumbnail_size', 'wpcm_vehicle_listings_item'), array('title' => $title, 'alt' => $title, 'class' => 'wpcm-admin-image'));
} else {
$placeholder = apply_filters('wpcm_listings_vehicle_thumbnail_placeholder', wp_car_manager()->service('file')->image_url('placeholder-list.png'), $vehicle);
$val = sprintf('<img src="%s" alt="%s" class="wpcm-admin-image" />', $placeholder, __('Placeholder', 'wp-car-manager'));
}
$val = '<a href="' . admin_url(sprintf('post.php?post=%d&action=edit', $post->ID)) . '">' . $val . '</a>';
break;
case 'make':
$val = $vehicle->get_make_name();
break;
case 'model':
$val = $vehicle->get_model_name();
break;
case 'price':
$val = $vehicle->get_formatted_price();
break;
case 'mileage':
$val = $vehicle->get_formatted_mileage();
break;
case 'frdate':
$val = $vehicle->get_formatted_frdate();
break;
case 'expires':
$expiration = $vehicle->get_expiration();
if (null != $expiration) {
$val = $expiration->format(str_ireplace('F', 'M', get_option('date_format')));
}
break;
case 'actions':
if ('pending' == $vehicle->get_status()) {
$val = '<a href="' . add_query_arg(array('wpcm_action' => 'approve', 'wpcm_action_val' => $post->ID, 'wpcm_nonce' => wp_create_nonce('wpcm_action_approve_' . $post->ID)), admin_url('edit.php?post_type=wpcm_vehicle')) . '" class="button wpcm-btn-approve"></a>';
}
break;
}
// if val is empty set to -
if ('' == $val) {
$val = '-';
}
// echo val
echo $val;
}
开发者ID:barrykooij,项目名称:wp-car-manager,代码行数:61,代码来源:CustomColumns.php
示例8: meta_box_output
/**
* Actual meta box output
*
* @param \WP_Post $post
*/
public function meta_box_output($post)
{
// nonce
$this->output_nonce();
// get attachments
$product_image_gallery = '';
if (metadata_exists('post', $post->ID, '_car_gallery')) {
$product_image_gallery = get_post_meta($post->ID, '_car_gallery', true);
}
// explode and filter
$attachments = array_filter(explode(',', $product_image_gallery));
// view
wp_car_manager()->service('view_manager')->display('meta-box/gallery', array('car_gallery' => $product_image_gallery, 'attachments' => $attachments));
}
开发者ID:valeriosouza,项目名称:wp-car-manager,代码行数:19,代码来源:Gallery.php
示例9: output
/**
* @param array $atts
*
* @return string
*/
public function output($atts)
{
// get attributes, defaults filterable via 'wpcm_shortcode_cars_defaults' filter
$atts = shortcode_atts(apply_filters('wpcm_shortcode_' . $this->get_tag() . '_defaults', array('per_page' => -1, 'orderby' => 'date', 'order' => 'DESC')), $atts);
// start output buffer
ob_start();
// global $wp_query;
// echo '<pre>';
// print_r($wp_query->query_vars);
// echo '</pre>';
// load template
wp_car_manager()->service('template_manager')->get_template_part('listings-vehicle', '', array('atts' => $atts));
return ob_get_clean();
}
开发者ID:valeriosouza,项目名称:wp-car-manager,代码行数:19,代码来源:Cars.php
示例10: can_edit_listing
/**
* Check if current user is allowed to edit given listing
*
* @param int $listing_id
*
* @return bool
*/
public function can_edit_listing($listing_id)
{
$can_edit = true;
// deny access if user is not logged in or the listing id equals zero
if (!is_user_logged_in() || 0 == $listing_id) {
$can_edit = false;
} else {
/** @var Vehicle\Vehicle $listing */
$listing = wp_car_manager()->service('vehicle_factory')->make($listing_id);
// check if listing author is equal to currently logged in user and if user has permission to edit listing
if ($listing->get_author() != get_current_user_id() && !current_user_can('edit_car_listing', $listing->get_id())) {
$can_edit = false;
}
}
return apply_filters('wpcm_user_can_edit_listing', $can_edit, $listing_id);
}
开发者ID:barrykooij,项目名称:wp-car-manager,代码行数:23,代码来源:UserManager.php
示例11: run
/**
* Installation actions
*/
public static function run()
{
// register post type and custom taxonomies
Vehicle\PostType::register();
WPCarManager\Taxonomies::register_model_make();
WPCarManager\Taxonomies::register_features();
// setup user roles
$role_manager = new WPCarManager\RoleManager();
$role_manager->setup_roles();
// setup cron
$cron = new Vehicle\Cron();
$cron->schedule();
// flush rules after install
flush_rewrite_rules();
// set version
update_option(Upgrade::OPTION_CURRENT_VERSION, wp_car_manager()->get_version());
}
开发者ID:barrykooij,项目名称:wp-car-manager,代码行数:20,代码来源:Install.php
示例12: output
/**
* @param array $atts
*
* @return string
*/
public function output($atts)
{
// JS
WPCarManager\Assets::enqueue_shortcode_dashboard();
// get attributes, defaults filterable via 'wpcm_shortcode_dashboard_defaults' filter
$atts = shortcode_atts(apply_filters('wpcm_shortcode_' . $this->get_tag() . '_defaults', array('orderby' => 'date', 'order' => 'DESC')), $atts);
// start output buffer
ob_start();
if (is_user_logged_in()) {
// load dashboard template
wp_car_manager()->service('template_manager')->get_template_part('dashboard', '', array('atts' => $atts));
} else {
// load not logged in template
wp_car_manager()->service('template_manager')->get_template_part('dashboard/not-logged-in', '', array('atts' => $atts));
}
return ob_get_clean();
}
开发者ID:barrykooij,项目名称:wp-car-manager,代码行数:22,代码来源:Dashboard.php
示例13: run
/**
* AJAX callback method
*
* @return void
*/
public function run()
{
// check nonce
$this->check_nonce();
// set sort
$sort = isset($_GET['sort']) ? esc_attr($_GET['sort']) : 'price-desc';
// get vehicles
$vehicle_manager = new Vehicle\Manager();
$vehicles = $vehicle_manager->get_vehicles(array(), $sort, -1, array('author' => get_current_user_id(), 'post_status' => apply_filters('wpcm_dashboard_post_status', array('publish', 'expired', 'pending'))));
// check & loop
if (count($vehicles) > 0) {
// Today
$today = new \DateTime();
$today->setTime(0, 0, 0);
foreach ($vehicles as $vehicle) {
// title
$title = get_the_title($vehicle->get_id());
// check if there's a thumbnail
if (has_post_thumbnail($vehicle->get_id())) {
// get image
$image = get_the_post_thumbnail($vehicle->get_id(), apply_filters('wpcm_dashboard_vehicle_thumbnail_size', 'wpcm_vehicle_listings_item'), array('title' => $title, 'alt' => $title, 'class' => 'wpcm-dashboard-item-image'));
} else {
$placeholder = apply_filters('wpcm_dashboard_vehicle_thumbnail_placeholder', wp_car_manager()->service('file')->image_url('placeholder-list.png'), $vehicle);
$image = sprintf('<img src="%s" alt="%s" class="wpcm-dashboard-item-image" />', $placeholder, __('Placeholder', 'wp-car-manager'));
}
$expires = 'n/a';
if (null != $vehicle->get_expiration()) {
if ($today > $vehicle->get_expiration()) {
$expires = __('Expired', 'wp-car-manager');
} else {
$expires = $vehicle->get_expiration()->format('d-m-Y');
}
}
// load template
wp_car_manager()->service('template_manager')->get_template_part('dashboard/item', '', array('id' => $vehicle->get_id(), 'url' => $vehicle->get_url(), 'title' => $title, 'image' => $image, 'price' => $vehicle->get_formatted_price(), 'mileage' => $vehicle->get_formatted_mileage(), 'frdate' => $vehicle->get_formatted_frdate(), 'expires' => $expires, 'vehicle' => $vehicle));
}
} else {
wp_car_manager()->service('template_manager')->get_template_part('dashboard/no-results', '', array());
}
// bye
exit;
}
开发者ID:barrykooij,项目名称:wp-car-manager,代码行数:47,代码来源:GetDashboard.php
示例14: get_price_format
/**
* Get price format
*
* @return String
*/
public static function get_price_format()
{
$currency_pos = wp_car_manager()->service('settings')->get_option('currency_pos');
$format = '%1$s%2$s';
switch ($currency_pos) {
case 'left':
$format = '%1$s%2$s';
break;
case 'right':
$format = '%2$s%1$s';
break;
case 'left_space':
$format = '%1$s %2$s';
break;
case 'right_space':
$format = '%2$s %1$s';
break;
}
return $format;
}
开发者ID:valeriosouza,项目名称:wp-car-manager,代码行数:25,代码来源:Price.php
示例15: run
/**
* AJAX callback method
*
* @return void
*/
public function run()
{
// vehicle must be set
if (!isset($_POST['vehicle']) || empty($_POST['vehicle'])) {
wp_send_json(array('success' => false));
}
// check nonce
$this->check_nonce();
// sanitize variables
$vehicle_id = absint($_POST['vehicle']);
// check if user is allowed to edit this vehicle
if (!wp_car_manager()->service('user_manager')->can_edit_listing($vehicle_id)) {
wp_send_json(array('success' => false));
}
// delete vehicle
wp_trash_post($vehicle_id);
// done
wp_send_json(array('success' => true));
// bye
exit;
}
开发者ID:barrykooij,项目名称:wp-car-manager,代码行数:26,代码来源:DeleteVehicle.php
示例16: output
/**
* @param array $atts
*
* @return string
*/
public function output($atts)
{
// JS
WPCarManager\Assets::enqueue_shortcode_cars();
// get attributes, defaults filterable via 'wpcm_shortcode_cars_defaults' filter
$atts = shortcode_atts(apply_filters('wpcm_shortcode_' . $this->get_tag() . '_defaults', array('show_filters' => true, 'show_sort' => true, 'orderby' => 'date', 'order' => 'DESC', 'make' => '', 'make_id' => '', 'sort' => 'price-asc', 'condition' => '')), $atts);
// make sure show_filters is a bool
if ('false' === $atts['show_filters']) {
$atts['show_filters'] = false;
} else {
$atts['show_filters'] = true;
}
// make sure show_sort is a bool
if ('false' === $atts['show_sort']) {
$atts['show_sort'] = false;
} else {
$atts['show_sort'] = true;
}
// check if we need to set a make_id
if (!empty($atts['make']) && empty($atts['make_id'])) {
$term = get_term_by('name', $atts['make'], 'wpcm_make_model');
if ($term != false) {
$atts['make_id'] = $term->term_id;
}
}
// build data atts
$data_atts = array('sort', 'condition', 'make_id');
$data_str = '';
foreach ($data_atts as $data_att) {
if (!empty($atts[$data_att])) {
$data_str .= ' data-' . $data_att . '="' . esc_attr($atts[$data_att]) . '"';
}
}
// start output buffer
ob_start();
// load template
wp_car_manager()->service('template_manager')->get_template_part('listings-vehicle', '', array('atts' => $atts, 'data_atts' => $data_str));
return ob_get_clean();
}
开发者ID:barrykooij,项目名称:wp-car-manager,代码行数:44,代码来源:Cars.php
示例17: enqueue_backend
/**
* Enqueue backend(admin) assets
*/
public static function enqueue_backend()
{
global $pagenow, $post;
// Enqueue Downloadable Files Metabox JS
if ($pagenow == 'post.php' && isset($post) && PostType::VEHICLE === $post->post_type || $pagenow == 'post-new.php' && isset($_GET['post_type']) && PostType::VEHICLE == $_GET['post_type']) {
// datepicker
wp_enqueue_script('jquery-ui-datepicker');
wp_enqueue_style('jquery-style', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css');
// enqueue edit vehicle script
wp_enqueue_script('wpcm_edit_download', wp_car_manager()->service('file')->plugin_url('/assets/js/edit-vehicle' . (!SCRIPT_DEBUG ? '.min' : '') . '.js'), array('jquery', 'jquery-ui-sortable', 'jquery-ui-datepicker'), wp_car_manager()->get_version());
}
if ('edit.php' == $pagenow && isset($_GET['page']) && ('wpcm-settings' === $_GET['page'] || 'wpcm-extensions' === $_GET['page'])) {
// enqueue settings and extensions script
wp_enqueue_script('wpcm_settings', wp_car_manager()->service('file')->plugin_url('/assets/js/settings' . (!SCRIPT_DEBUG ? '.min' : '') . '.js'), array('jquery'), wp_car_manager()->get_version());
}
// extensions Js
if (isset($_GET['page']) && 'wpcm-extensions' === $_GET['page']) {
wp_enqueue_script('wpcm_extensions', wp_car_manager()->service('file')->plugin_url('/assets/js/extensions' . (!SCRIPT_DEBUG ? '.min' : '') . '.js'), array('jquery'), wp_car_manager()->get_version());
}
// admin CSS
wp_enqueue_style('wpcm_admin', wp_car_manager()->service('file')->plugin_url('/assets/css/admin.css'), array(), wp_car_manager()->get_version());
}
开发者ID:valeriosouza,项目名称:wp-car-manager,代码行数:25,代码来源:Assets.php
示例18: load_view
/**
* Load the correct view
*/
private function load_view()
{
// check if we're editing a page
if (isset($_GET['edit'])) {
$term = get_term(absint($_GET['edit']), 'wpcm_make_model');
// form action URL
$form_action_url = admin_url('edit.php?post_type=wpcm_vehicle&page=wpcm-makes');
// check if make is set
if (isset($_GET['make'])) {
// add make to form action URL
$form_action_url = add_query_arg(array('make' => absint($_GET['make'])), $form_action_url);
}
// load view
wp_car_manager()->service('view_manager')->display('page/edit-make-model', array('form_action' => $form_action_url, 'title' => sprintf(__('Edit %s', 'wp-car-manager'), $term->name), 'item' => array('id' => $term->term_id, 'name' => $term->name, 'slug' => $term->slug)));
} elseif (isset($_GET['make'])) {
// get make
$make = get_term(absint($_GET['make']), 'wpcm_make_model');
// load view
wp_car_manager()->service('view_manager')->display('page/models', array('title' => sprintf(__('%s Models', 'wp-car-manager'), $make->name), 'items' => wp_car_manager()->service('make_model_manager')->get_models($make->term_id)));
} else {
// load view
wp_car_manager()->service('view_manager')->display('page/makes', array('title' => __('Makes', 'wp-car-manager'), 'items' => wp_car_manager()->service('make_model_manager')->get_makes()));
}
}
开发者ID:barrykooij,项目名称:wp-car-manager,代码行数:27,代码来源:Makes.php
示例19: antispambot
echo antispambot($email);
?>
?subject=<?php
the_title();
?>
"
class="wpcm-button wpcm-contact-button"><?php
_e('Email Us', 'wp-car-manager');
?>
</a>
<?php
}
?>
<?php
$phone_number = wp_car_manager()->service('settings')->get_option('contact_phone');
if ('' !== $phone_number) {
?>
<a href="tel:<?php
echo esc_attr($phone_number);
?>
"
class="wpcm-button wpcm-contact-button"><?php
_e('Call Us', 'wp-car-manager');
?>
</a>
<?php
}
?>
</div>
开发者ID:barrykooij,项目名称:wp-car-manager,代码行数:31,代码来源:contact.php
示例20: foreach
foreach ($fields as $key => $section) {
// check if we're showing this tab
$show = $key == $active_tab ? '' : 'hidden';
echo '<div id="settings-' . sanitize_title($key) . '" class="settings_panel ' . $show . '">';
echo '<table class="form-table">';
// loop through fields
foreach ($section[1] as $option) {
// placeholder
$placeholder = !empty($option['placeholder']) ? 'placeholder="' . $option['placeholder'] . '"' : '';
// label
echo '<tr valign="top"><th scope="row"><label for="setting-' . $option['name'] . '">' . $option['label'] . '</a></th><td>';
if (!isset($option['type'])) {
$option['type'] = '';
}
// get value
$value = wp_car_manager()->service('settings')->get_option($option['name']);
// switch type
switch ($option['type']) {
case "checkbox":
?>
<label><input id="setting-<?php
echo $option['name'];
?>
"
name="wpcm_<?php
echo $option['name'];
?>
" type="checkbox"
value="1" <?php
checked('1', $value);
?>
开发者ID:barrykooij,项目名称:wp-car-manager,代码行数:31,代码来源:settings.php
注:本文中的wp_car_manager函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论