Code Embed - Version 2.2

Version Description

  • Enhancement: Added support for embedding code in excerpts
  • Enhancement: Validated, sanitised and escaped the admin screen data
  • Maintenance: Overhauled the way default options are fetched and/or generated. Now a lot more efficient
  • Maintenance: Updated the admin screens so they are formatted in a similar way to the default WordPress screens
  • Maintenance: Removed hardcoding of plugin folder
  • Maintenance: Updated author and removed donation links
  • Maintenance: Renamed files and file functions - removed prefix from files and update it on functions
  • Maintenance: Added a domain path for translations
Download this release

Release Info

Developer codedart
Plugin Icon 128x128 Code Embed
Version 2.2
Comparing to
See all releases

Code changes from version 2.1.2 to 2.2

css/ace-video-container.css DELETED
@@ -1 +0,0 @@
1
- .ace-video-container{position:relative;padding-bottom:56.25%;height:0;overflow:hidden;}.ace-video-container iframe,.ace-video-container object,.ace-video-container embed{position:absolute;top:0;left:0;width:100%;height:100%;}
 
css/{ace-video-container UNCOMPRESSED.css → video-container UNCOMPRESSED.css } RENAMED
@@ -1,13 +1,13 @@
1
- .ace-video-container {
2
  position: relative;
3
  padding-bottom: 56.25%;
4
  height: 0;
5
  overflow: hidden;
6
  }
7
 
8
- .ace-video-container iframe,
9
- .ace-video-container object,
10
- .ace-video-container embed {
11
  position: absolute;
12
  top: 0;
13
  left: 0;
1
+ .ce-video-container {
2
  position: relative;
3
  padding-bottom: 56.25%;
4
  height: 0;
5
  overflow: hidden;
6
  }
7
 
8
+ .ce-video-container iframe,
9
+ .ce-video-container object,
10
+ .ce-video-container embed {
11
  position: absolute;
12
  top: 0;
13
  left: 0;
css/video-container.css ADDED
@@ -0,0 +1 @@
 
1
+ .ce-video-container{position:relative;padding-bottom:56.25%;height:0;overflow:hidden;}.ce-video-container iframe,.ce-video-container object,.ce-video-container embed{position:absolute;top:0;left:0;width:100%;height:100%;}
images/menu_icon.png DELETED
Binary file
images/screen_icon.png DELETED
Binary file
includes/ace-add-scripts.php DELETED
@@ -1,27 +0,0 @@
1
- <?php
2
- /**
3
- * Add Scripts
4
- *
5
- * Add CSS to the main theme
6
- *
7
- * @package Artiss-Code-Embed
8
- */
9
-
10
- /**
11
- * Add scripts to theme
12
- *
13
- * Add styles to the main theme
14
- *
15
- * @since 2.0
16
- */
17
-
18
- function ace_main_scripts() {
19
-
20
- wp_register_style( 'ace_responsive', plugins_url( '/simple-embed-code/css/ace-video-container.css' ) );
21
-
22
- wp_enqueue_style( 'ace_responsive' );
23
-
24
- }
25
-
26
- add_action( 'wp_enqueue_scripts', 'ace_main_scripts' );
27
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/ace-get-options.php DELETED
@@ -1,40 +0,0 @@
1
- <?php
2
- /**
3
- * Get Code Embed Parameters
4
- *
5
- * Fetch options - if none exist set them. If the old options exist, move them over
6
- *
7
- * @package Artiss-Code-Embed
8
- * @since 1.5
9
- *
10
- * @return string Array of default options
11
- */
12
-
13
- function ace_get_embed_paras() {
14
-
15
- $options = get_option( 'artiss_code_embed' );
16
- $changed = false;
17
-
18
- // If array doesn't exist, set defaults
19
-
20
- if ( !is_array( $options ) ) {
21
- $options = array( 'opening_ident' => '%', 'keyword_ident' => 'CODE', 'closing_ident' => '%', 'debug' => '' );
22
- $changed = true;
23
- }
24
-
25
- // If the old options exist, import and delete them
26
-
27
- if ( get_option( 'simple_code_embed' ) ) {
28
- $old_option = get_option( 'simple_code_embed' );
29
- $options[ 'keyword_ident' ] = $old_option[ 'prefix'];
30
- delete_option( 'simple_code_embed' );
31
- $changed = true;
32
- }
33
-
34
- // Update the options, if changed, and return the result
35
-
36
- if ( $changed ) { update_option( 'artiss_code_embed', $options );}
37
-
38
- return $options;
39
- }
40
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/{ace-filter.php → add-embeds.php} RENAMED
@@ -4,7 +4,7 @@
4
  *
5
  * Functions to add embed code to posts
6
  *
7
- * @package Artiss-Code-Embed
8
  */
9
 
10
  /**
@@ -12,22 +12,21 @@
12
  *
13
  * Filter to add embed to any posts
14
  *
15
- * @since 1.5
16
  *
17
- * @uses ace_get_embed_paras Get default options
18
- * @uses ace_get_embed_code Get embed code from other posts
19
  *
20
  * @param string $content Post content without embedded code
21
  * @return string Post content with embedded code
22
  */
23
 
24
- function ace_filter( $content ) {
25
 
26
  global $post;
27
 
28
  // Set initial values
29
 
30
- $options = ace_get_embed_paras();
31
  $found_pos = strpos( $content, $options[ 'opening_ident' ] . $options[ 'keyword_ident' ], 0 );
32
  $prefix_len = strlen( $options[ 'opening_ident' ] . $options[ 'keyword_ident' ] );
33
 
@@ -86,7 +85,7 @@ function ace_filter( $content ) {
86
  $html = $post_meta[ 0 ];
87
  } else {
88
  // No meta found, so look for it elsewhere
89
- $html = ace_get_embed_code( $options[ 'keyword_ident' ], $suffix );
90
  }
91
 
92
  // Build the string to search for
@@ -95,7 +94,7 @@ function ace_filter( $content ) {
95
 
96
  // Build the string of code to replace with
97
 
98
- $replace = ace_generate_code( $html, 'Code Embed', $responsive, $max_width, $options[ 'debug' ] );
99
 
100
  // Now modify all references
101
 
@@ -107,17 +106,17 @@ function ace_filter( $content ) {
107
 
108
  // Loop around the post content looking for HTTP addresses
109
 
110
- $content = ace_quick_replace( $content, $options, 'http://' );
111
 
112
  // Loop around the post content looking for HTTPS addresses
113
 
114
- $content = ace_quick_replace( $content, $options, 'https://' );
115
 
116
  return $content;
117
  }
118
 
119
- add_filter( 'the_content', 'ace_filter' );
120
- add_filter( 'widget_content', 'ace_filter' );
121
 
122
  /**
123
  * Quick Replace
@@ -132,7 +131,7 @@ add_filter( 'widget_content', 'ace_filter' );
132
  * @return string The updated content
133
  */
134
 
135
- function ace_quick_replace( $content = '', $options = '', $search = '' ) {
136
 
137
  $start_pos = strpos( $content, $options[ 'opening_ident' ] . $search, 0 );
138
  $prefix_len = strlen( $options[ 'opening_ident' ] );
@@ -143,7 +142,7 @@ function ace_quick_replace( $content = '', $options = '', $search = '' ) {
143
  $end_pos = strpos( $content, $options[ 'closing_ident' ], $start_pos );
144
  if ( $end_pos !== false ) {
145
  $url = substr( $content, $start_pos, $end_pos - $start_pos );
146
- $file = ace_get_file( $url );
147
  $content = str_replace ( $options[ 'opening_ident' ] . $url . $options[ 'closing_ident' ], $file[ 'file' ], $content );
148
  }
149
  $start_pos = strpos( $content, $options[ 'opening_ident' ] . $search, $found_pos );
@@ -168,14 +167,14 @@ function ace_quick_replace( $content = '', $options = '', $search = '' ) {
168
  * @return string The embed code
169
  */
170
 
171
- function ace_generate_code( $html, $plugin_name, $responsive = '', $max_width = '', $debug = '' ) {
172
 
173
  $code = "\n";
174
- if ( $debug != 1 ) { $code .= '<!-- ' . $plugin_name . ' v' . artiss_code_embed_version . " -->\n"; }
175
 
176
  if ( $max_width !== false ) { $code .= '<div style="width: ' . $max_width . 'px; max-width: 100%">'; }
177
 
178
- if ( $responsive ) { $code .= '<div class="ace-video-container">'; }
179
 
180
  $code .= $html;
181
 
@@ -196,14 +195,14 @@ function ace_generate_code( $html, $plugin_name, $responsive = '', $max_width =
196
  *
197
  * @since 1.6
198
  *
199
- * @uses ace_report_error Generate an error message
200
  *
201
  * @param $ident string The embed code opening identifier
202
  * @param $suffix string The embed code suffix
203
  * @return string The embed code (or error)
204
  */
205
 
206
- function ace_get_embed_code( $ident, $suffix ) {
207
 
208
  // Meta was not found in current post so look across meta table - find the number of distinct code results
209
 
@@ -231,14 +230,14 @@ function ace_get_embed_code( $ident, $suffix ) {
231
 
232
  // More than one unique code result returned, so output the list of posts
233
 
234
- $error = sprintf( __( 'Cannot use %s as a global code as it is being used to store %d unique pieces of code in %d posts - <a href="%s">click here</a> for more details', 'simple-embed-code' ), $meta_name, $records, $total_records, get_bloginfo( 'wpurl' ) . '/wp-admin/admin.php?page=ace-search&amp;suffix=' . $suffix );
235
- $html = ace_report_error( $error, 'Code Embed', false );
236
  }
237
  } else {
238
 
239
  // No meta code was found so write out an error
240
 
241
- $html = ace_report_error( sprintf( __( 'No embed code was found for %s', 'simple-embed-code' ), $meta_name ), 'Code Embed', false );
242
 
243
  }
244
  return $html;
@@ -257,7 +256,7 @@ function ace_get_embed_code( $ident, $suffix ) {
257
  * @return string Array containing file contents and response
258
  */
259
 
260
- function ace_get_file( $filein, $header = false ) {
261
 
262
  $rc = 0;
263
  $error = '';
@@ -303,7 +302,7 @@ function ace_get_file( $filein, $header = false ) {
303
  * @return string True or the output text
304
  */
305
 
306
- function ace_report_error( $error, $plugin_name, $echo = true ) {
307
 
308
  $output = '<p style="color: #f00; font-weight: bold;">' . $plugin_name . ': ' . $error . "</p>\n";
309
 
4
  *
5
  * Functions to add embed code to posts
6
  *
7
+ * @package Code-Embed
8
  */
9
 
10
  /**
12
  *
13
  * Filter to add embed to any posts
14
  *
15
+ * @since 1.5
16
  *
17
+ * @uses ce_get_embed_code Get embed code from other posts
 
18
  *
19
  * @param string $content Post content without embedded code
20
  * @return string Post content with embedded code
21
  */
22
 
23
+ function ce_filter( $content ) {
24
 
25
  global $post;
26
 
27
  // Set initial values
28
 
29
+ $options = get_option( 'artiss_code_embed' );
30
  $found_pos = strpos( $content, $options[ 'opening_ident' ] . $options[ 'keyword_ident' ], 0 );
31
  $prefix_len = strlen( $options[ 'opening_ident' ] . $options[ 'keyword_ident' ] );
32
 
85
  $html = $post_meta[ 0 ];
86
  } else {
87
  // No meta found, so look for it elsewhere
88
+ $html = ce_get_embed_code( $options[ 'keyword_ident' ], $suffix );
89
  }
90
 
91
  // Build the string to search for
94
 
95
  // Build the string of code to replace with
96
 
97
+ $replace = ce_generate_code( $html, 'Code Embed', $responsive, $max_width, $options[ 'debug' ] );
98
 
99
  // Now modify all references
100
 
106
 
107
  // Loop around the post content looking for HTTP addresses
108
 
109
+ $content = ce_quick_replace( $content, $options, 'http://' );
110
 
111
  // Loop around the post content looking for HTTPS addresses
112
 
113
+ $content = ce_quick_replace( $content, $options, 'https://' );
114
 
115
  return $content;
116
  }
117
 
118
+ add_filter( 'the_content', 'ce_filter' );
119
+ add_filter( 'widget_content', 'ce_filter' );
120
 
121
  /**
122
  * Quick Replace
131
  * @return string The updated content
132
  */
133
 
134
+ function ce_quick_replace( $content = '', $options = '', $search = '' ) {
135
 
136
  $start_pos = strpos( $content, $options[ 'opening_ident' ] . $search, 0 );
137
  $prefix_len = strlen( $options[ 'opening_ident' ] );
142
  $end_pos = strpos( $content, $options[ 'closing_ident' ], $start_pos );
143
  if ( $end_pos !== false ) {
144
  $url = substr( $content, $start_pos, $end_pos - $start_pos );
145
+ $file = ce_get_file( $url );
146
  $content = str_replace ( $options[ 'opening_ident' ] . $url . $options[ 'closing_ident' ], $file[ 'file' ], $content );
147
  }
148
  $start_pos = strpos( $content, $options[ 'opening_ident' ] . $search, $found_pos );
167
  * @return string The embed code
168
  */
169
 
170
+ function ce_generate_code( $html, $plugin_name, $responsive = '', $max_width = '', $debug = '' ) {
171
 
172
  $code = "\n";
173
+ if ( $debug != 1 ) { $code .= '<!-- ' . $plugin_name . ' v' . code_embed_version . " -->\n"; }
174
 
175
  if ( $max_width !== false ) { $code .= '<div style="width: ' . $max_width . 'px; max-width: 100%">'; }
176
 
177
+ if ( $responsive ) { $code .= '<div class="ce-video-container">'; }
178
 
179
  $code .= $html;
180
 
195
  *
196
  * @since 1.6
197
  *
198
+ * @uses ce_report_error Generate an error message
199
  *
200
  * @param $ident string The embed code opening identifier
201
  * @param $suffix string The embed code suffix
202
  * @return string The embed code (or error)
203
  */
204
 
205
+ function ce_get_embed_code( $ident, $suffix ) {
206
 
207
  // Meta was not found in current post so look across meta table - find the number of distinct code results
208
 
230
 
231
  // More than one unique code result returned, so output the list of posts
232
 
233
+ $error = sprintf( __( 'Cannot use %s as a global code as it is being used to store %d unique pieces of code in %d posts - <a href="%s">click here</a> for more details', 'simple-embed-code' ), $meta_name, $records, $total_records, get_bloginfo( 'wpurl' ) . '/wp-admin/admin.php?page=ce-search&amp;suffix=' . $suffix );
234
+ $html = ce_report_error( $error, 'Code Embed', false );
235
  }
236
  } else {
237
 
238
  // No meta code was found so write out an error
239
 
240
+ $html = ce_report_error( sprintf( __( 'No embed code was found for %s', 'simple-embed-code' ), $meta_name ), 'Code Embed', false );
241
 
242
  }
243
  return $html;
256
  * @return string Array containing file contents and response
257
  */
258
 
259
+ function ce_get_file( $filein, $header = false ) {
260
 
261
  $rc = 0;
262
  $error = '';
302
  * @return string True or the output text
303
  */
304
 
305
+ function ce_report_error( $error, $plugin_name, $echo = true ) {
306
 
307
  $output = '<p style="color: #f00; font-weight: bold;">' . $plugin_name . ': ' . $error . "</p>\n";
308
 
includes/add-scripts.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Add Scripts
4
+ *
5
+ * Add CSS to the main theme
6
+ *
7
+ * @package Code-Embed
8
+ */
9
+
10
+ /**
11
+ * Add scripts to theme
12
+ *
13
+ * Add styles to the main theme
14
+ *
15
+ * @since 2.0
16
+ */
17
+
18
+ function ce_main_scripts() {
19
+
20
+ wp_register_style( 'ce_responsive', plugins_url( 'css/video-container.css', dirname(__FILE__) ) );
21
+
22
+ wp_enqueue_style( 'ce_responsive' );
23
+
24
+ }
25
+
26
+ add_action( 'wp_enqueue_scripts', 'ce_main_scripts' );
27
+ ?>
includes/{ace-admin-config.php → admin-config.php} RENAMED
@@ -4,7 +4,7 @@
4
  *
5
  * Add various adminstration menu options
6
  *
7
- * @package Artiss-Code-Embed
8
  */
9
 
10
  /**
@@ -19,20 +19,21 @@
19
  * @return string Links, now with settings added
20
  */
21
 
22
- function ace_add_settings_link( $links, $file ) {
23
 
24
  static $this_plugin;
25
 
26
  if ( !$this_plugin ) { $this_plugin = plugin_basename( __FILE__ ); }
27
 
28
  if ( strpos( $file, 'code-embed.php' ) !== false ) {
29
- $settings_link = '<a href="admin.php?page=ace-options">' . __( 'Settings', 'simple-embed-code' ) . '</a>';
30
  array_unshift( $links, $settings_link );
31
  }
32
 
33
  return $links;
34
  }
35
- add_filter( 'plugin_action_links', 'ace_add_settings_link', 10, 2 );
 
36
 
37
  /**
38
  * Add meta to plugin details
@@ -46,17 +47,18 @@ add_filter( 'plugin_action_links', 'ace_add_settings_link', 10, 2 );
46
  * @return string Links, now with settings added
47
  */
48
 
49
- function ace_set_plugin_meta( $links, $file ) {
50
 
51
  if ( strpos( $file, 'code-embed.php' ) !== false ) {
52
 
53
  $links = array_merge( $links, array( '<a href="http://wordpress.org/support/plugin/simple-embed-code">' . __( 'Support', 'simple-embed-code' ) . '</a>' ) );
54
- $links = array_merge( $links, array( '<a href="http://www.artiss.co.uk/donate">' . __( 'Donate', 'simple-embed-code' ) . '</a>' ) );
55
  }
56
 
57
  return $links;
58
  }
59
- add_filter( 'plugin_row_meta', 'ace_set_plugin_meta', 10, 2 );
 
60
 
61
  /**
62
  * Code Embed Menu
@@ -65,29 +67,30 @@ add_filter( 'plugin_row_meta', 'ace_set_plugin_meta', 10, 2 );
65
  *
66
  * @since 1.4
67
  *
68
- * @uses ace_help Return help text
69
  */
70
 
71
- function ace_menu() {
72
 
73
- // Add search sub-menu
74
 
75
- global $ace_search_hook;
76
 
77
- $ace_search_hook = add_submenu_page( 'tools.php', __( 'Code Embed Search', 'simple-embed-code' ), __( 'Code Search', 'simple-embed-code' ), 'edit_posts', 'ace-search', 'ace_search' );
 
 
78
 
79
- add_action('load-'.$ace_search_hook, 'ace_add_search_help');
80
-
81
  // Add options sub-menu
82
 
83
- global $ace_options_hook;
84
 
85
- $ace_options_hook = add_submenu_page( 'options-general.php', __( 'Code Embed Settings', 'simple-embed-code' ), __( 'Code Embed', 'simple-embed-code' ), 'manage_options', 'ace-options', 'ace_options' );
86
 
87
- add_action('load-'.$ace_options_hook, 'ace_add_options_help');
88
 
89
  }
90
- add_action( 'admin_menu','ace_menu' );
 
91
 
92
  /**
93
  * Add Options Help
@@ -96,17 +99,17 @@ add_action( 'admin_menu','ace_menu' );
96
  *
97
  * @since 2.0
98
  *
99
- * @uses ace_options_help Return help text
100
  */
101
 
102
- function ace_add_options_help() {
103
 
104
- global $ace_options_hook;
105
  $screen = get_current_screen();
106
 
107
- if ( $screen->id != $ace_options_hook ) { return; }
108
 
109
- $screen -> add_help_tab( array( 'id' => 'ace-options-help-tab', 'title' => __( 'Help', 'simple-embed-code' ), 'content' => ace_options_help() ) );
110
  }
111
 
112
  /**
@@ -116,17 +119,17 @@ function ace_add_options_help() {
116
  *
117
  * @since 2.0
118
  *
119
- * @uses ace_search_help Return help text
120
  */
121
 
122
- function ace_add_search_help() {
123
 
124
- global $ace_search_hook;
125
  $screen = get_current_screen();
126
 
127
- if ( $screen->id != $ace_search_hook ) { return; }
128
 
129
- $screen -> add_help_tab( array( 'id' => 'ace-search-help-tab', 'title' => __( 'Help', 'simple-embed-code' ), 'content' => ace_search_help() ) );
130
  }
131
 
132
  /**
@@ -137,9 +140,9 @@ function ace_add_search_help() {
137
  * @since 1.4
138
  */
139
 
140
- function ace_options() {
141
 
142
- include_once( WP_PLUGIN_DIR . '/' . str_replace( basename( __FILE__ ), '', plugin_basename( __FILE__ ) ) . 'ace-options.php' );
143
 
144
  }
145
 
@@ -151,9 +154,9 @@ function ace_options() {
151
  * @since 1.6
152
  */
153
 
154
- function ace_search() {
155
 
156
- include_once( WP_PLUGIN_DIR . '/' . str_replace( basename( __FILE__ ), '', plugin_basename( __FILE__ ) ) . 'ace-search.php' );
157
 
158
  }
159
 
@@ -167,14 +170,13 @@ function ace_search() {
167
  * @return string Help Text
168
  */
169
 
170
- function ace_options_help() {
171
 
172
  $help_text = '<p>' . __( 'Use this screen to modify the various settings, including the identifiers and keyword used to specify your embedded code.', 'simple-embed-code' ) . '</p>';
173
  $help_text .= '<p>' . __( 'The first option allows to suppress debug output. Normally this is an HTML comment in your page source - if you wish to hide this then simply ticket this option.', 'simple-embed-code' ) . '</p>';
174
- $help_text .= '<p>' . __( 'The keyword is the name used for your custom field. The custom field\'s value is the code that you wish to embed.', 'simple-embed-code' ) . '</p>';
 
175
  $help_text .= '<p>' . __( 'The keyword, sandwiched with the identifier before and after, is what you then need to add to your post or page to activate the embed code.', 'simple-embed-code' ) . '</p>';
176
- $help_text .= '<p>' . sprintf( __( 'You are using Code Embed version %s. It was written by David Artiss.', 'simple-embed-code' ), artiss_code_embed_version ) . '</p>';
177
-
178
 
179
  return $help_text;
180
  }
@@ -189,7 +191,7 @@ function ace_options_help() {
189
  * @return string Help Text
190
  */
191
 
192
- function ace_search_help() {
193
 
194
  $help_text = '<p>' . __( 'This screen allows you to search for the post and pages that a particular code embed has been used in.', 'simple-embed-code' ) . '</p>';
195
  $help_text .= '<p>' . __( 'Simply enter the code suffix that you wish to search for and press the \'Search\' key to display a list of all the posts using it. In addition the code will be shown alongside it. Click on the post name to edit the post.', 'simple-embed-code' ) . '</p>';
4
  *
5
  * Add various adminstration menu options
6
  *
7
+ * @package Code-Embed
8
  */
9
 
10
  /**
19
  * @return string Links, now with settings added
20
  */
21
 
22
+ function ce_add_settings_link( $links, $file ) {
23
 
24
  static $this_plugin;
25
 
26
  if ( !$this_plugin ) { $this_plugin = plugin_basename( __FILE__ ); }
27
 
28
  if ( strpos( $file, 'code-embed.php' ) !== false ) {
29
+ $settings_link = '<a href="admin.php?page=ce-options">' . __( 'Settings', 'simple-embed-code' ) . '</a>';
30
  array_unshift( $links, $settings_link );
31
  }
32
 
33
  return $links;
34
  }
35
+
36
+ add_filter( 'plugin_action_links', 'ce_add_settings_link', 10, 2 );
37
 
38
  /**
39
  * Add meta to plugin details
47
  * @return string Links, now with settings added
48
  */
49
 
50
+ function ce_set_plugin_meta( $links, $file ) {
51
 
52
  if ( strpos( $file, 'code-embed.php' ) !== false ) {
53
 
54
  $links = array_merge( $links, array( '<a href="http://wordpress.org/support/plugin/simple-embed-code">' . __( 'Support', 'simple-embed-code' ) . '</a>' ) );
55
+
56
  }
57
 
58
  return $links;
59
  }
60
+
61
+ add_filter( 'plugin_row_meta', 'ce_set_plugin_meta', 10, 2 );
62
 
63
  /**
64
  * Code Embed Menu
67
  *
68
  * @since 1.4
69
  *
70
+ * @uses ce_help Return help text
71
  */
72
 
73
+ function ce_menu() {
74
 
75
+ // Add search sub-menu
76
 
77
+ global $ce_search_hook;
78
 
79
+ $ce_search_hook = add_submenu_page( 'tools.php', __( 'Code Embed Search', 'simple-embed-code' ), __( 'Code Search', 'simple-embed-code' ), 'edit_posts', 'ce-search', 'ce_search' );
80
+
81
+ add_action('load-'.$ce_search_hook, 'ce_add_search_help');
82
 
 
 
83
  // Add options sub-menu
84
 
85
+ global $ce_options_hook;
86
 
87
+ $ce_options_hook = add_submenu_page( 'options-general.php', __( 'Code Embed Settings', 'simple-embed-code' ), __( 'Code Embed', 'simple-embed-code' ), 'manage_options', 'ce-options', 'ce_options' );
88
 
89
+ add_action('load-'.$ce_options_hook, 'ce_add_options_help');
90
 
91
  }
92
+
93
+ add_action( 'admin_menu','ce_menu' );
94
 
95
  /**
96
  * Add Options Help
99
  *
100
  * @since 2.0
101
  *
102
+ * @uses ce_options_help Return help text
103
  */
104
 
105
+ function ce_add_options_help() {
106
 
107
+ global $ce_options_hook;
108
  $screen = get_current_screen();
109
 
110
+ if ( $screen->id != $ce_options_hook ) { return; }
111
 
112
+ $screen -> add_help_tab( array( 'id' => 'ce-options-help-tab', 'title' => __( 'Help', 'simple-embed-code' ), 'content' => ce_options_help() ) );
113
  }
114
 
115
  /**
119
  *
120
  * @since 2.0
121
  *
122
+ * @uses ce_search_help Return help text
123
  */
124
 
125
+ function ce_add_search_help() {
126
 
127
+ global $ce_search_hook;
128
  $screen = get_current_screen();
129
 
130
+ if ( $screen->id != $ce_search_hook ) { return; }
131
 
132
+ $screen -> add_help_tab( array( 'id' => 'ce-search-help-tab', 'title' => __( 'Help', 'simple-embed-code' ), 'content' => ce_search_help() ) );
133
  }
134
 
135
  /**
140
  * @since 1.4
141
  */
142
 
143
+ function ce_options() {
144
 
145
+ include_once( WP_PLUGIN_DIR . '/' . str_replace( basename( __FILE__ ), '', plugin_basename( __FILE__ ) ) . 'options-screen.php' );
146
 
147
  }
148
 
154
  * @since 1.6
155
  */
156
 
157
+ function ce_search() {
158
 
159
+ include_once( WP_PLUGIN_DIR . '/' . str_replace( basename( __FILE__ ), '', plugin_basename( __FILE__ ) ) . 'search-screen.php' );
160
 
161
  }
162
 
170
  * @return string Help Text
171
  */
172
 
173
+ function ce_options_help() {
174
 
175
  $help_text = '<p>' . __( 'Use this screen to modify the various settings, including the identifiers and keyword used to specify your embedded code.', 'simple-embed-code' ) . '</p>';
176
  $help_text .= '<p>' . __( 'The first option allows to suppress debug output. Normally this is an HTML comment in your page source - if you wish to hide this then simply ticket this option.', 'simple-embed-code' ) . '</p>';
177
+ $help_text .= '<p>' . __( 'The second option allows to specify whether code embed requests should work in excerpts.', 'simple-embed-code' ) . '</p>';
178
+ $help_text .= '<p>' . __( 'The keyword is the name used for your custom field. The custom field\'s value is the code that you wish to embed.', 'simple-embed-code' ) . '</p>';
179
  $help_text .= '<p>' . __( 'The keyword, sandwiched with the identifier before and after, is what you then need to add to your post or page to activate the embed code.', 'simple-embed-code' ) . '</p>';
 
 
180
 
181
  return $help_text;
182
  }
191
  * @return string Help Text
192
  */
193
 
194
+ function ce_search_help() {
195
 
196
  $help_text = '<p>' . __( 'This screen allows you to search for the post and pages that a particular code embed has been used in.', 'simple-embed-code' ) . '</p>';
197
  $help_text .= '<p>' . __( 'Simply enter the code suffix that you wish to search for and press the \'Search\' key to display a list of all the posts using it. In addition the code will be shown alongside it. Click on the post name to edit the post.', 'simple-embed-code' ) . '</p>';
includes/initialise.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Initialisation script
4
+ *
5
+ * Run everytime the plugin is initialised
6
+ *
7
+ * @package Code-Embed
8
+ * @since 2.2
9
+ */
10
+
11
+ function ce_initialisation() {
12
+
13
+ // Load text domain for translations
14
+
15
+ $language_dir = plugin_basename( dirname( __FILE__ ) ) . '/languages/';
16
+
17
+ load_plugin_textdomain( 'simple-embed-code', false, $language_dir );
18
+
19
+ // Add exerpt filter, if required
20
+
21
+ $options = get_option( 'artiss_code_embed' );
22
+ if ( isset( $options[ 'excerpt' ] ) && $options[ 'excerpt' ] == 1 ) {
23
+ add_filter( 'the_excerpt', 'ce_filter', 1 );
24
+ }
25
+
26
+ // Check if plugin has upgraded and, if so, perform further actions
27
+
28
+ $version = get_option( 'code_embed_version' );
29
+
30
+ if ( $version != code_embed_version ) {
31
+
32
+ // Set up default option values (if not already set)
33
+
34
+ $options = get_option( 'artiss_code_embed' );
35
+
36
+ // If options don't exist, create an empty array
37
+
38
+ if ( !is_array( $options ) ) { $options = array(); }
39
+
40
+ // Because of upgrading, check each option - if not set, apply default
41
+
42
+ $default_array = array(
43
+ 'opening_ident' => '%',
44
+ 'keyword_ident' => 'CODE',
45
+ 'closing_ident' => '%',
46
+ 'debug' => '',
47
+ 'excerpts' => '',
48
+ );
49
+
50
+ // Merge existing and default options - any missing from existing will take the default settings
51
+
52
+ $new_options = array_merge( $default_array, $options );
53
+
54
+ // Update the options, if changed, and return the result
55
+
56
+ if ( $options != $new_options ) { update_option( 'artiss_code_embed', $new_options ); }
57
+
58
+ }
59
+
60
+ }
61
+
62
+ add_action( 'init', 'ce_initialisation' );
63
+ ?>
includes/{ace-options.php → options-screen.php} RENAMED
@@ -4,11 +4,10 @@
4
  *
5
  * Allow the user to change the default options
6
  *
7
- * @package Artiss-Code-Embed
8
  * @since 1.4
9
  *
10
- * @uses ace_get_embed_paras Get the options
11
- * @uses ace_help Return help text
12
  */
13
  ?>
14
  <div class="wrap">
@@ -18,16 +17,21 @@ if ( ( float ) $wp_version >= 4.3 ) { $heading = '1'; } else { $heading = '2'; }
18
  ?>
19
  <h<?php echo $heading; ?>><?php _e( 'Code Embed Options', 'simple-embed-code' ); ?></h<?php echo $heading; ?>>
20
  <?php
 
21
  // If options have been updated on screen, update the database
 
22
  if ( ( !empty( $_POST ) ) && ( check_admin_referer( 'code-embed-profile' , 'code_embed_profile_nonce' ) ) ) {
23
 
24
  // Update the options array from the form fields. Strip invalid tags.
25
- $options[ 'opening_ident' ] = strtoupper( trim( $_POST[ 'code_embed_opening' ], '[]<>' ) );
26
- $options[ 'keyword_ident' ] = strtoupper( trim( $_POST[ 'code_embed_keyword' ], '[]<>' ) );
27
- $options[ 'closing_ident' ] = strtoupper( trim( $_POST[ 'code_embed_closing' ], '[]<>' ) );
28
- $options[ 'debug' ] = $_POST[ 'code_embed_debug' ];
 
 
29
 
30
  // If any fields are blank assign default values
 
31
  if ( $options[ 'opening_ident' ] == '' ) { $options[ 'opening_ident' ] = '%'; }
32
  if ( $options[ 'keyword_ident' ] == '' ) { $options[ 'keyword_ident' ] = 'CODE'; }
33
  if ( $options[ 'closing_ident' ] == '' ) { $options[ 'closing_ident' ] = '%'; }
@@ -36,15 +40,21 @@ if ( ( !empty( $_POST ) ) && ( check_admin_referer( 'code-embed-profile' , 'code
36
  }
37
 
38
  // Fetch options into an array
39
- $options = ace_get_embed_paras();
 
40
  ?>
41
 
42
- <form method="post" action="<?php echo get_bloginfo( 'wpurl' ) . '/wp-admin/admin.php?page=ace-options&amp;updated=true' ?>">
43
 
44
  <table class="form-table">
45
  <tr>
46
- <th scope="row"><?php _e( 'Hide Debug', 'simple-embed-code' ); ?></th>
47
- <td><input type="checkbox" name="code_embed_debug" value="1"<?php if ( $options[ 'debug' ] == "1" ) { echo ' checked="checked"'; } ?>/>&nbsp;<span class="description"><?php _e( 'Hide debug HTML comments in source.', 'simple-embed-code' ); ?></span></td>
 
 
 
 
 
48
  </tr>
49
  </table>
50
 
@@ -53,25 +63,25 @@ $options = ace_get_embed_paras();
53
  <table class="form-table">
54
 
55
  <tr>
56
- <th scope="row"><?php _e( 'Keyword', 'simple-embed-code' ); ?></th>
57
- <td><input type="text" size="12" maxlength="12" name="code_embed_keyword" value="<?php echo $options[ 'keyword_ident' ] ; ?>"/>&nbsp;<span class="description"><?php _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' ); ?></span></td>
58
  </tr>
59
 
60
  <tr>
61
- <th scope="row"><?php _e( 'Opening Identifier', 'simple-embed-code' ); ?></th>
62
- <td><input type="text" size="4" maxlength="4" name="code_embed_opening" value="<?php echo $options[ 'opening_ident' ]; ?>"/>&nbsp;<span class="description"><?php _e( 'The character(s) that must be placed in the post before the keyword to uniquely identify it.', 'simple-embed-code' ); ?></span></td>
63
  </tr>
64
 
65
  <tr>
66
- <th scope="row"><?php _e( 'Closing Identifier', 'simple-embed-code' ); ?></th>
67
- <td><input type="text" size="4" maxlength="4" name="code_embed_closing" value="<?php echo $options[ 'closing_ident' ]; ?>"/>&nbsp;<span class="description"><?php _e( 'The character(s) that must be placed in the post after the keyword to uniquely identify it.', 'simple-embed-code' ); ?></span></td>
68
  </tr>
69
 
70
  </table>
71
 
72
  <?php wp_nonce_field( 'code-embed-profile', 'code_embed_profile_nonce', true, true ); ?>
73
 
74
- <br/><input type="submit" name="Submit" class="button-primary" value="<?php _e( 'Save Settings', 'simple-embed-code' ); ?>"/>
75
 
76
  </form>
77
 
@@ -80,8 +90,8 @@ $options = ace_get_embed_paras();
80
  // How to embed
81
 
82
  echo "<br/><h3>" . __( 'How to Embed', 'simple-embed-code' ) . "</h3>\n";
83
- echo '<p>' . sprintf ( __( 'Based upon your current settings to embed some code simply add a custom field named %s, where %s is any suffix you wish. The code to embed is then added as the field value.', 'simple-embed-code' ), '<strong>' . $options[ 'keyword_ident' ] . 'x</strong>', '<strong>x</strong>' ) . "</p>\n";
84
- echo '<p>' . sprintf ( __( 'Then, to add the code into your post simple add %s where you wish it to appear. %s is the suffix you used for the custom field name.', 'simple-embed-code' ), '<strong>' . $options[ 'opening_ident' ] . $options[ 'keyword_ident' ] . "x" . $options[ 'closing_ident' ] . '</strong>', '<strong>x</strong>' ) . "</p>\n";
85
  echo '<p>' . sprintf ( __( 'For example, I may add a custom field named %s, where the value is the code I wish to embed. I would then in my post add %s where I wish the code to then appear.', 'simple-embed-code' ), '<strong>' . $options[ 'keyword_ident' ].'1</strong>', '<strong>' . $options[ 'opening_ident' ] . $options[ 'keyword_ident' ] . "1" . $options[ 'closing_ident' ] . '</strong>' ) . "</p>\n";
86
  echo '<p>' . sprintf ( __( 'To embed the same code but to make it responsive you would use %s. To set a maximum width you would use %s, where %s is the maximum width in pixels.', 'simple-embed-code' ), '<strong>' . $options[ 'opening_ident' ] . $options[ 'keyword_ident' ] . "x_RES" . $options[ 'closing_ident' ] . '</strong>', '<strong>' . $options[ 'opening_ident' ] . $options[ 'keyword_ident' ] . "x_RES_y" . $options[ 'closing_ident' ] . '</strong>', '<strong>y</strong>' ) . "</p>\n";
87
  echo '<p>' . sprintf ( __( 'To embed an external URL you would type %s, where %s is the URL.', 'simple-embed-code' ), '<strong>' . $options[ 'opening_ident' ] . 'url' . $options[ 'closing_ident' ] . '</strong>', '<strong>url</strong>' ) . "</p>\n";
4
  *
5
  * Allow the user to change the default options
6
  *
7
+ * @package Code-Embed
8
  * @since 1.4
9
  *
10
+ * @uses ce_help Return help text
 
11
  */
12
  ?>
13
  <div class="wrap">
17
  ?>
18
  <h<?php echo $heading; ?>><?php _e( 'Code Embed Options', 'simple-embed-code' ); ?></h<?php echo $heading; ?>>
19
  <?php
20
+
21
  // If options have been updated on screen, update the database
22
+
23
  if ( ( !empty( $_POST ) ) && ( check_admin_referer( 'code-embed-profile' , 'code_embed_profile_nonce' ) ) ) {
24
 
25
  // Update the options array from the form fields. Strip invalid tags.
26
+
27
+ $options[ 'opening_ident' ] = sanitize_text_field( strtoupper( trim( $_POST[ 'code_embed_opening' ], '[]<>' ) ) );
28
+ $options[ 'keyword_ident' ] = sanitize_text_field( strtoupper( trim( $_POST[ 'code_embed_keyword' ], '[]<>' ) ) );
29
+ $options[ 'closing_ident' ] = sanitize_text_field( strtoupper( trim( $_POST[ 'code_embed_closing' ], '[]<>' ) ) );
30
+ if ( isset( $_POST[ 'code_embed_debug' ] ) ) { $options[ 'debug' ] = sanitize_text_field( $_POST[ 'code_embed_debug' ] ); } else { $options[ 'debug' ] = ''; }
31
+ if ( isset( $_POST[ 'code_embed_excerpt' ] ) ) { $options[ 'excerpt' ] = sanitize_text_field( $_POST[ 'code_embed_excerpt' ] ); } else { $options[ 'excerpt' ] = ''; }
32
 
33
  // If any fields are blank assign default values
34
+
35
  if ( $options[ 'opening_ident' ] == '' ) { $options[ 'opening_ident' ] = '%'; }
36
  if ( $options[ 'keyword_ident' ] == '' ) { $options[ 'keyword_ident' ] = 'CODE'; }
37
  if ( $options[ 'closing_ident' ] == '' ) { $options[ 'closing_ident' ] = '%'; }
40
  }
41
 
42
  // Fetch options into an array
43
+
44
+ $options = get_option( 'artiss_code_embed' );
45
  ?>
46
 
47
+ <form method="post" action="<?php echo get_bloginfo( 'wpurl' ) . '/wp-admin/admin.php?page=ce-options&amp;updated=true' ?>">
48
 
49
  <table class="form-table">
50
  <tr>
51
+ <th scope="row"><label for="code_embed_debug"><?php _e( 'Hide Debug', 'simple-embed-code' ); ?></label></th>
52
+ <td><input type="checkbox" name="code_embed_debug" value="1"<?php if ( $options[ 'debug' ] == "1" ) { echo ' checked="checked"'; } ?>/><?php _e( 'Hide debug HTML comments in source', 'simple-embed-code' ); ?></td>
53
+ </tr>
54
+
55
+ <tr>
56
+ <th scope="row"><label for="code_embed_excerpt"><?php _e( 'Allow in Excerpts', 'simple-embed-code' ); ?></label></th>
57
+ <td><input type="checkbox" name="code_embed_excerpt" value="1"<?php if ( $options[ 'excerpt' ] == "1" ) { echo ' checked="checked"'; } ?>/><?php _e( 'Allow embedded code to be shown in excerpts', 'simple-embed-code' ); ?></td>
58
  </tr>
59
  </table>
60
 
63
  <table class="form-table">
64
 
65
  <tr>
66
+ <th scope="row"><label for="code_embed_keyword"><?php _e( 'Keyword', 'simple-embed-code' ); ?></label></th>
67
+ <td><input type="text" size="12" maxlength="12" name="code_embed_keyword" value="<?php echo esc_html( $options[ 'keyword_ident' ] ); ?>"/><p class="description"><?php _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>
68
  </tr>
69
 
70
  <tr>
71
+ <th scope="row"><label for="code_embed_opening"><?php _e( 'Opening Identifier', 'simple-embed-code' ); ?></label></th>
72
+ <td><input type="text" size="4" maxlength="4" name="code_embed_opening" value="<?php echo esc_html( $options[ 'opening_ident' ] ); ?>"/><p class="description"><?php _e( 'The character(s) that must be placed in the post before the keyword to uniquely identify it.', 'simple-embed-code' ); ?></p></td>
73
  </tr>
74
 
75
  <tr>
76
+ <th scope="row"><label for="code_embed_closing"><?php _e( 'Closing Identifier', 'simple-embed-code' ); ?></label></th>
77
+ <td><input type="text" size="4" maxlength="4" name="code_embed_closing" value="<?php echo esc_html( $options[ 'closing_ident' ] ); ?>"/><p class="description"><?php _e( 'The character(s) that must be placed in the post after the keyword to uniquely identify it.', 'simple-embed-code' ); ?></p></td>
78
  </tr>
79
 
80
  </table>
81
 
82
  <?php wp_nonce_field( 'code-embed-profile', 'code_embed_profile_nonce', true, true ); ?>
83
 
84
+ <br/><input type="submit" name="Submit" class="button-primary" value="<?php _e( 'Save Changes', 'simple-embed-code' ); ?>"/>
85
 
86
  </form>
87
 
90
  // How to embed
91
 
92
  echo "<br/><h3>" . __( 'How to Embed', 'simple-embed-code' ) . "</h3>\n";
93
+ echo '<p>' . sprintf ( __( 'Based upon your current settings to embed some code simply add a custom field named %s, where %s is any suffix you wish. The code to embed is then added as the field value.', 'simple-embed-code' ), '<strong>' . $options[ 'keyword_ident' ] . 'x</strong>', '<strong>x</strong>' ) . "\n";
94
+ echo ' ' . sprintf ( __( 'Then, to add the code into your post simple add %s where you wish it to appear. %s is the suffix you used for the custom field name.', 'simple-embed-code' ), '<strong>' . $options[ 'opening_ident' ] . $options[ 'keyword_ident' ] . "x" . $options[ 'closing_ident' ] . '</strong>', '<strong>x</strong>' ) . "</p>\n";
95
  echo '<p>' . sprintf ( __( 'For example, I may add a custom field named %s, where the value is the code I wish to embed. I would then in my post add %s where I wish the code to then appear.', 'simple-embed-code' ), '<strong>' . $options[ 'keyword_ident' ].'1</strong>', '<strong>' . $options[ 'opening_ident' ] . $options[ 'keyword_ident' ] . "1" . $options[ 'closing_ident' ] . '</strong>' ) . "</p>\n";
96
  echo '<p>' . sprintf ( __( 'To embed the same code but to make it responsive you would use %s. To set a maximum width you would use %s, where %s is the maximum width in pixels.', 'simple-embed-code' ), '<strong>' . $options[ 'opening_ident' ] . $options[ 'keyword_ident' ] . "x_RES" . $options[ 'closing_ident' ] . '</strong>', '<strong>' . $options[ 'opening_ident' ] . $options[ 'keyword_ident' ] . "x_RES_y" . $options[ 'closing_ident' ] . '</strong>', '<strong>y</strong>' ) . "</p>\n";
97
  echo '<p>' . sprintf ( __( 'To embed an external URL you would type %s, where %s is the URL.', 'simple-embed-code' ), '<strong>' . $options[ 'opening_ident' ] . 'url' . $options[ 'closing_ident' ] . '</strong>', '<strong>url</strong>' ) . "</p>\n";
includes/{ace-search.php → search-screen.php} RENAMED
@@ -4,10 +4,8 @@
4
  *
5
  * Allow the user to change the default options
6
  *
7
- * @package Artiss-Code-Embed
8
  * @since 1.6
9
- *
10
- * @uses ace_get_embed_paras Get the options
11
  */
12
  ?>
13
  <div class="wrap">
@@ -22,26 +20,29 @@ echo '<p>' . __( 'Enter the suffix to search for below and press the \'Search\'
22
  ?>
23
 
24
  <?php
 
25
  // Get the suffix - either from the submitted field or via the URL line
 
26
  if ( isset ( $_GET[ 'suffix' ] ) ) {
27
  $suffix = htmlspecialchars( $_GET[ 'suffix' ] );
28
  } else {
29
  if ( ( !empty( $_POST ) ) && ( check_admin_referer( 'code-embed-search' , 'code_embed_search_nonce' ) ) ) {
30
- $suffix = htmlspecialchars( $_POST[ 'ace_suffix' ] );
31
  } else {
32
  $suffix = '';
33
  }
34
  }
35
 
36
  // Fetch options into an array
37
- $options = ace_get_embed_paras();
 
38
  ?>
39
 
40
- <form method="post" action="<?php echo get_bloginfo( 'wpurl' ) . '/wp-admin/admin.php?page=ace-search&amp;updated=true'; ?>">
41
 
42
  <?php echo $options[ 'opening_ident' ] . $options[ 'keyword_ident' ]; ?>
43
 
44
- <input type="text" size="6" name="ace_suffix" value="<?php echo $suffix; ?>"/>
45
 
46
  <?php echo $options[ 'closing_ident' ]; ?>
47
 
4
  *
5
  * Allow the user to change the default options
6
  *
7
+ * @package Code-Embed
8
  * @since 1.6
 
 
9
  */
10
  ?>
11
  <div class="wrap">
20
  ?>
21
 
22
  <?php
23
+
24
  // Get the suffix - either from the submitted field or via the URL line
25
+
26
  if ( isset ( $_GET[ 'suffix' ] ) ) {
27
  $suffix = htmlspecialchars( $_GET[ 'suffix' ] );
28
  } else {
29
  if ( ( !empty( $_POST ) ) && ( check_admin_referer( 'code-embed-search' , 'code_embed_search_nonce' ) ) ) {
30
+ $suffix = htmlspecialchars( $_POST[ 'ce_suffix' ] );
31
  } else {
32
  $suffix = '';
33
  }
34
  }
35
 
36
  // Fetch options into an array
37
+
38
+ $options = get_option( 'artiss_code_embed' );
39
  ?>
40
 
41
+ <form method="post" action="<?php echo get_bloginfo( 'wpurl' ) . '/wp-admin/admin.php?page=ce-search&amp;updated=true'; ?>">
42
 
43
  <?php echo $options[ 'opening_ident' ] . $options[ 'keyword_ident' ]; ?>
44
 
45
+ <input type="text" size="6" name="ce_suffix" value="<?php echo esc_html( $suffix ); ?>"/>
46
 
47
  <?php echo $options[ 'closing_ident' ]; ?>
48
 
languages/simple-embed-code.mo CHANGED
Binary file
languages/simple-embed-code.pot CHANGED
@@ -1,169 +1,228 @@
1
  msgid ""
2
  msgstr ""
3
- "Project-Id-Version: Artiss Code Embed\n"
4
  "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: 2012-03-20 14:13-0000\n"
6
- "PO-Revision-Date: 2012-03-20 14:13-0000\n"
7
  "Last-Translator: David Artiss <david.artiss@artiss.co.uk>\n"
8
- "Language-Team: dartiss\n"
 
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
- "X-Poedit-KeywordsList: __;_e;esc_attr__;esc_attr_e;esc_html__;esc_html_e;_x;_ex;esc_attr_x;esc_html_x;_n;_nx;_n_noop;_nx_noop\n"
 
13
  "X-Poedit-Basepath: ../\n"
 
 
14
  "X-Poedit-SearchPath-0: .\n"
15
 
16
- #: includes/ace-admin-config.php:29
 
 
 
 
 
 
 
 
 
 
 
 
17
  msgid "Settings"
18
  msgstr ""
19
 
20
- #: includes/ace-admin-config.php:53
21
  msgid "Support"
22
  msgstr ""
23
 
24
- #: includes/ace-admin-config.php:54
25
- msgid "Donate"
26
  msgstr ""
27
 
28
- #: includes/ace-admin-config.php:143
29
- msgid "Help & Support"
30
  msgstr ""
31
 
32
- #: includes/ace-admin-config.php:163
33
- msgid "Help"
34
  msgstr ""
35
 
36
- #: includes/ace-admin-config.php:206
37
- msgid "Artiss Code Embed Plugin Documentation"
38
  msgstr ""
39
 
40
- #: includes/ace-admin-config.php:207
41
- msgid "Artiss Code Embed Support Forum"
42
  msgstr ""
43
 
44
- #: includes/ace-admin-config.php:208
45
- msgid "All of my plugins are supported via <a title=\"Artiss.co.uk\" href=\"http://www.artiss.co.uk\" target=\"_blank\">my website</a>. Please feel free to visit the site for plugin updates and development news - either visit the site regularly, follow <a title=\"RSS News Feed\" href=\"http://www.artiss.co.uk/feed\" target=\"_blank\">my news feed</a> or <a title=\"Artiss.co.uk on Twitter\" href=\"http://www.twitter.com/artiss_tech\" target=\"_blank\">follow me on Twitter</a> (@artiss_tech)."
 
 
46
  msgstr ""
47
 
48
- #: includes/ace-admin-config.php:209
49
- #: includes/ace-search.php:55
50
- msgid "This plugin, and all support, is supplied for free, but <a title=\"Donate\" href=\"http://artiss.co.uk/donate\" target=\"_blank\">donations</a> are always welcome."
 
 
51
  msgstr ""
52
 
53
- #: includes/ace-admin-config.php:226
54
- msgid "This screen allows you to search for the post and pages that a particular code embed has been used in."
 
 
55
  msgstr ""
56
 
57
- #: includes/ace-admin-config.php:227
58
- msgid "Simply enter the code suffix that you wish to search for and press the 'Search' key to display a list of all the posts using it. In addition the code will be shown alongside it. Click on the post name to edit the post."
 
 
59
  msgstr ""
60
 
61
- #: includes/ace-admin-config.php:228
62
- msgid "The search results are grouped together in matching code groups, so posts with the same code will be shown together with the same colour background."
 
 
63
  msgstr ""
64
 
65
- #: includes/ace-admin-config.php:289
66
- msgid "Welcome to Artiss Code Embed"
 
 
67
  msgstr ""
68
 
69
- #: includes/ace-admin-config.php:290
70
- msgid "Thank you for installing this plugin."
 
 
 
71
  msgstr ""
72
 
73
- #: includes/ace-admin-config.php:291
74
- msgid "A new menu within 'Settings' will allow you to change the keywords and identifiers used for embedding. A search option also exists in the 'Tools' menu for searching for code embeds."
 
 
75
  msgstr ""
76
 
77
- #: includes/ace-filter.php:182
78
- #, php-format
79
- msgid "Cannot use %s as a global code as it is being used to store %d unique pieces of code in %d posts - <a href=\"%s\">click here</a> for more details"
80
  msgstr ""
81
 
82
- #: includes/ace-filter.php:189
83
- #, php-format
84
- msgid "No embed code was found for %s"
85
  msgstr ""
86
 
87
- #: includes/ace-options.php:16
88
- msgid "Artiss Code Embed Options"
89
  msgstr ""
90
 
91
- #: includes/ace-options.php:40
92
- msgid "Identifier Format"
93
  msgstr ""
94
 
95
- #: includes/ace-options.php:40
96
- msgid "Specify the format that will be used to define the way the code is embedded in your post."
97
  msgstr ""
98
 
99
- #: includes/ace-options.php:40
100
- msgid "The formats are case insensitive and characters &lt; &gt [ ] are invalid."
101
  msgstr ""
102
 
103
- #: includes/ace-options.php:45
 
 
 
 
 
 
 
104
  msgid "Keyword"
105
  msgstr ""
106
 
107
- #: includes/ace-options.php:46
108
- msgid "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."
 
 
 
109
  msgstr ""
110
 
111
- #: includes/ace-options.php:50
112
  msgid "Opening Identifier"
113
  msgstr ""
114
 
115
- #: includes/ace-options.php:51
116
- msgid "The character(s) that must be placed in the post before the keyword to uniquely identify it."
 
 
117
  msgstr ""
118
 
119
- #: includes/ace-options.php:55
120
  msgid "Closing Identifier"
121
  msgstr ""
122
 
123
- #: includes/ace-options.php:56
124
- msgid "The character(s) that must be placed in the post after the keyword to uniquely identify it."
 
 
125
  msgstr ""
126
 
127
- #: includes/ace-options.php:63
128
- msgid "Save Settings"
129
  msgstr ""
130
 
131
- #: includes/ace-options.php:68
132
  msgid "How to Embed"
133
  msgstr ""
134
 
135
- #: includes/ace-options.php:69
136
  #, php-format
137
- msgid "To add a custom field containing embed code simple name it %s, where %s is any suffix you wish. The code to embed is then added as the field value."
 
 
 
138
  msgstr ""
139
 
140
- #: includes/ace-options.php:70
141
  #, php-format
142
- msgid "Then, to add the code into your post simple add %s where you wish it to appear. %s is the suffix you used for the custom field name."
 
 
143
  msgstr ""
144
 
145
- #: includes/ace-options.php:71
146
  #, php-format
147
- msgid "For example, I may add a custom field named %s, where the value is the code I wish to embed. I would then in my post add %s where I wish the code to then appear."
 
 
 
148
  msgstr ""
149
 
150
- #: includes/ace-options.php:72
151
- msgid "Support Information"
 
 
 
152
  msgstr ""
153
 
154
- #: includes/ace-options.php:77
155
- msgid "Useful support information and links can be found by clicking on the Help tab at the top right-hand of the screen."
 
156
  msgstr ""
157
 
158
- #: includes/ace-search.php:21
159
- msgid "Enter the suffix to search for below and press the 'Search' button to view the results. Further help can be found by clicking on the Help tab at the top right-hand of the screen."
 
 
 
160
  msgstr ""
161
 
162
- #: includes/ace-search.php:51
163
  msgid "Search"
164
  msgstr ""
165
 
166
- #: includes/ace-search.php:92
167
  msgid "No posts were found containing that embed code."
168
  msgstr ""
169
-
1
  msgid ""
2
  msgstr ""
3
+ "Project-Id-Version: Code Embed\n"
4
  "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2016-01-30 10:14-0000\n"
6
+ "PO-Revision-Date: 2016-01-30 10:14-0000\n"
7
  "Last-Translator: David Artiss <david.artiss@artiss.co.uk>\n"
8
+ "Language-Team: \n"
9
+ "Language: en_GB\n"
10
  "MIME-Version: 1.0\n"
11
  "Content-Type: text/plain; charset=UTF-8\n"
12
  "Content-Transfer-Encoding: 8bit\n"
13
+ "X-Poedit-KeywordsList: __;_e;esc_attr__;esc_attr_e;esc_html__;esc_html_e;_x;"
14
+ "_ex;esc_attr_x;esc_html_x;_n;_nx;_n_noop;_nx_noop\n"
15
  "X-Poedit-Basepath: ../\n"
16
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
17
+ "X-Generator: Poedit 1.7.5\n"
18
  "X-Poedit-SearchPath-0: .\n"
19
 
20
+ #: includes/add-embeds.php:233
21
+ #, php-format
22
+ msgid ""
23
+ "Cannot use %s as a global code as it is being used to store %d unique pieces "
24
+ "of code in %d posts - <a href=\"%s\">click here</a> for more details"
25
+ msgstr ""
26
+
27
+ #: includes/add-embeds.php:240
28
+ #, php-format
29
+ msgid "No embed code was found for %s"
30
+ msgstr ""
31
+
32
+ #: includes/admin-config.php:29
33
  msgid "Settings"
34
  msgstr ""
35
 
36
+ #: includes/admin-config.php:54
37
  msgid "Support"
38
  msgstr ""
39
 
40
+ #: includes/admin-config.php:79 includes/search-screen.php:16
41
+ msgid "Code Embed Search"
42
  msgstr ""
43
 
44
+ #: includes/admin-config.php:79
45
+ msgid "Code Search"
46
  msgstr ""
47
 
48
+ #: includes/admin-config.php:87
49
+ msgid "Code Embed Settings"
50
  msgstr ""
51
 
52
+ #: includes/admin-config.php:87
53
+ msgid "Code Embed"
54
  msgstr ""
55
 
56
+ #: includes/admin-config.php:112 includes/admin-config.php:132
57
+ msgid "Help"
58
  msgstr ""
59
 
60
+ #: includes/admin-config.php:175
61
+ msgid ""
62
+ "Use this screen to modify the various settings, including the identifiers "
63
+ "and keyword used to specify your embedded code."
64
  msgstr ""
65
 
66
+ #: includes/admin-config.php:176
67
+ msgid ""
68
+ "The first option allows to suppress debug output. Normally this is an HTML "
69
+ "comment in your page source - if you wish to hide this then simply ticket "
70
+ "this option."
71
  msgstr ""
72
 
73
+ #: includes/admin-config.php:177
74
+ msgid ""
75
+ "The second option allows to specify whether code embed requests should work "
76
+ "in excerpts."
77
  msgstr ""
78
 
79
+ #: includes/admin-config.php:178
80
+ msgid ""
81
+ "The keyword is the name used for your custom field. The custom field's value "
82
+ "is the code that you wish to embed."
83
  msgstr ""
84
 
85
+ #: includes/admin-config.php:179
86
+ msgid ""
87
+ "The keyword, sandwiched with the identifier before and after, is what you "
88
+ "then need to add to your post or page to activate the embed code."
89
  msgstr ""
90
 
91
+ #: includes/admin-config.php:196
92
+ msgid ""
93
+ "This screen allows you to search for the post and pages that a particular "
94
+ "code embed has been used in."
95
  msgstr ""
96
 
97
+ #: includes/admin-config.php:197
98
+ msgid ""
99
+ "Simply enter the code suffix that you wish to search for and press the "
100
+ "'Search' key to display a list of all the posts using it. In addition the "
101
+ "code will be shown alongside it. Click on the post name to edit the post."
102
  msgstr ""
103
 
104
+ #: includes/admin-config.php:198
105
+ msgid ""
106
+ "The search results are grouped together in matching code groups, so posts "
107
+ "with the same code will be shown together with the same colour background."
108
  msgstr ""
109
 
110
+ #: includes/options-screen.php:18
111
+ msgid "Code Embed Options"
 
112
  msgstr ""
113
 
114
+ #: includes/options-screen.php:51
115
+ msgid "Hide Debug"
 
116
  msgstr ""
117
 
118
+ #: includes/options-screen.php:52
119
+ msgid "Hide debug HTML comments in source"
120
  msgstr ""
121
 
122
+ #: includes/options-screen.php:56
123
+ msgid "Allow in Excerpts"
124
  msgstr ""
125
 
126
+ #: includes/options-screen.php:57
127
+ msgid "Allow embedded code to be shown in excerpts"
128
  msgstr ""
129
 
130
+ #: includes/options-screen.php:61
131
+ msgid "Identifier Format"
132
  msgstr ""
133
 
134
+ #: includes/options-screen.php:61
135
+ msgid ""
136
+ "Specify the format that will be used to define the way the code is embedded "
137
+ "in your post. The formats are case insensitive and characters &lt; &gt [ ] "
138
+ "are invalid."
139
+ msgstr ""
140
+
141
+ #: includes/options-screen.php:66
142
  msgid "Keyword"
143
  msgstr ""
144
 
145
+ #: includes/options-screen.php:67
146
+ msgid ""
147
+ "The keyword that is used to name the custom field and then place in your "
148
+ "post where the code should be embedded. A suffix on any type can then be "
149
+ "placed on the end."
150
  msgstr ""
151
 
152
+ #: includes/options-screen.php:71
153
  msgid "Opening Identifier"
154
  msgstr ""
155
 
156
+ #: includes/options-screen.php:72
157
+ msgid ""
158
+ "The character(s) that must be placed in the post before the keyword to "
159
+ "uniquely identify it."
160
  msgstr ""
161
 
162
+ #: includes/options-screen.php:76
163
  msgid "Closing Identifier"
164
  msgstr ""
165
 
166
+ #: includes/options-screen.php:77
167
+ msgid ""
168
+ "The character(s) that must be placed in the post after the keyword to "
169
+ "uniquely identify it."
170
  msgstr ""
171
 
172
+ #: includes/options-screen.php:84
173
+ msgid "Save Changes"
174
  msgstr ""
175
 
176
+ #: includes/options-screen.php:92
177
  msgid "How to Embed"
178
  msgstr ""
179
 
180
+ #: includes/options-screen.php:93
181
  #, php-format
182
+ msgid ""
183
+ "Based upon your current settings to embed some code simply add a custom "
184
+ "field named %s, where %s is any suffix you wish. The code to embed is then "
185
+ "added as the field value."
186
  msgstr ""
187
 
188
+ #: includes/options-screen.php:94
189
  #, php-format
190
+ msgid ""
191
+ "Then, to add the code into your post simple add %s where you wish it to "
192
+ "appear. %s is the suffix you used for the custom field name."
193
  msgstr ""
194
 
195
+ #: includes/options-screen.php:95
196
  #, php-format
197
+ msgid ""
198
+ "For example, I may add a custom field named %s, where the value is the code "
199
+ "I wish to embed. I would then in my post add %s where I wish the code to "
200
+ "then appear."
201
  msgstr ""
202
 
203
+ #: includes/options-screen.php:96
204
+ #, php-format
205
+ msgid ""
206
+ "To embed the same code but to make it responsive you would use %s. To set a "
207
+ "maximum width you would use %s, where %s is the maximum width in pixels."
208
  msgstr ""
209
 
210
+ #: includes/options-screen.php:97
211
+ #, php-format
212
+ msgid "To embed an external URL you would type %s, where %s is the URL."
213
  msgstr ""
214
 
215
+ #: includes/search-screen.php:19
216
+ msgid ""
217
+ "Enter the suffix to search for below and press the 'Search' button to view "
218
+ "the results. Further help can be found by clicking on the Help tab at the "
219
+ "top right-hand of the screen."
220
  msgstr ""
221
 
222
+ #: includes/search-screen.php:51
223
  msgid "Search"
224
  msgstr ""
225
 
226
+ #: includes/search-screen.php:91
227
  msgid "No posts were found containing that embed code."
228
  msgstr ""
 
readme.txt CHANGED
@@ -1,10 +1,9 @@
1
  === Code Embed ===
2
- Contributors: dartiss
3
- Donate link: http://artiss.co.uk/donate
4
- Tags: artiss, embed, code, html, javascript, script, simple, video, xhtml, youtube
5
  Requires at least: 3.3
6
- Tested up to: 4.3.1
7
- Stable tag: 2.1.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -33,13 +32,13 @@ Here's how easy it is...
33
 
34
  And that's it - when the post or page is viewed `%CODE1%` will be replaced with the code that you asked to be embedded.
35
 
36
- This should get you started - for more information and advanced options please read the "Other Notes" tab.
37
 
38
  Although this plugin works for both posts and pages for simplicity I will simply refer to posts - bear in mind that pages work in the same way.
39
 
40
  == Options Screen ==
41
 
42
- In the administration menu there is a new settings option named "Code Embed".
43
 
44
  Code embedding is performed via a special keyword that you must use to uniquely identify where you wish the code to appear. This consist of an opening identifier (some that that goes at the beginning), a keyword and then a closing identifier. You may also add a suffix to the end of the keyword if you wish to embed multiple pieces of code within the same post.
45
 
@@ -109,9 +108,9 @@ If you don't wish the output to be full width you can specify a maximum width by
109
 
110
  **It should be noted that this is an experimental addition and will not work in all circumstances.**
111
 
112
- == Licence ==
113
 
114
- This WordPress plugin is licensed under the [GPLv2 (or later)](http://wordpress.org/about/gpl/ "GNU General Public License").
115
 
116
  == Reviews & Mentions ==
117
 
@@ -157,6 +156,16 @@ WordPress stores the custom field contents in a MySQL table using the `longtext`
157
 
158
  == Changelog ==
159
 
 
 
 
 
 
 
 
 
 
 
160
  = 2.1.2 =
161
  * Maintenance: Added missing text domain, ready for automatic translation.
162
 
@@ -230,6 +239,9 @@ versions of this plugin
230
 
231
  == Upgrade Notice ==
232
 
 
 
 
233
  = 2.1.2 =
234
  * Update with text domain, ready for automatic translation
235
 
1
  === Code Embed ===
2
+ Contributors: codedart
3
+ Tags: code, embed, html, javascript, script, simple, video, xhtml, youtube
 
4
  Requires at least: 3.3
5
+ Tested up to: 4.4.2
6
+ Stable tag: 2.2
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
32
 
33
  And that's it - when the post or page is viewed `%CODE1%` will be replaced with the code that you asked to be embedded.
34
 
35
+ This should get you started - for more information and advanced options please read the "Other Notes" tab. Alternatively, there's a fantastic guide at [Elftronix](http://www.elftronix.com/free-easy-plugin-add-javascript-to-wordpress-posts-pages/ "Free Easy Plugin! Add Javascript to WordPress Posts & Pages") which I would recommend.
36
 
37
  Although this plugin works for both posts and pages for simplicity I will simply refer to posts - bear in mind that pages work in the same way.
38
 
39
  == Options Screen ==
40
 
41
+ In the administration menu there is a settings option named "Code Embed".
42
 
43
  Code embedding is performed via a special keyword that you must use to uniquely identify where you wish the code to appear. This consist of an opening identifier (some that that goes at the beginning), a keyword and then a closing identifier. You may also add a suffix to the end of the keyword if you wish to embed multiple pieces of code within the same post.
44
 
108
 
109
  **It should be noted that this is an experimental addition and will not work in all circumstances.**
110
 
111
+ == Embedding in excerpts ==
112
 
113
+ By default embed code will not appear in excerpts. However, you can switch this ability on via the Code Embed options screen. If you do this then the standard rules of excerpts will still apply, but now once the code embed has applied - for example, excerpts are just text, a specific length, etc.
114
 
115
  == Reviews & Mentions ==
116
 
156
 
157
  == Changelog ==
158
 
159
+ = 2.2 =
160
+ * Enhancement: Added support for embedding code in excerpts
161
+ * Enhancement: Validated, sanitised and escaped the admin screen data
162
+ * Maintenance: Overhauled the way default options are fetched and/or generated. Now a lot more efficient
163
+ * Maintenance: Updated the admin screens so they are formatted in a similar way to the default WordPress screens
164
+ * Maintenance: Removed hardcoding of plugin folder
165
+ * Maintenance: Updated author and removed donation links
166
+ * Maintenance: Renamed files and file functions - removed prefix from files and update it on functions
167
+ * Maintenance: Added a domain path for translations
168
+
169
  = 2.1.2 =
170
  * Maintenance: Added missing text domain, ready for automatic translation.
171
 
239
 
240
  == Upgrade Notice ==
241
 
242
+ = 2.2 =
243
+ * Upgrade to add ability to embed code in excerpts. Also tidied and refreshed
244
+
245
  = 2.1.2 =
246
  * Update with text domain, ready for automatic translation
247
 
simple-code-embed.php CHANGED
@@ -3,43 +3,39 @@
3
  Plugin Name: Code Embed
4
  Plugin URI: https://wordpress.org/plugins/simple-code-embed/
5
  Description: Allows you to embed code into your posts & pages
6
- Version: 2.1.2
7
- Author: David Artiss
8
- Author URI: http://www.artiss.co.uk
9
  Text Domain: simple-embed-code
 
10
  */
11
 
12
  /**
13
- * Artiss Code Embed
14
  *
15
  * Embed code into a post
16
  *
17
- * @package Artiss-Code-Embed
18
  * @since 1.6
19
  */
20
 
21
- define( 'artiss_code_embed_version', '2.1.2' );
22
-
23
- function ace_load_plugin_textdomain() {
24
- load_plugin_textdomain( 'simple-embed-code', false, 'simple-embed-code/languages' );
25
- }
26
- add_action( 'init', 'ace_load_plugin_textdomain' );
27
-
28
- $functions_dir = WP_PLUGIN_DIR . '/simple-embed-code/includes/';
29
 
30
  // Include all the various functions
31
 
32
- include_once( $functions_dir . 'ace-get-options.php' ); // Get the default options
 
 
33
 
34
  if ( is_admin() ) {
35
 
36
- include_once( $functions_dir . 'ace-admin-config.php' ); // Various administration config. options
37
 
38
  } else {
39
 
40
- include_once( $functions_dir . 'ace-add-scripts.php' ); // Add scripts to the main theme
41
 
42
- include_once( $functions_dir . 'ace-filter.php' ); // Filter to apply code embeds
43
 
44
  }
45
  ?>
3
  Plugin Name: Code Embed
4
  Plugin URI: https://wordpress.org/plugins/simple-code-embed/
5
  Description: Allows you to embed code into your posts & pages
6
+ Version: 2.2
7
+ Author: Coded Art
8
+ Author URI: http://codedart.co
9
  Text Domain: simple-embed-code
10
+ Domain Path: /languages
11
  */
12
 
13
  /**
14
+ * Code Embed
15
  *
16
  * Embed code into a post
17
  *
18
+ * @package Code-Embed
19
  * @since 1.6
20
  */
21
 
22
+ define( 'code_embed_version', '2.2' );
 
 
 
 
 
 
 
23
 
24
  // Include all the various functions
25
 
26
+ $functions_dir = plugin_dir_path( __FILE__ ) . 'includes/';
27
+
28
+ include_once( $functions_dir . 'initialise.php' ); // Initialisation scripts
29
 
30
  if ( is_admin() ) {
31
 
32
+ include_once( $functions_dir . 'admin-config.php' ); // Various administration config. options
33
 
34
  } else {
35
 
36
+ include_once( $functions_dir . 'add-scripts.php' ); // Add scripts to the main theme
37
 
38
+ include_once( $functions_dir . 'add-embeds.php' ); // Filter to apply code embeds
39
 
40
  }
41
  ?>
uninstall.php CHANGED
@@ -4,17 +4,17 @@
4
  *
5
  * Uninstall the plugin by removing any options from the database
6
  *
7
- * @package Artiss-Code-Embed
8
  * @since 1.6
9
  */
10
 
11
  // If the uninstall was not called by WordPress, exit
 
12
  if ( !defined( 'WP_UNINSTALL_PLUGIN' ) ) {
13
  exit();
14
  }
15
 
16
  // Delete any options
17
- delete_option( 'artiss_code_embed' );
18
- delete_option( 'simple_code_embed' );
19
- delete_option( 'artiss_code_embed_activated' );
20
  ?>
4
  *
5
  * Uninstall the plugin by removing any options from the database
6
  *
7
+ * @package Code-Embed
8
  * @since 1.6
9
  */
10
 
11
  // If the uninstall was not called by WordPress, exit
12
+
13
  if ( !defined( 'WP_UNINSTALL_PLUGIN' ) ) {
14
  exit();
15
  }
16
 
17
  // Delete any options
18
+
19
+ delete_site_option( 'artiss_code_embed' );
 
20
  ?>