PATH:
home
/
letacommog
/
laindinois
/
OLD
/
wp-content
/
plugins
/
downtown-rest-api
/
classes
/
packages
<?php add_action( 'rest_api_init', 'dwt_listing_pack_get', 0 ); function dwt_listing_pack_get() { register_rest_route( 'downtown/app', '/packages/', array( 'methods' => WP_REST_Server::EDITABLE, 'callback' => 'dwt_listing_create_packages', ) ); } // Get Listing Form if (!function_exists('dwt_listing_create_packages')) { function dwt_listing_create_packages($request) { global $dwt_listing_api; //global $dwt_listing_options; $user = wp_get_current_user(); $user_id = $user->ID; $check_respone = false; $has_package = false; $payment_methods = $package_expiry = $packages = $package_details = array(); $gey_packtype = $create_event = $allow_coupon_code = $bump_listing = $allow_tags = $business_hours = $price_range = $no_of_images = $website_link = $video_listing = $featured_listing_expiry = $regular_listing = $featured_listing = $product_type = $package_id = ''; $days = dwt_listing_text('d_pkg_daytxt'); $yes = dwt_listing_text('d_pkg_yes'); $no = dwt_listing_text('d_pkg_no'); $never_expire = dwt_listing_text('d_never_exp'); $packages['has_package'] = false; $packages['stripe']['pub_key'] = $dwt_listing_api['stripe_pub_key']; $packages['stripe']['sec_key'] = $dwt_listing_api['stripe_sec_key']; $packages['paypal']['pub_key'] = $dwt_listing_api['pay_clientid']; $packages['paypal']['sec_key'] = $dwt_listing_api['pay_secret']; $packages['paypal']['mode'] = $dwt_listing_api['paypal_mode']; $unlimited = dwt_listing_text('d_pkg_unlimited'); if(class_exists('WooCommerce') && in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) { $check_respone = true; if(!empty($dwt_listing_api['app_lisitng_package_type'])) { $package_id = $dwt_listing_api['app_lisitng_package_type']; if(!empty($package_id) && count($package_id) > 0) { $payment_methods[] = array("key" => "", "value" =>__( 'Choose Plan', 'dwt-listing-api' )); if(isset($dwt_listing_api['app_lisitng_payment_type']) && $dwt_listing_api['app_lisitng_payment_type'] !="") { $pay_methods = $dwt_listing_api['app_lisitng_payment_type']; if(!empty($pay_methods) && count($pay_methods) > 0) { foreach($pay_methods as $types) { $name = dwt_listing_payment_types($types); $payment_methods[] = array("key" => $types, "value" => $name ); } } } $packages['has_package'] = true; $packages['generic_msg'] = esc_html__("Package keys are required.", 'dwt-listing-api'); $packages['btn_txt'] = esc_html__("Choose Plan", 'dwt-listing-api'); $packages['user_btn'] = esc_html__("Already Used", 'dwt-listing-api'); $packages['placeholder'] = esc_html__("Choose Plan", 'dwt-listing-api'); foreach($package_id as $product_id) { $product_type = wc_get_product($product_id); if($product_type->get_type() == 'dwt_listing_pkgs') { if(get_post_meta($product_id, 'package_type', true ) !="") { $gey_packtype = get_post_meta($product_id, 'package_type', true ); } $package_details['package_type'] = $gey_packtype; $package_details['package_id'] = esc_attr($product_id); //for just in app purchase $and = false; $and_key = ''; if(get_post_meta($product_id, 'in_app_dwt_android', true)!="") { $and = true; $and_key = get_post_meta($product_id, 'in_app_dwt_android', true); } $ios = false; $ios_key = ''; if(get_post_meta($product_id, 'in_app_dwt_ios', true)!="") { $ios = true; $ios_key = get_post_meta($product_id, 'in_app_dwt_ios', true); } $package_details['android'] = array("key" => $and ,"code" =>$and_key); $package_details['ios'] = array("key" => $ios,"code" =>$ios_key); /* $package_details['has_android_inapp'] = false; if(get_post_meta($product_id, 'in_app_dwt_android', true)!="") { $package_details['android_key'] = get_post_meta($product_id, 'in_app_dwt_android', true); $package_details['has_android_inapp'] = true; } $package_details['has_ios_inapp'] = false; if(get_post_meta($product_id, 'in_app_dwt_ios', true)!="") { $package_details['ios_key'] = get_post_meta($product_id, 'in_app_dwt_ios', true); $package_details['has_ios_inapp'] = true; }*/ //paid or free $package_details['already_purchased'] = false; if(get_user_meta($user_id, 'd_is_free_pgk', true) == $product_id) { $package_details['already_purchased'] = true; } //package name $package_details['package_info'] = array("title" =>get_the_title($product_id) ,"symbol" =>dwt_listing_convert_uniText(get_woocommerce_currency_symbol()) ,"price" => $product_type->get_price(), "currency" => get_woocommerce_currency()); //package expiry $package_expiry = get_post_meta($product_id, 'package_expiry', true); if($package_expiry == '-1') { $package_details['expiry'] = array("title" => dwt_listing_text('d_p_exp'),"value" => dwt_listing_text('d_never_exp') ,"status" => true); } else { $package_details['expiry'] = array("title" => dwt_listing_text('d_p_exp'),"value" => esc_attr($package_expiry).' '.$days,"status" => true ); } //regular listings expiry if(get_post_meta($product_id, 'regular_listing', true ) !="") { $regular_listing = get_post_meta($product_id, 'regular_listing', true ); if($regular_listing == '-1') { $package_details['listings'] = array("title" => dwt_listing_text('d_reg_listing'),"value" => $unlimited,"status" => true); } else { $package_details['listings'] = array("title" => dwt_listing_text('d_reg_listing'),"value" => esc_attr($regular_listing),"status" => true); } } //featured listings if(get_post_meta($product_id, 'featured_listing', true ) !="") { $featured_listing = get_post_meta($product_id, 'featured_listing', true ); if($featured_listing == '-1') { $package_details['featured'] = array("title" => dwt_listing_text('d_feat_listing'),"value" => $never_expire ,"status" => true); } else { $package_details['featured'] = array("title" => dwt_listing_text('d_feat_listing'),"value" => esc_attr($featured_listing) .' '.$days ,"status" => true); } } //featured listings expiry if(get_post_meta($product_id, 'featured_listing_expiry', true ) !="") { $featured_listing_expiry = get_post_meta($product_id, 'featured_listing_expiry', true ); if($featured_listing_expiry == '-1') { $package_details['featured_expiry'] = array("title" => dwt_listing_text('d_feat_for'),"value" => $never_expire ,"status" => true); } else { $package_details['featured_expiry'] = array("title" => dwt_listing_text('d_feat_for'),"value" => esc_attr($featured_listing_expiry) .' '.$days ,"status" => true); } } //video listing if(get_post_meta($product_id, 'video_listing', true ) !="") { $video_listing = get_post_meta($product_id, 'video_listing', true ); if($video_listing == 'yes') { $package_details['video'] = array("title" => dwt_listing_text('d_vid_listing'),"value" => esc_attr($yes) ,"status" => true); } else { $package_details['video'] = array("title" => dwt_listing_text('d_vid_listing'),"value" => esc_attr($no) ,"status" => false); } } //web link if(get_post_meta($product_id, 'website_link', true ) !="") { $website_link = get_post_meta($product_id, 'website_link', true ); if($website_link == 'yes') { $package_details['weblink'] = array("title" => dwt_listing_text('d_web_link'),"value" => esc_attr($yes) ,"status" => true); } else { $package_details['weblink'] = array("title" => dwt_listing_text('d_web_link'),"value" => esc_attr($no) ,"status" => false); } } //images if(get_post_meta($product_id, 'no_of_images', true ) !="") { $no_of_images = get_post_meta($product_id, 'no_of_images', true ); $package_details['images'] = array("title" => dwt_listing_text('d_no_images'),"value" => esc_attr($no_of_images),"status" => true); } //price range if(get_post_meta($product_id, 'price_range', true ) !="") { $price_range = get_post_meta($product_id, 'price_range', true ); if($price_range == 'yes') { $package_details['price_range'] = array("title" => dwt_listing_text('d_p_range'),"value" => esc_attr($yes) ,"status" => true); } else { $package_details['price_range'] = array("title" => dwt_listing_text('d_p_range'),"value" => esc_attr($no) ,"status" => false); } } //business hours if(get_post_meta($product_id, 'business_hours', true ) !="") { $business_hours = get_post_meta($product_id, 'business_hours', true ); if($business_hours == 'yes') { $package_details['business_hours'] = array("title" => dwt_listing_text('d_b_hours'),"value" => esc_attr($yes) ,"status" => true); } else { $package_details['business_hours'] = array("title" => dwt_listing_text('d_b_hours'),"value" => esc_attr($no) ,"status" => false); } } //tags if(get_post_meta($product_id, 'allow_tags', true ) !="") { $allow_tags = get_post_meta($product_id, 'allow_tags', true ); if($allow_tags == 'yes') { $package_details['tags'] = array("title" => dwt_listing_text('d_llow_tag'),"value" => esc_attr($yes) ,"status" => true); } else { $package_details['tags'] = array("title" => dwt_listing_text('d_llow_tag'),"value" => esc_attr($no) ,"status" => false); } } //bump if(get_post_meta($product_id, 'bump_listing', true ) !="") { $bump_listing = get_post_meta($product_id, 'bump_listing', true ); $package_details['bump'] = array("title" => dwt_listing_text('d_bump_listing'),"value" => esc_attr($bump_listing) ,"status" => true); } //coupon code if(get_post_meta($product_id, 'allow_coupon_code', true ) !="") { $allow_coupon_code = get_post_meta($product_id, 'allow_coupon_code', true ); if($allow_coupon_code == 'yes') { $package_details['coupon'] = array("title" => dwt_listing_text('d_coupon_code'),"value" => esc_attr($yes) ,"status" => true); } else { $package_details['coupon'] = array("title" => dwt_listing_text('d_coupon_code'),"value" => esc_attr($no) ,"status" => false); } } //event if(get_post_meta($product_id, 'create_event', true ) !="") { $create_event = get_post_meta($product_id, 'create_event', true ); if($create_event == 'yes') { $package_details['event'] = array("title" => dwt_listing_text('d_create_event'),"value" => esc_attr($yes) ,"status" => true); } else { $package_details['event'] = array("title" => dwt_listing_text('d_create_event'),"value" => esc_attr($no) ,"status" => false); } } //payment methods $package_details['payments_methods'] = $payment_methods; } else { return rest_ensure_response(array('success' => false, "message" => esc_html__('Only packages are allowed.', 'dwt-listing-api'))); } $packages['packages'][] = $package_details; } } } } $response = rest_ensure_response(array('success' => $check_respone, 'data' => $packages, "message" => esc_html__('Packages are not available.','dwt-listing-api'))); return $response; } }
[+]
..
[-] packages.php
[edit]