茄子在线看片免费人成视频,午夜福利精品a在线观看,国产高清自产拍在线观看,久久综合久久狠狠综合

    <s id="ddbnn"></s>
  • <sub id="ddbnn"><ol id="ddbnn"></ol></sub>

  • <legend id="ddbnn"></legend><s id="ddbnn"></s>

    分享wordpress添加游客投稿頁面功能
    來源:易賢網(wǎng) 閱讀:1380 次 日期:2016-06-14 15:14:57
    溫馨提示:易賢網(wǎng)小編為您整理了“分享wordpress添加游客投稿頁面功能”,方便廣大網(wǎng)友查閱!

    相信有不少站長朋友都或多或少接觸過wordpress吧,其中很多人都需要一個投稿頁面,當然其中好處不言而喻了。網(wǎng)上有的投稿插件是英文的,有的類似于留言本,有的會顯示亂碼,而今天筆者就教大家自己做一個插件來實現(xiàn)投稿功能。

    首先新建submit_posts_ajax.php,將以下內(nèi)容復制進去:

    <?php

    function submit_posts_ajax(){

    if($_post['submit_posts_ajax']=='yinheli'){

    $title=strip_tags(trim($_post['post_title']));

    $name=trim($_post['your_name']);

    $mail=trim($_post['your_email']);

    $site=trim($_post['your_site']);

    $content=stripslashes(trim($_post['post_content']));

    $tags=strip_tags(trim($_post['post_tags']));

    global $wpdb;

    $db=select post_title from $wpdb->posts where post_title = '$title' limit 1;

    if ($wpdb->get_var($db)){

    echo '<div class=ps_errormsg>發(fā)現(xiàn)重復文章.你已經(jīng)發(fā)表過了.或者存在該文章</div>';

    die();

    }

    if(!empty($site)){

    if(substr($site, 0, 7) != 'http://') $site= 'http://'.$site;

    $author='<a href='.$site.' title='.$name.'>'.$name.'</a>';

    }else{

    $author=$name;

    }

    $info='<div class=post_submit_info>感謝: '.$author.' 的供稿.</div>'.nn;

    if(isset($_post['post_submit'])){

    //錯誤判斷

    if($title==''){

    echo '<div class=ps_errormsg>錯誤:沒有填寫標題!</div>';

    die();

    }

    elseif($mail==''){

    echo '<div class=ps_errormsg>錯誤:沒有填寫郵箱地址.</div>';

    die();

    }

    elseif($content==''){

    echo '<div class=ps_errormsg>錯誤:還沒有填寫內(nèi)容!!!</div>';

    die();

    }else{

    //提交數(shù)據(jù)

    $content=$info.$content;

    $submitdata=array(

    'post_title' =>$title,

    'post_content' =>$content,

    'tags_input' =>$tags,

    'post_status' => 'pending'

    );

    $post_id = wp_insert_post($submitdata,$wp_error = false);

    $subject='您給[ '.get_option('blogname').' ]寫了篇文章 標題是: '.$title;

    $message='非常感謝您的供稿.您的稿件已經(jīng)提交.等待管理員的審核. 以下是您提交的內(nèi)容:<hr>'.stripslashes(trim($_post['post_content']));

    yinheli_sendmail_ps($mail,$subject,$message);

    echo '<div class=ps_msg>非常感謝您的供稿.您的稿件已經(jīng)提交.等待管理員的審核.請耐心等待.</div>';

    @header('content-type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));

    die();

    }

    }

    if(isset($_post['post_review'])){

    if(''==$content){

    echo '還沒有填寫內(nèi)容';

    die();

    }

    if(''==$tags) $tags='您還沒有填寫 標簽 (tags)';

    echo '<div class=ps_reviewmsg>

    <h2>'.$title.'</h2>

    <div class=ps_reviewcontent>

    '.$info.$content.'

    <p class=ps_reviewtags>標簽:'.$tags.'</p>

    </div>

    </div>';

    die();

    }

    die();

    }

    }

    function yinheli_sendmail_ps($to,$subject,$message){

    $blogname = get_option('blogname');

    $charset = get_option('blog_charset');

    $ps_sendmail_headers = from: $blogname n ;

    $ps_sendmail_headers .= mime-version: 1.0n;

    $ps_sendmail_headers .= content-type: text/html;charset=$charsetn;

    return @wp_mail($to, $subject, $message, $ps_sendmail_headers);

    }

    function submit_posts_load_js(){

    echo n.'<script type=text/javascript src=' . get_bloginfo('wpurl') . '/wp-content/plugins/submit_posts/submit_posts.js></script>'.n;

    }

    add_action('init', 'submit_posts_ajax');

    require_once('submit_posts.php');

    function submit_posts_display(){

    submit_posts_load_js();

    $submit_posts_html=submit_posts_html();

    return $submit_posts_html;

    }

    add_shortcode('submit_posts','submit_posts_display');

    ?>

    接下來新建submit_posts.php,同樣將以下內(nèi)容復制進去:

    <script type=text/javascript>

    <!--

    //-->

    </script><?php

    function submit_posts_html(){

    ob_end_clean();

    ob_start();

    ?>

    <div id=ps_msg>歡迎給我供稿</div>

    <form id=post_submit_form name=post_submit_form method=post action=>

    <div class=row>

    <input type=hidden name=submit_posts_ajax id=submit_posts_ajax value=yinheli/>

    <label><input type=text name=post_title id=post_title tabindex=1 value=<?php echo strip_tags($_post['post_title']);?>/> 投稿標題(必填)</label>

    </div>

    <div class=row>

    <label><input type=text name=your_name id=your_name tabindex=2 value=<?php echo $_post['your_name'];?> /> 您的名字或昵稱</label>

    </div>

    <div class=row>

    <label><input type=text name=your_email id=your_email tabindex=3 value=<?php echo $_post['your_email'];?> /> 您的郵箱(必填)</label>

    </div>

    <div class=row>

    <label><input type=text name=your_site id=your_site tabindex=4 value=<?php echo $_post['your_site'];?> /> 您的網(wǎng)站</label>

    </div>

    <div class=row>

    <textarea name=post_content cols=50 rows=15 id=post_content tabindex=5><?php echo stripslashes($_post['post_content']);?></textarea>

    </div>

    <div class=row>

    <label><input type=text name=post_tags id=post_tags tabindex=6 value=<?php echo strip_tags($_post['post_tags']);?> /> 標簽(tags)[每個標簽用半角的逗號分開]</label>

    </div>

    <div id=submit_post>

    <input type=submit name=post_review id=post_review value=預覽 tabindex=7 />

    <input type=submit name=post_submit id=post_submit value=提交 tabindex=8 />

    </div>

    <div style=clear:both></div>

    </form>

    <?php

    $html=ob_get_contents();

    ob_end_clean();

    return $html;

    }

    ?>

    最后再新建submit_posts.js,將以下內(nèi)容復制進去:

    /*

    author: 89948

    update: 2009/04/11

    author uri: 

    */

    (function(){

    if(!window.yhljsps) window['yhljsps']={};

    function iscompatible(other) {

    if( other===false

    || !array.prototype.push

    || !object.hasownproperty

    || !document.createelement

    || !document.getelementsbytagname

    ) {

    alert('tr- if you see this message iscompatible is failing incorrectly.');

    return false;

    }

    return true;

    }

    function $(id){

    return document.getelementbyid(id);

    }

    var xmlhttp;

    function getxmlhttpobject(){

    var xmlhttp = null;

    try {

    xmlhttp = new xmlhttprequest();

    } catch(e) {

    try {

    xmlhttp = new activexobject(msxml2.xmlhttp);

    } catch(e) {

    xmlhttp = new activexobject(microsoft.xmlhttp);

    }

    }

    return xmlhttp;

    }

    function setstyle(element, key, value) {

    element.style[key] = value;

    }

    function addevent(node,type,listener){

    if(!iscompatible()) { return false }

    if(node.addeventlistener){

    node.addeventlistener(type,listener,false);

    return true;

    }else if(node.attachevent){

    node['e'+type+listener]=listener;

    node[type+listener]=function(){

    node['e'+type+listener](window.event);

    }

    node.attachevent('on'+type,node[type+listener]);

    return true;

    }

    }

    function insertafter(node, referencenode) {

    if(!(node = $(node))) return false;

    if(!(referencenode = $(referencenode))) return false;

    return referencenode.parentnode.insertbefore(node, referencenode.nextsibling);

    };

    function preventdefault(eventobject) {

    eventobject = eventobject || geteventobject(eventobject);

    if(eventobject.preventdefault) {

    eventobject.preventdefault();

    } else {

    eventobject.returnvalue = false;

    }

    }

    function formtorequeststring(form_obj,val){

    var query_string='';

    var and='&';

    for (i=0;i<form_obj.length ;i++ ){

    e=form_obj[i];

    if (e.name!='' && e.type!='submit'){

    if (e.type=='select-one'){

    element_value=e.options[e.selectedindex].value;

    }else if (e.type=='checkbox' || e.type=='radio'){

    if (e.checked==false){

    break; 

    }element_value=e.value;

    }else{

    element_value=e.value;

    }

    query_string+=and+encodeuricomponent(e.name)+'='+encodeuricomponent(element_value);

    }

    }

    return query_string;

    }

    function setopacity(node,opacity){

    setstyle(node, 'opacity', opacity);

    setstyle(node, 'mozopacity', opacity);

    setstyle(node, 'khtmlopacity', opacity);

    setstyle(node, 'filter', 'alpha(opacity=' + opacity * 100 + ')');

    return;

    }

    function statechangelistener(){

    var r_msg=$('ps_msg');

    var the_form=$('post_submit_form');

    if(xmlhttp.readystate==1){

    r_msg.innerhtml='數(shù)據(jù)載入中,請稍候...';

    setopacity(the_form,0.8);

    $('post_submit').disabled=true;

    window.scrollto(0,r_msg.offsettop+15);

    }else if(xmlhttp.readystate==4 && xmlhttp.status==200){

    r_msg.innerhtml=xmlhttp.responsetext;

    setopacity(the_form,1);

    settimeout(function(){$('post_submit').disabled=false;},1000);

    }else if(xmlhttp.status!=200){

    alert('呃 出錯了 (建議您保存好文章再刷新瀏覽器.) 錯誤信息:'+xmlhttp.statustext);

    }

    }

    function submitactiontype(type){

    var a=formtorequeststring($('post_submit_form'))+'&'+encodeuricomponent($(type).name)+'='+encodeuricomponent($(type).value);

    return a;

    }

    function ps_submit(action){

    xmlhttp = getxmlhttpobject();

    if (xmlhttp == null) {

    alert (oop! browser does not support http request.)

    return;

    }

    var url=window.location.href;

    if(action=='post_submit'){

    var senddata=submitactiontype(action);

    }

    if(action=='post_review'){

    var senddata=submitactiontype(action);

    }

    xmlhttp.onreadystatechange=function(){

    statechangelistener();

    }

    xmlhttp.open(post, url, true);

    xmlhttp.setrequestheader('content-type','application/x-www-form-urlencoded');

    xmlhttp.send(senddata);

    }

    function initps(){

    addevent($('post_submit'),'click',function(w3cevent){

    ps_submit(action='post_submit');

    //alert(action);

    preventdefault(w3cevent);

    });

    addevent($('post_review'),'click',function(w3cevent){

    ps_submit(action='post_review');

    //alert(action);

    preventdefault(w3cevent);

    });

    }

    if (document.addeventlistener) {

    document.addeventlistener(domcontentloaded, initps, false);

    } else if (/msie/i.test(navigator.useragent)) {

    document.write('<script id=__ie_onload_for_post_posts defer src=javascript:void(0)></script>');

    var script = $('__ie_onload_for_post_posts');

    script.onreadystatechange = function() {

    if (this.readystate == 'complete') {

    initps();

    }

    }

    } else if (/webkit/i.test(navigator.useragent)) {

    var _timer = setinterval( function() {

    if (/loaded|complete/.test(document.readystate)) {

    clearinterval(_timer);

    initps();

    }

    }, 10);

    } else {

    window.onload = function(e) {

    initps();

    }

    }

    })();

    把以上三個文件保存在submit_posts文件夾內(nèi),上傳至插件目錄,并進后臺安裝該插件。使用時只需要新建頁面并輸入[submit_posts]即可調(diào)用出。

    更多信息請查看CMS教程
    易賢網(wǎng)手機網(wǎng)站地址:分享wordpress添加游客投稿頁面功能
    由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復僅供參考,敬請考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇剩?/div>
    相關(guān)閱讀CMS教程

    2026國考·省考課程試聽報名

    • 報班類型
    • 姓名
    • 手機號
    • 驗證碼
    關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點 | 投訴建議
    工業(yè)和信息化部備案號:滇ICP備2023014141號-1 云南省教育廳備案號:云教ICP備0901021 滇公網(wǎng)安備53010202001879號 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號
    聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關(guān)注公眾號:hfpxwx
    咨詢QQ:1093837350(9:00—18:00)版權(quán)所有:易賢網(wǎng)