Version Description
- Renamed plugin to bring in line with new plugin conventions
- Plugin re-write to create more efficient code - can now also completely personalise the embed code used in the post
- PHPDoc used throughout for documentation purposes, plus new coding standards
- Support information improved, including contextual help on the settings screen (if supported)
- All of the changes are backwards compatible with previous versions of this plugin
- Instructions completely re-written
=
Download this release
Release Info
Developer | dartiss |
Plugin | Code Embed |
Version | 1.5 |
Comparing to | |
See all releases |
Code changes from version 1.4.1 to 1.5
- readme.txt +74 -26
- screenshot-1.png +0 -0
- screenshot-2.png +0 -0
- screenshot-3.png +0 -0
- simple-code-embed-options.php +56 -29
- simple-code-embed.php +138 -32
readme.txt
CHANGED
@@ -1,55 +1,92 @@
|
|
1 |
-
===
|
2 |
Contributors: dartiss
|
3 |
Donate link: http://artiss.co.uk/donate
|
4 |
-
Tags:
|
5 |
Requires at least: 2.0.0
|
6 |
-
Tested up to: 3.
|
7 |
-
Stable tag: 1.
|
8 |
|
9 |
-
Embed
|
10 |
|
11 |
== Description ==
|
12 |
|
13 |
-
|
14 |
|
15 |
-
This plugin
|
16 |
|
17 |
-
|
18 |
|
19 |
-
|
20 |
|
21 |
-
|
22 |
|
23 |
-
|
24 |
-
`<param name="movie" value="http://www.youtube.com/v/oHg5SJYRHA0&hl=en&fs=1"></param>`
|
25 |
-
`<param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param>`
|
26 |
-
`<embed src="http://www.youtube.com/v/oHg5SJYRHA0&hl=en&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed>`
|
27 |
-
`</object>`
|
28 |
|
29 |
-
|
30 |
|
31 |
-
|
32 |
|
33 |
-
The
|
34 |
|
35 |
-
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
|
38 |
== Installation ==
|
39 |
|
40 |
-
1. Upload the entire `simple-code-embed` folder to your
|
41 |
2. Activate the plugin through the 'Plugins' menu in WordPress.
|
|
|
|
|
42 |
|
43 |
== Frequently Asked Questions ==
|
44 |
|
45 |
-
= How can I get help or request possible changes =
|
46 |
-
|
47 |
-
Feel free to report any problems, or suggestions for enhancements, to me either via [my contact form](http://www.artiss.co.uk/contact "Contact Me") or by [the plugins' homepage](http://www.artiss.co.uk/simple-code-embed "Simple Code Embed").
|
48 |
-
|
49 |
= My code doesn't work =
|
50 |
|
51 |
If you code contains the characters `]]>` then you'll find that it doesn't - WordPress modifies this itself.
|
52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
== Changelog ==
|
54 |
|
55 |
= 1.0 =
|
@@ -72,6 +109,14 @@ If you code contains the characters `]]>` then you'll find that it doesn't - Wor
|
|
72 |
= 1.4.1 =
|
73 |
* Version details as HTML comments were being output whether an embed existed or not - corrected
|
74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
== Upgrade Notice ==
|
76 |
|
77 |
= 1.3 =
|
@@ -81,4 +126,7 @@ If you code contains the characters `]]>` then you'll find that it doesn't - Wor
|
|
81 |
* Update to specify your own embed word and max. embeds per post
|
82 |
|
83 |
= 1.4.1 =
|
84 |
-
* Minor bug fix
|
|
|
|
|
|
1 |
+
=== Artiss Code Embed ===
|
2 |
Contributors: dartiss
|
3 |
Donate link: http://artiss.co.uk/donate
|
4 |
+
Tags: embed, code, artiss, script, HTML, JavaScript, XHTML, YouTube, video
|
5 |
Requires at least: 2.0.0
|
6 |
+
Tested up to: 3.1.2
|
7 |
+
Stable tag: 1.5
|
8 |
|
9 |
+
Artiss Code Embed (formally Simple Code Embed) provides a very easy and efficient way to embed code (JavaScript and HTML) in your posts and pages.
|
10 |
|
11 |
== Description ==
|
12 |
|
13 |
+
Artiss Code Embed (formally Simple Code Embed) allows you to embed code - JavaScript and HTML primarily - in a post. This is incredibly useful for embedding video, etc, when required. It cannot be used for server side code, such as PHP.
|
14 |
|
15 |
+
This plugin works for both posts and pages. However, for simplicity I will simply refer to posts - bear in mind that pages work in the same way.
|
16 |
|
17 |
+
**Options Screen**
|
18 |
|
19 |
+
To use first of all visit the options page. In the Administration menu, under the Settings section there will a new settings option titled "Code Embed". Click on this and an options screen will appear.
|
20 |
|
21 |
+
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.
|
22 |
|
23 |
+
From this options screen you can specify the above identifier that you wish to use. By default the opening and closing identifiers are percentage signs and the keyword is `CODE`. During these instructions these will be used in all examples.
|
|
|
|
|
|
|
|
|
24 |
|
25 |
+
**Embedding**
|
26 |
|
27 |
+
To embed in a post you need to find the meta box under the post named "Custom Fields". If this is missing you may need to add it by clicking on the "Screen Options" tab at the top of the new post screen.
|
28 |
|
29 |
+
Now create a new custom field with the name of your keyword - e.g. `CODE`. The value of this field will be the code that you wish to embed. Save this custom field.
|
30 |
|
31 |
+
Now, wherever you wish the code to appear in your post, simply put the full identifier (opening, keyword and closing characters). For example, `%CODE%`.
|
32 |
+
|
33 |
+
If you wish to embed multiple pieces of code within a post you can add a suffix to the keyword. So we may set up 2 custom fields named `CODE1` and `CODE2`. Then in our post we would specify either `%CODE1%` or `%CODE2%` depending on which you wish to display.
|
34 |
+
|
35 |
+
Don't forget - via the options screen you can change any part of this identifier to your own taste.
|
36 |
+
|
37 |
+
**For help with this plugin, or simply to comment or get in touch, please read the appropriate section in "Other Notes" for details. This plugin, and all support, is supplied for free, but [donations](http://artiss.co.uk/donate "Donate") are always welcome.**
|
38 |
+
|
39 |
+
== Licence ==
|
40 |
+
|
41 |
+
This WordPRess plugin is licensed under the [GPLv2 (or later)](http://wordpress.org/about/gpl/ "GNU General Public License").
|
42 |
+
|
43 |
+
== Support ==
|
44 |
+
|
45 |
+
All of my plugins are supported via [my website](http://www.artiss.co.uk "Artiss.co.uk").
|
46 |
+
|
47 |
+
Please feel free to visit the site for plugin updates and development news - either visit the site regularly, follow [my news feed](http://www.artiss.co.uk/feed "RSS News Feed") or [follow me on Twitter](http://www.twitter.com/artiss_tech "Artiss.co.uk on Twitter") (@artiss_tech).
|
48 |
+
|
49 |
+
For problems, suggestions or enhancements for this plugin, there is [a dedicated page](http://www.artiss.co.uk/code-embed "Simple Code Embed") and [a forum](http://www.artiss.co.uk/forum "WordPress Plugins Forum"). The dedicated page will also list any known issues and planned enhancements.
|
50 |
+
|
51 |
+
**This plugin, and all support, is supplied for free, but [donations](http://artiss.co.uk/donate "Donate") are always welcome.**
|
52 |
+
|
53 |
+
== Reviews & Mentions ==
|
54 |
+
|
55 |
+
"Works like a dream. Fantastic!" - Anita.
|
56 |
+
|
57 |
+
"Thank you for this plugin. I tried numerous other iframe plugins and none of them would work for me! This plugin worked like a charm the FIRST time." - KerryAnn May.
|
58 |
+
|
59 |
+
[Embedding content](http://wsdblog.westbrook.k12.me.us/blog/2009/12/24/embedding-content/ "Embedding content") - WSD Blogging Server.
|
60 |
+
|
61 |
+
[Animating images with PhotoPeach](http://comohago.conectandonos.gov.ar/2009/08/05/animando-imagenes-con-photopeach/ "Animando imágenes con PhotoPeach") - Cómo hago.
|
62 |
|
63 |
== Installation ==
|
64 |
|
65 |
+
1. Upload the entire `simple-code-embed` folder to your wp-content/plugins/ directory.
|
66 |
2. Activate the plugin through the 'Plugins' menu in WordPress.
|
67 |
+
3. Under the Settings section of the administration menu there should now be a new option named "Code Embed". Select this option to set the default options.
|
68 |
+
4. Add the identifier code to the appropriate posts and pages where you wish the code to be embedded.
|
69 |
|
70 |
== Frequently Asked Questions ==
|
71 |
|
|
|
|
|
|
|
|
|
72 |
= My code doesn't work =
|
73 |
|
74 |
If you code contains the characters `]]>` then you'll find that it doesn't - WordPress modifies this itself.
|
75 |
|
76 |
+
= What's the maximum size of the embed code that I can save in a custom field? =
|
77 |
+
|
78 |
+
WordPress stores the custom field contents in a MySQL table using the `longtext` format. This can hold over 4 billion characters.
|
79 |
+
|
80 |
+
= Which version of PHP does this plugin work with? =
|
81 |
+
|
82 |
+
It has been tested and been found valid from PHP 4 upwards.
|
83 |
+
|
84 |
+
== Screenshots ==
|
85 |
+
|
86 |
+
1. The custom field meta box with a Code Embed field set up to show some YouTube embed code
|
87 |
+
2. Example embed code in a post
|
88 |
+
3. The resultant video from the previous example code
|
89 |
+
|
90 |
== Changelog ==
|
91 |
|
92 |
= 1.0 =
|
109 |
= 1.4.1 =
|
110 |
* Version details as HTML comments were being output whether an embed existed or not - corrected
|
111 |
|
112 |
+
= 1.5 =
|
113 |
+
* Renamed plugin to bring in line with new plugin conventions
|
114 |
+
* Plugin re-write to create more efficient code - can now also completely personalise the embed code used in the post
|
115 |
+
* PHPDoc used throughout for documentation purposes, plus new coding standards
|
116 |
+
* Support information improved, including contextual help on the settings screen (if supported)
|
117 |
+
* All of the changes are backwards compatible with previous versions of this plugin
|
118 |
+
* Instructions completely re-written
|
119 |
+
|
120 |
== Upgrade Notice ==
|
121 |
|
122 |
= 1.3 =
|
126 |
* Update to specify your own embed word and max. embeds per post
|
127 |
|
128 |
= 1.4.1 =
|
129 |
+
* Minor bug fix
|
130 |
+
|
131 |
+
= 1.5 =
|
132 |
+
* Much more efficient performance and ability to totally personalise the embed code used in posts
|
screenshot-1.png
ADDED
Binary file
|
screenshot-2.png
ADDED
Binary file
|
screenshot-3.png
ADDED
Binary file
|
simple-code-embed-options.php
CHANGED
@@ -1,52 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<div class="wrap">
|
2 |
<?php screen_icon(); ?>
|
3 |
-
<h2>
|
4 |
<?php
|
5 |
// If options have been updated on screen, update the database
|
6 |
-
if(!empty($_POST['Submit'])) {
|
7 |
-
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
}
|
|
|
11 |
// Fetch options into an array
|
12 |
-
$options=
|
13 |
-
// Set defaults if no array is defined
|
14 |
-
if (!is_array($options)) {
|
15 |
-
echo "<div class=\"updated\"><p><strong>Please review the options below and click \"Save Settings\" to update them.</strong></p></div>\n";
|
16 |
-
$options = array('prefix'=>'CODE','number'=>'20');}
|
17 |
?>
|
18 |
|
19 |
-
<form
|
20 |
-
<input type="hidden" name="cmd" value="_s-xclick"/>
|
21 |
-
<input type="hidden" name="hosted_button_id" value="2827258"/>
|
22 |
-
<input type="image" src="https://www.paypal.com/en_GB/i/btn/btn_donate_SM.gif" name="submit" alt="Donate!"/>
|
23 |
-
<img alt="" border="0" src="https://www.paypal.com/en_GB/i/scr/pixel.gif" width="1" height="1"/>
|
24 |
-
</form>
|
25 |
|
26 |
-
|
27 |
|
28 |
-
<form method="post" action="<?php echo get_bloginfo('wpurl').'/wp-admin/options-general.php?page=simple-code-embed-settings&updated=true' ?>">
|
29 |
<table class="form-table">
|
30 |
|
31 |
<tr>
|
32 |
-
<th scope="row"><?php _e('
|
33 |
-
<td><input type="text" size="12" maxlength="12" name="
|
|
|
|
|
|
|
|
|
|
|
34 |
</tr>
|
35 |
|
36 |
<tr>
|
37 |
-
<th scope="row"><?php _e('
|
38 |
-
<td><input type="text" size="
|
39 |
</tr>
|
40 |
|
41 |
</table>
|
42 |
-
|
43 |
-
<input type="submit" name="Submit" class="button-primary" value="<?php _e('Save Settings'); ?>"/>
|
44 |
-
|
45 |
</form>
|
46 |
|
47 |
-
|
48 |
-
|
49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
-
<p><a href="http://validator.w3.org"><img src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Transitional" height="31px" width="88px" style="float: right"/></a></p>
|
52 |
</div>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Code Embed Options
|
4 |
+
*
|
5 |
+
* Allow the user to change the default options
|
6 |
+
*
|
7 |
+
* @package Artiss-Code-Embed
|
8 |
+
* @since 1.4
|
9 |
+
*
|
10 |
+
* @uses artiss_code_embed_help Return help text
|
11 |
+
*/
|
12 |
+
?>
|
13 |
<div class="wrap">
|
14 |
<?php screen_icon(); ?>
|
15 |
+
<h2>Artiss Code Embed Options</h2>
|
16 |
<?php
|
17 |
// If options have been updated on screen, update the database
|
18 |
+
if( !empty( $_POST[ 'Submit' ] ) ) {
|
19 |
+
|
20 |
+
// Update the options array from the form fields. Strip invalid tags.
|
21 |
+
$options[ 'opening_ident' ] = strtoupper( trim( $_POST[ 'code_embed_opening' ], '[]<>' ) );
|
22 |
+
$options[ 'keyword_ident' ] = strtoupper( trim( $_POST[ 'code_embed_keyword' ], '[]<>' ) );
|
23 |
+
$options[ 'closing_ident' ] = strtoupper( trim( $_POST[ 'code_embed_closing' ], '[]<>' ) );
|
24 |
+
|
25 |
+
// If any fields are blank assign default values
|
26 |
+
if ( $options[ 'opening_ident' ] == "" ) {$options[ 'opening_ident' ] = "%";}
|
27 |
+
if ( $options[ 'keyword_ident' ] == "" ) {$options[ 'keyword_ident' ] = "CODE";}
|
28 |
+
if ( $options[ 'closing_ident' ] == "" ) {$options[ 'closing_ident' ] = "%";}
|
29 |
+
|
30 |
+
update_option( 'artiss_code_embed', $options );
|
31 |
}
|
32 |
+
|
33 |
// Fetch options into an array
|
34 |
+
$options = get_code_embed_paras();
|
|
|
|
|
|
|
|
|
35 |
?>
|
36 |
|
37 |
+
<form method="post" action="<?php echo get_bloginfo('wpurl').'/wp-admin/options-general.php?page=artiss-code-embed-settings&updated=true' ?>">
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
+
<?php _e( '<h3>Identifier Format</h3>Specify the format that will be used to define the way the code is embedded in your post.<br/>The formats are case insensitive and characters < > [ ] are invalid.' ); ?>
|
40 |
|
|
|
41 |
<table class="form-table">
|
42 |
|
43 |
<tr>
|
44 |
+
<th scope="row"><?php _e('Keyword'); ?></th>
|
45 |
+
<td><input type="text" size="12" maxlength="12" name="code_embed_keyword" value="<?php echo $options['keyword_ident']; ?>"/> <span class="description">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.</span></td>
|
46 |
+
</tr>
|
47 |
+
|
48 |
+
<tr>
|
49 |
+
<th scope="row"><?php _e('Opening Identifier'); ?></th>
|
50 |
+
<td><input type="text" size="4" maxlength="4" name="code_embed_opening" value="<?php echo $options['opening_ident']; ?>"/> <span class="description">The character(s) that must be placed in the post before the keyword to uniquely identify it.</span></td>
|
51 |
</tr>
|
52 |
|
53 |
<tr>
|
54 |
+
<th scope="row"><?php _e('Closing Identifier'); ?></th>
|
55 |
+
<td><input type="text" size="4" maxlength="4" name="code_embed_closing" value="<?php echo $options['closing_ident']; ?>"/> <span class="description">The character(s) that must be placed in the post after the keyword to uniquely identify it.</span></td>
|
56 |
</tr>
|
57 |
|
58 |
</table>
|
59 |
+
|
60 |
+
<br/><input type="submit" name="Submit" class="button-primary" value="<?php _e('Save Settings'); ?>"/>
|
61 |
+
|
62 |
</form>
|
63 |
|
64 |
+
<?php
|
65 |
+
|
66 |
+
_e( '<h3>How to Embed</h3>' );
|
67 |
+
_e( '<p>To add a custom field containing embed code simple name it <strong>'.$options[ 'keyword_ident'].'x</strong>, where <strong>x</strong> is any suffix you wish. The code to embed is then added as the field value.</p>' );
|
68 |
+
_e( '<p>Then, to add the code into your post simple add <strong>'.$options[ 'opening_ident'].$options[ 'keyword_ident']."x".$options[ 'closing_ident'].'</strong> where you wish it to appear. <strong>x</strong> is the suffix you used for the custom field name.</p>' );
|
69 |
+
_e( '<p>For example, I may add a custom field named <strong>'.$options[ 'keyword_ident'].'1</strong>, where the value is the code I wish to embed. I would then in my post add <strong>'.$options[ 'opening_ident'].$options[ 'keyword_ident']."1".$options[ 'closing_ident'].'</strong> where I wish the code to then appear.</p>' );
|
70 |
+
|
71 |
+
_e( '<h3>Support Information</h3>' );
|
72 |
+
if ( !function_exists( 'add_contextual_help' ) ) {
|
73 |
+
_e( artiss_code_embed_help() );
|
74 |
+
} else {
|
75 |
+
_e( '<p>Useful support information and links can be found by clicking on the Help tab at the top right-hand of the screen.</p>' );
|
76 |
+
}
|
77 |
+
?>
|
78 |
|
|
|
79 |
</div>
|
simple-code-embed.php
CHANGED
@@ -1,43 +1,149 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
-
Plugin Name:
|
4 |
-
Plugin URI: http://www.artiss.co.uk/
|
5 |
Description: Allows you to embed code into your posts & pages
|
6 |
-
Version: 1.
|
7 |
Author: David Artiss
|
8 |
Author URI: http://www.artiss.co.uk
|
9 |
*/
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
}
|
34 |
|
35 |
-
|
36 |
-
|
37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
}
|
39 |
|
40 |
-
|
41 |
-
|
42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
?>
|
1 |
<?php
|
2 |
/*
|
3 |
+
Plugin Name: Artiss Code Embed
|
4 |
+
Plugin URI: http://www.artiss.co.uk/artiss-code-embed
|
5 |
Description: Allows you to embed code into your posts & pages
|
6 |
+
Version: 1.5
|
7 |
Author: David Artiss
|
8 |
Author URI: http://www.artiss.co.uk
|
9 |
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Artiss Code Embed
|
13 |
+
*
|
14 |
+
* Embed code into a post
|
15 |
+
*
|
16 |
+
* @package Artiss-Code-Embed
|
17 |
+
*/
|
18 |
+
|
19 |
+
define( 'artiss_code_embed_version', '1.5' );
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Artiss Code Embed
|
23 |
+
*
|
24 |
+
* Filter to add embed to any posts
|
25 |
+
*
|
26 |
+
* @since 1.5
|
27 |
+
*
|
28 |
+
* @uses get_code_embed_paras Get default options
|
29 |
+
*
|
30 |
+
* @param string $content Post content without embedded code
|
31 |
+
* @return string Post content with embedded code
|
32 |
+
*/
|
33 |
+
add_filter( 'the_content', 'artiss_code_embed' );
|
34 |
+
function artiss_code_embed( $content ) {
|
35 |
+
|
36 |
+
$plugin_name = 'Artiss Code Embed';
|
37 |
+
global $post;
|
38 |
+
|
39 |
+
// Set initial values
|
40 |
+
$options = get_code_embed_paras();
|
41 |
+
$found_pos = strpos( $content, $options[ 'opening_ident' ] . $options[ 'keyword_ident' ], 0 );
|
42 |
+
$prefix_len = strlen( $options[ 'opening_ident' ] . $options[ 'keyword_ident' ] );
|
43 |
+
|
44 |
+
// Loop around the post content looking for all requests for code embeds
|
45 |
+
while ( $found_pos !== false ) {
|
46 |
+
|
47 |
+
// Get the position of the closing identifier - ignore if one is not found
|
48 |
+
$end_pos = strpos( $content, $options[ 'closing_ident' ], $found_pos + $prefix_len );
|
49 |
+
if ( $end_pos !== false ) {
|
50 |
+
|
51 |
+
// Extract the suffix
|
52 |
+
$suffix_len = $end_pos - ( $found_pos + $prefix_len );
|
53 |
+
if ( $suffix_len == 0 ) {
|
54 |
+
$suffix = '';
|
55 |
+
} else {
|
56 |
+
$suffix = substr( $content, $found_pos + $prefix_len, $suffix_len );
|
57 |
+
}
|
58 |
+
|
59 |
+
// Get the custom field data and replace in the post
|
60 |
+
if ( $suffix_len < 13 ) {
|
61 |
+
$html = get_post_meta( $post -> ID, $options[ 'keyword_ident' ].$suffix, false );
|
62 |
+
$search = $options[ 'opening_ident' ] . $options[ 'keyword_ident' ] . $suffix . $options[ 'closing_ident' ];
|
63 |
+
$replace = '<!-- ' . $plugin_name . ' v' . artiss_code_embed_version . ' | http://www.artiss.co.uk/' . str_replace( ' ', '-', strtolower( $plugin_name ) ) . " -->\n" . $html[ 0 ] .= '<!-- End of ' . $plugin_name . " code -->\n";
|
64 |
+
$content = str_replace($search , $replace, $content );
|
65 |
+
}
|
66 |
+
}
|
67 |
+
$found_pos = strpos( $content, $options[ 'opening_ident' ] . $options[ 'keyword_ident' ], $found_pos + 1 );
|
68 |
+
}
|
69 |
+
|
70 |
+
return $content;
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Get Code Embed Parameters
|
75 |
+
*
|
76 |
+
* Fetch options - if none exist set them. If the old options exist, move them over
|
77 |
+
*
|
78 |
+
* @since 1.5
|
79 |
+
*
|
80 |
+
* @return string Array of default options
|
81 |
+
*/
|
82 |
+
function get_code_embed_paras() {
|
83 |
+
|
84 |
+
$options = get_option( 'artiss_code_embed' );
|
85 |
+
$changed = false;
|
86 |
+
|
87 |
+
// If array doesn't exist, set defaults
|
88 |
+
if ( !is_array( $options ) ) {
|
89 |
+
$options = array( 'opening_ident' => '%', 'keyword_ident' => 'CODE', 'closing_ident' => '%' );
|
90 |
+
$changed = true;
|
91 |
+
}
|
92 |
+
|
93 |
+
// If the old options exist, import and delete them
|
94 |
+
if ( get_option( 'simple_code_embed' ) ) {
|
95 |
+
$old_option = get_option( 'simple_code_embed' );
|
96 |
+
$options[ 'keyword_ident' ] = $old_option[ 'prefix'];
|
97 |
+
delete_option( 'simple_code_embed' );
|
98 |
+
$changed = true;
|
99 |
+
}
|
100 |
+
|
101 |
+
// Update the options, if changed, and return the result
|
102 |
+
if ( $changed ) {update_option( 'artiss_code_embed', $options );}
|
103 |
+
|
104 |
+
return $options;
|
105 |
}
|
106 |
|
107 |
+
/**
|
108 |
+
* Code Embed Menu
|
109 |
+
*
|
110 |
+
* Add a new option to the Admin menu
|
111 |
+
*
|
112 |
+
* @since 1.4
|
113 |
+
*
|
114 |
+
* @uses artiss_code_embed_help Return help text
|
115 |
+
*/
|
116 |
+
add_action( 'admin_menu','artiss_code_embed_menu' );
|
117 |
+
function artiss_code_embed_menu() {
|
118 |
+
$code_embed_hook = add_options_page( 'Artiss Code Embed Settings', 'Code Embed', 10, 'artiss-code-embed-settings', 'artiss_code_embed_options' );
|
119 |
+
if ( function_exists( 'add_contextual_help' ) ) {add_contextual_help( $code_embed_hook, __( artiss_code_embed_help() ) );}
|
120 |
}
|
121 |
|
122 |
+
/**
|
123 |
+
* Code Embed Options
|
124 |
+
*
|
125 |
+
* Define an option screen
|
126 |
+
*
|
127 |
+
* @since 1.4
|
128 |
+
*/
|
129 |
+
function artiss_code_embed_options() {
|
130 |
+
include_once( WP_PLUGIN_DIR . '/' . str_replace( basename( __FILE__ ), '', plugin_basename( __FILE__ ) ) . "/simple-code-embed-options.php" );
|
131 |
+
}
|
132 |
+
|
133 |
+
/**
|
134 |
+
* Code Embed Help
|
135 |
+
*
|
136 |
+
* Return help text
|
137 |
+
*
|
138 |
+
* @since 1.5
|
139 |
+
*
|
140 |
+
* @return string Help Text
|
141 |
+
*/
|
142 |
+
function artiss_code_embed_help() {
|
143 |
+
$help_text = '<p><a href="http://www.artiss.co.uk/code-embed">Artiss Code Embed Plugin Documentation</a></p>';
|
144 |
+
$help_text .= '<p><a href="http://www.artiss.co.uk/forum/specific-plugins-group2/artiss-code-embed-forum3">Artiss Code Embed Support Forum</a></p>';
|
145 |
+
$help_text .= '<p>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).</p>';
|
146 |
+
$help_text .= '<h4>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.</h4>';
|
147 |
+
return $help_text;
|
148 |
+
}
|
149 |
?>
|