PluginProbe
Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts / 2.1.91
Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts v2.1.91
2.7.6 2.7.5 2.7.4 trunk 1.3 2.0.4 2.0.6 2.1.91 2.2.4 2.2.7 2.2.9 2.3.1 2.3.10 2.4.10 2.4.2 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.6.0 2.6.1 2.7.0 2.7.1 All 27 releases
insert-php / admin / pages / settings.php

settings.php in Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts 2.1.91, at admin/pages/settings.php

249 lines 7.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The file contains a short help info.
4 *
5 * @author Alex Kovalev <alex.kovalevv@gmail.com>
6 * @copyright (c) 2018, OnePress Ltd
7 *s
8 * @package core
9 * @since 1.0.0
10 */
11
12 // Exit if accessed directly
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16
17 /**
18 * Common Settings
19 */
20 class WINP_SettingsPage extends Wbcr_FactoryPages411_AdminPage {
21
22 /**
23 * @param Wbcr_Factory410_Plugin $plugin
24 */
25 public function __construct( Wbcr_Factory410_Plugin $plugin ) {
26 $this->menu_post_type = WINP_SNIPPETS_POST_TYPE;
27
28 /*if( !current_user_can('administrator') ) {
29 $this->capabilitiy = "read_wbcr-scrapes";
30 }*/
31
32 $this->id = "settings";
33 $this->menu_title = __( 'Settings', 'insert-php' );
34
35 parent::__construct( $plugin );
36
37 $this->plugin = $plugin;
38 }
39
40 public function assets( $scripts, $styles ) {
41 $this->scripts->request( 'jquery' );
42
43 $this->scripts->request( array(
44 'control.checkbox',
45 'control.dropdown'
46 ), 'bootstrap' );
47
48 $this->styles->request( array(
49 'bootstrap.core',
50 'bootstrap.form-group',
51 'bootstrap.separator',
52 'control.dropdown',
53 'control.checkbox',
54 ), 'bootstrap' );
55 }
56
57 /**
58 * Returns options for the Basic Settings screen.
59 *
60 * @since 1.0.0
61 * @return array
62 */
63 public function getOptions() {
64
65 $options = array();
66
67 $options[] = array(
68 'type' => 'separator'
69 );
70
71 $options[] = array(
72 'type' => 'checkbox',
73 'way' => 'buttons',
74 'name' => 'activate_by_default',
75 'title' => __( 'Activate by Default', 'insert-php' ),
76 'default' => true,
77 'hint' => __( 'When creating a new snippet or updating an old one, make the code snippets active by default.', 'insert-php' )
78 );
79
80 $options[] = array(
81 'type' => 'checkbox',
82 'way' => 'buttons',
83 'name' => 'complete_uninstall',
84 'title' => __( 'Complete Uninstall', 'insert-php' ),
85 'default' => false,
86 'hint' => __( 'When the plugin is deleted from the Plugins menu, also delete all snippets and plugin settings.', 'insert-php' )
87 );
88
89 $options[] = array(
90 'type' => 'html',
91 'html' => '<h3 style="margin-left:0">Code Editor</h3>'
92 );
93
94 $options[] = array(
95 'type' => 'separator'
96 );
97
98 $options[] = array(
99 'type' => 'dropdown',
100 'name' => 'code_editor_theme',
101 'title' => __( 'Code style', 'insert-php' ),
102 'data' => $this->getAvailableThemes(),
103 'default' => 'default',
104 'hint' => __( 'The optional feature. You can customize the code style in the snippet editor. The "Default" style is applied by default.', 'insert-php' )
105 );
106
107 $options[] = array(
108 'type' => 'checkbox',
109 'way' => 'buttons',
110 'name' => 'code_editor_indent_with_tabs',
111 'title' => __( 'Indent With Tabs', 'insert-php' ),
112 'default' => false,
113 'hint' => __( 'The optional feature. Whether, when indenting, the first N*tabSize spaces should be replaced by N tabs. The default is false.', 'insert-php' )
114 );
115
116 $options[] = array(
117 'type' => 'integer',
118 'way' => 'buttons',
119 'name' => 'code_editor_tab_size',
120 'title' => __( 'Tab Size', 'insert-php' ),
121 'default' => 4,
122 'hint' => __( 'The optional feature. Pressing Tab in the code editor increases left indent to N spaces. N is a number pre-defined by you.', 'insert-php' )
123 );
124
125 $options[] = array(
126 'type' => 'integer',
127 'way' => 'buttons',
128 'name' => 'code_editor_indent_unit',
129 'title' => __( 'Indent Unit', 'insert-php' ),
130 'default' => 4,
131 'hint' => __( 'The optional feature. The indent for code lines (units). Example: select a snippet, press Tab. The left indent in the selected code increases to N spaces. N is a number pre-defined by you.', 'insert-php' )
132 );
133
134 $options[] = array(
135 'type' => 'checkbox',
136 'way' => 'buttons',
137 'name' => 'code_editor_wrap_lines',
138 'title' => __( 'Wrap Lines', 'insert-php' ),
139 'default' => true,
140 'hint' => __( 'The optional feature. If ON, the editor will wrap long lines. Otherwise, it will create a horizontal scroll.', 'insert-php' )
141 );
142
143 $options[] = array(
144 'type' => 'checkbox',
145 'way' => 'buttons',
146 'name' => 'code_editor_line_numbers',
147 'title' => __( 'Line Numbers', 'insert-php' ),
148 'default' => true,
149 'hint' => __( 'The optional feature. If ON, all lines in the editor will be numbered.', 'insert-php' )
150 );
151
152 $options[] = array(
153 'type' => 'checkbox',
154 'way' => 'buttons',
155 'name' => 'code_editor_auto_close_brackets',
156 'title' => __( 'Auto Close Brackets', 'insert-php' ),
157 'default' => true,
158 'hint' => __( 'The optional feature. If ON, the editor will automatically close opened quotes or brackets. Sometimes, it speeds up coding.', 'insert-php' )
159 );
160
161 $options[] = array(
162 'type' => 'checkbox',
163 'way' => 'buttons',
164 'name' => 'code_editor_highlight_selection_matches',
165 'title' => __( 'Highlight Selection Matches', 'insert-php' ),
166 'default' => false,
167 'hint' => __( 'The optional feature. If ON, it searches for matches for the selected variable/function name. Highlight matches with green. Improves readability.', 'insert-php' )
168 );
169
170 $options[] = array(
171 'type' => 'separator'
172 );
173
174 return $options;
175 }
176
177
178 public function indexAction() {
179
180 // creating a form
181 $form = new Wbcr_FactoryForms411_Form( array(
182 'scope' => substr( $this->plugin->getPrefix(), 0, - 1 ),
183 'name' => 'setting'
184 ), $this->plugin );
185
186 $form->setProvider( new Wbcr_FactoryForms411_OptionsValueProvider( $this->plugin ) );
187
188 $form->add( $this->getOptions() );
189
190 if ( isset( $_POST[ $this->plugin->getPrefix() . 'saved' ] ) ) {
191 if ( ! wp_verify_nonce( $_POST[ $this->plugin->getPrefix() . 'nonce' ], $this->plugin->getPrefix() . 'settings_form' ) ) {
192 wp_die( 'Permission error. You can not edit this page.' );
193 }
194 $form->save();
195 }
196
197 ?>
198 <div class="wrap ">
199 <div class="factory-bootstrap-410 factory-fontawesome-000">
200 <h3><?php _e( 'Settings', 'insert-php' ) ?></h3>
201 <form method="post" class="form-horizontal">
202 <?php if ( isset( $_POST[ $this->plugin->getPrefix() . 'saved' ] ) ) { ?>
203 <div id="message" class="alert alert-success">
204 <p><?php _e( 'The settings have been updated successfully!', 'insert-php' ) ?></p>
205 </div>
206 <?php } ?>
207 <div style="padding-top: 10px;">
208 <?php $form->html(); ?>
209 </div>
210 <div class="form-group form-horizontal">
211 <label class="col-sm-2 control-label"> </label>
212 <div class="control-group controls col-sm-10">
213 <?php wp_nonce_field( $this->plugin->getPrefix() . 'settings_form', $this->plugin->getPrefix() . 'nonce' ); ?>
214 <input name="<?= $this->plugin->getPrefix() . 'saved' ?>" class="btn btn-primary" type="submit" value="<?php _e( 'Save settings', 'insert-php' ) ?>"/>
215 </div>
216 </div>
217 </form>
218 </div>
219 </div>
220 <?php
221 }
222
223 /**
224 * Retrieve a list of the available CodeMirror themes
225 * @return array the available themes
226 */
227 public function getAvailableThemes() {
228 static $themes = null;
229
230 if ( ! is_null( $themes ) ) {
231 return $themes;
232 }
233
234 $themes = array();
235 $themes_dir = WINP_PLUGIN_DIR . '/admin/assets/css/cmthemes/';
236 $theme_files = glob( $themes_dir . '*.css' );
237
238 foreach ( $theme_files as $i => $theme ) {
239 $theme = str_replace( $themes_dir, '', $theme );
240 $theme = str_replace( '.css', '', $theme );
241 $themes[] = array( $theme, $theme );
242 }
243
244 array_unshift( $themes, array( 'default', 'default' ) );
245
246 return $themes;
247 }
248 }
249