. **/ global $wp_version; if (!version_compare($wp_version,"3.0",">=")) { die("Wordpress 3.0 or higher is required to use this plugin."); } // EO If /** ================================================== ========== Activation **/ function opmwp_activate() { global $wpdb; $table_name = $wpdb->prefix . "onepointmail"; // Check to see if the tbl exists, return NULL if there is not a table if($wpdb->get_var('SHOW TABLES LIKE "' . $table_name . '"') != $table_name){ $sql ='CREATE TABLE ' . $table_name . ' ( id INTEGER(10) UNSIGNED AUTO_INCREMENT, username VARCHAR(50), password VARCHAR(100), endpoint VARCHAR(200), listid INT(10), listname VARCHAR(200), recip_total INT(10), recip_active INT(10), recip_unsub INT(10), last_update DATETIME, PRIMARY KEY (id) )'; // Create database table require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); dbDelta($sql); // Set option in main WP so we know what version of our table schema // We can use this later for upgrades (check this version vs the updated one, etc.) add_option('onepointmail_database_version','1.0'); // Insert the 1st row so we can just do updates $wpdb->insert($table_name,array('endpoint'=>''),array('%s')); } // EO If } // EO Function register_activation_hook(__FILE__,'opmwp_activate'); /** ================================================== ========== Admin Menu **/ // Admin function function opmwp_option_page(){ global $wpdb; $table_name = $wpdb->prefix . "onepointmail"; // Check to see that the nonce has been created and passed etc. if(isset($_POST['opmwp_settings_updated']) && wp_verify_nonce($_POST['opmwp_settings_updated'],'opmwp_settings')) { // In here we need to update the settings passed by the user $endpoint = strip_tags($_POST['opmwp-endpoint']); $username = strip_tags($_POST['opmwp-username']); $password = strip_tags($_POST['opmwp-password']); $listid = strip_tags($_POST['opmwp-listid']); //$sql = $wpdb->prepare('UPDATE ' . $table_name . ' SET endpoint = %1s', $endpoint); //$wpdb->query($sql); $wpdb->update($table_name, array( 'endpoint' => $endpoint, 'username' => $username, 'password' => $password, 'listid' => $listid, ), array( 'ID' => '1' ), array( '%s', '%s', '%s', '%s', ) ); //exit( var_dump( $wpdb->last_query ) ); //opmwp_runsync(); // Get List Name if (($endpoint!=null)&&($username!=null)&&($password!=null)&&($listid!=null)) { $url = $endpoint . "/GetListByListID?UserId=" . $username . "&Password=" . $password . "&ListID=" . $listid; $data = @file_get_contents( $url ); // @ will surpress errors // Regex to get the message response from the API $regex = '%ListName>(.*?)%'; preg_match( $regex, $data, $matches ); // Set the string value of the message to $ret $ret = false; if( $matches && $matches[1] ) $ret = $matches[1]; if ($ret != null) { $tDate = date("Y-m-d H:i:s"); $wpdb->update($table_name, array( 'listname' => $ret, 'last_update' => $tDate, ), array( 'ID' => '1' ), array( '%s', '%s', ) ); } // EO if } // EO If ?>
Settings Updated
get_var($wpdb->prepare('SELECT endpoint FROM ' . $table_name . ' WHERE ID = %d'),'1'); $id = '1'; $sql = $wpdb->prepare("SELECT endpoint FROM " . $table_name . " WHERE ID = %d",$id); $endpoint = $wpdb->get_var($sql); $sql = $wpdb->prepare("SELECT username FROM " . $table_name . " WHERE ID = %d",$id); $username = $wpdb->get_var($sql); $sql = $wpdb->prepare("SELECT password FROM " . $table_name . " WHERE ID = %d",$id); $password = $wpdb->get_var($sql); $sql = $wpdb->prepare("SELECT listid FROM " . $table_name . " WHERE ID = %d",$id); $listid = $wpdb->get_var($sql); ?>

" alt="1PointMail Logo" style="border: #000 1px solid;">
  Options Page

Please Note: All information is required.

API Information

The URL to the 1PointMail API Endpoint
(ex: http://api.1pointinteractive.com/OnePointAPIService.asmx)

 

Test Login

List Information

The ListID of the list you wish to add subscribers to. It can be found under Lists -> Lists, and is next to the name of the list in the table.

 
prefix . "onepointmail"; $id = '1'; $sql = $wpdb->prepare("SELECT listname FROM " . $table_name . " WHERE ID = %d",$id); $listname = $wpdb->get_var($sql); $sql = $wpdb->prepare("SELECT listid FROM " . $table_name . " WHERE ID = %d",$id); $listid = $wpdb->get_var($sql); $sql = $wpdb->prepare("SELECT last_update FROM " . $table_name . " WHERE ID = %d",$id); $lastupdate = $wpdb->get_var($sql); ?>

List ID:
List Name:

Last Updated:
(Server Time)

Sync Now

" alt="1PointMail Logo">

prefix . "onepointmail"; $id = '1'; $sql = $wpdb->prepare("SELECT endpoint FROM " . $table_name . " WHERE ID = %d",$id); $endpoint = $wpdb->get_var($sql); $sql = $wpdb->prepare("SELECT username FROM " . $table_name . " WHERE ID = %d",$id); $username = $wpdb->get_var($sql); $sql = $wpdb->prepare("SELECT password FROM " . $table_name . " WHERE ID = %d",$id); $password = $wpdb->get_var($sql); $sql = $wpdb->prepare("SELECT listid FROM " . $table_name . " WHERE ID = %d",$id); $listid = $wpdb->get_var($sql); $email = isset($_POST['boptin_email']) ? $_POST['boptin_email'] : null; $fname = isset($_POST['boptin_fname']) ? $_POST['boptin_fname'] : null; $lname = isset($_POST['boptin_lname']) ? $_POST['boptin_lname'] : null; $msg = "Error"; if (($endpoint!=null)&&($username!=null)&&($password!=null)&&($listid!=null)&&($email!=null)) { $url = $endpoint . "/AddRecipient?UserId=" . $username . "&Password=" . $password; $url .= "&EmailAddress=" . $email . "&ListIds=" . $listid . "&FirstName=" . $fname . "&LastName=" . $lname; $data = @file_get_contents( $url ); // @ will surpress errors // Regex to get the message response from the API $regex = '%Message>(.*?)%'; preg_match( $regex, $data, $matches ); // Set the string value of the message to $ret $ret = false; if( $matches && $matches[1] ) $ret = $matches[1]; // 1st use wordpress is_email to test email syntax if (is_email($email)) { // Valid email - do nothing and continue } else { // No use in calling the API for the fun of it // if the email is not valid... // pass back invalid for the JS and die early... $msg = "invalid"; echo $msg; die(); } // EO if // Test our cases... if (strpos($ret, 'Email Already Exist') !== false) { $msg = "exists"; } elseif (strpos($ret, 'Please Enter Valid Email Format') !== false) { $msg = "invalid"; } elseif (strpos($ret, 'Recipient Added Successfully') !== false) { $msg = "ok"; } // EO if } // EO If echo $msg; die(); } // EO Function // Register the action add_action('wp_ajax_opmwp_boptin_subscribe','opmwp_boptin_subscribe'); // Register the action for NON AUTHENTICATED users add_action('wp_ajax_nopriv_opmwp_boptin_subscribe','opmwp_boptin_subscribe'); // Function called by the unsubscribe box function opmwp_boptin_unsubscribe() { global $wpdb; $table_name = $wpdb->prefix . "onepointmail"; $id = '1'; $sql = $wpdb->prepare("SELECT endpoint FROM " . $table_name . " WHERE ID = %d",$id); $endpoint = $wpdb->get_var($sql); $sql = $wpdb->prepare("SELECT username FROM " . $table_name . " WHERE ID = %d",$id); $username = $wpdb->get_var($sql); $sql = $wpdb->prepare("SELECT password FROM " . $table_name . " WHERE ID = %d",$id); $password = $wpdb->get_var($sql); $email = isset($_POST['boptinu_email']) ? $_POST['boptinu_email'] : null; $msg = "Error"; if (($endpoint!=null)&&($username!=null)&&($password!=null)&&($email!=null)) { $url = $endpoint . "/UnsubscribeContactByEmailAddress?UserId=" . $username . "&Password=" . $password; $url .= "&EmailAddress=" . $email; #$data = @file_get_contents( $url ); // @ will surpress errors if (is_email($email)) { // If the email is valid via Wordpress, then continue $url = $endpoint . "/UnsubscribeContactByEmailAddress"; $data = wp_remote_post($url, array( 'method' => 'POST', 'timeout' => 45, 'redirection' => 5, 'httpversion' => '1.0', 'blocking' => true, 'headers' => array(), 'body' => array('UserId' => $username, 'Password' => $password, 'EmailAddress' => $email), 'cookies' => array() ) ); // EO wp_remote_post // test for wp errors if( is_wp_error( $data) ) { // show error message to admins $this->show_error( "HTTP Error: " . $data->get_error_message() ); return false; } // Regex to get the message response from the API $regex = '%Message>(.*?)%'; preg_match( $regex, $data['body'], $matches ); // Set the string value of the message to $ret $ret = false; if( $matches && $matches[1] ) $ret = $matches[1]; // Test our cases... if (strpos($ret, 'exist in Database.') !== false) { $msg = "exists"; } elseif (strpos($ret, 'cannot be unsubscribed again') !== false) { $msg = "already"; } elseif (strpos($ret, 'unsubscribed successfully.') !== false) { $msg = "ok"; } // EO if } else { // Wordpress says no-go for the email format, pass back invalid for the JS and die... $msg = "invalid"; echo $msg; die(); } // EO if is_email #echo "E: $endpoint
\n"; #echo "U: $username
\n"; #echo "P: $password
\n"; #echo "E: $email
\n"; # // Regex to get the message response from the API # $regex = '%Message>(.*?)%'; # preg_match( $regex, $data, $matches ); # # // Set the string value of the message to $ret # $ret = false; # if( $matches && $matches[1] ) $ret = $matches[1]; # # // 1st use wordpress is_email to test email syntax # if (is_email($email)) { # // Valid email - do nothing and continue # } else { # // No use in calling the API for the fun of it # // if the email is not valid... # // pass back invalid for the JS and die early... # $msg = "invalid"; # echo $msg; # die(); # } // EO if # # // Test our cases... # if (strpos($ret, 'exist in Database.') !== false) { # $msg = "exists"; # } elseif (strpos($ret, 'cannot be unsubscribed again') !== false) { # $msg = "already"; # } elseif (strpos($ret, 'unsubscribed successfully.') !== false) { # $msg = "ok"; # } // EO if #echo "R: $ret
\n"; #echo "M:$msg
\n"; } // EO If echo $msg; die(); } // EO Function // Register the action add_action('wp_ajax_opmwp_boptin_unsubscribe','opmwp_boptin_unsubscribe'); // Register the action for NON AUTHENTICATED users add_action('wp_ajax_nopriv_opmwp_boptin_unsubscribe','opmwp_boptin_unsubscribe'); // Dashboard - Run Sync function opmwp_runsync() { global $wpdb; $table_name = $wpdb->prefix . "onepointmail"; $id = '1'; $sql = $wpdb->prepare("SELECT endpoint FROM " . $table_name . " WHERE ID = %d",$id); $endpoint = $wpdb->get_var($sql); $sql = $wpdb->prepare("SELECT username FROM " . $table_name . " WHERE ID = %d",$id); $username = $wpdb->get_var($sql); $sql = $wpdb->prepare("SELECT password FROM " . $table_name . " WHERE ID = %d",$id); $password = $wpdb->get_var($sql); $sql = $wpdb->prepare("SELECT listid FROM " . $table_name . " WHERE ID = %d",$id); $listid = $wpdb->get_var($sql); $msg = "Error"; // Get List Name if (($endpoint!=null)&&($username!=null)&&($password!=null)&&($listid!=null)) { $url = $endpoint . "/GetListByListID?UserId=" . $username . "&Password=" . $password . "&ListID=" . $listid; $data = @file_get_contents( $url ); // @ will surpress errors // Regex to get the message response from the API $regex = '%ListName>(.*?)%'; preg_match( $regex, $data, $matches ); // Set the string value of the message to $ret $ret = false; if( $matches && $matches[1] ) $ret = $matches[1]; if ($ret != null) { $tDate = date("Y-m-d H:i:s"); $wpdb->update($table_name, array( 'listname' => $ret, 'last_update' => $tDate, ), array( 'ID' => '1' ), array( '%s', '%s', ) ); $msg = "ok"; } // EO if } // EO If echo $msg; die(); } // EO Function // Register the action add_action('wp_ajax_opmwp_runsync','opmwp_runsync'); // Include JS for the front end add_action('wp_print_scripts','opmwp_boptin_script'); function opmwp_boptin_script() { wp_enqueue_script("opmwp",path_join(WP_PLUGIN_URL, basename(dirname(__FILE__))."/assets/js/jq_opmwp.js"), array('jquery')); } // EO Function /** ================================================== ========== Widget(s) **/ class opwmpUnsub extends WP_Widget { function opwmpUnsub() { $widget_options = array ( 'classname' => 'widget-opwmpUnsub', 'description' => '1PointMail Unsubscribe Box', ); parent::WP_Widget('opmwp_widget_unsub','1PointMail Unsubscribe Box',$widget_options); } // EO Function function widget($args,$instance) { extract($args, EXTR_SKIP); $title = ($instance['title']) ? $instance['title'] : 'Unsubscribe'; $submit_val = ($instance['submit_val']) ? $instance['submit_val'] : 'Unsubscribe'; $pb = ($instance['cb_pb']) ? 'true' : 'false'; // Crate the Widget display $body = ""; $body .= "
"; if('on' == $instance['cb_pb'] ) { $body .= "Powered By 1PointMail!"; }; // EO If $body .= "
"; $body .= "
"; $body .= "

 

"; ?>


Display Powered By 1PointMail?     id="get_field_id('cb_pb'); ?>" name="get_field_name('cb_pb'); ?>" />


'widget-opmwpBasicOptin', 'description' => '1PointMail Basic Opt-In Subscription Box', ); parent::WP_Widget('opmwp_widget_basicoptin','1PointMail Basic OptIn Box',$widget_options); } // EO Function function widget($args,$instance) { extract($args, EXTR_SKIP); $title = ($instance['title']) ? $instance['title'] : 'Subscribe!'; $submit_val = ($instance['submit_val']) ? $instance['submit_val'] : 'Subscribe'; $fn = ($instance['cb_fn']) ? 'true' : 'false'; $ln = ($instance['cb_ln']) ? 'true' : 'false'; $lbl = ($instance['cb_lbl']) ? 'true' : 'false'; $pb = ($instance['cb_pb']) ? 'true' : 'false'; //$body = ($instance['body']) ? $instance['body'] : $body_default; #'Subscribe Box Goes here...'; // Create the use display of the widget $body = ""; // show firstname / lastname based on if the option is selected if('on' == $instance['cb_fn'] ) { if('on' == $instance['cb_lbl'] ) { $body .= "First Name:

"; } else { $body .= "

"; } // EO if } // EO if if('on' == $instance['cb_ln'] ) { if('on' == $instance['cb_lbl'] ) { $body .= "Last Name:

"; } else { $body .= "

"; } // EO if } // EO if if('on' == $instance['cb_lbl'] ) { $body .= "Email:
"; } else { $body .= "
"; } // EO if if('on' == $instance['cb_pb'] ) { $body .= "Powered By 1PointMail!"; }; // EO If $body .= "
"; $body .= "
"; $body .= "

 

"; ?>


Display input boxes for:
     id="get_field_id('cb_fn'); ?>" name="get_field_name('cb_fn'); ?>" />     
     id="get_field_id('cb_ln'); ?>" name="get_field_name('cb_ln'); ?>" />

Display input box labels?     id="get_field_id('cb_lbl'); ?>" name="get_field_name('cb_lbl'); ?>" />


Display Powered By 1PointMail?     id="get_field_id('cb_pb'); ?>" name="get_field_name('cb_pb'); ?>" />


Rate this plugin'; } return $links; } add_filter('plugin_row_meta', 'rate_opmwp', 10, 2); ?>