PluginProbe
Code Embed / 2.4
Code Embed v2.4
2.6.4 2.6.3 2.6.2 2.6.1 trunk 1.0 1.1 1.2 1.3 1.4.1 1.5.1 1.6.1 2.0.2 2.1.2 2.2.2 2.3.9 2.4 2.5.1 2.5.2 2.6
simple-embed-code / includes / options-screen.php

options-screen.php in Code Embed 2.4, at includes/options-screen.php

139 lines 8.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Code Embed Options
4 *
5 * Allow the user to change the default options
6 *
7 * @package simple-embed-code
8 *
9 * @uses ce_help Return help text
10 */
11
12 ?>
13 <div class="wrap">
14 <h1><?php echo esc_html( ucwords( __( 'Code Embed options', 'simple-embed-code' ) ) ); ?></h1>
15 <?php
16
17 // If options have been updated on screen, update the database.
18
19 if ( ( ! empty( $_POST ) ) && ( check_admin_referer( 'code-embed-profile', 'code_embed_profile_nonce' ) ) ) { // Input var okay.
20
21 // Update the options array from the form fields. Strip invalid tags.
22
23 if ( ! empty( $_POST['code_embed_opening'] ) ) {
24 $options['opening_ident'] = strtoupper( trim( sanitize_text_field( wp_unslash( $_POST['code_embed_opening'] ) ) ) ); // Input var okay.
25 } else {
26 $options['opening_ident'] = '{{';
27 }
28
29 if ( ! empty( $_POST['code_embed_keyword'] ) ) {
30 $options['keyword_ident'] = strtoupper( trim( sanitize_text_field( wp_unslash( $_POST['code_embed_keyword'] ) ) ) ); // Input var okay.
31 } else {
32 $options['keyword_ident'] = 'CODE';
33 }
34
35 if ( ! empty( $_POST['code_embed_closing'] ) ) {
36 $options['closing_ident'] = strtoupper( trim( sanitize_text_field( wp_unslash( $_POST['code_embed_closing'] ) ) ) ); // Input var okay.
37 } else {
38 $options['closing_ident'] = '}}';
39 }
40
41 if ( isset( $_POST['code_embed_excerpt'] ) ) {
42 $options['excerpt'] = sanitize_text_field( wp_unslash( $_POST['code_embed_excerpt'] ) ); // Input var okay.
43 } else {
44 $options['excerpt'] = '';
45 }
46
47 if ( isset( $_POST['code_embed_meta_box'] ) ) {
48 $options['meta_box'] = sanitize_text_field( wp_unslash( $_POST['code_embed_meta_box'] ) ); // Input var okay.
49 } else {
50 $options['meta_box'] = '';
51 }
52
53 update_option( 'artiss_code_embed', $options );
54
55 echo '<div class="updated fade"><p><strong>' . esc_html( __( 'Settings saved.', 'simple-embed-code' ) ) . "</strong></p></div>\n";
56 }
57
58 // Fetch options into an array.
59
60 $options = get_option( 'artiss_code_embed' );
61
62 // Display a message box if the custom meta box removal has been overridden.
63
64 if ( '1' === $options['meta_box'] ) {
65 echo '<div class="error fade"><p><strong>' . esc_html( __( 'Warning: You have custom post fields switched on for users who do not have the unfiltered HTML capability. This means that insecure code can be added. Please see the plugin README for more details.', 'simple-embed-code' ) ) . "</strong></p></div>\n";
66 }
67 ?>
68
69 <form method="post" action="<?php echo esc_url( get_bloginfo( 'wpurl' ) ) . '/wp-admin/options-general.php?page=ce-options'; ?>">
70
71 <table class="form-table">
72
73 <tr>
74 <th scope="row"><label for="code_embed_excerpt"><?php echo esc_html( ucwords( __( 'Allow in excerpts', 'simple-embed-code' ) ) ); ?></label></th>
75 <td><input type="checkbox" name="code_embed_excerpt" value="1"
76 <?php checked( '1', $options['excerpt'] ); ?>
77 /><?php esc_html_e( 'Allow embedded code to be shown in excerpts', 'simple-embed-code' ); ?></td>
78 </tr>
79
80 <tr>
81 <th scope="row"><label for="code_embed_meta_box"><?php echo esc_html( ucwords( __( 'Allow custom fields for all users', 'simple-embed-code' ) ) ); ?></label></th>
82 <td><input type="checkbox" name="code_embed_meta_box" value="1"
83 <?php checked( '1', $options['meta_box'] ); ?>
84 /><?php esc_html_e( 'Allows custom meta boxes to be shown for all users, including those without unfiltered HTML permissions.', 'simple-embed-code' ); ?><p class="description"><?php esc_html_e( 'For security purposes, it is recommended that you do not select this option unless you have to. Please the plugin README for more details.' ); ?></p></td>
85 </tr>
86
87 </table>
88
89 <?php echo '<h3>' . esc_html( ucwords( __( 'Identifier format', 'simple-embed-code' ) ) ) . '</h3>' . esc_html__( 'Specify the format that will be used to define the way the code is embedded in your post. The formats are case insensitive and characters &lt; &gt [ ] are invalid.', 'simple-embed-code' ); ?>
90
91 <table class="form-table">
92
93 <tr>
94 <th scope="row"><label for="code_embed_keyword"><?php echo esc_html( ucwords( __( 'Keyword', 'simple-embed-code' ) ) ); ?></label></th>
95 <td><input type="text" size="12" maxlength="12" name="code_embed_keyword" value="<?php echo esc_attr( $options['keyword_ident'] ); ?>"/><p class="description"><?php esc_html_e( 'The keyword that is used to name the custom field and then place in your post where the code should be embedded. A suffix on any type can then be placed on the end.', 'simple-embed-code' ); ?></p></td>
96 </tr>
97
98 <tr>
99 <th scope="row"><label for="code_embed_opening"><?php echo esc_html( ucwords( __( 'Opening Identifier', 'simple-embed-code' ) ) ); ?></label></th>
100 <td><input type="text" size="4" maxlength="4" name="code_embed_opening" value="<?php echo esc_attr( $options['opening_ident'] ); ?>"/><p class="description"><?php esc_html_e( 'The character(s) that must be placed in the post before the keyword to uniquely identify it.', 'simple-embed-code' ); ?></p></td>
101 </tr>
102
103 <tr>
104 <th scope="row"><label for="code_embed_closing"><?php echo esc_html( ucwords( __( 'Closing Identifier', 'simple-embed-code' ) ) ); ?></label></th>
105 <td><input type="text" size="4" maxlength="4" name="code_embed_closing" value="<?php echo esc_attr( $options['closing_ident'] ); ?>"/><p class="description"><?php esc_html_e( 'The character(s) that must be placed in the post after the keyword to uniquely identify it.', 'simple-embed-code' ); ?></p></td>
106 </tr>
107
108 </table>
109
110 <?php wp_nonce_field( 'code-embed-profile', 'code_embed_profile_nonce', true, true ); ?>
111
112 <br/><input type="submit" name="Submit" class="button-primary" value="<?php echo esc_attr( ucwords( __( 'Save changes', 'simple-embed-code' ) ) ); ?>"/>
113
114 </form>
115
116 <?php
117
118 // How to embed.
119
120 echo '<br/><h3>' . esc_html( ucwords( __( 'How to embed', 'simple-embed-code' ) ) ) . "</h3>\n";
121
122 /* translators: %1$s: example of custom field key value to use based on current settings, %2$s: details of key used in example */
123 echo '<p>' . sprintf( esc_html__( 'Based upon your current settings to embed some code simply add a custom field named %1$s, where %2$s is any suffix you wish. The code to embed is then added as the field value.', 'simple-embed-code' ), '<strong>' . esc_html( $options['keyword_ident'] ) . 'x</strong>', '<strong>x</strong>' ) . "\n";
124
125 /* translators: %1$s: example of how to embed code in a post based on current settings, %2$s: details of key used in example */
126 echo ' ' . sprintf( esc_html__( 'Then, to add the code into your post simple add %1$s where you wish it to appear. %2$s is the suffix you used for the custom field name.', 'simple-embed-code' ), '<strong>' . esc_html( $options['opening_ident'] ) . esc_html( $options['keyword_ident'] ) . 'x' . esc_html( $options['closing_ident'] ) . '</strong>', '<strong>x</strong>' ) . "</p>\n";
127
128 /* translators: %1$s: another example of adding a custom field, %2$s: another example of adding embed to a post */
129 echo '<p>' . sprintf( esc_html__( 'For example, I may add a custom field named %1$s, where the value is the code I wish to embed. I would then in my post add %2$s where I wish the code to then appear.', 'simple-embed-code' ), '<strong>' . esc_html( $options['keyword_ident'] ) . '1</strong>', '<strong>' . esc_html( $options['opening_ident'] ) . esc_html( $options['keyword_ident'] ) . '1' . esc_html( $options['closing_ident'] ) . '</strong>' ) . "</p>\n";
130
131 /* translators: %1$s: example embedding for responsive layout , %2$s: details of key used in example */
132 echo '<p>' . sprintf( esc_html__( 'To embed the same code but to make it responsive you would use %1$s. To set a maximum width you would use %2$s, where %3$s is the maximum width in pixels.', 'simple-embed-code' ), '<strong>' . esc_html( $options['opening_ident'] ) . esc_html( $options['keyword_ident'] ) . 'x_RES' . esc_html( $options['closing_ident'] ) . '</strong>', '<strong>' . esc_html( $options['opening_ident'] ) . esc_html( $options['keyword_ident'] ) . 'x_RES_y' . esc_html( $options['closing_ident'] ) . '</strong>', '<strong>y</strong>' ) . "</p>\n";
133
134 /* translators: %1$s: example of embedding a file, %2$s: details of key used in example */
135 echo '<p>' . sprintf( esc_html__( 'To embed an external URL you would type %1$s, where %2$s is the URL.', 'simple-embed-code' ), '<strong>' . esc_html( $options['opening_ident'] ) . 'url' . esc_html( $options['closing_ident'] ) . '</strong>', '<strong>url</strong>' ) . "</p>\n";
136 ?>
137
138 </div>
139