PluginProbe
Code Embed / 2.5.1
Code Embed v2.5.1
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.5.1, at includes/options-screen.php

120 lines 6.9 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 update_option( 'artiss_code_embed', $options );
48
49 echo '<div class="updated fade"><p><strong>' . esc_html( __( 'Settings saved.', 'simple-embed-code' ) ) . "</strong></p></div>\n";
50 }
51
52 // Fetch options into an array.
53
54 $options = get_option( 'artiss_code_embed' );
55 ?>
56
57 <form method="post" action="<?php echo esc_url( get_bloginfo( 'wpurl' ) ) . '/wp-admin/options-general.php?page=ce-options'; ?>">
58
59 <table class="form-table">
60
61 <tr>
62 <th scope="row"><label for="code_embed_excerpt"><?php echo esc_html( ucwords( __( 'Allow in excerpts', 'simple-embed-code' ) ) ); ?></label></th>
63 <td><input type="checkbox" name="code_embed_excerpt" value="1"
64 <?php checked( '1', $options['excerpt'] ); ?>
65 /><?php esc_html_e( 'Allow embedded code to be shown in excerpts', 'simple-embed-code' ); ?></td>
66 </tr>
67
68 </table>
69
70 <?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' ); ?>
71
72 <table class="form-table">
73
74 <tr>
75 <th scope="row"><label for="code_embed_keyword"><?php echo esc_html( ucwords( __( 'Keyword', 'simple-embed-code' ) ) ); ?></label></th>
76 <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>
77 </tr>
78
79 <tr>
80 <th scope="row"><label for="code_embed_opening"><?php echo esc_html( ucwords( __( 'Opening Identifier', 'simple-embed-code' ) ) ); ?></label></th>
81 <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>
82 </tr>
83
84 <tr>
85 <th scope="row"><label for="code_embed_closing"><?php echo esc_html( ucwords( __( 'Closing Identifier', 'simple-embed-code' ) ) ); ?></label></th>
86 <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>
87 </tr>
88
89 </table>
90
91 <?php wp_nonce_field( 'code-embed-profile', 'code_embed_profile_nonce', true, true ); ?>
92
93 <br/><input type="submit" name="Submit" class="button-primary" value="<?php echo esc_attr( ucwords( __( 'Save changes', 'simple-embed-code' ) ) ); ?>"/>
94
95 </form>
96
97 <?php
98
99 // How to embed.
100
101 echo '<br/><h3>' . esc_html( ucwords( __( 'How to embed', 'simple-embed-code' ) ) ) . "</h3>\n";
102
103 /* translators: %1$s: example of custom field key value to use based on current settings, %2$s: details of key used in example */
104 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";
105
106 /* translators: %1$s: example of how to embed code in a post based on current settings, %2$s: details of key used in example */
107 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";
108
109 /* translators: %1$s: another example of adding a custom field, %2$s: another example of adding embed to a post */
110 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";
111
112 /* translators: %1$s: example embedding for responsive layout , %2$s: details of key used in example */
113 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";
114
115 /* translators: %1$s: example of embedding a file, %2$s: details of key used in example */
116 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";
117 ?>
118
119 </div>
120