PluginProbe
Comments Extra Fields For Post,Pages and CPT / 2.2
Comments Extra Fields For Post,Pages and CPT v2.2
trunk 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 2.2 2.3 4.0 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 5.0 5.1 5.2
wp-comment-fields / classes / inputs / input.checkbox.php

input.checkbox.php in Comments Extra Fields For Post,Pages and CPT 2.2, at classes/inputs/input.checkbox.php

124 lines 3.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 * Followig class handling checkbox input control and their
4 * dependencies. Do not make changes in code
5 * Create on: 9 November, 2013
6 */
7
8 class NM_Checkbox extends NM_Inputs_wpcomment{
9
10 /*
11 * input control settings
12 */
13 var $title, $desc, $settings;
14
15 /*
16 * this var is pouplated with current plugin meta
17 */
18 var $plugin_meta;
19
20 function __construct(){
21
22 $this -> plugin_meta = get_plugin_meta_wpcomment();
23
24 $this -> title = __ ( 'Checkbox Input', 'nm-wpcomments' );
25 $this -> desc = __ ( 'regular checkbox input', 'nm-wpcomments' );
26 $this -> settings = self::get_settings();
27
28 }
29
30
31
32
33 private function get_settings(){
34
35 return array (
36 'title' => array (
37 'type' => 'text',
38 'title' => __ ( 'Title', 'nm-wpcomments' ),
39 'desc' => __ ( 'It will be shown as field label', 'nm-wpcomments' )
40 ),
41 'data_name' => array (
42 'type' => 'text',
43 'title' => __ ( 'Data name', 'nm-wpcomments' ),
44 'desc' => __ ( 'REQUIRED: The identification name of this field, that you can insert into body email configuration. Note:Use only lowercase characters and underscores.', 'nm-wpcomments' )
45 ),
46 'description' => array (
47 'type' => 'text',
48 'title' => __ ( 'Description', 'nm-wpcomments' ),
49 'desc' => __ ( 'Small description, it will be diplay near name title.', 'nm-wpcomments' )
50 ),
51 'error_message' => array (
52 'type' => 'text',
53 'title' => __ ( 'Error message', 'nm-wpcomments' ),
54 'desc' => __ ( 'Insert the error message for validation.', 'nm-wpcomments' )
55 ),
56 'options' => array (
57 'type' => 'textarea',
58 'title' => __ ( 'Add options', 'nm-wpcomments' ),
59 'desc' => __ ( 'Type each option per line', 'nm-wpcomments' )
60 ),
61
62 'required' => array (
63 'type' => 'checkbox',
64 'title' => __ ( 'Required', 'nm-wpcomments' ),
65 'desc' => __ ( 'Select this if it must be required.', 'nm-wpcomments' )
66 ),
67 'class' => array (
68 'type' => 'text',
69 'title' => __ ( 'Class', 'nm-wpcomments' ),
70 'desc' => __ ( 'Insert an additional class(es) (separateb by comma) for more personalization.', 'nm-wpcomments' )
71 ),
72 'checked' => array (
73 'type' => 'textarea',
74 'title' => __ ( 'Checked option(s)', 'nm-wpcomments' ),
75 'desc' => __ ( 'Type option(s) name (given above) if you want already checked.', 'nm-wpcomments' )
76 ),
77
78 'width' => array (
79 'type' => 'select',
80 'default' => '6',
81 'options' => array('12'=>'12 Columns','6'=>'6 Columns', '4'=>'4 Columns', '3'=>'3 Columns',),
82 'title' => __ ( 'Width', 'nm-wpcomments' ),
83 'desc' => __ ( 'Select column for this field (12 Columns Grid)', 'nm-wpcomments' )
84 ),
85
86 );
87 }
88
89
90 /*
91 * @params: $options
92 */
93 function render_input($args, $options = "", $default = '') {
94
95 $_html = '';
96 foreach ( $options as $opt ) {
97
98 if ($default) {
99 if ( is_array($default) && in_array ( $opt, $default ))
100 $checked = 'checked="checked"';
101 else
102 $checked = '';
103 }
104
105 $output = stripslashes ( trim ( $opt ) );
106 $_html .= '<label for="f-meta-' . $opt . '"> <input type="checkbox" ';
107
108 foreach ($args as $attr => $value){
109
110 if ($attr == 'name') {
111 $value .= '[]';
112 }
113 $_html .= $attr.'="'.stripslashes( $value ).'"';
114 }
115
116 $_html .= ' value="'.$opt.'" '.$checked.'>';
117 $_html .= $output;
118
119 echo '</label>';
120 }
121
122 echo $_html;
123 }
124 }