Changeset 1287956
- Timestamp:
- 11/17/2015 01:19:39 PM (10 years ago)
- Location:
- sendmachine
- Files:
-
- 34 edited
- 1 copied
-
tags/1.0.4 (copied) (copied from sendmachine/trunk)
-
tags/1.0.4/api/SendmachineApiClient.php (modified) (3 diffs)
-
tags/1.0.4/api/examples/list_examples.php (modified) (3 diffs)
-
tags/1.0.4/api/library/Campaigns.php (modified) (3 diffs)
-
tags/1.0.4/api/library/Lists.php (modified) (6 diffs)
-
tags/1.0.4/api/library/Sender.php (modified) (2 diffs)
-
tags/1.0.4/api/library/Templates.php (modified) (3 diffs)
-
tags/1.0.4/includes/sendmachine_api.php (modified) (1 diff)
-
tags/1.0.4/includes/sendmachine_defaults.php (modified) (4 diffs)
-
tags/1.0.4/includes/sendmachine_email_manager.php (modified) (3 diffs)
-
tags/1.0.4/includes/sendmachine_feed_manager.php (modified) (6 diffs)
-
tags/1.0.4/includes/sendmachine_subscribe_manager.php (modified) (9 diffs)
-
tags/1.0.4/includes/utils.php (modified) (1 diff)
-
tags/1.0.4/readme.txt (modified) (2 diffs)
-
tags/1.0.4/sendmachine_widget.php (modified) (1 diff)
-
tags/1.0.4/sendmachine_wp.php (modified) (3 diffs)
-
tags/1.0.4/sendmachine_wp_admin.php (modified) (13 diffs)
-
tags/1.0.4/views/wp_sm_feed_settings.php (modified) (2 diffs)
-
trunk/api/SendmachineApiClient.php (modified) (3 diffs)
-
trunk/api/examples/list_examples.php (modified) (3 diffs)
-
trunk/api/library/Campaigns.php (modified) (3 diffs)
-
trunk/api/library/Lists.php (modified) (6 diffs)
-
trunk/api/library/Sender.php (modified) (2 diffs)
-
trunk/api/library/Templates.php (modified) (3 diffs)
-
trunk/includes/sendmachine_api.php (modified) (1 diff)
-
trunk/includes/sendmachine_defaults.php (modified) (4 diffs)
-
trunk/includes/sendmachine_email_manager.php (modified) (3 diffs)
-
trunk/includes/sendmachine_feed_manager.php (modified) (6 diffs)
-
trunk/includes/sendmachine_subscribe_manager.php (modified) (9 diffs)
-
trunk/includes/utils.php (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/sendmachine_widget.php (modified) (1 diff)
-
trunk/sendmachine_wp.php (modified) (3 diffs)
-
trunk/sendmachine_wp_admin.php (modified) (13 diffs)
-
trunk/views/wp_sm_feed_settings.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sendmachine/tags/1.0.4/api/SendmachineApiClient.php
r1226818 r1287956 84 84 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); 85 85 curl_setopt($ch, CURLOPT_POSTFIELDS, $params); 86 curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json', 'Content-Length: ' . strlen($params)]);86 curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen($params))); 87 87 break; 88 88 case 'DELETE': 89 89 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); 90 curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);90 curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); 91 91 break; 92 92 } … … 145 145 public function check_config() { 146 146 147 $config_paths = [".sendmachine.conf", "/etc/.sendmachine.conf"];147 $config_paths = array(".sendmachine.conf", "/etc/.sendmachine.conf"); 148 148 $username = null; 149 149 $password = null; … … 166 166 } 167 167 168 return [$username, $password];168 return array($username, $password); 169 169 } 170 170 -
sendmachine/tags/1.0.4/api/examples/list_examples.php
r1226818 r1287956 47 47 * update list details 48 48 */ 49 $sc->lists->edit($list_id, ['name' => 'new_list_name']);49 $sc->lists->edit($list_id, array('name' => 'new_list_name')); 50 50 $list_details = $sc->lists->details($list_id); 51 51 print_r($list_details); … … 53 53 * add contacts list to a existing list 54 54 */ 55 $sc->lists->manage_contacts($list_id, ['email2@example.com', 'email3@example.com'], 'subscribe');55 $sc->lists->manage_contacts($list_id, array('email2@example.com', 'email3@example.com'), 'subscribe'); 56 56 57 57 $updated_details = $sc->lists->recipients($list_id); … … 61 61 print_r($contact_details); 62 62 63 $sc->lists->manage_contact($list_id, 'email2@example.com', ['status' => 'unsubscribe']);63 $sc->lists->manage_contact($list_id, 'email2@example.com', array('status' => 'unsubscribe')); 64 64 65 65 /* -
sendmachine/tags/1.0.4/api/library/Campaigns.php
r1226818 r1287956 35 35 public function get($filter = 'all', $orderby = 'cdate', $offset = 0, $limit = 25, $search = null) { 36 36 37 $params = ['filter' => $filter, 'orderby' => $orderby, 'offset' => $offset, 'limit' => $limit, 'search' => $search];37 $params = array('filter' => $filter, 'orderby' => $orderby, 'offset' => $offset, 'limit' => $limit, 'search' => $search); 38 38 return $this->master->request('/campaigns', 'GET', $params); 39 39 } … … 106 106 public function schedule($campaign_id, $date = "") { 107 107 108 $params = ['date' => $date];108 $params = array('date' => $date); 109 109 return $this->master->request('/campaigns/schedule/' . $campaign_id, 'POST', $params); 110 110 } … … 134 134 public function test($campaign_id, $addresses = "") { 135 135 136 $params = ['addresses' => $addresses];136 $params = array('addresses' => $addresses); 137 137 return $this->master->request('/campaigns/test/' . $campaign_id, 'POST', $params); 138 138 } -
sendmachine/tags/1.0.4/api/library/Lists.php
r1226818 r1287956 31 31 public function get($limit = 25, $offset = 0) { 32 32 33 $params = ['limit' => $limit, 'offset' => $offset];33 $params = array('limit' => $limit, 'offset' => $offset); 34 34 return $this->master->request('/list', 'GET', $params); 35 35 } … … 62 62 public function recipients($list_id, $limit = 25, $offset = 0, $filter = 'all', $order_by = 'email', $segment_id = 0) { 63 63 64 $params = ['limit' => $limit, 'offset' => $offset, 'filter' => $filter, 'orderby' => $order_by, 'sid' => $segment_id];64 $params = array('limit' => $limit, 'offset' => $offset, 'filter' => $filter, 'orderby' => $order_by, 'sid' => $segment_id); 65 65 return $this->master->request('/list/' . $list_id, 'GET', $params); 66 66 } … … 132 132 public function create($data) { 133 133 134 $params = ['list_details' => $data];134 $params = array('list_details' => $data); 135 135 return $this->master->request('/list', 'POST', $params); 136 136 } … … 150 150 public function manage_contacts($list_id, $emails = "", $action = 'subscribe', $list_name = null) { 151 151 152 $params = ['contacts' => $emails, 'action' => $action, 'name' => $list_name];152 $params = array('contacts' => $emails, 'action' => $action, 'name' => $list_name); 153 153 return $this->master->request('/list/' . $list_id, 'POST', $params); 154 154 } … … 203 203 public function edit($list_id, $data){ 204 204 205 $params = ['list_details' => $data];205 $params = array('list_details' => $data); 206 206 return $this->master->request('/list/'.$list_id.'/details', 'POST', $params); 207 207 } … … 247 247 public function list_segments($list_id, $limit = 25, $offset = 0, $orderby = "adate", $sort = "desc") { 248 248 249 $params = ['limit' => $limit, 'offset' => $offset, 'orderby' => $orderby, 'sort' => $sort];249 $params = array('limit' => $limit, 'offset' => $offset, 'orderby' => $orderby, 'sort' => $sort); 250 250 return $this->master->request('/list/'.$list_id.'/segment', 'GET', $params); 251 251 } -
sendmachine/tags/1.0.4/api/library/Sender.php
r1226818 r1287956 31 31 public function get($status = 'active', $type = 'email', $group = null, $limit = null, $offset = null) { 32 32 33 $params = ['status' => $status, 'type' => $type, 'group' => $group, 'limit' => $limit, 'offset' => $offset];33 $params = array('status' => $status, 'type' => $type, 'group' => $group, 'limit' => $limit, 'offset' => $offset); 34 34 return $this->master->request('/sender', 'GET', $params); 35 35 } … … 49 49 public function add($email) { 50 50 51 $params = ['type' => 'email', 'address' => $email];51 $params = array('type' => 'email', 'address' => $email); 52 52 return $this->master->request('/sender', 'POST', $params); 53 53 } -
sendmachine/tags/1.0.4/api/library/Templates.php
r1226818 r1287956 27 27 public function get($limit = 25, $offset = 0) { 28 28 29 $params = ['limit' => $limit, 'offset' => $offset];29 $params = array('limit' => $limit, 'offset' => $offset); 30 30 return $this->master->request('/templates', 'GET', $params); 31 31 } … … 57 57 public function create($name, $body = "") { 58 58 59 $params = ['name' => $name, 'body' => $body];59 $params = array('name' => $name, 'body' => $body); 60 60 return $this->master->request('/templates', 'POST', $params); 61 61 } … … 72 72 public function update($template_id, $body = "") { 73 73 74 $params = ['body' => $body];74 $params = array('body' => $body); 75 75 return $this->master->request('/templates/' . $template_id, 'POST', $params); 76 76 } -
sendmachine/tags/1.0.4/includes/sendmachine_api.php
r1226818 r1287956 149 149 } 150 150 151 public function create_campaign($params = []){151 public function create_campaign($params = array()){ 152 152 153 153 if(!$params) return NULL; -
sendmachine/tags/1.0.4/includes/sendmachine_defaults.php
r1226818 r1287956 1 1 <?php 2 2 3 $sm_config = [4 "keys_to_encode" => ["header_template", "body_template", "footer_template"],5 "to_reset" => ['list|id','list|data','list|fields','email|senderlist','email|provider_settings','email|host','email|port','email|from_email','feed|sender_email','feed|list_id'],3 $sm_config = array( 4 "keys_to_encode" => array("header_template", "body_template", "footer_template"), 5 "to_reset" => array('list|id','list|data','list|fields','email|senderlist','email|provider_settings','email|host','email|port','email|from_email','feed|sender_email','feed|list_id'), 6 6 "feed_delimiter" => "||%s||" 7 ];7 ); 8 8 9 $sendmachine_defaults = [10 "list" => [9 $sendmachine_defaults = array( 10 "list" => array( 11 11 "hide_subscribed" => 0, 12 12 "redirect_subscribed" => "", … … 19 19 "checkbox_checked" => 0, 20 20 "simple_subscribe" => 1 21 ],22 "email" => [21 ), 22 "email" => array( 23 23 "enable_service" => 1, 24 24 "encryption" => "no_encryption", … … 27 27 "register_post_label" => "Register", 28 28 "comment_post_label" => "Comment" 29 ],30 "feed" => [29 ), 30 "feed" => array( 31 31 "post_nr" => 10, 32 32 "header_template" => "<h1>||SITENAME||</h1>", … … 35 35 "template_width" => "600px", 36 36 "template_bgcolor" => "#fff" 37 ]38 ];37 ) 38 ); -
sendmachine/tags/1.0.4/includes/sendmachine_email_manager.php
r1226818 r1287956 7 7 public function __construct() { 8 8 9 add_action('init', [$this, 'manage_email_requests']);9 add_action('init', array($this, 'manage_email_requests')); 10 10 11 add_action('comment_post', [$this, 'add_sm_headers']);12 add_action('register_post', [$this, 'add_sm_headers']);11 add_action('comment_post', array($this, 'add_sm_headers')); 12 add_action('register_post', array($this, 'add_sm_headers')); 13 13 14 add_action('phpmailer_init', [$this, 'configure_smtp']);14 add_action('phpmailer_init', array($this, 'configure_smtp')); 15 15 } 16 16 … … 30 30 if (empty($sm->app['email']['enable_service']) || (empty($sm->app['email']['emailconfirmed']) && empty($sm->bypass_emailconfirmation))) return false; 31 31 32 $required_items = ['encryption','host','port','from_email'];32 $required_items = array('encryption','host','port','from_email'); 33 33 34 34 foreach($required_items as $k => $v) { … … 96 96 $ret = wp_mail($data['email'], 'Test email -'.$blogname, 'This is a test email from your wordpress site'); 97 97 98 if($ret) $message = ["smEmailSentSuccess","email_sent_success", sprintf(__("Email to %s sent successfully!", SM_LANGUAGE_DOMAIN), $data['email']), "updated"];99 else $message = ["smEmailSentError","email_sent_error", __("Something went wrong. Email not sent.", SM_LANGUAGE_DOMAIN), "error"];98 if($ret) $message = array("smEmailSentSuccess","email_sent_success", sprintf(__("Email to %s sent successfully!", SM_LANGUAGE_DOMAIN), $data['email']), "updated"); 99 else $message = array("smEmailSentError","email_sent_error", __("Something went wrong. Email not sent.", SM_LANGUAGE_DOMAIN), "error"); 100 100 101 101 Sm_wp::instance()->enqueue_admin_message($message); -
sendmachine/tags/1.0.4/includes/sendmachine_feed_manager.php
r1226818 r1287956 18 18 ) { 19 19 20 $args = ['numberposts' => $feed['post_nr']];20 $args = array('numberposts' => $feed['post_nr']); 21 21 22 22 $body = $this->build_newsletter($feed); 23 23 24 24 if (!$body) 25 return ['smSendCampaignErrorNoPost', 'campaignsend_err_nopost', __("No post found.Campaign not created!", SM_LANGUAGE_DOMAIN), "error"];25 return array('smSendCampaignErrorNoPost', 'campaignsend_err_nopost', __("No post found.Campaign not created!", SM_LANGUAGE_DOMAIN), "error"); 26 26 27 $res = $sm->create_campaign( [27 $res = $sm->create_campaign(array( 28 28 "name" => $feed['sm_feed_campaign_name'], 29 29 "subject" => $feed['sm_feed_campaign_subject'], … … 31 31 "sender_email" => $feed['sender_email'], 32 32 "body_html" => $body 33 ]);33 )); 34 34 35 35 if (isset($res['status']) && ($res['status'] == "created")) { … … 38 38 39 39 $link = "<a target='_blank' href='" . SM_SITE_APP_URL . "/#/campaigns/" . $res['id'] . "/source_editor' >" . __("here", SM_LANGUAGE_DOMAIN) . "</a>"; 40 return ['smSendCampaignSaveDraft', 'campaignsend_saved_draft', sprintf(__("Campaign saved as draft in your Sendmachine account. Click %s to access it.", SM_LANGUAGE_DOMAIN), $link), "updated"];40 return array('smSendCampaignSaveDraft', 'campaignsend_saved_draft', sprintf(__("Campaign saved as draft in your Sendmachine account. Click %s to access it.", SM_LANGUAGE_DOMAIN), $link), "updated"); 41 41 } 42 42 elseif ($action == 'sm_feed_send_campaign') { 43 43 44 44 if (!$tested_cmp = $sm->test_campaign($res['id'])) 45 return ['smSendCampaignErrorGeneral', 'campaignsend_err_general', __("Something went wrong.Campaign could not be tested.", SM_LANGUAGE_DOMAIN), "error"];45 return array('smSendCampaignErrorGeneral', 'campaignsend_err_general', __("Something went wrong.Campaign could not be tested.", SM_LANGUAGE_DOMAIN), "error"); 46 46 47 47 if ($tested_cmp != "ok") { … … 61 61 $reasons .= "</ul>"; 62 62 63 return ['smSendCampaignErrorTestFail', 'campaignsend_err_testfail', sprintf(__("Campaign created, but not started. Reported reasons: %s", SM_LANGUAGE_DOMAIN), $reasons), "error"];63 return array('smSendCampaignErrorTestFail', 'campaignsend_err_testfail', sprintf(__("Campaign created, but not started. Reported reasons: %s", SM_LANGUAGE_DOMAIN), $reasons), "error"); 64 64 } 65 65 … … 67 67 68 68 $track_url = "<a target='_blank' href='" . SM_SITE_APP_URL . "//#/stats/" . $res['id'] . "' >" . __("here", SM_LANGUAGE_DOMAIN) . "</a>"; 69 return ['smSendCampaignStartedSuccess', 'campaignsend_started_success', sprintf(__("Campaign started successfully. You can track it by clicking %s.", SM_LANGUAGE_DOMAIN), $track_url), "updated"];69 return array('smSendCampaignStartedSuccess', 'campaignsend_started_success', sprintf(__("Campaign started successfully. You can track it by clicking %s.", SM_LANGUAGE_DOMAIN), $track_url), "updated"); 70 70 } 71 71 72 return ['smSendCampaignLaunchErrpr', 'campaignsend_launch_error', __("For some reason campaign was not started.", SM_LANGUAGE_DOMAIN), "error"];72 return array('smSendCampaignLaunchErrpr', 'campaignsend_launch_error', __("For some reason campaign was not started.", SM_LANGUAGE_DOMAIN), "error"); 73 73 } 74 74 } 75 75 76 return ['smSendCampaignErrorNotCreated', 'campaignsend_err_notcreated', isset($res['status']) ? $res['status'] : $res, "error"];76 return array('smSendCampaignErrorNotCreated', 'campaignsend_err_notcreated', isset($res['status']) ? $res['status'] : $res, "error"); 77 77 } 78 78 79 return ['smSendCampaignError', 'campaignsend_error', __("All fields are required.", SM_LANGUAGE_DOMAIN), "error"];79 return array('smSendCampaignError', 'campaignsend_error', __("All fields are required.", SM_LANGUAGE_DOMAIN), "error"); 80 80 } 81 81 82 82 private function build_newsletter($feed_data = NULL) { 83 83 84 $args = ['numberposts' => $feed_data['post_nr']];84 $args = array('numberposts' => $feed_data['post_nr']); 85 85 86 86 $rp = wp_get_recent_posts($args); … … 119 119 } 120 120 121 public function keywords($action, $args = []) {121 public function keywords($action, $args = array()) { 122 122 123 $keywords = [124 "SITENAME" => [123 $keywords = array( 124 "SITENAME" => array( 125 125 "value" => get_bloginfo('name'), 126 126 "description" => __("Your blog's title", SM_LANGUAGE_DOMAIN) 127 ],128 "SITEDESCRIPTION" => [127 ), 128 "SITEDESCRIPTION" => array( 129 129 "value" => get_option('blogdescription'), 130 130 "description" => __("Blog's description", SM_LANGUAGE_DOMAIN) 131 ],132 "ADMINEMAIL" => [131 ), 132 "ADMINEMAIL" => array( 133 133 "value" => get_option('admin_email'), 134 134 "description" => __("Administrator's email address", SM_LANGUAGE_DOMAIN) 135 ],136 "SITEURL" => [135 ), 136 "SITEURL" => array( 137 137 "value" => get_option('siteurl'), 138 138 "description" => __("Blog URL.", SM_LANGUAGE_DOMAIN) 139 ],140 "POSTTITLE" => [139 ), 140 "POSTTITLE" => array( 141 141 "value" => isset($args['post_title']) ? $args['post_title'] : "", 142 142 "description" => __("Display post title.Works only in template body", SM_LANGUAGE_DOMAIN) 143 ],144 "POSTURL" => [143 ), 144 "POSTURL" => array( 145 145 "value" => isset($args['guid']) ? $args['guid'] : "", 146 146 "description" => __("Post url. Works only in template body", SM_LANGUAGE_DOMAIN) 147 ],148 "POSTCONTENTSUMMARY" => [147 ), 148 "POSTCONTENTSUMMARY" => array( 149 149 "value" => isset($args['post_content']) ? substr($args['post_content'], 0, 300) . " [...]" : "", 150 150 "description" => __("Post's content summary.Display first 300 characters of content. Works only in template body", SM_LANGUAGE_DOMAIN) 151 ],152 "POSTCONTENTFULL" => [151 ), 152 "POSTCONTENTFULL" => array( 153 153 "value" => isset($args['post_content']) ? $args['post_content'] : "", 154 154 "description" => __("Post's content (full content). Works only in template body", SM_LANGUAGE_DOMAIN) 155 ],156 "POSTAUTHOR" => [155 ), 156 "POSTAUTHOR" => array( 157 157 "value" => isset($args['post_author']) ? get_user_by('id', $args['post_author'])->data->user_nicename : "", 158 158 "description" => __("Who wrote post. Works only in template body", SM_LANGUAGE_DOMAIN) 159 ],160 "POSTDATE" => [159 ), 160 "POSTDATE" => array( 161 161 "value" => isset($args['post_date']) ? $args['post_date'] : "", 162 162 "description" => __("Post publish date. Works only in template body", SM_LANGUAGE_DOMAIN) 163 ]164 ];163 ) 164 ); 165 165 166 $ret_arr = [];166 $ret_arr = array(); 167 167 168 168 foreach ($keywords as $keyword => $data) { -
sendmachine/tags/1.0.4/includes/sendmachine_subscribe_manager.php
r1230263 r1287956 11 11 $this->app = $app_config; 12 12 13 if (!empty($this->app['list']['checkbox_comment'])) add_action('comment_form', [$this, 'build_checkbox']);14 if (!empty($this->app['list']['checkbox_register'])) add_action('register_form', [$this, 'build_checkbox']);15 16 add_action('init', [$this, 'manage_subscribe_requests']);17 18 add_shortcode('sm_subscribe_form', [$this, 'build_shortcode_form']);13 if (!empty($this->app['list']['checkbox_comment'])) add_action('comment_form', array($this, 'build_checkbox')); 14 if (!empty($this->app['list']['checkbox_register'])) add_action('register_form', array($this, 'build_checkbox')); 15 16 add_action('init', array($this, 'manage_subscribe_requests')); 17 18 add_shortcode('sm_subscribe_form', array($this, 'build_shortcode_form')); 19 19 } 20 20 … … 80 80 wp_enqueue_style('sm-wp-widget-styles', plugins_url('static/css/sm-widget.css', SM_PLUGIN_FILE)); 81 81 wp_enqueue_script('sm-wp-widget-script', plugins_url('static/js/sm-widget.js', SM_PLUGIN_FILE)); 82 wp_localize_script('sm-wp-widget-script', 'SM_JS_DATA', [82 wp_localize_script('sm-wp-widget-script', 'SM_JS_DATA', array( 83 83 'loading_img' => plugin_dir_url(SM_PLUGIN_FILE) . 'static/images/loading.gif', 84 84 'redirect' => $this->app['list']['redirect_subscribed'], 85 85 'response_not_arrived' => $this->app['list']['message_not_subscribed'] 86 ]);86 )); 87 87 } 88 88 … … 103 103 $list_fields .= $list_field['form_name'] . " $required<br>"; 104 104 105 if (in_array($list_field['cf_type'], ["text", "number", "email","date","birthday"])) {105 if (in_array($list_field['cf_type'], array("text", "number", "email","date","birthday"))) { 106 106 $placeholder = ""; 107 107 … … 168 168 $fields = $this->app['list']['fields']; 169 169 170 $fn = [];170 $fn = array(); 171 171 foreach($fields as $f) $fn[] = $f['name']; 172 172 … … 176 176 177 177 if ($sm_api->get_recipient($this->app['list']['id'], $email)) 178 $msg = ["message" => $this->app['list']['message_subscriber_exists'], "status" => "error"];178 $msg = array("message" => $this->app['list']['message_subscriber_exists'], "status" => "error"); 179 179 elseif ($resp = $sm_api->subscribe($this->app['list']['id'], $email, $data)) { 180 180 … … 183 183 if (trim($this->app['list']['redirect_subscribed']) && !$is_ajax) wp_redirect($this->app['list']['redirect_subscribed']); 184 184 185 $msg = ["message" => $this->app['list']['message_success_subscribe'], "status" => "success"];185 $msg = array("message" => $this->app['list']['message_success_subscribe'], "status" => "success"); 186 186 } 187 187 else 188 $msg = ["message" => $this->app['list']['message_not_subscribed'], "status" => "error"];188 $msg = array("message" => $this->app['list']['message_not_subscribed'], "status" => "error"); 189 189 190 190 if ($is_ajax) { echo json_encode($msg); exit(); } … … 217 217 218 218 if (empty($this->app['list']['id'])) { 219 $message = ["smUsersSyncErrorApiLost", "users_sync_api_lost", __("API must be connected and you have to select a list in order to sync your users.", SM_LANGUAGE_DOMAIN), "error"];219 $message = array("smUsersSyncErrorApiLost", "users_sync_api_lost", __("API must be connected and you have to select a list in order to sync your users.", SM_LANGUAGE_DOMAIN), "error"); 220 220 Sm_wp::instance()->enqueue_admin_message($message); 221 221 return NULL; … … 226 226 $users = get_users(array( 'fields' => array( 'user_email' ) )); 227 227 228 $recipients = [];228 $recipients = array(); 229 229 foreach($users as $k => $u){ 230 230 array_push($recipients, $u->user_email); … … 235 235 $ret = $sm_api->mass_subscribe($this->app['list']['id'], $recipients); 236 236 237 if($ret) $message = ["smUsersSyncSuccess","users_sync success", sprintf(__("Sync complete! %u users were added to your contact list.", SM_LANGUAGE_DOMAIN), $cnt), "updated"];238 else $message = ["smUsersSyncError","users_sync_error", __("Something went wrong. Users not synced.", SM_LANGUAGE_DOMAIN), "error"];237 if($ret) $message = array("smUsersSyncSuccess","users_sync success", sprintf(__("Sync complete! %u users were added to your contact list.", SM_LANGUAGE_DOMAIN), $cnt), "updated"); 238 else $message = array("smUsersSyncError","users_sync_error", __("Something went wrong. Users not synced.", SM_LANGUAGE_DOMAIN), "error"); 239 239 240 240 Sm_wp::instance()->enqueue_admin_message($message); -
sendmachine/tags/1.0.4/includes/utils.php
r1265625 r1287956 7 7 public static function add_notification($message = '', $section = 'general', $type = 'success') { 8 8 9 self::$notifications[$section] = ["message" => $message, "type" => $type];9 self::$notifications[$section] = array("message" => $message, "type" => $type); 10 10 } 11 11 -
sendmachine/tags/1.0.4/readme.txt
r1265625 r1287956 4 4 Requires at least: 3.2.1 5 5 Tested up to: 4.3 6 Stable tag: 1.0. 36 Stable tag: 1.0.4 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 96 96 == Changelog == 97 97 98 = 1.0.4 = 99 * added php 5.3 compatibility 100 98 101 = 1.0.3 = 99 102 * array_column bugfix -
sendmachine/tags/1.0.4/sendmachine_widget.php
r1230263 r1287956 5 5 function __construct() { 6 6 7 $options = ['description' => __('Allow visitors to subscribe to your contact lists using this widget.', SM_LANGUAGE_DOMAIN)];7 $options = array('description' => __('Allow visitors to subscribe to your contact lists using this widget.', SM_LANGUAGE_DOMAIN)); 8 8 $title = __('Sendmachine list subscription', SM_LANGUAGE_DOMAIN); 9 9 -
sendmachine/tags/1.0.4/sendmachine_wp.php
r1265625 r1287956 5 5 Plugin URI: https://www.sendmachine.com 6 6 Description: The official Sendmachine plugin featuring subscribe forms, users sync, news feed, email sending and transactional campaigns. 7 Version: 1.0. 37 Version: 1.0.4 8 8 Author: Sendmachine team 9 9 Author URI: http://developers.sendmachine.com/ … … 22 22 define('SM_WP_DEV_MODE', false); 23 23 } 24 25 error_reporting(E_ALL); 24 26 25 27 require_once SM_PLUGIN_DIR . 'includes/utils.php'; … … 52 54 $this->api_connected = !empty($this->app['api_connected']) ? true : false; 53 55 54 add_action('init', [$this, 'load_translations']);56 add_action('init', array($this, 'load_translations')); 55 57 56 58 if ($this->api_connected) { 57 59 58 add_action('widgets_init', [$this, 'load_widgets']);60 add_action('widgets_init', array($this, 'load_widgets')); 59 61 } 60 62 } -
sendmachine/tags/1.0.4/sendmachine_wp_admin.php
r1226818 r1287956 3 3 class Sm_wp_admin extends Sm_wp { 4 4 5 private $messages_queue = [];5 private $messages_queue = array(); 6 6 7 7 public function __construct() { … … 11 11 $this->load_admin_hooks(); 12 12 13 register_activation_hook(SM_PLUGIN_FILE, [$this, 'sendmachine_wp_install']);14 register_deactivation_hook(SM_PLUGIN_FILE, [$this, 'sendmachine_wp_uninstall']);13 register_activation_hook(SM_PLUGIN_FILE, array($this, 'sendmachine_wp_install')); 14 register_deactivation_hook(SM_PLUGIN_FILE, array($this, 'sendmachine_wp_uninstall')); 15 15 } 16 16 … … 19 19 global $pagenow; 20 20 21 add_action('admin_enqueue_scripts', [$this, 'styles_scripts']);21 add_action('admin_enqueue_scripts', array($this, 'styles_scripts')); 22 22 23 23 if ($pagenow == "plugins.php") { 24 24 25 add_filter('plugin_action_links_' . plugin_basename(SM_PLUGIN_FILE), [$this, 'enable_settings']);26 } 27 28 add_action('admin_init', [$this, 'sendmachine_admin_init']);29 add_action('admin_menu', [$this, 'sendmachine_settings_skeleton']);25 add_filter('plugin_action_links_' . plugin_basename(SM_PLUGIN_FILE), array($this, 'enable_settings')); 26 } 27 28 add_action('admin_init', array($this, 'sendmachine_admin_init')); 29 add_action('admin_menu', array($this, 'sendmachine_settings_skeleton')); 30 30 } 31 31 … … 52 52 wp_enqueue_style('sm-wp-admin-styles', plugins_url('static/css/sm-admin.css', SM_PLUGIN_FILE)); 53 53 wp_enqueue_script('sm-wp-admin-script', plugins_url('static/js/sm-admin.js', SM_PLUGIN_FILE)); 54 wp_localize_script('sm-wp-admin-script', 'SM_JS_DATA', [54 wp_localize_script('sm-wp-admin-script', 'SM_JS_DATA', array( 55 55 'startcampaign_text' => __("You are about to start a campaign with the following properties:\nCampaign name: %s\nCampaign subject: %s\nContact list: %s\nSender address: %s\n\nAgree?", SM_LANGUAGE_DOMAIN) 56 ]);56 )); 57 57 } 58 58 … … 66 66 public function sendmachine_settings_skeleton() { 67 67 68 add_menu_page('Sendmachine Setup', 'Sendmachine', 'manage_options', 'sendmachine_settings', [$this, 'sendmachine_load_page'], plugins_url('static/images/wp_sendmachine_logo.png', SM_PLUGIN_FILE));69 70 add_submenu_page('sendmachine_settings', 'Sendmachine -' . ' General', 'General', 'manage_options', 'sendmachine_settings', [$this, 'sendmachine_load_page']);71 add_submenu_page('sendmachine_settings', 'Sendmachine -' . ' Lists', 'Lists', 'manage_options', 'sendmachine_lists', [$this, 'sendmachine_load_page']);72 add_submenu_page('sendmachine_settings', 'Sendmachine -' . ' Feed', 'Feed', 'manage_options', 'sendmachine_feed', [$this, 'sendmachine_load_page']);73 add_submenu_page('sendmachine_settings', 'Sendmachine -' . ' Email Settings', 'Email Settings', 'manage_options', 'sendmachine_email', [$this, 'sendmachine_load_page']);68 add_menu_page('Sendmachine Setup', 'Sendmachine', 'manage_options', 'sendmachine_settings', array($this, 'sendmachine_load_page'), plugins_url('static/images/wp_sendmachine_logo.png', SM_PLUGIN_FILE)); 69 70 add_submenu_page('sendmachine_settings', 'Sendmachine -' . ' General', 'General', 'manage_options', 'sendmachine_settings', array($this, 'sendmachine_load_page')); 71 add_submenu_page('sendmachine_settings', 'Sendmachine -' . ' Lists', 'Lists', 'manage_options', 'sendmachine_lists', array($this, 'sendmachine_load_page')); 72 add_submenu_page('sendmachine_settings', 'Sendmachine -' . ' Feed', 'Feed', 'manage_options', 'sendmachine_feed', array($this, 'sendmachine_load_page')); 73 add_submenu_page('sendmachine_settings', 'Sendmachine -' . ' Email Settings', 'Email Settings', 'manage_options', 'sendmachine_email', array($this, 'sendmachine_load_page')); 74 74 } 75 75 … … 111 111 112 112 public function sm_include($path = "", $display_notifications = true) { 113 113 114 114 if($display_notifications) settings_errors(); 115 115 include(SM_PLUGIN_DIR . '/views/' . $path ); … … 134 134 update_option(SM_OPTIONS_APP_NAME, $this->app); 135 135 136 if(!isset($message)) $message = ["smSettingsUpdateSuccess","admin_settings_updated", __("Saved!", SM_LANGUAGE_DOMAIN), "updated"];136 if(!isset($message)) $message = array("smSettingsUpdateSuccess","admin_settings_updated", __("Saved!", SM_LANGUAGE_DOMAIN), "updated"); 137 137 call_user_func_array("add_settings_error",$message); 138 138 } 139 139 140 private function manage_admin_actions($action = NULL, $data = []) {140 private function manage_admin_actions($action = NULL, $data = array()) { 141 141 142 142 if(!$this->api_connected) $this->reset_app_data(); … … 175 175 } 176 176 177 return ['smUpdateListSuccess', 'settings_updated', __("Contact Lists Updated!", SM_LANGUAGE_DOMAIN), "updated"];177 return array('smUpdateListSuccess', 'settings_updated', __("Contact Lists Updated!", SM_LANGUAGE_DOMAIN), "updated"); 178 178 } 179 179 } … … 188 188 189 189 if ($this->app['list']['fields']) 190 return ['smListIdUpdateSuccess', 'list_updated', __("Contact list saved!", SM_LANGUAGE_DOMAIN), "updated"];190 return array('smListIdUpdateSuccess', 'list_updated', __("Contact list saved!", SM_LANGUAGE_DOMAIN), "updated"); 191 191 else 192 return ['smListIdUpdateError', 'settings_error', __("Something went wrong. Please retry", SM_LANGUAGE_DOMAIN), "error"];192 return array('smListIdUpdateError', 'settings_error', __("Something went wrong. Please retry", SM_LANGUAGE_DOMAIN), "error"); 193 193 } 194 194 } … … 209 209 210 210 if(isset($data['sm_already_confirmed_wp'])) 211 return ['smConfirmationMailLiar', 'confirmationmail_liar', __('Press "I already confirmed my address" only after you confirm your account.', SM_LANGUAGE_DOMAIN), "error"];211 return array('smConfirmationMailLiar', 'confirmationmail_liar', __('Press "I already confirmed my address" only after you confirm your account.', SM_LANGUAGE_DOMAIN), "error"); 212 212 213 213 if(!empty($this->app['email']['enable_service']) && empty($this->app['email']['emailpending'])) { … … 218 218 219 219 if(wp_mail($from, "This is a test email", "This is a test email for confirmation purposes")) 220 return ['smConfirmationMailSuccess', 'confirmationmail_success', sprintf(__("A confirmation email has been sent to %s.", SM_LANGUAGE_DOMAIN), $from), "updated"];220 return array('smConfirmationMailSuccess', 'confirmationmail_success', sprintf(__("A confirmation email has been sent to %s.", SM_LANGUAGE_DOMAIN), $from), "updated"); 221 221 else 222 return ['smConfirmationMailFail', 'confirmationmail_fail', sprintf(__("Something went wrong.For some reason a confirmation email cannnot be sent to '%s'. Please try again later.", SM_LANGUAGE_DOMAIN), $from), "error"];222 return array('smConfirmationMailFail', 'confirmationmail_fail', sprintf(__("Something went wrong.For some reason a confirmation email cannnot be sent to '%s'. Please try again later.", SM_LANGUAGE_DOMAIN), $from), "error"); 223 223 } 224 224 } … … 230 230 231 231 $action = isset($data['sm_feed_send_campaign']) ? "sm_feed_send_campaign" : (isset($data['sm_feed_save_draft']) ? "sm_feed_save_draft" : ""); 232 $feed = array_merge($this->app['feed'], ["sm_feed_campaign_name" => $data['sm_feed_campaign_name'], "sm_feed_campaign_subject" => $data['sm_feed_campaign_subject']]);232 $feed = array_merge($this->app['feed'], array("sm_feed_campaign_name" => $data['sm_feed_campaign_name'], "sm_feed_campaign_subject" => $data['sm_feed_campaign_subject'])); 233 233 234 234 return $this->feed_manager->manage_feed($feed, $this->sm, $action); … … 251 251 $keys_to_encode = $this->config["keys_to_encode"]; 252 252 253 function do_walk(&$master_array, $merge_values, $keys_to_encode = [], $encode = false) {253 function do_walk(&$master_array, $merge_values, $keys_to_encode = array(), $encode = false) { 254 254 255 255 if (is_array($merge_values)) foreach ($merge_values as $k => $v) do_walk($master_array[$k], $v, $keys_to_encode, in_array($k, $keys_to_encode) ? true : false); -
sendmachine/tags/1.0.4/views/wp_sm_feed_settings.php
r1226818 r1287956 1 1 <?php 2 $sm_feed_editor_settings = [2 $sm_feed_editor_settings = array( 3 3 'editor_height' => 150, 4 4 'wpautop' => false 5 ];5 ); 6 6 ?> 7 7 <div class="wrap"> … … 100 100 <select class='sm_full' name="update[feed][post_nr]"> 101 101 <?php 102 $nr = ['5', '10', '15', '20'];102 $nr = array('5', '10', '15', '20'); 103 103 104 104 foreach ($nr as $k => $v) { -
sendmachine/trunk/api/SendmachineApiClient.php
r1226818 r1287956 84 84 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); 85 85 curl_setopt($ch, CURLOPT_POSTFIELDS, $params); 86 curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json', 'Content-Length: ' . strlen($params)]);86 curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen($params))); 87 87 break; 88 88 case 'DELETE': 89 89 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); 90 curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);90 curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); 91 91 break; 92 92 } … … 145 145 public function check_config() { 146 146 147 $config_paths = [".sendmachine.conf", "/etc/.sendmachine.conf"];147 $config_paths = array(".sendmachine.conf", "/etc/.sendmachine.conf"); 148 148 $username = null; 149 149 $password = null; … … 166 166 } 167 167 168 return [$username, $password];168 return array($username, $password); 169 169 } 170 170 -
sendmachine/trunk/api/examples/list_examples.php
r1226818 r1287956 47 47 * update list details 48 48 */ 49 $sc->lists->edit($list_id, ['name' => 'new_list_name']);49 $sc->lists->edit($list_id, array('name' => 'new_list_name')); 50 50 $list_details = $sc->lists->details($list_id); 51 51 print_r($list_details); … … 53 53 * add contacts list to a existing list 54 54 */ 55 $sc->lists->manage_contacts($list_id, ['email2@example.com', 'email3@example.com'], 'subscribe');55 $sc->lists->manage_contacts($list_id, array('email2@example.com', 'email3@example.com'), 'subscribe'); 56 56 57 57 $updated_details = $sc->lists->recipients($list_id); … … 61 61 print_r($contact_details); 62 62 63 $sc->lists->manage_contact($list_id, 'email2@example.com', ['status' => 'unsubscribe']);63 $sc->lists->manage_contact($list_id, 'email2@example.com', array('status' => 'unsubscribe')); 64 64 65 65 /* -
sendmachine/trunk/api/library/Campaigns.php
r1226818 r1287956 35 35 public function get($filter = 'all', $orderby = 'cdate', $offset = 0, $limit = 25, $search = null) { 36 36 37 $params = ['filter' => $filter, 'orderby' => $orderby, 'offset' => $offset, 'limit' => $limit, 'search' => $search];37 $params = array('filter' => $filter, 'orderby' => $orderby, 'offset' => $offset, 'limit' => $limit, 'search' => $search); 38 38 return $this->master->request('/campaigns', 'GET', $params); 39 39 } … … 106 106 public function schedule($campaign_id, $date = "") { 107 107 108 $params = ['date' => $date];108 $params = array('date' => $date); 109 109 return $this->master->request('/campaigns/schedule/' . $campaign_id, 'POST', $params); 110 110 } … … 134 134 public function test($campaign_id, $addresses = "") { 135 135 136 $params = ['addresses' => $addresses];136 $params = array('addresses' => $addresses); 137 137 return $this->master->request('/campaigns/test/' . $campaign_id, 'POST', $params); 138 138 } -
sendmachine/trunk/api/library/Lists.php
r1226818 r1287956 31 31 public function get($limit = 25, $offset = 0) { 32 32 33 $params = ['limit' => $limit, 'offset' => $offset];33 $params = array('limit' => $limit, 'offset' => $offset); 34 34 return $this->master->request('/list', 'GET', $params); 35 35 } … … 62 62 public function recipients($list_id, $limit = 25, $offset = 0, $filter = 'all', $order_by = 'email', $segment_id = 0) { 63 63 64 $params = ['limit' => $limit, 'offset' => $offset, 'filter' => $filter, 'orderby' => $order_by, 'sid' => $segment_id];64 $params = array('limit' => $limit, 'offset' => $offset, 'filter' => $filter, 'orderby' => $order_by, 'sid' => $segment_id); 65 65 return $this->master->request('/list/' . $list_id, 'GET', $params); 66 66 } … … 132 132 public function create($data) { 133 133 134 $params = ['list_details' => $data];134 $params = array('list_details' => $data); 135 135 return $this->master->request('/list', 'POST', $params); 136 136 } … … 150 150 public function manage_contacts($list_id, $emails = "", $action = 'subscribe', $list_name = null) { 151 151 152 $params = ['contacts' => $emails, 'action' => $action, 'name' => $list_name];152 $params = array('contacts' => $emails, 'action' => $action, 'name' => $list_name); 153 153 return $this->master->request('/list/' . $list_id, 'POST', $params); 154 154 } … … 203 203 public function edit($list_id, $data){ 204 204 205 $params = ['list_details' => $data];205 $params = array('list_details' => $data); 206 206 return $this->master->request('/list/'.$list_id.'/details', 'POST', $params); 207 207 } … … 247 247 public function list_segments($list_id, $limit = 25, $offset = 0, $orderby = "adate", $sort = "desc") { 248 248 249 $params = ['limit' => $limit, 'offset' => $offset, 'orderby' => $orderby, 'sort' => $sort];249 $params = array('limit' => $limit, 'offset' => $offset, 'orderby' => $orderby, 'sort' => $sort); 250 250 return $this->master->request('/list/'.$list_id.'/segment', 'GET', $params); 251 251 } -
sendmachine/trunk/api/library/Sender.php
r1226818 r1287956 31 31 public function get($status = 'active', $type = 'email', $group = null, $limit = null, $offset = null) { 32 32 33 $params = ['status' => $status, 'type' => $type, 'group' => $group, 'limit' => $limit, 'offset' => $offset];33 $params = array('status' => $status, 'type' => $type, 'group' => $group, 'limit' => $limit, 'offset' => $offset); 34 34 return $this->master->request('/sender', 'GET', $params); 35 35 } … … 49 49 public function add($email) { 50 50 51 $params = ['type' => 'email', 'address' => $email];51 $params = array('type' => 'email', 'address' => $email); 52 52 return $this->master->request('/sender', 'POST', $params); 53 53 } -
sendmachine/trunk/api/library/Templates.php
r1226818 r1287956 27 27 public function get($limit = 25, $offset = 0) { 28 28 29 $params = ['limit' => $limit, 'offset' => $offset];29 $params = array('limit' => $limit, 'offset' => $offset); 30 30 return $this->master->request('/templates', 'GET', $params); 31 31 } … … 57 57 public function create($name, $body = "") { 58 58 59 $params = ['name' => $name, 'body' => $body];59 $params = array('name' => $name, 'body' => $body); 60 60 return $this->master->request('/templates', 'POST', $params); 61 61 } … … 72 72 public function update($template_id, $body = "") { 73 73 74 $params = ['body' => $body];74 $params = array('body' => $body); 75 75 return $this->master->request('/templates/' . $template_id, 'POST', $params); 76 76 } -
sendmachine/trunk/includes/sendmachine_api.php
r1226818 r1287956 149 149 } 150 150 151 public function create_campaign($params = []){151 public function create_campaign($params = array()){ 152 152 153 153 if(!$params) return NULL; -
sendmachine/trunk/includes/sendmachine_defaults.php
r1226818 r1287956 1 1 <?php 2 2 3 $sm_config = [4 "keys_to_encode" => ["header_template", "body_template", "footer_template"],5 "to_reset" => ['list|id','list|data','list|fields','email|senderlist','email|provider_settings','email|host','email|port','email|from_email','feed|sender_email','feed|list_id'],3 $sm_config = array( 4 "keys_to_encode" => array("header_template", "body_template", "footer_template"), 5 "to_reset" => array('list|id','list|data','list|fields','email|senderlist','email|provider_settings','email|host','email|port','email|from_email','feed|sender_email','feed|list_id'), 6 6 "feed_delimiter" => "||%s||" 7 ];7 ); 8 8 9 $sendmachine_defaults = [10 "list" => [9 $sendmachine_defaults = array( 10 "list" => array( 11 11 "hide_subscribed" => 0, 12 12 "redirect_subscribed" => "", … … 19 19 "checkbox_checked" => 0, 20 20 "simple_subscribe" => 1 21 ],22 "email" => [21 ), 22 "email" => array( 23 23 "enable_service" => 1, 24 24 "encryption" => "no_encryption", … … 27 27 "register_post_label" => "Register", 28 28 "comment_post_label" => "Comment" 29 ],30 "feed" => [29 ), 30 "feed" => array( 31 31 "post_nr" => 10, 32 32 "header_template" => "<h1>||SITENAME||</h1>", … … 35 35 "template_width" => "600px", 36 36 "template_bgcolor" => "#fff" 37 ]38 ];37 ) 38 ); -
sendmachine/trunk/includes/sendmachine_email_manager.php
r1226818 r1287956 7 7 public function __construct() { 8 8 9 add_action('init', [$this, 'manage_email_requests']);9 add_action('init', array($this, 'manage_email_requests')); 10 10 11 add_action('comment_post', [$this, 'add_sm_headers']);12 add_action('register_post', [$this, 'add_sm_headers']);11 add_action('comment_post', array($this, 'add_sm_headers')); 12 add_action('register_post', array($this, 'add_sm_headers')); 13 13 14 add_action('phpmailer_init', [$this, 'configure_smtp']);14 add_action('phpmailer_init', array($this, 'configure_smtp')); 15 15 } 16 16 … … 30 30 if (empty($sm->app['email']['enable_service']) || (empty($sm->app['email']['emailconfirmed']) && empty($sm->bypass_emailconfirmation))) return false; 31 31 32 $required_items = ['encryption','host','port','from_email'];32 $required_items = array('encryption','host','port','from_email'); 33 33 34 34 foreach($required_items as $k => $v) { … … 96 96 $ret = wp_mail($data['email'], 'Test email -'.$blogname, 'This is a test email from your wordpress site'); 97 97 98 if($ret) $message = ["smEmailSentSuccess","email_sent_success", sprintf(__("Email to %s sent successfully!", SM_LANGUAGE_DOMAIN), $data['email']), "updated"];99 else $message = ["smEmailSentError","email_sent_error", __("Something went wrong. Email not sent.", SM_LANGUAGE_DOMAIN), "error"];98 if($ret) $message = array("smEmailSentSuccess","email_sent_success", sprintf(__("Email to %s sent successfully!", SM_LANGUAGE_DOMAIN), $data['email']), "updated"); 99 else $message = array("smEmailSentError","email_sent_error", __("Something went wrong. Email not sent.", SM_LANGUAGE_DOMAIN), "error"); 100 100 101 101 Sm_wp::instance()->enqueue_admin_message($message); -
sendmachine/trunk/includes/sendmachine_feed_manager.php
r1226818 r1287956 18 18 ) { 19 19 20 $args = ['numberposts' => $feed['post_nr']];20 $args = array('numberposts' => $feed['post_nr']); 21 21 22 22 $body = $this->build_newsletter($feed); 23 23 24 24 if (!$body) 25 return ['smSendCampaignErrorNoPost', 'campaignsend_err_nopost', __("No post found.Campaign not created!", SM_LANGUAGE_DOMAIN), "error"];25 return array('smSendCampaignErrorNoPost', 'campaignsend_err_nopost', __("No post found.Campaign not created!", SM_LANGUAGE_DOMAIN), "error"); 26 26 27 $res = $sm->create_campaign( [27 $res = $sm->create_campaign(array( 28 28 "name" => $feed['sm_feed_campaign_name'], 29 29 "subject" => $feed['sm_feed_campaign_subject'], … … 31 31 "sender_email" => $feed['sender_email'], 32 32 "body_html" => $body 33 ]);33 )); 34 34 35 35 if (isset($res['status']) && ($res['status'] == "created")) { … … 38 38 39 39 $link = "<a target='_blank' href='" . SM_SITE_APP_URL . "/#/campaigns/" . $res['id'] . "/source_editor' >" . __("here", SM_LANGUAGE_DOMAIN) . "</a>"; 40 return ['smSendCampaignSaveDraft', 'campaignsend_saved_draft', sprintf(__("Campaign saved as draft in your Sendmachine account. Click %s to access it.", SM_LANGUAGE_DOMAIN), $link), "updated"];40 return array('smSendCampaignSaveDraft', 'campaignsend_saved_draft', sprintf(__("Campaign saved as draft in your Sendmachine account. Click %s to access it.", SM_LANGUAGE_DOMAIN), $link), "updated"); 41 41 } 42 42 elseif ($action == 'sm_feed_send_campaign') { 43 43 44 44 if (!$tested_cmp = $sm->test_campaign($res['id'])) 45 return ['smSendCampaignErrorGeneral', 'campaignsend_err_general', __("Something went wrong.Campaign could not be tested.", SM_LANGUAGE_DOMAIN), "error"];45 return array('smSendCampaignErrorGeneral', 'campaignsend_err_general', __("Something went wrong.Campaign could not be tested.", SM_LANGUAGE_DOMAIN), "error"); 46 46 47 47 if ($tested_cmp != "ok") { … … 61 61 $reasons .= "</ul>"; 62 62 63 return ['smSendCampaignErrorTestFail', 'campaignsend_err_testfail', sprintf(__("Campaign created, but not started. Reported reasons: %s", SM_LANGUAGE_DOMAIN), $reasons), "error"];63 return array('smSendCampaignErrorTestFail', 'campaignsend_err_testfail', sprintf(__("Campaign created, but not started. Reported reasons: %s", SM_LANGUAGE_DOMAIN), $reasons), "error"); 64 64 } 65 65 … … 67 67 68 68 $track_url = "<a target='_blank' href='" . SM_SITE_APP_URL . "//#/stats/" . $res['id'] . "' >" . __("here", SM_LANGUAGE_DOMAIN) . "</a>"; 69 return ['smSendCampaignStartedSuccess', 'campaignsend_started_success', sprintf(__("Campaign started successfully. You can track it by clicking %s.", SM_LANGUAGE_DOMAIN), $track_url), "updated"];69 return array('smSendCampaignStartedSuccess', 'campaignsend_started_success', sprintf(__("Campaign started successfully. You can track it by clicking %s.", SM_LANGUAGE_DOMAIN), $track_url), "updated"); 70 70 } 71 71 72 return ['smSendCampaignLaunchErrpr', 'campaignsend_launch_error', __("For some reason campaign was not started.", SM_LANGUAGE_DOMAIN), "error"];72 return array('smSendCampaignLaunchErrpr', 'campaignsend_launch_error', __("For some reason campaign was not started.", SM_LANGUAGE_DOMAIN), "error"); 73 73 } 74 74 } 75 75 76 return ['smSendCampaignErrorNotCreated', 'campaignsend_err_notcreated', isset($res['status']) ? $res['status'] : $res, "error"];76 return array('smSendCampaignErrorNotCreated', 'campaignsend_err_notcreated', isset($res['status']) ? $res['status'] : $res, "error"); 77 77 } 78 78 79 return ['smSendCampaignError', 'campaignsend_error', __("All fields are required.", SM_LANGUAGE_DOMAIN), "error"];79 return array('smSendCampaignError', 'campaignsend_error', __("All fields are required.", SM_LANGUAGE_DOMAIN), "error"); 80 80 } 81 81 82 82 private function build_newsletter($feed_data = NULL) { 83 83 84 $args = ['numberposts' => $feed_data['post_nr']];84 $args = array('numberposts' => $feed_data['post_nr']); 85 85 86 86 $rp = wp_get_recent_posts($args); … … 119 119 } 120 120 121 public function keywords($action, $args = []) {121 public function keywords($action, $args = array()) { 122 122 123 $keywords = [124 "SITENAME" => [123 $keywords = array( 124 "SITENAME" => array( 125 125 "value" => get_bloginfo('name'), 126 126 "description" => __("Your blog's title", SM_LANGUAGE_DOMAIN) 127 ],128 "SITEDESCRIPTION" => [127 ), 128 "SITEDESCRIPTION" => array( 129 129 "value" => get_option('blogdescription'), 130 130 "description" => __("Blog's description", SM_LANGUAGE_DOMAIN) 131 ],132 "ADMINEMAIL" => [131 ), 132 "ADMINEMAIL" => array( 133 133 "value" => get_option('admin_email'), 134 134 "description" => __("Administrator's email address", SM_LANGUAGE_DOMAIN) 135 ],136 "SITEURL" => [135 ), 136 "SITEURL" => array( 137 137 "value" => get_option('siteurl'), 138 138 "description" => __("Blog URL.", SM_LANGUAGE_DOMAIN) 139 ],140 "POSTTITLE" => [139 ), 140 "POSTTITLE" => array( 141 141 "value" => isset($args['post_title']) ? $args['post_title'] : "", 142 142 "description" => __("Display post title.Works only in template body", SM_LANGUAGE_DOMAIN) 143 ],144 "POSTURL" => [143 ), 144 "POSTURL" => array( 145 145 "value" => isset($args['guid']) ? $args['guid'] : "", 146 146 "description" => __("Post url. Works only in template body", SM_LANGUAGE_DOMAIN) 147 ],148 "POSTCONTENTSUMMARY" => [147 ), 148 "POSTCONTENTSUMMARY" => array( 149 149 "value" => isset($args['post_content']) ? substr($args['post_content'], 0, 300) . " [...]" : "", 150 150 "description" => __("Post's content summary.Display first 300 characters of content. Works only in template body", SM_LANGUAGE_DOMAIN) 151 ],152 "POSTCONTENTFULL" => [151 ), 152 "POSTCONTENTFULL" => array( 153 153 "value" => isset($args['post_content']) ? $args['post_content'] : "", 154 154 "description" => __("Post's content (full content). Works only in template body", SM_LANGUAGE_DOMAIN) 155 ],156 "POSTAUTHOR" => [155 ), 156 "POSTAUTHOR" => array( 157 157 "value" => isset($args['post_author']) ? get_user_by('id', $args['post_author'])->data->user_nicename : "", 158 158 "description" => __("Who wrote post. Works only in template body", SM_LANGUAGE_DOMAIN) 159 ],160 "POSTDATE" => [159 ), 160 "POSTDATE" => array( 161 161 "value" => isset($args['post_date']) ? $args['post_date'] : "", 162 162 "description" => __("Post publish date. Works only in template body", SM_LANGUAGE_DOMAIN) 163 ]164 ];163 ) 164 ); 165 165 166 $ret_arr = [];166 $ret_arr = array(); 167 167 168 168 foreach ($keywords as $keyword => $data) { -
sendmachine/trunk/includes/sendmachine_subscribe_manager.php
r1230263 r1287956 11 11 $this->app = $app_config; 12 12 13 if (!empty($this->app['list']['checkbox_comment'])) add_action('comment_form', [$this, 'build_checkbox']);14 if (!empty($this->app['list']['checkbox_register'])) add_action('register_form', [$this, 'build_checkbox']);15 16 add_action('init', [$this, 'manage_subscribe_requests']);17 18 add_shortcode('sm_subscribe_form', [$this, 'build_shortcode_form']);13 if (!empty($this->app['list']['checkbox_comment'])) add_action('comment_form', array($this, 'build_checkbox')); 14 if (!empty($this->app['list']['checkbox_register'])) add_action('register_form', array($this, 'build_checkbox')); 15 16 add_action('init', array($this, 'manage_subscribe_requests')); 17 18 add_shortcode('sm_subscribe_form', array($this, 'build_shortcode_form')); 19 19 } 20 20 … … 80 80 wp_enqueue_style('sm-wp-widget-styles', plugins_url('static/css/sm-widget.css', SM_PLUGIN_FILE)); 81 81 wp_enqueue_script('sm-wp-widget-script', plugins_url('static/js/sm-widget.js', SM_PLUGIN_FILE)); 82 wp_localize_script('sm-wp-widget-script', 'SM_JS_DATA', [82 wp_localize_script('sm-wp-widget-script', 'SM_JS_DATA', array( 83 83 'loading_img' => plugin_dir_url(SM_PLUGIN_FILE) . 'static/images/loading.gif', 84 84 'redirect' => $this->app['list']['redirect_subscribed'], 85 85 'response_not_arrived' => $this->app['list']['message_not_subscribed'] 86 ]);86 )); 87 87 } 88 88 … … 103 103 $list_fields .= $list_field['form_name'] . " $required<br>"; 104 104 105 if (in_array($list_field['cf_type'], ["text", "number", "email","date","birthday"])) {105 if (in_array($list_field['cf_type'], array("text", "number", "email","date","birthday"))) { 106 106 $placeholder = ""; 107 107 … … 168 168 $fields = $this->app['list']['fields']; 169 169 170 $fn = [];170 $fn = array(); 171 171 foreach($fields as $f) $fn[] = $f['name']; 172 172 … … 176 176 177 177 if ($sm_api->get_recipient($this->app['list']['id'], $email)) 178 $msg = ["message" => $this->app['list']['message_subscriber_exists'], "status" => "error"];178 $msg = array("message" => $this->app['list']['message_subscriber_exists'], "status" => "error"); 179 179 elseif ($resp = $sm_api->subscribe($this->app['list']['id'], $email, $data)) { 180 180 … … 183 183 if (trim($this->app['list']['redirect_subscribed']) && !$is_ajax) wp_redirect($this->app['list']['redirect_subscribed']); 184 184 185 $msg = ["message" => $this->app['list']['message_success_subscribe'], "status" => "success"];185 $msg = array("message" => $this->app['list']['message_success_subscribe'], "status" => "success"); 186 186 } 187 187 else 188 $msg = ["message" => $this->app['list']['message_not_subscribed'], "status" => "error"];188 $msg = array("message" => $this->app['list']['message_not_subscribed'], "status" => "error"); 189 189 190 190 if ($is_ajax) { echo json_encode($msg); exit(); } … … 217 217 218 218 if (empty($this->app['list']['id'])) { 219 $message = ["smUsersSyncErrorApiLost", "users_sync_api_lost", __("API must be connected and you have to select a list in order to sync your users.", SM_LANGUAGE_DOMAIN), "error"];219 $message = array("smUsersSyncErrorApiLost", "users_sync_api_lost", __("API must be connected and you have to select a list in order to sync your users.", SM_LANGUAGE_DOMAIN), "error"); 220 220 Sm_wp::instance()->enqueue_admin_message($message); 221 221 return NULL; … … 226 226 $users = get_users(array( 'fields' => array( 'user_email' ) )); 227 227 228 $recipients = [];228 $recipients = array(); 229 229 foreach($users as $k => $u){ 230 230 array_push($recipients, $u->user_email); … … 235 235 $ret = $sm_api->mass_subscribe($this->app['list']['id'], $recipients); 236 236 237 if($ret) $message = ["smUsersSyncSuccess","users_sync success", sprintf(__("Sync complete! %u users were added to your contact list.", SM_LANGUAGE_DOMAIN), $cnt), "updated"];238 else $message = ["smUsersSyncError","users_sync_error", __("Something went wrong. Users not synced.", SM_LANGUAGE_DOMAIN), "error"];237 if($ret) $message = array("smUsersSyncSuccess","users_sync success", sprintf(__("Sync complete! %u users were added to your contact list.", SM_LANGUAGE_DOMAIN), $cnt), "updated"); 238 else $message = array("smUsersSyncError","users_sync_error", __("Something went wrong. Users not synced.", SM_LANGUAGE_DOMAIN), "error"); 239 239 240 240 Sm_wp::instance()->enqueue_admin_message($message); -
sendmachine/trunk/includes/utils.php
r1265625 r1287956 7 7 public static function add_notification($message = '', $section = 'general', $type = 'success') { 8 8 9 self::$notifications[$section] = ["message" => $message, "type" => $type];9 self::$notifications[$section] = array("message" => $message, "type" => $type); 10 10 } 11 11 -
sendmachine/trunk/readme.txt
r1265625 r1287956 4 4 Requires at least: 3.2.1 5 5 Tested up to: 4.3 6 Stable tag: 1.0. 36 Stable tag: 1.0.4 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 96 96 == Changelog == 97 97 98 = 1.0.4 = 99 * added php 5.3 compatibility 100 98 101 = 1.0.3 = 99 102 * array_column bugfix -
sendmachine/trunk/sendmachine_widget.php
r1230263 r1287956 5 5 function __construct() { 6 6 7 $options = ['description' => __('Allow visitors to subscribe to your contact lists using this widget.', SM_LANGUAGE_DOMAIN)];7 $options = array('description' => __('Allow visitors to subscribe to your contact lists using this widget.', SM_LANGUAGE_DOMAIN)); 8 8 $title = __('Sendmachine list subscription', SM_LANGUAGE_DOMAIN); 9 9 -
sendmachine/trunk/sendmachine_wp.php
r1265625 r1287956 5 5 Plugin URI: https://www.sendmachine.com 6 6 Description: The official Sendmachine plugin featuring subscribe forms, users sync, news feed, email sending and transactional campaigns. 7 Version: 1.0. 37 Version: 1.0.4 8 8 Author: Sendmachine team 9 9 Author URI: http://developers.sendmachine.com/ … … 22 22 define('SM_WP_DEV_MODE', false); 23 23 } 24 25 error_reporting(E_ALL); 24 26 25 27 require_once SM_PLUGIN_DIR . 'includes/utils.php'; … … 52 54 $this->api_connected = !empty($this->app['api_connected']) ? true : false; 53 55 54 add_action('init', [$this, 'load_translations']);56 add_action('init', array($this, 'load_translations')); 55 57 56 58 if ($this->api_connected) { 57 59 58 add_action('widgets_init', [$this, 'load_widgets']);60 add_action('widgets_init', array($this, 'load_widgets')); 59 61 } 60 62 } -
sendmachine/trunk/sendmachine_wp_admin.php
r1226818 r1287956 3 3 class Sm_wp_admin extends Sm_wp { 4 4 5 private $messages_queue = [];5 private $messages_queue = array(); 6 6 7 7 public function __construct() { … … 11 11 $this->load_admin_hooks(); 12 12 13 register_activation_hook(SM_PLUGIN_FILE, [$this, 'sendmachine_wp_install']);14 register_deactivation_hook(SM_PLUGIN_FILE, [$this, 'sendmachine_wp_uninstall']);13 register_activation_hook(SM_PLUGIN_FILE, array($this, 'sendmachine_wp_install')); 14 register_deactivation_hook(SM_PLUGIN_FILE, array($this, 'sendmachine_wp_uninstall')); 15 15 } 16 16 … … 19 19 global $pagenow; 20 20 21 add_action('admin_enqueue_scripts', [$this, 'styles_scripts']);21 add_action('admin_enqueue_scripts', array($this, 'styles_scripts')); 22 22 23 23 if ($pagenow == "plugins.php") { 24 24 25 add_filter('plugin_action_links_' . plugin_basename(SM_PLUGIN_FILE), [$this, 'enable_settings']);26 } 27 28 add_action('admin_init', [$this, 'sendmachine_admin_init']);29 add_action('admin_menu', [$this, 'sendmachine_settings_skeleton']);25 add_filter('plugin_action_links_' . plugin_basename(SM_PLUGIN_FILE), array($this, 'enable_settings')); 26 } 27 28 add_action('admin_init', array($this, 'sendmachine_admin_init')); 29 add_action('admin_menu', array($this, 'sendmachine_settings_skeleton')); 30 30 } 31 31 … … 52 52 wp_enqueue_style('sm-wp-admin-styles', plugins_url('static/css/sm-admin.css', SM_PLUGIN_FILE)); 53 53 wp_enqueue_script('sm-wp-admin-script', plugins_url('static/js/sm-admin.js', SM_PLUGIN_FILE)); 54 wp_localize_script('sm-wp-admin-script', 'SM_JS_DATA', [54 wp_localize_script('sm-wp-admin-script', 'SM_JS_DATA', array( 55 55 'startcampaign_text' => __("You are about to start a campaign with the following properties:\nCampaign name: %s\nCampaign subject: %s\nContact list: %s\nSender address: %s\n\nAgree?", SM_LANGUAGE_DOMAIN) 56 ]);56 )); 57 57 } 58 58 … … 66 66 public function sendmachine_settings_skeleton() { 67 67 68 add_menu_page('Sendmachine Setup', 'Sendmachine', 'manage_options', 'sendmachine_settings', [$this, 'sendmachine_load_page'], plugins_url('static/images/wp_sendmachine_logo.png', SM_PLUGIN_FILE));69 70 add_submenu_page('sendmachine_settings', 'Sendmachine -' . ' General', 'General', 'manage_options', 'sendmachine_settings', [$this, 'sendmachine_load_page']);71 add_submenu_page('sendmachine_settings', 'Sendmachine -' . ' Lists', 'Lists', 'manage_options', 'sendmachine_lists', [$this, 'sendmachine_load_page']);72 add_submenu_page('sendmachine_settings', 'Sendmachine -' . ' Feed', 'Feed', 'manage_options', 'sendmachine_feed', [$this, 'sendmachine_load_page']);73 add_submenu_page('sendmachine_settings', 'Sendmachine -' . ' Email Settings', 'Email Settings', 'manage_options', 'sendmachine_email', [$this, 'sendmachine_load_page']);68 add_menu_page('Sendmachine Setup', 'Sendmachine', 'manage_options', 'sendmachine_settings', array($this, 'sendmachine_load_page'), plugins_url('static/images/wp_sendmachine_logo.png', SM_PLUGIN_FILE)); 69 70 add_submenu_page('sendmachine_settings', 'Sendmachine -' . ' General', 'General', 'manage_options', 'sendmachine_settings', array($this, 'sendmachine_load_page')); 71 add_submenu_page('sendmachine_settings', 'Sendmachine -' . ' Lists', 'Lists', 'manage_options', 'sendmachine_lists', array($this, 'sendmachine_load_page')); 72 add_submenu_page('sendmachine_settings', 'Sendmachine -' . ' Feed', 'Feed', 'manage_options', 'sendmachine_feed', array($this, 'sendmachine_load_page')); 73 add_submenu_page('sendmachine_settings', 'Sendmachine -' . ' Email Settings', 'Email Settings', 'manage_options', 'sendmachine_email', array($this, 'sendmachine_load_page')); 74 74 } 75 75 … … 111 111 112 112 public function sm_include($path = "", $display_notifications = true) { 113 113 114 114 if($display_notifications) settings_errors(); 115 115 include(SM_PLUGIN_DIR . '/views/' . $path ); … … 134 134 update_option(SM_OPTIONS_APP_NAME, $this->app); 135 135 136 if(!isset($message)) $message = ["smSettingsUpdateSuccess","admin_settings_updated", __("Saved!", SM_LANGUAGE_DOMAIN), "updated"];136 if(!isset($message)) $message = array("smSettingsUpdateSuccess","admin_settings_updated", __("Saved!", SM_LANGUAGE_DOMAIN), "updated"); 137 137 call_user_func_array("add_settings_error",$message); 138 138 } 139 139 140 private function manage_admin_actions($action = NULL, $data = []) {140 private function manage_admin_actions($action = NULL, $data = array()) { 141 141 142 142 if(!$this->api_connected) $this->reset_app_data(); … … 175 175 } 176 176 177 return ['smUpdateListSuccess', 'settings_updated', __("Contact Lists Updated!", SM_LANGUAGE_DOMAIN), "updated"];177 return array('smUpdateListSuccess', 'settings_updated', __("Contact Lists Updated!", SM_LANGUAGE_DOMAIN), "updated"); 178 178 } 179 179 } … … 188 188 189 189 if ($this->app['list']['fields']) 190 return ['smListIdUpdateSuccess', 'list_updated', __("Contact list saved!", SM_LANGUAGE_DOMAIN), "updated"];190 return array('smListIdUpdateSuccess', 'list_updated', __("Contact list saved!", SM_LANGUAGE_DOMAIN), "updated"); 191 191 else 192 return ['smListIdUpdateError', 'settings_error', __("Something went wrong. Please retry", SM_LANGUAGE_DOMAIN), "error"];192 return array('smListIdUpdateError', 'settings_error', __("Something went wrong. Please retry", SM_LANGUAGE_DOMAIN), "error"); 193 193 } 194 194 } … … 209 209 210 210 if(isset($data['sm_already_confirmed_wp'])) 211 return ['smConfirmationMailLiar', 'confirmationmail_liar', __('Press "I already confirmed my address" only after you confirm your account.', SM_LANGUAGE_DOMAIN), "error"];211 return array('smConfirmationMailLiar', 'confirmationmail_liar', __('Press "I already confirmed my address" only after you confirm your account.', SM_LANGUAGE_DOMAIN), "error"); 212 212 213 213 if(!empty($this->app['email']['enable_service']) && empty($this->app['email']['emailpending'])) { … … 218 218 219 219 if(wp_mail($from, "This is a test email", "This is a test email for confirmation purposes")) 220 return ['smConfirmationMailSuccess', 'confirmationmail_success', sprintf(__("A confirmation email has been sent to %s.", SM_LANGUAGE_DOMAIN), $from), "updated"];220 return array('smConfirmationMailSuccess', 'confirmationmail_success', sprintf(__("A confirmation email has been sent to %s.", SM_LANGUAGE_DOMAIN), $from), "updated"); 221 221 else 222 return ['smConfirmationMailFail', 'confirmationmail_fail', sprintf(__("Something went wrong.For some reason a confirmation email cannnot be sent to '%s'. Please try again later.", SM_LANGUAGE_DOMAIN), $from), "error"];222 return array('smConfirmationMailFail', 'confirmationmail_fail', sprintf(__("Something went wrong.For some reason a confirmation email cannnot be sent to '%s'. Please try again later.", SM_LANGUAGE_DOMAIN), $from), "error"); 223 223 } 224 224 } … … 230 230 231 231 $action = isset($data['sm_feed_send_campaign']) ? "sm_feed_send_campaign" : (isset($data['sm_feed_save_draft']) ? "sm_feed_save_draft" : ""); 232 $feed = array_merge($this->app['feed'], ["sm_feed_campaign_name" => $data['sm_feed_campaign_name'], "sm_feed_campaign_subject" => $data['sm_feed_campaign_subject']]);232 $feed = array_merge($this->app['feed'], array("sm_feed_campaign_name" => $data['sm_feed_campaign_name'], "sm_feed_campaign_subject" => $data['sm_feed_campaign_subject'])); 233 233 234 234 return $this->feed_manager->manage_feed($feed, $this->sm, $action); … … 251 251 $keys_to_encode = $this->config["keys_to_encode"]; 252 252 253 function do_walk(&$master_array, $merge_values, $keys_to_encode = [], $encode = false) {253 function do_walk(&$master_array, $merge_values, $keys_to_encode = array(), $encode = false) { 254 254 255 255 if (is_array($merge_values)) foreach ($merge_values as $k => $v) do_walk($master_array[$k], $v, $keys_to_encode, in_array($k, $keys_to_encode) ? true : false); -
sendmachine/trunk/views/wp_sm_feed_settings.php
r1226818 r1287956 1 1 <?php 2 $sm_feed_editor_settings = [2 $sm_feed_editor_settings = array( 3 3 'editor_height' => 150, 4 4 'wpautop' => false 5 ];5 ); 6 6 ?> 7 7 <div class="wrap"> … … 100 100 <select class='sm_full' name="update[feed][post_nr]"> 101 101 <?php 102 $nr = ['5', '10', '15', '20'];102 $nr = array('5', '10', '15', '20'); 103 103 104 104 foreach ($nr as $k => $v) {
Note: See TracChangeset
for help on using the changeset viewer.