id, $_POST['wpcf7-campaignmonitor'] ); } add_action( 'wpcf7_admin_before_subsubsub', 'add_cm_meta' ); function add_cm_meta (){ if ( wpcf7_admin_has_edit_cap() ) { add_meta_box( 'cf7cmdiv', __( 'Campaign Monitor', 'wpcf7' ), 'wpcf7_cm_add_campaignmonitor', 'cfseven', 'cf7_cm', 'core', array( 'id' => 'wpcf7-cf7', 'name' => 'cf7_cm', 'use' => __( 'Use Campaign Monitor', 'wpcf7' ) ) ); } } add_action( 'wpcf7_admin_after_mail_2', 'show_cm_metabox' ); function show_cm_metabox($cf){ do_meta_boxes( 'cfseven', 'cf7_cm', $cf ); } function wpcf7_cm_add_campaignmonitor($args) { $cf7_cm_defaults = array(); $cf7_cm = get_option( 'cf7_cm_'.$args->id, $cf7_cm_defaults ); ?>
/>





/>





/>





id ); if( $cf7_cm ) { $subscribe = false; $regex = '/\[\s*([a-zA-Z_][0-9a-zA-Z:._-]*)\s*\]/'; $callback = array( &$obj, 'cf7_cm_callback' ); $email = cf7_cm_tag_replace( $regex, $cf7_cm['email'], $obj->posted_data ); $name = cf7_cm_tag_replace( $regex, $cf7_cm['name'], $obj->posted_data ); $lists = cf7_cm_tag_replace( $regex, $cf7_cm['list'], $obj->posted_data ); $listarr = explode(',',$lists); if( isset($cf7_cm['accept']) && strlen($cf7_cm['accept']) != 0 ) { $accept = cf7_cm_tag_replace( $regex, $cf7_cm['accept'], $obj->posted_data ); if($accept != $cf7_cm['accept']) { if(strlen($accept) > 0) $subscribe = true; } } else { $subscribe = true; } for($i=1;$i<=20;$i++){ if( isset($cf7_cm['CustomKey'.$i]) && isset($cf7_cm['CustomValue'.$i]) && strlen(trim($cf7_cm['CustomValue'.$i])) != 0 ) { $CustomFields[] = array('Key'=>trim($cf7_cm['CustomKey'.$i]), 'Value'=>cf7_cm_tag_replace( $regex, trim($cf7_cm['CustomValue'.$i]), $obj->posted_data ) ); } } if( isset($cf7_cm['resubscribeoption']) && strlen($cf7_cm['resubscribeoption']) != 0 ) { $ResubscribeOption = true; } else { $ResubscribeOption = false; } if($subscribe && $email != $cf7_cm['email']) { require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'csrest_subscribers.php'); $wrap = new CF7CM_CS_REST_Subscribers( trim($listarr[0]), $cf7_cm['api'] ); foreach($listarr as $listid) { $wrap->set_list_id(trim($listid)); $wrap->add(array( 'EmailAddress' => $email, 'Name' => $name, 'CustomFields' => $CustomFields, 'Resubscribe' => $ResubscribeOption )); } } } } function cf7_cm_tag_replace( $pattern, $subject, $posted_data, $html = false ) { if( preg_match($pattern,$subject,$matches) > 0) { if ( isset( $posted_data[$matches[1]] ) ) { $submitted = $posted_data[$matches[1]]; if ( is_array( $submitted ) ) $replaced = join( ', ', $submitted ); else $replaced = $submitted; if ( $html ) { $replaced = strip_tags( $replaced ); $replaced = wptexturize( $replaced ); } $replaced = apply_filters( 'wpcf7_mail_tag_replaced', $replaced, $submitted ); return stripslashes( $replaced ); } if ( $special = apply_filters( 'wpcf7_special_mail_tags', '', $matches[1] ) ) return $special; return $matches[0]; } return $subject; } function wpcf7_cm_plugin_url( $path = '' ) { return plugins_url( $path, WPCF7_CM_PLUGIN_BASENAME ); } add_filter( 'plugin_action_links', 'wpcf7_cm_plugin_action_links', 10, 2 ); function wpcf7_cm_plugin_action_links( $links, $file ) { if ( $file != plugin_basename( __FILE__ ) ) return $links; $url = wpcf7_admin_url( array( 'page' => 'wpcf7' ) ); $settings_link = '' . esc_html( __( 'Settings', 'wpcf7' ) ) . ''; array_unshift( $links, $settings_link ); return $links; }