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

secure.php in Code Embed 2.5.1, at includes/secure.php

56 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Meta boxes
4 *
5 * Functions related to meta-box management.
6 *
7 * @package simple-embed-code
8 */
9
10 // Exit if accessed directly.
11
12 if ( ! defined( 'ABSPATH' ) ) {
13 exit;
14 }
15
16 /**
17 * Remove Custom Fields
18 *
19 * Remove the custom field meta boxes if the user doesn't have the unfiltered HTML permissions.
20 *
21 * @param string $post_id Post ID.
22 * @param string $post Post object.
23 * @param boolean $update Whether this is an existing post being updated.
24 */
25 function sec_check_post_fields( $post_id, $post, $update ) {
26
27 $options = get_option( 'artiss_code_embed' );
28
29 // Check if it's an autosave or if the current user has the 'unfiltered_html' capability.
30 if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || ( current_user_can( 'unfiltered_html' ) ) ) {
31 return;
32 }
33
34 // Fetch all post meta (custom fields) associated with the post.
35 $custom_fields = get_post_meta( $post_id );
36
37 // If there are custom fields, read through them.
38 if ( ! empty( $custom_fields ) ) {
39
40 foreach ( $custom_fields as $key => $value ) {
41
42 // Check to see if any begining with this plugin's prefix.
43 if ( substr( $key, 0, strlen( $options['keyword_ident'] ) ) === $options['keyword_ident'] ) {
44
45 // Filter the meta value.
46 $new_value = wp_kses_post( $value[0] );
47
48 // Now write out the new value.
49 update_post_meta( $post_id, $key, $new_value );
50 }
51 }
52 }
53 }
54
55 add_action( 'save_post', 'sec_check_post_fields', 10, 3 );
56