PluginProbe
Code Embed / 2.6.3
Code Embed v2.6.3
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 / initialise.php

initialise.php in Code Embed 2.6.3, at includes/initialise.php

68 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 * Initialization script
4 *
5 * Run every time the plugin is initialized.
6 *
7 * @package simple-embed-code
8 */
9
10 // Exit if accessed directly.
11
12 if ( ! defined( 'ABSPATH' ) ) {
13 exit;
14 }
15
16 /**
17 * Initialization
18 *
19 * All initial processes.
20 */
21 function ce_initialisation() {
22
23 // Add excerpt filter, if required.
24
25 $options = get_option( 'artiss_code_embed' );
26 if ( isset( $options['excerpt'] ) && '1' === $options['excerpt'] ) {
27 add_filter( 'the_excerpt', 'ce_filter', 1 );
28 }
29
30 // Check if the plugin has upgraded and, if so, perform further actions.
31
32 $version = get_option( 'code_embed_version' );
33
34 if ( version_compare( CODE_EMBED_VERSION, $version, '!=' ) ) {
35
36 // If options don't exist, create an empty array.
37
38 if ( ! is_array( $options ) ) {
39 $options = array();
40 }
41
42 // Because of upgrading, check each option - if not set, apply default.
43
44 $default_array = array(
45 'opening_ident' => '{{',
46 'keyword_ident' => 'CODE',
47 'closing_ident' => '}}',
48 'excerpt' => '',
49 );
50
51 // Merge existing and default options - any missing from existing will take the default settings.
52
53 $new_options = array_merge( $default_array, $options );
54
55 // Update the options, if changed.
56
57 if ( $options !== $new_options ) {
58 update_option( 'artiss_code_embed', $new_options );
59 }
60
61 // Finally, update the saved version.
62
63 update_option( 'code_embed_version', CODE_EMBED_VERSION );
64 }
65 }
66
67 add_action( 'init', 'ce_initialisation' );
68