function rcl_publication_editor()
{
    global $editpost, $rcl_options, $formfields, $formData;
    //print_r($formData);
    if ($formData->type_editor) {
        rcl_wp_editor();
    } else {
        $content = is_object($editpost) && $editpost->post_content ? $editpost->post_content : '';
        rcl_sortable_scripts();
        echo '<script>
		jQuery(function(){
			jQuery(".rcl-editor-content").sortable({ axis: "y", containment: "parent", handle: ".move-box", cursor: "move" });
		});
		</script>';
        if ($content) {
            $rcl_box = strpos($content, '[rcl-box');
            if ($rcl_box === false) {
                rcl_wp_editor(array('type_editor' => 1, 'wp_editor' => 3), $content);
                return;
            }
        }
        $panel = '';
        $buttons = array();
        if (isset($rcl_options['rcl_editor_buttons'])) {
            $icons = array('text' => 'fa-align-left', 'header' => 'fa-header', 'image' => 'fa-picture-o', 'html' => 'fa-code');
            $names = array('text' => __('Text Box', 'wp-recall'), 'header' => __('Subtitle', 'wp-recall'), 'image' => __('Image', 'wp-recall'), 'html' => __('HTML- code', 'wp-recall'));
            foreach ($rcl_options['rcl_editor_buttons'] as $type) {
                $buttons[] = '<li><a href="#" title="' . $names[$type] . '" class="get-' . $type . '-box" onclick="return rcl_add_editor_box(this,\'' . $type . '\');"><i class="fa ' . $icons[$type] . '"></i></a></li>';
            }
            if ($buttons) {
                $panel = '<div class="rcl-tools-panel">
						<ul>' . implode('', $buttons) . '</ul>
						</div>';
            }
        }
        echo '
		<div class="rcl-public-editor">

			<div class="rcl-editor-content">
				' . rcl_get_editor_content($content) . '
			</div>
			' . $panel . '
		</div>';
    }
}
Пример #2
0
function rcl_preview_post()
{
    global $user_ID, $rcl_options;
    $log = array();
    $user_can = $rcl_options['user_public_access_recall'];
    if (!$user_can && !$user_ID) {
        $email_new_user = sanitize_email($_POST['email-user']);
        $name_new_user = $_POST['name-user'];
        if (!$email_new_user) {
            $log['error'] = 'Введите свой e-mail!';
        }
        if (!$name_new_user) {
            $log['error'] = 'Введите свое имя!';
        }
        $res_email = email_exists($email_new_user);
        $res_login = username_exists($email_new_user);
        $correctemail = is_email($email_new_user);
        $valid = validate_username($email_new_user);
        if ($res_login || $res_email || !$correctemail || !$valid) {
            if (!$valid || !$correctemail) {
                $log['error'] .= 'Вы ввели некорректный email!';
            }
            if ($res_login || $res_email) {
                $log['error'] .= 'Этот email уже используется!<br>' . 'Если это ваш email, то авторизуйтесь и опубликуйте свою запись';
            }
        }
    }
    //if(!$_POST['post_title']) $log['error'] = 'Заполните заголовок публикации';
    if (!$_POST['post_content']) {
        $log['error'] = 'Добавьте содержимое публикации!';
    }
    if ($log['error']) {
        echo json_encode($log);
        exit;
    }
    $post_content = '';
    if (is_array($_POST['post_content'])) {
        foreach ($_POST['post_content'] as $contents) {
            foreach ($contents as $type => $content) {
                if ($type == 'text') {
                    $content = strip_tags($content);
                }
                if ($type == 'header') {
                    $content = sanitize_text_field($content);
                }
                if ($type == 'html') {
                    $content = str_replace('\'', '"', $content);
                }
                $post_content .= "[rcl-box type='{$type}' content='{$content}']";
            }
        }
    } else {
        //$content = str_replace('\\"','',$_POST['post_content']);
        //$post_content = "[rcl-box type='html' content='$content']";
        $post_content = stripslashes_deep($_POST['post_content']);
    }
    $post_content = rcl_get_editor_content($post_content, 'preview');
    $preview = '<div id="rcl-preview">';
    $preview .= '<h2>Предварительный просмотр</h2>
		<h3 class="title-post">' . $_POST['post_title'] . '</h3>
		' . $post_content;
    $preview .= '<div class="rcl-notice-preview">
			<p>Если все в порядке - публикуйте! Если нет, то вы можете вернуться в редактор.</p>
			<div class="rcl-preview-buttons">
				<input type="button" class="recall-button" onclick="rcl_preview_close(this);" value="Редактировать">
				<input type="submit" class="recall-button" id="edit-post-rcl" value="' . __('To publish', 'wp-recall') . '">
			</div>
		</div>';
    $preview .= '</div>';
    $log['content'] = $preview;
    echo json_encode($log);
    exit;
}