<?php
class lumise_launcher {
public $url;
public $path;
public $cfg;
public $bashboardUrl = '';
public $newDesignUrl = '';
public function __construct() {
global $lumise_woo, $lumise, $wp;
$lumise_woo->load_core();
$this->url = $lumise->cfg->upload_url.'addons/vendors/';
$this->path = $lumise->cfg->upload_path.'addons'.DS.'vendors'.DS.'launcher'.DS;
$store_url = get_option( 'woocommerce_myaccount_page_id' );
if ( $store_url ) {
$store_url = get_permalink( $store_url ).'store';
}
@ini_set('upload_max_filesize', '500M');
@ini_set('post_max_size', '500M');
// get this url via wordpress
$thisUrl = home_url($wp->request);
// process url string to dashboard
$indexOfDash = strpos($thisUrl, "dashboard");
if($indexOfDash !== FALSE){
$this->bashboardUrl = substr($thisUrl, 0, ($indexOfDash+9)).'/';
}
if($thisUrl == home_url()){
$this->bashboardUrl = $thisUrl.'/dashboard/';
}
// hash : 8f7b20574418bd167fef885d1694619f
if($this->bashboardUrl != ''){
$this->newDesignUrl = $this->bashboardUrl.'design-launcher';
}
$this->cfg = array(
"version" => '1.5',
"url" => $this->url,
"upload_url" => $lumise->cfg->upload_url,
"tool_assests" => $lumise->cfg->assets_url,
"checkout_url" => "",
// "dashboard_url" => "", old code
"dashboard_url" => $this->bashboardUrl,
"new_design_url" => $this->newDesignUrl, // hash : 8f7b20574418bd167fef885d1694619f
"store_url" => $store_url,
"cart_url" => "",
"ajax" => $lumise->cfg->ajax_url,
"assets" => $this->url."assets/",
"max_size" => (int)ini_get('post_max_size'),
"nonce" => lumise_secure::create_nonce('LAUNCHER-SECURITY')
);
}
public function cms_product($id) {
$wc_product = wc_get_product($id);
return array(
'id' => $id,
'title' => html_entity_decode( get_the_title($id) ),
'image' => get_the_post_thumbnail_url($id),
'price' => $wc_product->get_price()
);
}
private function valid_upload_designs() {
@ini_set('upload_max_filesize', '500M');
@ini_set('post_max_size', '500M');
global $lumise;
$time = time();
$check = $lumise->check_upload($time);
if ($check !== 1) {
echo $lumise->lang($check);
exit;
}
$max_size = (int)ini_get('post_max_size');
$upload_size = ((int)$_POST['upload_size'])/1024000;
if ( $max_size > 0 && $upload_size > $max_size ) {
echo $lumise->lang('Error: The upload file size is larger than the server configuration').' (upload '.$upload_size.' of max '.$max_size.'MB)';
exit;
}
return true;
}
private function upload_designs() {
global $lumise;
$time = time();
$this->valid_upload_designs();
$designs = $lumise->lib->dejson($_POST['designs']);
if (count(array_keys((Array)$designs)) === 0) {
echo 'Error: no designs uploaded';
exit;
}
foreach ($designs as $id => $design) {
if (!isset($_FILES[$id])) {
echo 'Error: failed on uploading designs';
exit;
}
}
$path = $lumise->cfg->upload_path;
$dpath = 'templates'.DS.date('Y', $time).DS.date('m', $time).DS;
$durl = $lumise->cfg->upload_url.'templates/'.date('Y', $time).'/'.date('m', $time).'/';
$uid = (string)get_current_user_id();
$lumise->set_vendor($uid);
/*
* @ move design file & design thumbnail to upload folder
*/
foreach ($designs as $id => $design){
$check = $lumise->db->rawQuery("SELECT `id` FROM {$lumise->db->prefix}templates WHERE `name`='{$id}' AND `author`={$uid}");
if (filesize($_FILES[$id]['tmp_name']) === 0) {
echo 'Error while upload design file';
exit;
}
if (count($check) > 0) {
$designs->{$id}->db_id = $check[0]['id'];
continue;
}
if (
move_uploaded_file($_FILES[$id]['tmp_name'], $path.$dpath.$design->file) &&
move_uploaded_file($_FILES[$id.'-thumbnail']['tmp_name'], $path.$dpath.$design->thumbnail)
) {
/*
* @ create template
*/
$designs->{$id}->db_id = $lumise->lib->add_row( array(
'name' => $id,
'price' => 0,
'screenshot' => $durl.$design->thumbnail,
'upload' => $dpath.$design->file,
'featured' => 0,
'active' => 1,
'tags' => '',
'order' => 0,
'updated' => date("Y-m-d").' '.date("H:i:s"),
'created' => date("Y-m-d").' '.date("H:i:s")
), 'templates' );
}
}
return $designs;
}
private function create_products($designs = array()) {
global $lumise;
require_once('wp-admin/includes/image.php');
require_once('wp-admin/includes/file.php');
require_once('wp-admin/includes/media.php');
$products = $lumise->lib->dejson($_POST['products']);
$user_id = get_current_user_id();
$time = time();
$first_product = 0;
$dpath = 'templates'.DS.date('Y', $time).DS.date('m', $time).DS;
if ( dokan_is_seller_trusted( $user_id ) ) {
$status = get_post_status_object('publish') ? 'publish' : 'draft';
} else {
$status = dokan_get_option( 'product_status', 'dokan_selling', 'pending' );
$status = get_post_status_object( $status ) ? $status : 'draft';
}
if (!is_array($products) || count($products) === 0) {
echo 'Error: no product base found';
exit;
}
foreach ($products as $i => $product) {
$objProduct = new WC_Product();
$objProduct->set_name($product->name);
$objProduct->set_status($status);
$objProduct->set_catalog_visibility('visible');
$objProduct->set_description($product->description);
$objProduct->set_price($product->price+$product->design_price);
$objProduct->set_regular_price($product->price+$product->design_price);
/*$objProduct->set_manage_stock(true); // true or false
$objProduct->set_stock_quantity(10);
$objProduct->set_stock_status('instock');
$objProduct->set_backorders('no');
$objProduct->set_reviews_allowed(true);
$objProduct->set_sold_individually(false);
$objProduct->set_category_ids(array(1,2,3));*/
$media_ids = array();
/*
* @ move screenshots to product images
*/
foreach ($product->designs as $s => $design) {
if (
!isset($design->id) ||
!isset($designs->{$design->id}) ||
!isset($design->screenshot) ||
!isset($_FILES[str_replace('.', '_', $design->screenshot)])
) continue;
$media_id = media_handle_sideload(
$_FILES[str_replace('.', '_', $design->screenshot)], 0, null
);
if ($media_id) {
array_push($media_ids, $media_id);
}
/*
* @ update id of design template & thumbnail
*/
$product->designs->{$s}->screenshot = $dpath.$designs->{$design->id}->thumbnail;
$product->designs->{$s}->id = $designs->{$design->id}->db_id;
}
/*
* @ Create product gallery incase has more than 1 screenshot
*/
if (count($media_ids) > 0) {
$objProduct->set_image_id($media_ids[0]);
if (count($media_ids) > 1){
$objProduct->set_gallery_image_ids($media_ids);
}
}
/*
* @ Create new product
*/
$products[$i]->product_id = $objProduct->save();
/*
* @ Add Lumise design data to product
*/
update_post_meta($products[$i]->product_id, 'lumise_product_base', $product->id);
update_post_meta($products[$i]->product_id, 'lumise_customize', 'no');
update_post_meta($products[$i]->product_id, 'lumise_disable_add_cart', 'no');
update_post_meta($products[$i]->product_id, 'lumise_design_template', urlencode(json_encode($product->designs)));
if ($first_product === 0) {
$first_product = $products[$i]->product_id;
}
}
return $first_product;
}
public function ajax_init() {
global $lu
没有合适的资源?快使用搜索试试~ 我知道了~
【WordPress插件】2022年最新版完整功能demo+插件v1.1.zip
共28个文件
php:7个
js:6个
html:4个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 178 浏览量
2022-04-01
01:28:04
上传
评论
收藏 213KB ZIP 举报
温馨提示
"【WordPress插件】2022年最新版完整功能demo+插件v1.1 Dokan Integrate & Design Launcher Addon for LUMISE Product Designer Dokan Integrate&Design Launcher Addon for Lumus产品设计师" ---------- 泰森云每天更新发布最新WordPress主题、HTML主题、WordPress插件、shopify主题、opencart主题、PHP项目源码、安卓项目源码、ios项目源码,更有超10000个资源可供选择,如有需要请站内联系。
资源推荐
资源详情
资源评论
收起资源包目录
【WordPress插件】2022年最新版完整功能demo+插件v1.1.zip (28个子文件)
vendors
index.php 6KB
assets
css
index.html 0B
icons
fonts
lumise.svg 5KB
lumise.eot 4KB
lumise.ttf 4KB
lumise.woff 2KB
index.html 0B
styles.css 2KB
launcher.css 37KB
style.css 2KB
images
spinner-white.png 4KB
spinner.png 4KB
index.html 0B
icon.png 2KB
loading.gif 7KB
js
templates.js 21KB
jquery.min.js 339KB
launcher.uncompressor.js 84KB
vendors.js 21KB
index.html 0B
launcher.js 85KB
script.js 11KB
view
design.php 6KB
product.php 3KB
designs.php 12KB
launcher.php 2KB
includes
actions.php 7KB
launcher.php 16KB
共 28 条
- 1
资源评论
Lee达森
- 粉丝: 1518
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功