version >= '2.1' ) { $settings_url = admin_url( 'admin.php?page=wc-settings&tab=integration§ion=mailchimp' ); } $plugin_links = array( '' . __( 'Settings', 'ad_wc_mailchimp' ) . '', ); return array_merge( $plugin_links, $links ); } // Add the "Settings" links on the Plugins administration screen add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'action_links' ); } add_action( 'add_meta_boxes', 'add_mailchip_metaboxes' ); // Add the Events Meta Boxes function add_mailchip_metaboxes() { add_meta_box('wpt_mailchip_list', 'Mailchip List', 'wpt_mailchip_list', 'course', 'side', 'default'); add_meta_box('wpt_mailchip_list', 'Mailchip List', 'wpt_mailchip_list', 'product', 'side', 'default'); } // The Event Location Metabox function wpt_mailchip_list() { global $post; // Noncename needed to verify where the data originated echo ''; // Get the location data if its already been entered $location = get_post_meta($post->ID, '_mailchip_list', true); $grouping = get_post_meta($post->ID, '_mailchip_grouping', true); $group = get_post_meta($post->ID, '_mailchip_group', true); // Echo out the field $milchip= new SS_WC_Integration_MailChimp(); $lists= $milchip->get_lists(); $selectbox .=''; $selectbox .=''; $selectbox .=''; echo $selectbox; } // Save the Metabox Data function wpt_save_mailchip_meta($post_id, $post) { // verify this came from the our screen and with proper authorization, // because save_post can be triggered at other times if ( !wp_verify_nonce( $_POST['mailchipmeta_noncename'], plugin_basename(__FILE__) )) { return $post->ID; } // Is the user allowed to edit the post or page? if ( !current_user_can( 'edit_post', $post->ID )) return $post->ID; // OK, we're authenticated: we need to find and save the data // We'll put it into an array to make it easier to loop though. $events_meta['_mailchip_list'] = $_POST['_mailchip_list']; $events_meta['_mailchip_grouping'] = $_POST['_mailchip_grouping']; $events_meta['_mailchip_group'] = $_POST['_mailchip_group']; // Add values of $events_meta as custom fields foreach ($events_meta as $key => $value) { // Cycle through the $events_meta array! if( $post->post_type == 'revision' ) return; // Don't store custom data twice $value = implode(',', (array)$value); // If $value is an array, make it a CSV (unlikely) if(get_post_meta($post->ID, $key, FALSE)) { // If the custom field already has a value update_post_meta($post->ID, $key, $value); } else { // If the custom field doesn't have a value add_post_meta($post->ID, $key, $value); } if(!$value) delete_post_meta($post->ID, $key); // Delete if blank } } add_action('save_post', 'wpt_save_mailchip_meta', 1, 2); // save the custom fields