【问题标题】:Can I use Wordpress' editor and media uploader outside of a Wordpress site?我可以在 Wordpress 网站之外使用 Wordpress 的编辑器和媒体上传器吗?
【发布时间】:2012-01-09 21:24:58
【问题描述】:

我目前正在创建一个简单的 CMS,我真的很想在我的网站上使用编辑器,主要是来自 WordPress 的图像上传器。这可能吗?

我知道 WordPress 使用 TinyMCE,并且他们确实提供了图像管理器作为商业插件,如果不可能,我可能会使用它。

【问题讨论】:

    标签: wordpress file-upload upload content-management-system


    【解决方案1】:

    你可以使用wp函数the_editor:

    http://codex.wordpress.org/Function_Reference/the_editor

    如果您在 google 上查找该功能,您会发现一堆描述如何将 wordpress 编辑器插入插件的页面。它们提供了许多不同的方式来做您希望寻找的事情。

    我用过类似的东西:

    <form id="new_post" name="new_post" method="post" action="" enctype="multipart/form-data">
    
    <div><h2>Title</h2>
    
    <input type="text" id="title" value="" tabindex="1" name="title" AUTOCOMPLETE=OFF/>
    
    <div>
    <h2>Description</h2>
    <?php  the_editor('', 'description', 'title', true); ?>
    </div>
    
    <input type="hidden" name="action" value="post" />
    
    <p align="right"><input type="submit" value="Publish" tabindex="6" id="submit" name="submit" /></p>
    
    <?php wp_nonce_field( 'new-post' ); ?>
    
    </form>
    

    然后您必须使用以下内容将其保存到 wordpress db:

    if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] )) {
    
    // Do some minor form validation to make sure there is content
        if (isset ($_POST['title'])) {
            $title =  $_POST['title'];
        } else {
            echo 'Please enter a title';
        }
        if (isset ($_POST['description'])) {
            $description = $_POST['description'];
        } else {
            echo 'Please enter the content';
        }
    
        // Add the content of the form to $post as an array
        $post = array(
            'post_title'    => $title,
            'post_content'  => $description,
        /*  'post_category' => array('cat' => '3'), */ // Usable for custom taxonomies too
            'post_status'   => 'pending',           // Choose: publish, pending, draft, auto-draft, future, etc.
            'post_type' => 'post'  // Use a custom post type if you want to
        );
        $newID = wp_insert_post($post);  // Pass  the value of $post to WordPress the insert function
                                // http://codex.wordpress.org/Function_Reference/wp_insert_post
    
    //  wp_redirect( home_url() );
    } // end IF
    
    // Do the wp_insert_post action to insert it
    do_action('wp_insert_post', 'wp_insert_post'); 
    

    这就是它的基本原理......祝你好运!

    【讨论】:

      【解决方案2】:

      在不知道您的项目细节的情况下,我可以提供此作为起点:

      关于图片上传器,WordPress 在当前版本的 WP (3.3) 中使用了某些版本的免费上传处理程序 Plupload,它将处理图片上传。

      http://www.plupload.com

      如果您正在寻找裁剪、调整大小、缩略图等功能,那么您是对的 - 他们确实有付费文件和图像管理器 (MCImageManager)

      http://www.tinymce.com/enterprise/mcimagemanager.php

      【讨论】:

        猜你喜欢
        • 2015-07-09
        • 2016-10-26
        • 1970-01-01
        • 2012-11-08
        • 2017-06-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多