| 1 |
<?php |
| 2 |
|
| 3 |
function wpstream_main_start(){ |
| 4 |
|
| 5 |
add_action( 'wp_enqueue_scripts', 'wpstream_enqueue_styles' ); |
| 6 |
add_action( 'admin_enqueue_scripts', 'wpstream_enqueue_styles_admin'); |
| 7 |
add_action( 'init', 'wpstream_my_custom_endpoints' ); |
| 8 |
add_filter( 'query_vars', 'wpstream_my_custom_query_vars', 0 ); |
| 9 |
add_filter( 'woocommerce_account_menu_items', 'wpstream_custom_my_account_menu_items' ); |
| 10 |
add_action( 'woocommerce_account_event-list_endpoint', 'wpstream_custom_endpoint_content_event_list' ); |
| 11 |
add_action( 'woocommerce_account_video-list_endpoint', 'wpstream_custom_endpoint_video_list' ); |
| 12 |
add_action( 'woocommerce_before_single_product', 'wpstream_user_logged_in_product_already_bought', 10 ); |
| 13 |
add_action( 'after_switch_theme', 'wpstream_custom_flush_rewrite_rules' ); |
| 14 |
add_action('init', 'wpstream_shortcodes'); |
| 15 |
|
| 16 |
if (is_admin()) { |
| 17 |
add_action('admin_menu', 'wpstream_manage_admin_menu',999); |
| 18 |
} |
| 19 |
|
| 20 |
$page_check = get_page_by_title('wpstream'); |
| 21 |
if (!isset($page_check->ID)) { |
| 22 |
$my_post = array( |
| 23 |
'post_title' => 'wpstream', |
| 24 |
'post_type' => 'page', |
| 25 |
'post_status' => 'publish', |
| 26 |
); |
| 27 |
$new_id = wp_insert_post($my_post); |
| 28 |
|
| 29 |
} |
| 30 |
|
| 31 |
$page_check = get_page_by_title('vodkey'); |
| 32 |
if (!isset($page_check->ID)) { |
| 33 |
$my_post = array( |
| 34 |
'post_title' => 'vodkey', |
| 35 |
'post_type' => 'page', |
| 36 |
'post_status' => 'publish', |
| 37 |
); |
| 38 |
$new_id = wp_insert_post($my_post); |
| 39 |
|
| 40 |
} |
| 41 |
|
| 42 |
$page_check = get_page_by_title('Userkey'); |
| 43 |
if (!isset($page_check->ID)) { |
| 44 |
$my_post = array( |
| 45 |
'post_title' => 'Userkey', |
| 46 |
'post_type' => 'page', |
| 47 |
'post_status' => 'publish', |
| 48 |
); |
| 49 |
$new_id = wp_insert_post($my_post); |
| 50 |
|
| 51 |
} |
| 52 |
|
| 53 |
|
| 54 |
} |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
function wpstream_manage_admin_menu() { |
| 60 |
add_menu_page( __('WpStream Options','wpestream'), __('WpStream','wpstream'), 'administrator', 'wpstream options', 'wpstream_new_general_set'); |
| 61 |
} |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
function wpstream_non_image_content_wrapper_start() { |
| 66 |
if ( is_user_logged_in() ) { |
| 67 |
global $product; |
| 68 |
$current_user = wp_get_current_user(); |
| 69 |
$product_id = get_the_ID(); |
| 70 |
|
| 71 |
if ( wc_customer_bought_product( $current_user->user_email, $current_user->ID, $product->id ) ){ |
| 72 |
echo '<div id="wpstream_product_wrap">'; |
| 73 |
}else{ |
| 74 |
echo '<div id="wpstream_product_wrap_no_buy">'; |
| 75 |
} |
| 76 |
} |
| 77 |
|
| 78 |
} |
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
function wpstream_non_image_content_wrapper_end() { |
| 83 |
echo '</div>'; |
| 84 |
} |
| 85 |
|
| 86 |
|
| 87 |
add_action( 'woocommerce_before_single_product', 'wpstream_non_image_content_wrapper_start', 20 ); |
| 88 |
add_action( 'woocommerce_after_single_product', 'wpstream_non_image_content_wrapper_end', 20 ); |
| 89 |
|