Skip to content
This repository has been archived by the owner on Mar 5, 2022. It is now read-only.

统一代码格式,修正一些错误...... #6

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ SM.MS WordPress Plugin

# 插件简介

SM.MS 图床插件基于官方 API2.0,部分功能参考自 https://github.com/qcgzxw/SMMS-UPLOADER
SM.MS 图床插件基于官方 [API2.0](https://doc.sm.ms/),部分功能参考自 [https://github.com/qcgzxw/SMMS-UPLOADER](https://github.com/qcgzxw/SMMS-UPLOADER)

# 插件预览

Expand Down
82 changes: 46 additions & 36 deletions class.smms.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,74 +4,85 @@
*/
class Smms
{

function __construct(){

add_action('wp_enqueue_scripts', array( $this, 'add_scripts_css') );;
$Uploader = get_option('SMMS_DATA');
if($Uploader['Content']){
add_action('admin_head', array( $this, 'admin_scripts_css') );
add_action('media_buttons', array( $this, 'admin_upload_img') );
public function __construct()
{
add_action('wp_enqueue_scripts', array( $this, 'add_scripts_css'));
$Uploader = get_option('SMMS_DATA');
if ($Uploader['Content']) {
add_action('admin_head', array( $this, 'admin_scripts_css'));
add_action('media_buttons', array( $this, 'admin_upload_img'));
}
if($Uploader['Comment']){
add_filter('comment_form', array( $this, 'comment_upload_img') );
if ($Uploader['Comment']) {
add_filter('comment_form', array( $this, 'comment_upload_img'));
}

add_filter( 'plugin_action_links', array( $this, 'SMMS_UPLOADER_LINKS'), 10, 4 );
add_filter('plugin_action_links', array( $this, 'SMMS_UPLOADER_LINKS'), 10, 4);
//默认数据
add_action('admin_init', array( $this, 'SMMS_options_default_options'));

}

function add_scripts_css() {
public function add_scripts_css()
{
wp_deregister_script('jquery');
wp_register_script('jquery', SMMS_URL . 'js/jquery.min.js', SMMS_VERSION);
wp_enqueue_script( 'jquery' );
wp_enqueue_script('jquery');

if(is_single() || is_page())wp_enqueue_script( 'smms-comment-js', SMMS_URL . 'js/comment.js', array(), SMMS_VERSION, true);
if(is_single() || is_page() || is_home())wp_enqueue_style( 'smms-widget-css', SMMS_URL . 'css/smms.diy.css', array(),SMMS_VERSION);
if (is_single() || is_page()) {
wp_enqueue_script('smms-comment-js', SMMS_URL . 'js/comment.js', array(), SMMS_VERSION, true);
}
if (is_single() || is_page() || is_home()) {
wp_enqueue_style('smms-widget-css', SMMS_URL . 'css/smms.diy.css', array(), SMMS_VERSION);
}
}

function admin_scripts_css() {
wp_enqueue_script( 'admin-content-js', SMMS_URL . 'js/content.js', array(), SMMS_VERSION, true);
wp_enqueue_script( 'modal-js', SMMS_URL . 'js/modal.js', array(), SMMS_VERSION, true);
wp_enqueue_style( 'admin-content-css', SMMS_URL . 'css/input.min.css', array(),SMMS_VERSION);
wp_enqueue_style( 'modal-css', SMMS_URL . 'css/modal.css', array(),SMMS_VERSION);
public function admin_scripts_css()
{
wp_enqueue_script('admin-content-js', SMMS_URL . 'js/content.js', array(), SMMS_VERSION, true);
wp_enqueue_script('modal-js', SMMS_URL . 'js/modal.js', array(), SMMS_VERSION, true);
wp_enqueue_style('admin-content-css', SMMS_URL . 'css/input.min.css', array(), SMMS_VERSION);
wp_enqueue_style('modal-css', SMMS_URL . 'css/modal.css', array(), SMMS_VERSION);
}

function SMMS_UPLOADER_LINKS( $actions, $plugin_file , $plugin_data){
static $plugin;
global $language;
if (!isset($plugin))
public function SMMS_UPLOADER_LINKS($actions, $plugin_file, $plugin_data)
{
static $plugin;
global $language;
if (!isset($plugin)) {
$plugin = plugin_basename(__FILE__);
}
//if ($plugin == $plugin_file) {
$settings = array('settings' => '<a href="admin.php?page=smms-image">'.$language[4].'</a>');
$actions = array_merge($settings, $actions);
$settings = array('settings' => '<a href="admin.php?page=smms-image">'.$language[4].'</a>');
$actions = array_merge($settings, $actions);
//}
return $actions;
}

function SMMS_options_default_options(){
public function SMMS_options_default_options()
{
$Uploader = get_option('SMMS_DATA');//获取选项
if( $Uploader == '' ){
if ($Uploader == '') {
$Uploader = array(//设置默认数据
'Content' => '',
'Comment' => '',
'Authorization' => ''
'Authorization' => '',
'Nolocal' => ''
);
update_option('SMMS_DATA', $Uploader);//更新选项
update_option('SMMS_DATA', $Uploader);//更新选项
}
}

//设置菜单

function comment_upload_img() {
public function comment_upload_img()
{
global $language;
echo '<div class="zz-add-img"><input id="zz-img-file" type="file" accept="image/*" multiple="multiple"><div id="zz-img-add">'.$language[31].'</div><div id="zz-img-show"></div></div>';
}
function admin_upload_img() {

public function admin_upload_img()
{
global $language;
echo '<a class="button" id="toggleModal" title="'.$language[0].'">'.$language[0].'</a><a href="javascript:;" class="file">'.$language[30].'<input id="admin-img-file" type="file" accept="image/*" multiple="multiple"></a><div class="modal">
echo '<a class="button" id="toggleModal" title="'.$language[0].'">'.$language[0].'</a><a href="javascript:;" class="file">'.$language[30].'<input id="admin-img-file" type="file" accept="image/*" multiple="multiple"></a><div class="modal">
<div class="modal-header">
<p class="close">×</p>
</div>
Expand All @@ -87,5 +98,4 @@ function admin_upload_img() {
</div>
</div><div class="mask"></div>';
}

}
}
150 changes: 75 additions & 75 deletions css/modal.css
Original file line number Diff line number Diff line change
@@ -1,123 +1,123 @@
.toggleModal{
padding: 10px 20px;
color: white;
background: #409EFF;
border:none;
box-shadow: 2px 3px 20px rgba(0,0,0,0.2);
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%,-50%);
padding: 10px 20px;
color: white;
background: #409EFF;
border:none;
box-shadow: 2px 3px 20px rgba(0,0,0,0.2);
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%,-50%);
}

.modal{
position: fixed;
top: 50%;
left: 50%;
width: 800px;
transform: translate(-50%,-50%);
border-radius: 5px;
background: #fff;
box-shadow: 2px 3px 20px rgba(0,0,0,0.2);
z-index: 120;
display: none;
position: fixed;
top: 50%;
left: 50%;
width: 800px;
transform: translate(-50%,-50%);
border-radius: 5px;
background: #fff;
box-shadow: 2px 3px 20px rgba(0,0,0,0.2);
z-index: 120;
display: none;
}
.modal .modal-header{
height: 40px;
border-bottom: 1px solid #f5f5f5;
padding: 0 15px;
height: 40px;
border-bottom: 1px solid #f5f5f5;
padding: 0 15px;
}
.modal .modal-header p {
line-height: 50px;
display: inline-block;
line-height: 50px;
display: inline-block;
}
.modal ul{
display: flex;
flex-flow: wrap;
justify-content: center;
}
.modal ul li{
margin: 8px;
width: 150px;
height: 150px;
text-align: center;
flex: auto;
display: flex;
align-items: center;
justify-content: center;
margin: 8px;
width: 150px;
height: 150px;
text-align: center;
flex: auto;
display: flex;
align-items: center;
justify-content: center;
}
.modal ul li button{
display:none;
display:none;
}
.modal .modal-image{
padding: 5px;
cursor:pointer;
width: 100%;
box-shadow: #dee1e8 0px 0px 6px 0px;
height: 150px;
transition: 0.3s all ease;
padding: 5px;
cursor:pointer;
width: 100%;
box-shadow: #dee1e8 0px 0px 6px 0px;
height: 150px;
transition: 0.3s all ease;
}
.modal li:hover .modal-image{
width: 88%;
height: 88%;
width: 88%;
height: 88%;
}
.modal .modal-header .title{
font-size: 18px;
color: #333;
font-size: 18px;
color: #333;
}
.modal .modal-header .close{
float: right;
font-size: 26px;
margin-top: -2px;
color: #9C9FA4;
cursor: default;
float: right;
font-size: 26px;
margin-top: -2px;
color: #9C9FA4;
cursor: default;
}
.modal .modal-content{
padding: 20px;
min-height: 100px;
max-height: 500px;
overflow-x: hidden;
overflow-y: scroll;
line-height: 30px;
padding: 20px;
min-height: 100px;
max-height: 500px;
overflow-x: hidden;
overflow-y: scroll;
line-height: 30px;
}
.img-insert{
background: #0da000;
background: #0da000;
}
.img-insert:hover{
background:#096900;
background:#096900;
}
.modal-content .btn,.modal-footer .btn{
padding: 0 20px;
height: 36px;
line-height: 36px;
color: white;
border: none;
cursor: pointer;
border-radius: 3px;
transition: 0.3s all ease;
padding: 0 20px;
height: 36px;
line-height: 36px;
color: white;
border: none;
cursor: pointer;
border-radius: 3px;
transition: 0.3s all ease;
}
.modal-footer .load{
background: #409EFF;
background: #409EFF;
}
.modal-footer .load:hover{
background: #1f70c3;
background: #1f70c3;
}
.modal-footer .close{
background: #6d6d6d;
background: #6d6d6d;
}
.modal-footer .close:hover{
background: #4a4a4a;
background: #4a4a4a;
}

.modal .modal-footer{
border-top: 1px solid #f5f5f5;
padding: 15px;
text-align: right;
border-top: 1px solid #f5f5f5;
padding: 15px;
text-align: right;

}
.container::after{
content:"";
display: block;
clear: both;
content:"";
display: block;
clear: both;
}
Loading