PluginProbe
Disable Comments & Delete All Comments / 1.3.0
Disable Comments & Delete All Comments v1.3.0
1.3.3 1.3.2 trunk 1.0.0 1.0.4 1.0.5 1.0.8 1.0.9 1.1.1 1.1.3 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 1.3.0 1.3.1
comments-plus / libs / factory / forms / controls / wp-editor.php

wp-editor.php in Disable Comments & Delete All Comments 1.3.0, at libs/factory/forms/controls/wp-editor.php

98 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * WP Editor Control
5 *
6 * Main options:
7 * name => a name of the control
8 * value => a value to show in the control
9 * default => a default value of the control if the "value" option is not specified
10 * tinymce => an array of options for tinymce
11 * @link http://codex.wordpress.org/Function_Reference/wp_editor
12 *
13 * @author Alex Kovalev <alex.kovalevv@gmail.com>
14 * @copyright (c) 2018, Webcraftic Ltd
15 *
16 * @package factory-forms
17 * @since 1.0.0
18 */
19
20 // Exit if accessed directly
21 if( !defined('ABSPATH') ) {
22 exit;
23 }
24
25 if( !class_exists('Wbcr_FactoryForms480_WpEditorControl') ) {
26
27 class Wbcr_FactoryForms480_WpEditorControl extends Wbcr_FactoryForms480_Control {
28
29 public $type = 'wp-editor';
30
31 /**
32 * Preparing html attributes and options for tinymce.
33 *
34 * @since 1.0.0
35 * @return void
36 */
37 protected function beforeHtml()
38 {
39
40 if( empty($this->options['tinymce']) ) {
41 $this->options['tinymce'] = array();
42 }
43
44 if( !isset($this->options['tinymce']['content_css']) ) {
45 $this->options['tinymce']['content_css'] = FACTORY_FORMS_480_URL . '/assets/css/editor.css';
46 }
47 }
48
49 /**
50 * Shows the html markup of the control.
51 *
52 * @since 1.0.0
53 * @return void
54 */
55 public function html()
56 {
57 $name_on_form = $this->getNameOnForm();
58
59 $value = $this->getValue();
60
61 ?>
62 <div class='factory-form-wp-editor'>
63 <?php wp_editor($value, $name_on_form, array(
64 'textarea_name' => $name_on_form,
65 'wpautop' => false,
66 'teeny' => true,
67 'tinymce' => $this->getOption('tinymce', array()),
68 'editor_height' => 213, // In pixels, takes precedence and has no default value
69 'textarea_rows' => 10, // Has no visible effect if editor_height is set, default is 20
70 )); ?>
71 </div>
72 <?php
73 }
74
75 /**
76 * Returns a submit value of the control by a given name.
77 *
78 * @since 1.0.0
79 * @return mixed
80 */
81 public function getSubmitValue($name, $subName)
82 {
83 $name_on_form = $this->getNameOnForm($name);
84
85 $value = isset($_POST[$name_on_form])
86 ? $_POST[$name_on_form]
87 : null;
88
89 if( is_array($value) ) {
90 $value = implode(',', $value);
91 }
92
93 return wp_kses_post($value);
94 }
95 }
96 }
97
98