PluginProbe
Insert Pages / 2.8
Insert Pages v2.8
3.11.5 trunk 1.4 2.4 2.5 2.6 2.7 2.7.1 2.7.2 2.8 2.9 2.9.1 3.0 3.0.1 3.0.2 3.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 All 79 releases
insert-pages / options.php

options.php in Insert Pages 2.8, at options.php

98 lines 3.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 function wpip_add_admin_menu() {
4 add_options_page( 'Insert Pages', 'Insert Pages', 'manage_options', 'insert_pages', 'wpip_options_page' );
5 }
6 add_action( 'admin_menu', 'wpip_add_admin_menu' );
7
8
9 function wpip_settings_init() {
10 register_setting( 'wpipSettings', 'wpip_settings' );
11 add_settings_section(
12 'wpip_section',
13 __( 'Insert Pages', 'wordpress' ),
14 'wpip_settings_section_callback',
15 'wpipSettings'
16 );
17 add_settings_field(
18 'wpip_format',
19 __( 'Shortcode format', 'wordpress' ),
20 'wpip_format_render',
21 'wpipSettings',
22 'wpip_section'
23 );
24 add_settings_field(
25 'wpip_wrapper',
26 __( 'Wrapper for inserts', 'wordpress' ),
27 'wpip_wrapper_render',
28 'wpipSettings',
29 'wpip_section'
30 );
31 }
32 add_action( 'admin_init', 'wpip_settings_init' );
33
34
35 function wpip_set_defaults() {
36 $options = get_option( 'wpip_settings' );
37 if ( $options === FALSE ) {
38 $options = array();
39 }
40
41 if ( ! array_key_exists( 'wpip_format', $options ) ) {
42 $options['wpip_format'] = 'slug';
43 }
44
45 if ( ! array_key_exists( 'wpip_wrapper', $options ) ) {
46 $options['wpip_wrapper'] = 'block';
47 }
48
49 update_option( 'wpip_settings', $options );
50
51 return $options;
52 }
53 register_activation_hook( __FILE__, 'wpip_set_defaults' );
54
55
56 function wpip_settings_section_callback() {
57 echo __( 'You may override some default settings here.', 'wordpress' );
58 }
59
60
61 function wpip_options_page() {
62 ?>
63 <form action='options.php' method='post'>
64 <?php
65 settings_fields( 'wpipSettings' );
66 do_settings_sections( 'wpipSettings' );
67 submit_button();
68 ?>
69 </form>
70 <?php
71 }
72
73
74 function wpip_format_render() {
75 $options = get_option( 'wpip_settings' );
76 if ( $options === FALSE ) {
77 $options = wpip_set_defaults();
78 }
79 ?>
80 <input type='radio' name='wpip_settings[wpip_format]' <?php checked( $options['wpip_format'], 'slug' ); ?> id="wpip_format_slug" value='slug'><label for="wpip_format_slug">Use page slugs (more readable). Example: <code>[insert&nbsp;page='hello&#8209;world&#8209;post'&nbsp;display='all']</code></label><br />
81 <input type='radio' name='wpip_settings[wpip_format]' <?php checked( $options['wpip_format'], 'post_id' ); ?> id="wpip_format_id" value='post_id'><label for="wpip_format_id">Use page IDs (more compatible). Example: <code>[insert&nbsp;page='1'&nbsp;display='all']</code></label><br />
82 <small><em>If your site reuses page slugs (for example, WPML sites often use the same page slug for each translation of the page in a different language), you should use page IDs.</em></small>
83 <?php
84 }
85
86
87 function wpip_wrapper_render() {
88 $options = get_option( 'wpip_settings' );
89 if ( $options === FALSE ) {
90 $options = wpip_set_defaults();
91 }
92 ?>
93 <input type='radio' name='wpip_settings[wpip_wrapper]' <?php checked( $options['wpip_wrapper'], 'block' ); ?> id="wpip_wrapper_block" value='block'><label for="wpip_wrapper_block">Use block wrapper (div). Example: <code>&lt;div data-post-id="1" class="insert-page">...&lt;/div></code></label><br />
94 <input type='radio' name='wpip_settings[wpip_wrapper]' <?php checked( $options['wpip_wrapper'], 'inline' ); ?> id="wpip_wrapper_inline" value='inline'><label for="wpip_wrapper_inline">Use inline wrapper (span). Example: <code>&lt;span data-post-id="1" class="insert-page">...&lt;/span></code></label><br />
95 <small><em>If you want to embed pages inline (for example, you can insert a link to a page in the flow of a normal paragraph), you should use inline tags. Note that the HTML spec does not allow block level elements within inline elements, so the inline wrapper has limited use.</em></small>
96 <?php
97 }
98