Skip to content

Instantly share code, notes, and snippets.

@kellenmace
Created March 20, 2015 19:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kellenmace/de9f4af0a807c2cc5a02 to your computer and use it in GitHub Desktop.
Save kellenmace/de9f4af0a807c2cc5a02 to your computer and use it in GitHub Desktop.
FCP
elseif ( is_admin() ) {
/**
* Include plugin options page
* @since 1.0
*/
include_once( plugin_dir_path( __FILE__ ) . 'includes/admin.php' );
/**
* Include Custom Metaboxes and Fields Library
* @since 1.2
*/
if ( file_exists( __DIR__ . '/includes/cmb2/init.php' ) ) {
require_once __DIR__ . '/includes/cmb2/init.php';
}
/**
* Display meta box in admin
* @since 1.2
*/
function fb_pxl_display_meta_box() {
$prefix = 'fb_pxl_';
$options = get_option( 'fb_pxl_options' );
$post_types = array();
foreach ( $options as $post_type => $checkbox ) {
if ( 'on' == $checkbox )
array_push( $post_types, $post_type );
}
$metabox = new_cmb2_box( array(
'id' => $prefix . 'metabox',
'title' => 'Facebook Conversion Pixel',
'object_types' => $post_types,
'context' => 'normal',
'priority' => 'high',
'show_names' => true,
) );
$metabox->add_field( array(
'name' => 'Insert Code',
'desc' => 'Insert Facebook Conversion Pixel code on this page',
'id' => $prefix . 'checkbox',
'type' => 'checkbox',
) );
$metabox->add_field( array(
'name' => 'Conversion Pixel',
'desc' => 'Paste your Facebook Conversion Pixel code here',
'id' => $prefix . 'conversion_code',
'type' => 'textarea_code',
) );
}
add_filter( 'cmb2_init', 'fb_pxl_display_meta_box' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment