<?php
class AWSSOFT_MagicEdge_Backend{
function __construct() {
add_action('admin_menu', array($this, 'addMenu'));
add_action('init', array($this, 'initHook'));
if (isset($_GET['page']) && $_GET['page'] == "awssoft-magic-edge") {
add_action('admin_init', array($this, 'enqueueJSCSS'));
}
add_action('wp_ajax_save_image', array($this, 'ajaxSaveImage'));
}
function ajaxSaveImage() {
$d = $_POST['data'];
$extension = $d["type"]=="png" ? "png" : "jpg";
$mime = $d["type"]=="png" ? "image/png" : "image/jpeg";
$uploads = wp_upload_dir();
$parts = pathinfo($d["orgImageFullPath"]);
$newFilename = $parts['filename'] . "-transparent." . $extension;
for ($i = 1; $i < 100; $i++) {
if (!is_file($uploads["path"] . "/" . $newFilename)) {
break;
}
$newFilename = $parts['filename'] . "-transparent-" . $i . "." . $extension;;
}
// full path
$filename = $uploads["path"] . "/" . $newFilename;
//PNG/JPG content
list(, $data) = explode(',', $d["imageBase64"]);
$iData = base64_decode($data);
if (!file_put_contents($filename, $iData)) {
$this->outputError("Error 2422 - Cannot save new image file");
die();
}
$attachment = array(
'guid' => $uploads["path"] . '/' . basename($filename),
'post_mime_type' => $mime,
'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)),
'post_content' => '',
'post_status' => 'inherit'
);
$attach_id = wp_insert_attachment($attachment, $filename);
if (!$attach_id) {
$this->outputError("Error 2423 - Failed to save record into database");
die();
}
require_once( ABSPATH . 'wp-admin/includes/image.php' );
$attach_data = wp_generate_attachment_metadata($attach_id, $filename);
wp_update_attachment_metadata($attach_id, $attach_data);
$this->outputSuccessMessage("Image has been saved. Image name: " . $newFilename);
die();
}
function initHook() {
}
function enqueueJSCSS() {
wp_enqueue_style('farbtastic');
wp_enqueue_script('farbtastic');
wp_enqueue_style('me-css', plugins_url('/css/magic-edge.css', __FILE__));
wp_enqueue_style('wp-me-css', plugins_url('/css/wp-me.css', __FILE__));
wp_enqueue_script('me-pica', plugins_url('/js/pica.min.js', __FILE__));
wp_enqueue_script('me-js', plugins_url('/js/magic-edge.js', __FILE__), array('jquery'), '', true);
wp_enqueue_script('filters-js', plugins_url('/js/filters.js', __FILE__), array('me-js'), '', true);
wp_enqueue_script('me-includes-js', plugins_url('/js/magic-edge-inc.js', __FILE__), array('me-js'), '', true);
wp_enqueue_script('wp-me-js', plugins_url('/js/wp-me.js', __FILE__), array('jquery', 'me-js'), '', true);
wp_enqueue_script('media-upload');
wp_enqueue_script('thickbox');
wp_enqueue_script('my-upload');
wp_enqueue_style('thickbox');
$BG_REM_GLOBAL = array( 'pluginUrl' => plugins_url( ) );
wp_localize_script( 'wp-me-js', 'BG_REM_GLOBAL', $BG_REM_GLOBAL );
}
function addMenu() {
add_media_page('Magic Edge', 'Magic Edge', 'upload_files', 'awssoft-magic-edge', array($this, 'addPageContentHandler'));
}
function addPageContentHandler() {
echo '<div class="wrap">';
echo '<h3 class="BR-magicEdgeTitle">Magic Edge</h3>';
echo '<div style="float:right;position: absolute;top: 10px;right: 10px;" class="BR-rightLinksHolder"><a href="http://www.awssoft.com/magic-edge/" target="_blank">Homepage & Support</a></div>';
echo '<div id="BR-rootHolder" class="BR-rootHolder"></div>';
echo '<input id="upload_image" type="text" size="36" name="upload_image" value="" style="display:none" />';
echo '</div>';
}
public function outputError($msq) {
$retObj = (object) array();
$retObj->error = true;
$retObj->errorMessage = $msq;
echo json_encode($retObj);
}
public function outputSuccessMessage($msq) {
$retObj = (object) array();
$retObj->success = true;
$retObj->message = $msq;
echo json_encode($retObj);
}
}
?>
没有合适的资源?快使用搜索试试~ 我知道了~
【WordPress插件】2022年最新版完整功能demo+插件v1.3.0.zip
共51个文件
png:33个
js:7个
cur:4个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 191 浏览量
2022-03-30
18:56:45
上传
评论
收藏 229KB ZIP 举报
温馨提示
"【WordPress插件】2022年最新版完整功能demo+插件v1.3.0 Magic Edge - Image Background Remover for WP | Media 魔术边缘 - WP的图像背景卸妆|媒体" ---------- 泰森云每天更新发布最新WordPress主题、HTML主题、WordPress插件、shopify主题、opencart主题、PHP项目源码、安卓项目源码、ios项目源码,更有超10000个资源可供选择,如有需要请站内联系。
资源推荐
资源详情
资源评论
收起资源包目录
【WordPress插件】2022年最新版完整功能demo+插件v1.3.0.zip (51个子文件)
magic-edge-wp
css
magic-edge.css 13KB
wp-me.css 1KB
images
greenDot20.png 3KB
greenDot10.png 3KB
eraser.png 5KB
foregroundLine.png 4KB
marker.png 360B
color.png 3KB
magicWandCursor.png 6KB
previewEdge.png 5KB
mask.png 2KB
outputSettings.png 5KB
removeDrawing.png 7KB
zoom-out.png 4KB
resizeHorizontalOposite.png 4KB
crop.png 3KB
magicWand.png 16KB
wheel.png 11KB
redDot20.png 3KB
settings.png 5KB
greenDot10.cur 502B
transparentBackground.png 3KB
handIcon.png 5KB
presetSettings.png 5KB
previewEdgeMask.png 6KB
redDot10.cur 502B
handIcon.cur 4KB
backgroundLine.png 4KB
undo.png 5KB
previewTransparent.png 7KB
hand.png 15KB
resizeHorizontal.png 4KB
zoom-in.png 4KB
magicEdge.png 6KB
redo.png 5KB
magicWandCursor.cur 8KB
redDot10.png 3KB
cbarrow.png 4KB
farbtastic.css 636B
magic-edge.php 459B
images
spinner.gif 4KB
transparentBackground.png 3KB
MagicEdgeFrontend.php 2KB
js
wp-me.js 7KB
farbtastic.js 8KB
wp-me-fe.js 8KB
pica.min.js 20KB
magic-edge-inc.js 12KB
magic-edge.js 139KB
filters.js 21KB
MagicEdgeBackend.php 5KB
共 51 条
- 1
资源评论
Lee达森
- 粉丝: 969
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Test Report TC-24-37 MQ012K0VPY 25.764-28.476MHz.SchDoc
- 服务器虚拟化工具VMware vSphere Client for windows(VMware-viclient-all-6)
- 文件批量改名工具,用于替换/更改字符,更改文件后缀等
- Home Assistant 接入小米空气净化器
- ngx-http-proxy-connect-module-master.tar.gz
- maven的setting配置文件
- LLC谐振变换器的闭环仿真设计
- tomcat安装及配置教程分享
- windows cpu和显卡温度监控
- 小启书桌-桌面快速启动/桌面文件整理美化工具
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功