本文整理汇总了PHP中WooThemes_Sensei_Utils::sensei_is_woocommerce_activated方法的典型用法代码示例。如果您正苦于以下问题:PHP WooThemes_Sensei_Utils::sensei_is_woocommerce_activated方法的具体用法?PHP WooThemes_Sensei_Utils::sensei_is_woocommerce_activated怎么用?PHP WooThemes_Sensei_Utils::sensei_is_woocommerce_activated使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WooThemes_Sensei_Utils
的用法示例。
在下文中一共展示了WooThemes_Sensei_Utils::sensei_is_woocommerce_activated方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sensei_check_woocommerce_version
function sensei_check_woocommerce_version($version = '2.1')
{
if (WooThemes_Sensei_Utils::sensei_is_woocommerce_activated()) {
global $woocommerce;
if (version_compare($woocommerce->version, $version, ">=")) {
return true;
}
}
return false;
}
示例2: sensei_woocommerce_complete_order
/**
* sensei_woocommerce_complete_order description
* @since 1.0.3
* @access public
* @param int $order_id WC order ID
* @return void
*/
public function sensei_woocommerce_complete_order($order_id = 0)
{
$order_user = array();
// Check for WooCommerce
if (WooThemes_Sensei_Utils::sensei_is_woocommerce_activated() && 0 < $order_id) {
// Get order object
$order = new WC_Order($order_id);
$user = get_user_by('id', $order->user_id);
$order_user['ID'] = $user->ID;
$order_user['user_login'] = $user->user_login;
$order_user['user_email'] = $user->user_email;
$order_user['user_url'] = $user->user_url;
// Run through each product ordered
if (0 < sizeof($order->get_items())) {
foreach ($order->get_items() as $item) {
$product_type = '';
if (isset($item['variation_id']) && 0 < $item['variation_id']) {
$item_id = $item['variation_id'];
$product_type = 'variation';
} else {
$item_id = $item['product_id'];
}
// End If Statement
$_product = $this->sensei_get_woocommerce_product_object($item_id, $product_type);
// Get courses that use the WC product
$courses = $this->post_types->course->get_product_courses($_product->id);
// Loop and update those courses
foreach ($courses as $course_item) {
$update_course = $this->woocommerce_course_update($course_item->ID, $order_user);
}
// End For Loop
}
// End For Loop
}
// End If Statement
// Add meta to indicate that payment has been completed successfully
update_post_meta($order_id, 'sensei_payment_complete', '1');
}
// End If Statement
}
示例3:
// Check if the user is taking the course
$is_user_taking_course = WooThemes_Sensei_Utils::user_started_course($post->ID, $current_user->ID);
// Content Access Permissions
$access_permission = false;
if (isset($woothemes_sensei->settings->settings['access_permission']) && !$woothemes_sensei->settings->settings['access_permission'] || sensei_all_access()) {
$access_permission = true;
}
// End If Statement
?>
<?php
/**
* woocommerce_before_single_product hook
*
* @hooked woocommerce_show_messages - 10
*/
if (WooThemes_Sensei_Utils::sensei_is_woocommerce_activated()) {
do_action('woocommerce_before_single_product');
}
// End If Statement
?>
<article <?php
post_class(array('course', 'post'));
?>
>
<?php
do_action('sensei_course_image', $post->ID);
do_action('sensei_course_single_title');
/**
* @hooked Sensei()->course->the_progress_statement - 15
示例4: lesson_course_meta_box_content
/**
* lesson_course_meta_box_content function.
*
* @access public
* @return void
*/
public function lesson_course_meta_box_content()
{
global $post;
// Setup Lesson Meta Data
$selected_lesson_course = 0;
if (0 < $post->ID) {
$selected_lesson_course = get_post_meta($post->ID, '_lesson_course', true);
}
// End If Statement
// Handle preselected course
if (isset($_GET['course_id']) && 0 < absint($_GET['course_id'])) {
$selected_lesson_course = absint($_GET['course_id']);
}
// End If Statement
// Get the Lesson Posts
$post_args = array('post_type' => 'course', 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC', 'post_status' => 'any', 'suppress_filters' => 0);
$posts_array = get_posts($post_args);
// Buid the HTML to Output
$html = '';
// Nonce
$html .= wp_nonce_field('sensei-save-post-meta', 'woo_' . $this->token . '_nonce', true, false);
// Select the course for the lesson
$drop_down_args = array('name' => 'lesson_course', 'id' => 'lesson-course-options');
$courses = WooThemes_Sensei_Course::get_all_courses();
$courses_options = array();
foreach ($courses as $course) {
$courses_options[$course->ID] = get_the_title($course);
}
$html .= WooThemes_Sensei_Utils::generate_drop_down($selected_lesson_course, $courses_options, $drop_down_args);
// Course Actions Panel
if (current_user_can('publish_courses')) {
$html .= '<div id="lesson-course-actions">';
$html .= '<p>';
// Add a course action link
$html .= '<a id="lesson-course-add" href="#course-add" class="lesson-add-course">+ ' . __('Add New Course', 'woothemes-sensei') . '</a>';
$html .= '</p>';
$html .= '</div>';
// Add a course input fields
$html .= '<div id="lesson-course-details" class="hidden">';
$html .= '<p>';
// Course Title input
$html .= '<label>' . __('Course Title', 'woothemes-sensei') . '</label> ';
$html .= '<input type="text" id="course-title" name="course_title" value="" size="25" class="widefat" />';
// Course Description input
$html .= '<label>' . __('Description', 'woothemes-sensei') . '</label> ';
$html .= '<textarea rows="10" cols="40" id="course-content" name="course_content" value="" size="300" class="widefat"></textarea>';
// Course Prerequisite
$html .= '<label>' . __('Course Prerequisite', 'woothemes-sensei') . '</label> ';
$html .= '<select id="course-prerequisite-options" name="course_prerequisite" class="chosen_select widefat">' . "\n";
$html .= '<option value="">' . __('None', 'woothemes-sensei') . '</option>';
foreach ($posts_array as $post_item) {
$html .= '<option value="' . esc_attr(absint($post_item->ID)) . '">' . esc_html($post_item->post_title) . '</option>' . "\n";
}
// End For Loop
$html .= '</select>' . "\n";
// Course Product
if (WooThemes_Sensei_Utils::sensei_is_woocommerce_activated()) {
// Get the Products
$select_course_woocommerce_product = get_post_meta($post_item->ID, '_course_woocommerce_product', true);
$product_args = array('post_type' => array('product', 'product_variation'), 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'DESC', 'post_status' => array('publish', 'private', 'draft'), 'tax_query' => array(array('taxonomy' => 'product_type', 'field' => 'slug', 'terms' => array('variable', 'grouped'), 'operator' => 'NOT IN')), 'suppress_filters' => 0);
$products_array = get_posts($product_args);
$html .= '<label>' . __('WooCommerce Product', 'woothemes-sensei') . '</label> ';
$html .= '<select id="course-woocommerce-product-options" name="course_woocommerce_product" class="chosen_select widefat">' . "\n";
$html .= '<option value="-">' . __('None', 'woothemes-sensei') . '</option>';
$prev_parent_id = 0;
foreach ($products_array as $products_item) {
if ('product_variation' == $products_item->post_type) {
$product_object = get_product($products_item->ID);
$parent_id = wp_get_post_parent_id($products_item->ID);
$product_name = ucwords(woocommerce_get_formatted_variation($product_object->variation_data, true));
} else {
$parent_id = false;
$prev_parent_id = 0;
$product_name = $products_item->post_title;
}
// Show variations in groups
if ($parent_id && $parent_id != $prev_parent_id) {
if (0 != $prev_parent_id) {
$html .= '</optgroup>';
}
$html .= '<optgroup label="' . get_the_title($parent_id) . '">';
$prev_parent_id = $parent_id;
} elseif (!$parent_id && 0 == $prev_parent_id) {
$html .= '</optgroup>';
}
$html .= '<option value="' . esc_attr(absint($products_item->ID)) . '">' . esc_html($products_item->post_title) . '</option>' . "\n";
}
// End For Loop
$html .= '</select>' . "\n";
} else {
// Default
$html .= '<input type="hidden" name="course_woocommerce_product" id="course-woocommerce-product-options" value="-" />';
}
// Course Category
//.........这里部分代码省略.........
示例5: sensei_simple_course_price
/**
* sensei_simple_course_price function.
*
* @access public
* @param mixed $post_id
* @return void
*/
function sensei_simple_course_price($post_id)
{
global $woothemes_sensei;
//WooCommerce Pricing
if (WooThemes_Sensei_Utils::sensei_is_woocommerce_activated()) {
$wc_post_id = get_post_meta($post_id, '_course_woocommerce_product', true);
if (0 < $wc_post_id) {
// Get the product
$product = $woothemes_sensei->sensei_get_woocommerce_product_object($wc_post_id);
if (isset($product) && !empty($product) && $product->is_purchasable() && $product->is_in_stock() && !sensei_check_if_product_is_in_cart($wc_post_id)) {
?>
<span class="course-price"><?php
echo $product->get_price_html();
?>
</span>
<?php
}
// End If Statement
}
// End If Statement
}
// End If Statement
}
示例6: activate_purchased_single_course
/**
* Activate single course if already purchases
* @return void
*/
public function activate_purchased_single_course()
{
global $post, $current_user;
if (WooThemes_Sensei_Utils::sensei_is_woocommerce_activated()) {
if (!is_user_logged_in()) {
return;
}
if (!isset($post->ID)) {
return;
}
$user_id = $current_user->ID;
$course_id = $post->ID;
$course_product_id = (int) get_post_meta($course_id, '_course_woocommerce_product', true);
if (!$course_product_id) {
return;
}
$user_course_status = WooThemes_Sensei_Utils::user_course_status(intval($course_id), $user_id);
// Ignore course if already completed
if (WooThemes_Sensei_Utils::user_completed_course($user_course_status)) {
return;
}
// Ignore course if already started
if ($user_course_status) {
return;
}
// Get all user's orders
$order_args = array('post_type' => 'shop_order', 'posts_per_page' => -1, 'post_status' => array('wc-processing', 'wc-completed'), 'meta_query' => array(array('key' => '_customer_user', 'value' => $user_id)), 'fields' => 'ids');
$orders = get_posts($order_args);
foreach ($orders as $order_post_id) {
// Get course product IDs from order
$order = new WC_Order($order_post_id);
$items = $order->get_items();
foreach ($items as $item) {
$product = wc_get_product($item['product_id']);
// handle product bundles
if ($product->is_type('bundle')) {
$bundled_product = new WC_Product_Bundle($product->id);
$bundled_items = $bundled_product->get_bundled_items();
foreach ($bundled_items as $item) {
if ($item->product_id == $course_product_id) {
WooThemes_Sensei_Utils::user_start_course($user_id, $course_id);
return;
}
}
} else {
// handle regular products
if ($item['product_id'] == $course_product_id) {
WooThemes_Sensei_Utils::user_start_course($user_id, $course_id);
return;
}
}
}
}
}
}
示例7: load_user_courses_content
//.........这里部分代码省略.........
if (isset($woothemes_sensei->settings->settings['course_author']) && $woothemes_sensei->settings->settings['course_author']) {
$active_html .= '<span class="course-author">' . __('by ', 'woothemes-sensei') . '<a href="' . esc_url(get_author_posts_url(absint($course_item->post_author))) . '" title="' . esc_attr($user_info->display_name) . '">' . esc_html($user_info->display_name) . '</a></span>';
}
// End If Statement
// Lesson count for this author
$lesson_count = $woothemes_sensei->post_types->course->course_lesson_count(absint($course_item->ID));
// Handle Division by Zero
if (0 == $lesson_count) {
$lesson_count = 1;
}
// End If Statement
$active_html .= '<span class="course-lesson-count">' . $lesson_count . ' ' . apply_filters('sensei_lessons_text', __('Lessons', 'woothemes-sensei')) . '</span>';
// Course Categories
if ('' != $category_output) {
$active_html .= '<span class="course-category">' . sprintf(__('in %s', 'woothemes-sensei'), $category_output) . '</span>';
}
// End If Statement
$active_html .= '<span class="course-lesson-progress">' . sprintf(__('%1$d of %2$d lessons completed', 'woothemes-sensei'), $lessons_completed, $lesson_count) . '</span>';
$active_html .= '</p>';
$active_html .= '<p class="course-excerpt">' . apply_filters('get_the_excerpt', $course_item->post_excerpt) . '</p>';
$progress_percentage = abs(round(doubleval($lessons_completed) * 100 / $lesson_count, 0));
$active_html .= $this->get_progress_meter($progress_percentage);
$active_html .= '</section>';
if ($manage) {
$active_html .= '<section class="entry-actions">';
$active_html .= '<form method="POST" action="' . esc_url(remove_query_arg(array('active_page', 'completed_page'))) . '">';
$active_html .= '<input type="hidden" name="' . esc_attr('woothemes_sensei_complete_course_noonce') . '" id="' . esc_attr('woothemes_sensei_complete_course_noonce') . '" value="' . esc_attr(wp_create_nonce('woothemes_sensei_complete_course_noonce')) . '" />';
$active_html .= '<input type="hidden" name="course_complete_id" id="course-complete-id" value="' . esc_attr(absint($course_item->ID)) . '" />';
if (0 < absint(count($course_lessons)) && $woothemes_sensei->settings->settings['course_completion'] == 'complete') {
$active_html .= '<span><input name="course_complete" type="submit" class="course-complete" value="' . apply_filters('sensei_mark_as_complete_text', __('Mark as Complete', 'woothemes-sensei')) . '"/></span>';
}
// End If Statement
$course_purchased = false;
if (WooThemes_Sensei_Utils::sensei_is_woocommerce_activated()) {
// Get the product ID
$wc_post_id = get_post_meta(absint($course_item->ID), '_course_woocommerce_product', true);
if (0 < $wc_post_id) {
$course_purchased = WooThemes_Sensei_Utils::sensei_customer_bought_product($user->user_email, $user->ID, $wc_post_id);
}
// End If Statement
}
// End If Statement
if (!$course_purchased) {
$active_html .= '<span><input name="course_complete" type="submit" class="course-delete" value="' . apply_filters('sensei_delete_course_text', __('Delete Course', 'woothemes-sensei')) . '"/></span>';
}
// End If Statement
$active_html .= '</form>';
$active_html .= '</section>';
}
$active_html .= '</article>';
}
// Active pagination
if ($active_count > $per_page) {
$current_page = 1;
if (isset($_GET['active_page']) && 0 < intval($_GET['active_page'])) {
$current_page = $_GET['active_page'];
}
$active_html .= '<nav class="pagination woo-pagination">';
$total_pages = ceil($active_count / $per_page);
$link = '';
if ($current_page > 1) {
$prev_link = add_query_arg('active_page', $current_page - 1);
$active_html .= '<a class="prev page-numbers" href="' . esc_url($prev_link) . '">' . __('Previous', 'woothemes-sensei') . '</a> ';
}
for ($i = 1; $i <= $total_pages; $i++) {
$link = add_query_arg('active_page', $i);
示例8: the_course_action_buttons
/**
* Prints out the course action buttons links
*
* - complete course
* - delete course
*
* @param WP_Post $course
*/
public static function the_course_action_buttons($course)
{
if (is_user_logged_in()) {
?>
<section class="entry-actions">
<form method="POST" action="<?php
echo esc_url(remove_query_arg(array('active_page', 'completed_page')));
?>
">
<input type="hidden"
name="<?php
esc_attr_e('woothemes_sensei_complete_course_noonce');
?>
"
id="<?php
esc_attr_e('woothemes_sensei_complete_course_noonce');
?>
"
value="<?php
esc_attr_e(wp_create_nonce('woothemes_sensei_complete_course_noonce'));
?>
"
/>
<input type="hidden" name="course_complete_id" id="course-complete-id" value="<?php
esc_attr_e(intval($course->ID));
?>
" />
<?php
if (0 < absint(count(Sensei()->course->course_lessons($course->ID))) && Sensei()->settings->settings['course_completion'] == 'complete') {
?>
<span><input name="course_complete" type="submit" class="course-complete" value="<? echo apply_filters( 'sensei_mark_as_complete_text', __( 'Mark as Complete', 'woothemes-sensei' ) ); ?>/></span>
<?php
}
// End If Statement
$course_purchased = false;
if (WooThemes_Sensei_Utils::sensei_is_woocommerce_activated()) {
// Get the product ID
$wc_post_id = get_post_meta(intval($course->ID), '_course_woocommerce_product', true);
if (0 < $wc_post_id) {
$user = wp_get_current_user();
$course_purchased = WooThemes_Sensei_Utils::sensei_customer_bought_product($user->user_email, $user->ID, $wc_post_id);
}
// End If Statement
}
// End If Statement
if (!$course_purchased && !WooThemes_Sensei_Utils::user_completed_course($course->ID, get_current_user_id())) {
?>
<span><input name="course_complete" type="submit" class="course-delete" value="<?php
echo apply_filters('sensei_delete_course_text', __('Delete Course', 'woothemes-sensei'));
?>
"/></span>
<?php
}
// End If Statement
$has_quizzes = Sensei()->course->course_quizzes($course->ID, true);
$results_link = '';
if ($has_quizzes) {
$results_link = '<a class="button view-results" href="' . Sensei()->course_results->get_permalink($course->ID) . '">' . apply_filters('sensei_view_results_text', __('View results', 'woothemes-sensei')) . '</a>';
}
// Output only if there is content to display
if (has_filter('sensei_results_links') || $has_quizzes) {
?>
<p class="sensei-results-links">
<?php
echo apply_filters('sensei_results_links', $results_link);
?>
</p>
<?php
}
// end if has filter
?>
</form>
</section>
<?php
}
// end if is user logged in
}