コード例 #1
0
function rtmedia_description_input($editor = true)
{
    global $rtmedia_media;
    $name = 'description';
    if (isset($rtmedia_media->post_content)) {
        $value = $rtmedia_media->post_content;
    } else {
        $post_details = get_post($rtmedia_media->media_id);
        $value = $post_details->post_content;
    }
    $html = '';
    if ($editor) {
        if (rtmedia_request_action() == 'edit') {
            $html .= wp_editor($value, $name, array('media_buttons' => false, 'textarea_rows' => 2, 'quicktags' => false));
        } else {
            $html .= '<div name="' . $name . '" id="' . $name . '">' . $value . '</div>';
        }
    } else {
        $html .= "<textarea name='" . $name . "' id='" . $name . "' class='rtmedia-desc-textarea'>" . strip_tags($value) . "</textarea>";
    }
    $html .= '';
    return $html;
}
コード例 #2
0
ファイル: rtmedia-functions.php プロジェクト: rtCamp/rtMedia
/**
 * Get text-area when editing media
 *
 * @global      object      $rtmedia_media
 *
 * @param       bool        $editor
 * @param       bool        $echo
 *
 * @return      string
 */
function rtmedia_description_input($editor = true, $echo = false)
{
    global $rtmedia_media;
    $name = 'description';
    if (isset($rtmedia_media->post_content)) {
        $value = $rtmedia_media->post_content;
    } else {
        $post_details = get_post($rtmedia_media->media_id);
        $value = $post_details->post_content;
    }
    $html = '';
    if ($editor) {
        if ('edit' === rtmedia_request_action()) {
            ob_start();
            wp_editor($value, $name, array('media_buttons' => false, 'textarea_rows' => 2, 'quicktags' => false));
            $html .= ob_get_clean();
        } else {
            $html .= '<div name="' . esc_attr($name) . '" id="' . esc_attr($name) . '">' . wp_kses_post($value) . '</div>';
        }
    } else {
        $html .= "<textarea name='" . esc_attr($name) . "' id='" . esc_attr($name) . "' class='rtmedia-desc-textarea'>" . esc_textarea($value) . '</textarea>';
    }
    $html .= '';
    if ($echo) {
        echo $html;
        // @codingStandardsIgnoreLine
    } else {
        return $html;
    }
}