-
Notifications
You must be signed in to change notification settings - Fork 9
/
ppibfi_meta.php
63 lines (52 loc) · 1.93 KB
/
ppibfi_meta.php
1
2
3
4
5
6
7
8
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
if ( ! empty( $_SERVER['SCRIPT_FILENAME'] ) && 'ppibfi_meta.php' == basename( $_SERVER['SCRIPT_FILENAME'] ) ) die ( 'Stop! Hammer time!' );
/*
=============================================================================
Meta box for single / page to disable the button on that post / page
=============================================================================
*/
/* Adds a box to the main column on the Post and Page edit screens */
function xcp_optin() {
add_meta_box( 'xcp_optin_sectionid', __( 'Pinterest plugin', 'ppibfi_translate' ), 'xcp_optin_custombox', '', 'side' );
}
/*
================
Meta box
================
*/
function xcp_optin_custombox( $post ) {
// Use nonce for verification
wp_nonce_field( plugin_basename( __FILE__ ), 'xcp_optin_noncename' );
$meta_values = get_post_meta($post->ID, 'xcp_optin_post' );
if( 'on' == $meta_values[0] ) $xc_check = 'checked="yes"';
else $xc_check = '';
// The actual fields for data entry
echo '<label for="xc_optin_field_disable">';
echo '<input type="checkbox" name="xc_optin_field_disable" id="xc_optin_field_disable" value="on" '.$xc_check.' /> ';
_e('Disable Pinterest Pin It button on all images in this page', 'ppibfi_translate' );
}
/*
============
Save
============
*/
add_action( 'save_post', 'xcp_optin_save' );
/* When the post is saved, saves our custom data */
function xcp_optin_save( $post_id ) {
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
if ( ! wp_verify_nonce( $_POST['xcp_optin_noncename'], plugin_basename( __FILE__ ) ) ) return;
$meta_values = get_post_meta( $post->ID, 'xcp_optin_post' );
$disable_field = $_POST['xc_optin_field_disable'];
update_post_meta( $post_id, 'xcp_optin_post', $disable_field );
}
/*
=================
Functions
=================
*/
function pibfi_replace_chars( $replace ) {
$dontallow = array( "&", "?" );
$onlyallow = array( "and", "" );
return str_replace( $dontallow, $onlyallow, $replace );
}
?>