/** * Add filter to add embed code * * Filter to add embed to any posts * * @since 1.5 * * @uses ace_get_embed_paras Get default options * @uses ace_get_embed_code Get embed code from other posts * * @param string $content Post content without embedded code * @return string Post content with embedded code */ function ace_filter($content) { global $post; // Set initial values $options = ace_get_embed_paras(); $found_pos = strpos($content, $options['opening_ident'] . $options['keyword_ident'], 0); $prefix_len = strlen($options['opening_ident'] . $options['keyword_ident']); // Loop around the post content looking for all requests for code embeds while ($found_pos !== false) { // Get the position of the closing identifier - ignore if one is not found $end_pos = strpos($content, $options['closing_ident'], $found_pos + $prefix_len); if ($end_pos !== false) { // Extract the suffix $suffix_len = $end_pos - ($found_pos + $prefix_len); if ($suffix_len == 0) { $suffix = ''; } else { $suffix = substr($content, $found_pos + $prefix_len, $suffix_len); } $full_suffix = $suffix; // Check for responsive part of suffix $responsive = false; $max_width = false; $res_pos = false; if (strlen($suffix) > 1) { $res_pos = strpos($suffix, '_RES', 1); } if ($res_pos !== false) { // If responsive section found, check it's at the end of has an underscore afterwards // Otherwise it may be part of something else if ($res_pos == strlen($suffix) - 4) { $responsive = true; } else { if (substr($suffix, $res_pos + 4, 1) == '_') { $responsive = true; $max_width = substr($suffix, $res_pos + 5); if (!is_numeric($max_width)) { $max_width = ''; } } } if ($responsive) { $suffix = substr($suffix, 0, $res_pos); } } // Get the custom field data and replace in the post $search = $options['opening_ident'] . $options['keyword_ident'] . $suffix . $options['closing_ident']; ///////////////////////// Place the following section in a seperate routine - can be shared with new SEO functions // Get the meta for the current post $post_meta = get_post_meta($post->ID, $options['keyword_ident'] . $suffix, false); if (isset($post_meta[0])) { $html = $post_meta[0]; } else { // No meta found, so look for it elsewhere $html = ace_get_embed_code($options['keyword_ident'], $suffix); } ///////////////////////////// // Build the string to search for $search = $options['opening_ident'] . $options['keyword_ident'] . $full_suffix . $options['closing_ident']; // Build the string of code to replace with $replace = ace_generate_code($html, 'Artiss Code Embed', $responsive, $max_width); // Now modify all references $content = str_replace($search, $replace, $content); } $found_pos = strpos($content, $options['opening_ident'] . $options['keyword_ident'], $found_pos + 1); } // Loop around the post content looking for HTTP addresses $content = ace_quick_replace($content, $options, 'http://'); // Loop around the post content looking for HTTPS addresses $content = ace_quick_replace($content, $options, 'https://'); return $content; }
echo plugins_url(); ?> /simple-embed-code/images/screen_icon.png" alt="" title="" height="32px" width="32px"/><br /></div> <h2><?php _e('Artiss Code Embed Support'); ?> </h2> <p><?php echo sprintf(__('You are using Artiss Code Embed version %s. It was written by David Artiss.'), artiss_code_embed_version); ?> </p> <?php $options = ace_get_embed_paras(); // How to embed echo "<h3>" . __('How to Embed') . "</h3>\n"; 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.'), '<strong>' . $options['keyword_ident'] . 'x</strong>', '<strong>x</strong>') . "</p>\n"; 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.'), '<strong>' . $options['opening_ident'] . $options['keyword_ident'] . "x" . $options['closing_ident'] . '</strong>', '<strong>x</strong>') . "</p>\n"; 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.'), '<strong>' . $options['keyword_ident'] . '1</strong>', '<strong>' . $options['opening_ident'] . $options['keyword_ident'] . "1" . $options['closing_ident'] . '</strong>') . "</p>\n"; 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.'), '<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"; echo '<p>' . sprintf(__('To embed an external URL you would type %s, where %s is the URL.'), '<strong>' . $options['opening_ident'] . 'url' . $options['closing_ident'] . '</strong>', '<strong>url</strong>') . "</p>\n"; // Support information echo '<h3>' . __('Support Information') . "</h3>\n"; echo '<p><a href="http://www.artiss.co.uk/code-embed">' . __('Artiss Code Embed Plugin Documentation') . "</a></p>\n"; echo '<p><a href="http://www.artiss.co.uk/forum/specific-plugins-group2/artiss-code-embed-forum3">' . __('Artiss Code Embed Support Forum') . "</a></p>\n"; echo '<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>\n"; // Acknowledgements echo '<h3>' . __('Acknowledgements') . "</h3>\n"; echo '<p>' . sprintf(__('Images have been compressed with %s.'), '<a href="http://www.smushit.com/ysmush.it/">Smush.it</a>') . "</p>\n";