Plugin Directory

Changeset 1287956


Ignore:
Timestamp:
11/17/2015 01:19:39 PM (10 years ago)
Author:
sendmachine
Message:

enhanced php 5.3 compatibility ~ v1.0.4

Location:
sendmachine
Files:
34 edited
1 copied

Legend:

Unmodified
Added
Removed
  • sendmachine/tags/1.0.4/api/SendmachineApiClient.php

    r1226818 r1287956  
    8484                curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
    8585                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)));
    8787                break;
    8888            case 'DELETE':
    8989                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'));
    9191                break;
    9292        }
     
    145145    public function check_config() {
    146146
    147         $config_paths = [".sendmachine.conf", "/etc/.sendmachine.conf"];
     147        $config_paths = array(".sendmachine.conf", "/etc/.sendmachine.conf");
    148148        $username = null;
    149149        $password = null;
     
    166166        }
    167167
    168         return [$username, $password];
     168        return array($username, $password);
    169169    }
    170170
  • sendmachine/tags/1.0.4/api/examples/list_examples.php

    r1226818 r1287956  
    4747     * update list details
    4848     */
    49     $sc->lists->edit($list_id, ['name' => 'new_list_name']);
     49    $sc->lists->edit($list_id, array('name' => 'new_list_name'));
    5050    $list_details = $sc->lists->details($list_id);
    5151    print_r($list_details);
     
    5353     * add contacts list to a existing list
    5454     */
    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');
    5656   
    5757    $updated_details = $sc->lists->recipients($list_id);
     
    6161    print_r($contact_details);
    6262   
    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'));
    6464   
    6565    /*
  • sendmachine/tags/1.0.4/api/library/Campaigns.php

    r1226818 r1287956  
    3535    public function get($filter = 'all', $orderby = 'cdate', $offset = 0, $limit = 25, $search = null) {
    3636
    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);
    3838        return $this->master->request('/campaigns', 'GET', $params);
    3939    }
     
    106106    public function schedule($campaign_id, $date = "") {
    107107
    108         $params = ['date' => $date];
     108        $params = array('date' => $date);
    109109        return $this->master->request('/campaigns/schedule/' . $campaign_id, 'POST', $params);
    110110    }
     
    134134    public function test($campaign_id, $addresses = "") {
    135135
    136         $params = ['addresses' => $addresses];
     136        $params = array('addresses' => $addresses);
    137137        return $this->master->request('/campaigns/test/' . $campaign_id, 'POST', $params);
    138138    }
  • sendmachine/tags/1.0.4/api/library/Lists.php

    r1226818 r1287956  
    3131    public function get($limit = 25, $offset = 0) {
    3232
    33         $params = ['limit' => $limit, 'offset' => $offset];
     33        $params = array('limit' => $limit, 'offset' => $offset);
    3434        return $this->master->request('/list', 'GET', $params);
    3535    }
     
    6262    public function recipients($list_id, $limit = 25, $offset = 0, $filter = 'all', $order_by = 'email', $segment_id = 0) {
    6363
    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);
    6565        return $this->master->request('/list/' . $list_id, 'GET', $params);
    6666    }
     
    132132    public function create($data) {
    133133
    134         $params = ['list_details' => $data];
     134        $params = array('list_details' => $data);
    135135        return $this->master->request('/list', 'POST', $params);
    136136    }
     
    150150    public function manage_contacts($list_id, $emails = "", $action = 'subscribe', $list_name = null) {
    151151
    152         $params = ['contacts' => $emails, 'action' => $action, 'name' => $list_name];
     152        $params = array('contacts' => $emails, 'action' => $action, 'name' => $list_name);
    153153        return $this->master->request('/list/' . $list_id, 'POST', $params);
    154154    }
     
    203203    public function edit($list_id, $data){
    204204       
    205         $params = ['list_details' => $data];
     205        $params = array('list_details' => $data);
    206206        return $this->master->request('/list/'.$list_id.'/details', 'POST', $params);
    207207    }
     
    247247    public function list_segments($list_id, $limit = 25, $offset = 0, $orderby = "adate", $sort = "desc") {
    248248
    249         $params = ['limit' => $limit, 'offset' => $offset, 'orderby' => $orderby, 'sort' => $sort];
     249        $params = array('limit' => $limit, 'offset' => $offset, 'orderby' => $orderby, 'sort' => $sort);
    250250        return $this->master->request('/list/'.$list_id.'/segment', 'GET', $params);
    251251    }
  • sendmachine/tags/1.0.4/api/library/Sender.php

    r1226818 r1287956  
    3131    public function get($status = 'active', $type = 'email', $group = null, $limit = null, $offset = null) {
    3232
    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);
    3434        return $this->master->request('/sender', 'GET', $params);
    3535    }
     
    4949    public function add($email) {
    5050
    51         $params = ['type' => 'email', 'address' => $email];
     51        $params = array('type' => 'email', 'address' => $email);
    5252        return $this->master->request('/sender', 'POST', $params);
    5353    }
  • sendmachine/tags/1.0.4/api/library/Templates.php

    r1226818 r1287956  
    2727    public function get($limit = 25, $offset = 0) {
    2828
    29         $params = ['limit' => $limit, 'offset' => $offset];
     29        $params = array('limit' => $limit, 'offset' => $offset);
    3030        return $this->master->request('/templates', 'GET', $params);
    3131    }
     
    5757    public function create($name, $body = "") {
    5858
    59         $params = ['name' => $name, 'body' => $body];
     59        $params = array('name' => $name, 'body' => $body);
    6060        return $this->master->request('/templates', 'POST', $params);
    6161    }
     
    7272    public function update($template_id, $body = "") {
    7373
    74         $params = ['body' => $body];
     74        $params = array('body' => $body);
    7575        return $this->master->request('/templates/' . $template_id, 'POST', $params);
    7676    }
  • sendmachine/tags/1.0.4/includes/sendmachine_api.php

    r1226818 r1287956  
    149149    }
    150150   
    151     public function create_campaign($params = []){
     151    public function create_campaign($params = array()){
    152152       
    153153        if(!$params) return NULL;
  • sendmachine/tags/1.0.4/includes/sendmachine_defaults.php

    r1226818 r1287956  
    11<?php
    22
    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'),
    66    "feed_delimiter" => "||%s||"
    7 ];
     7);
    88
    9 $sendmachine_defaults = [
    10     "list" => [
     9$sendmachine_defaults = array(
     10    "list" => array(
    1111        "hide_subscribed" => 0,
    1212        "redirect_subscribed" => "",
     
    1919        "checkbox_checked" => 0,
    2020        "simple_subscribe" => 1
    21     ],
    22     "email" => [
     21    ),
     22    "email" => array(
    2323        "enable_service" => 1,
    2424        "encryption" => "no_encryption",
     
    2727        "register_post_label" => "Register",
    2828        "comment_post_label" => "Comment"
    29     ],
    30     "feed" => [
     29    ),
     30    "feed" => array(
    3131        "post_nr" => 10,
    3232        "header_template" => "<h1>||SITENAME||</h1>",
     
    3535        "template_width" => "600px",
    3636        "template_bgcolor" => "#fff"
    37     ]
    38 ];
     37    )
     38);
  • sendmachine/tags/1.0.4/includes/sendmachine_email_manager.php

    r1226818 r1287956  
    77    public function __construct() {
    88
    9         add_action('init', [$this, 'manage_email_requests']);
     9        add_action('init', array($this, 'manage_email_requests'));
    1010
    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'));
    1313
    14         add_action('phpmailer_init', [$this, 'configure_smtp']);
     14        add_action('phpmailer_init', array($this, 'configure_smtp'));
    1515    }
    1616
     
    3030        if (empty($sm->app['email']['enable_service']) || (empty($sm->app['email']['emailconfirmed']) && empty($sm->bypass_emailconfirmation))) return false;
    3131       
    32         $required_items = ['encryption','host','port','from_email'];
     32        $required_items = array('encryption','host','port','from_email');
    3333       
    3434        foreach($required_items as $k => $v) {
     
    9696            $ret = wp_mail($data['email'], 'Test email -'.$blogname, 'This is a test email from your wordpress site');
    9797
    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");
    100100           
    101101            Sm_wp::instance()->enqueue_admin_message($message);
  • sendmachine/tags/1.0.4/includes/sendmachine_feed_manager.php

    r1226818 r1287956  
    1818        ) {
    1919
    20             $args = ['numberposts' => $feed['post_nr']];
     20            $args = array('numberposts' => $feed['post_nr']);
    2121
    2222            $body = $this->build_newsletter($feed);
    2323
    2424            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");
    2626               
    27             $res = $sm->create_campaign([
     27            $res = $sm->create_campaign(array(
    2828                "name" => $feed['sm_feed_campaign_name'],
    2929                "subject" => $feed['sm_feed_campaign_subject'],
     
    3131                "sender_email" => $feed['sender_email'],
    3232                "body_html" => $body
    33             ]);
     33            ));
    3434
    3535            if (isset($res['status']) && ($res['status'] == "created")) {
     
    3838
    3939                    $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");
    4141                }
    4242                elseif ($action == 'sm_feed_send_campaign') {
    4343
    4444                    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");
    4646
    4747                    if ($tested_cmp != "ok") {
     
    6161                        $reasons .= "</ul>";
    6262
    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");
    6464                    }
    6565
     
    6767
    6868                        $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");
    7070                    }
    7171                   
    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");
    7373                }
    7474            }
    7575           
    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");
    7777        }
    7878
    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");
    8080    }
    8181   
    8282    private function build_newsletter($feed_data = NULL) {
    8383
    84         $args = ['numberposts' => $feed_data['post_nr']];
     84        $args = array('numberposts' => $feed_data['post_nr']);
    8585
    8686        $rp = wp_get_recent_posts($args);
     
    119119    }
    120120   
    121     public function keywords($action, $args = []) {
     121    public function keywords($action, $args = array()) {
    122122
    123         $keywords = [
    124             "SITENAME" => [
     123        $keywords = array(
     124            "SITENAME" => array(
    125125                "value" => get_bloginfo('name'),
    126126                "description" => __("Your blog's title", SM_LANGUAGE_DOMAIN)
    127             ],
    128             "SITEDESCRIPTION" => [
     127            ),
     128            "SITEDESCRIPTION" => array(
    129129                "value" => get_option('blogdescription'),
    130130                "description" => __("Blog's description", SM_LANGUAGE_DOMAIN)
    131             ],
    132             "ADMINEMAIL" => [
     131            ),
     132            "ADMINEMAIL" => array(
    133133                "value" => get_option('admin_email'),
    134134                "description" => __("Administrator's email address", SM_LANGUAGE_DOMAIN)
    135             ],
    136             "SITEURL" => [
     135            ),
     136            "SITEURL" => array(
    137137                "value" => get_option('siteurl'),
    138138                "description" => __("Blog URL.", SM_LANGUAGE_DOMAIN)
    139             ],
    140             "POSTTITLE" => [
     139            ),
     140            "POSTTITLE" => array(
    141141                "value" => isset($args['post_title']) ? $args['post_title'] : "",
    142142                "description" => __("Display post title.Works only in template body", SM_LANGUAGE_DOMAIN)
    143             ],
    144             "POSTURL" => [
     143            ),
     144            "POSTURL" => array(
    145145                "value" => isset($args['guid']) ? $args['guid'] : "",
    146146                "description" => __("Post url. Works only in template body", SM_LANGUAGE_DOMAIN)
    147             ],
    148             "POSTCONTENTSUMMARY" => [
     147            ),
     148            "POSTCONTENTSUMMARY" => array(
    149149                "value" => isset($args['post_content']) ? substr($args['post_content'], 0, 300) . " [...]" : "",
    150150                "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(
    153153                "value" => isset($args['post_content']) ? $args['post_content'] : "",
    154154                "description" => __("Post's content (full content). Works only in template body", SM_LANGUAGE_DOMAIN)
    155             ],
    156             "POSTAUTHOR" => [
     155            ),
     156            "POSTAUTHOR" => array(
    157157                "value" => isset($args['post_author']) ? get_user_by('id', $args['post_author'])->data->user_nicename : "",
    158158                "description" => __("Who wrote post. Works only in template body", SM_LANGUAGE_DOMAIN)
    159             ],
    160             "POSTDATE" => [
     159            ),
     160            "POSTDATE" => array(
    161161                "value" => isset($args['post_date']) ? $args['post_date'] : "",
    162162                "description" => __("Post publish date. Works only in template body", SM_LANGUAGE_DOMAIN)
    163             ]
    164         ];
     163            )
     164        );
    165165
    166         $ret_arr = [];
     166        $ret_arr = array();
    167167       
    168168        foreach ($keywords as $keyword => $data) {
  • sendmachine/tags/1.0.4/includes/sendmachine_subscribe_manager.php

    r1230263 r1287956  
    1111        $this->app = $app_config;
    1212       
    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'));
    1919    }
    2020
     
    8080            wp_enqueue_style('sm-wp-widget-styles', plugins_url('static/css/sm-widget.css', SM_PLUGIN_FILE));
    8181            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(
    8383                'loading_img' => plugin_dir_url(SM_PLUGIN_FILE) . 'static/images/loading.gif',
    8484                'redirect' => $this->app['list']['redirect_subscribed'],
    8585                'response_not_arrived' => $this->app['list']['message_not_subscribed']
    86             ]);
     86            ));
    8787        }
    8888
     
    103103                $list_fields .= $list_field['form_name'] . " $required<br>";
    104104
    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"))) {
    106106                    $placeholder = "";
    107107                   
     
    168168            $fields = $this->app['list']['fields'];
    169169           
    170             $fn = [];
     170            $fn = array();
    171171            foreach($fields as $f) $fn[] = $f['name'];
    172172
     
    176176           
    177177            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");
    179179            elseif ($resp = $sm_api->subscribe($this->app['list']['id'], $email, $data)) {
    180180
     
    183183                if (trim($this->app['list']['redirect_subscribed']) && !$is_ajax) wp_redirect($this->app['list']['redirect_subscribed']);
    184184
    185                 $msg = ["message" => $this->app['list']['message_success_subscribe'], "status" => "success"];
     185                $msg = array("message" => $this->app['list']['message_success_subscribe'], "status" => "success");
    186186            }
    187187            else
    188                 $msg = ["message" => $this->app['list']['message_not_subscribed'], "status" => "error"];
     188                $msg = array("message" => $this->app['list']['message_not_subscribed'], "status" => "error");
    189189
    190190            if ($is_ajax) { echo json_encode($msg); exit(); }
     
    217217           
    218218            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");
    220220                Sm_wp::instance()->enqueue_admin_message($message);
    221221                return NULL;
     
    226226            $users = get_users(array( 'fields' => array( 'user_email' ) ));
    227227           
    228             $recipients = [];
     228            $recipients = array();
    229229            foreach($users as $k => $u){
    230230                array_push($recipients, $u->user_email);
     
    235235            $ret = $sm_api->mass_subscribe($this->app['list']['id'], $recipients);
    236236           
    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");
    239239
    240240            Sm_wp::instance()->enqueue_admin_message($message);
  • sendmachine/tags/1.0.4/includes/utils.php

    r1265625 r1287956  
    77    public static function add_notification($message = '', $section = 'general', $type = 'success') {
    88
    9         self::$notifications[$section] = ["message" => $message, "type" => $type];
     9        self::$notifications[$section] = array("message" => $message, "type" => $type);
    1010    }
    1111
  • sendmachine/tags/1.0.4/readme.txt

    r1265625 r1287956  
    44Requires at least: 3.2.1
    55Tested up to: 4.3
    6 Stable tag: 1.0.3
     6Stable tag: 1.0.4
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    9696== Changelog ==
    9797
     98= 1.0.4 =
     99* added php 5.3 compatibility
     100
    98101= 1.0.3 =
    99102* array_column bugfix
  • sendmachine/tags/1.0.4/sendmachine_widget.php

    r1230263 r1287956  
    55    function __construct() {
    66
    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));
    88        $title = __('Sendmachine list subscription', SM_LANGUAGE_DOMAIN);
    99
  • sendmachine/tags/1.0.4/sendmachine_wp.php

    r1265625 r1287956  
    55  Plugin URI: https://www.sendmachine.com
    66  Description: The official Sendmachine plugin featuring subscribe forms, users sync, news feed, email sending and transactional campaigns.
    7   Version: 1.0.3
     7  Version: 1.0.4
    88  Author: Sendmachine team
    99  Author URI: http://developers.sendmachine.com/
     
    2222    define('SM_WP_DEV_MODE', false);
    2323}
     24
     25error_reporting(E_ALL);
    2426
    2527require_once SM_PLUGIN_DIR . 'includes/utils.php';
     
    5254        $this->api_connected = !empty($this->app['api_connected']) ? true : false;
    5355
    54         add_action('init', [$this, 'load_translations']);
     56        add_action('init', array($this, 'load_translations'));
    5557       
    5658        if ($this->api_connected) {
    5759
    58             add_action('widgets_init', [$this, 'load_widgets']);
     60            add_action('widgets_init', array($this, 'load_widgets'));
    5961        }
    6062    }
  • sendmachine/tags/1.0.4/sendmachine_wp_admin.php

    r1226818 r1287956  
    33class Sm_wp_admin extends Sm_wp {
    44
    5     private $messages_queue = [];
     5    private $messages_queue = array();
    66   
    77    public function __construct() {
     
    1111        $this->load_admin_hooks();
    1212
    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'));
    1515    }
    1616
     
    1919        global $pagenow;
    2020
    21         add_action('admin_enqueue_scripts', [$this, 'styles_scripts']);
     21        add_action('admin_enqueue_scripts', array($this, 'styles_scripts'));
    2222       
    2323        if ($pagenow == "plugins.php") {
    2424
    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'));
    3030    }
    3131
     
    5252        wp_enqueue_style('sm-wp-admin-styles', plugins_url('static/css/sm-admin.css', SM_PLUGIN_FILE));
    5353        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(
    5555            '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        ));
    5757    }
    5858
     
    6666    public function sendmachine_settings_skeleton() {
    6767
    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'));
    7474    }
    7575
     
    111111   
    112112    public function sm_include($path = "", $display_notifications = true) {
    113 
     113       
    114114        if($display_notifications) settings_errors();
    115115        include(SM_PLUGIN_DIR . '/views/' . $path );
     
    134134        update_option(SM_OPTIONS_APP_NAME, $this->app);
    135135       
    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");
    137137        call_user_func_array("add_settings_error",$message);
    138138    }
    139139   
    140     private function manage_admin_actions($action = NULL, $data = []) {
     140    private function manage_admin_actions($action = NULL, $data = array()) {
    141141       
    142142        if(!$this->api_connected) $this->reset_app_data();
     
    175175                }
    176176
    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");
    178178            }
    179179        }
     
    188188
    189189                    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");
    191191                    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");
    193193                }
    194194            }
     
    209209                   
    210210                    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");
    212212                   
    213213                    if(!empty($this->app['email']['enable_service']) && empty($this->app['email']['emailpending'])) {
     
    218218                       
    219219                        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");
    221221                        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");
    223223                    }
    224224                }
     
    230230
    231231            $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']));
    233233           
    234234            return $this->feed_manager->manage_feed($feed, $this->sm, $action);
     
    251251        $keys_to_encode = $this->config["keys_to_encode"];
    252252       
    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) {
    254254           
    255255            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  
    11<?php
    2 $sm_feed_editor_settings = [
     2$sm_feed_editor_settings = array(
    33    'editor_height' => 150,
    44    'wpautop' => false
    5 ];
     5);
    66?>
    77<div class="wrap">
     
    100100                            <select class='sm_full' name="update[feed][post_nr]">
    101101                                <?php
    102                                 $nr = ['5', '10', '15', '20'];
     102                                $nr = array('5', '10', '15', '20');
    103103
    104104                                foreach ($nr as $k => $v) {
  • sendmachine/trunk/api/SendmachineApiClient.php

    r1226818 r1287956  
    8484                curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
    8585                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)));
    8787                break;
    8888            case 'DELETE':
    8989                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'));
    9191                break;
    9292        }
     
    145145    public function check_config() {
    146146
    147         $config_paths = [".sendmachine.conf", "/etc/.sendmachine.conf"];
     147        $config_paths = array(".sendmachine.conf", "/etc/.sendmachine.conf");
    148148        $username = null;
    149149        $password = null;
     
    166166        }
    167167
    168         return [$username, $password];
     168        return array($username, $password);
    169169    }
    170170
  • sendmachine/trunk/api/examples/list_examples.php

    r1226818 r1287956  
    4747     * update list details
    4848     */
    49     $sc->lists->edit($list_id, ['name' => 'new_list_name']);
     49    $sc->lists->edit($list_id, array('name' => 'new_list_name'));
    5050    $list_details = $sc->lists->details($list_id);
    5151    print_r($list_details);
     
    5353     * add contacts list to a existing list
    5454     */
    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');
    5656   
    5757    $updated_details = $sc->lists->recipients($list_id);
     
    6161    print_r($contact_details);
    6262   
    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'));
    6464   
    6565    /*
  • sendmachine/trunk/api/library/Campaigns.php

    r1226818 r1287956  
    3535    public function get($filter = 'all', $orderby = 'cdate', $offset = 0, $limit = 25, $search = null) {
    3636
    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);
    3838        return $this->master->request('/campaigns', 'GET', $params);
    3939    }
     
    106106    public function schedule($campaign_id, $date = "") {
    107107
    108         $params = ['date' => $date];
     108        $params = array('date' => $date);
    109109        return $this->master->request('/campaigns/schedule/' . $campaign_id, 'POST', $params);
    110110    }
     
    134134    public function test($campaign_id, $addresses = "") {
    135135
    136         $params = ['addresses' => $addresses];
     136        $params = array('addresses' => $addresses);
    137137        return $this->master->request('/campaigns/test/' . $campaign_id, 'POST', $params);
    138138    }
  • sendmachine/trunk/api/library/Lists.php

    r1226818 r1287956  
    3131    public function get($limit = 25, $offset = 0) {
    3232
    33         $params = ['limit' => $limit, 'offset' => $offset];
     33        $params = array('limit' => $limit, 'offset' => $offset);
    3434        return $this->master->request('/list', 'GET', $params);
    3535    }
     
    6262    public function recipients($list_id, $limit = 25, $offset = 0, $filter = 'all', $order_by = 'email', $segment_id = 0) {
    6363
    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);
    6565        return $this->master->request('/list/' . $list_id, 'GET', $params);
    6666    }
     
    132132    public function create($data) {
    133133
    134         $params = ['list_details' => $data];
     134        $params = array('list_details' => $data);
    135135        return $this->master->request('/list', 'POST', $params);
    136136    }
     
    150150    public function manage_contacts($list_id, $emails = "", $action = 'subscribe', $list_name = null) {
    151151
    152         $params = ['contacts' => $emails, 'action' => $action, 'name' => $list_name];
     152        $params = array('contacts' => $emails, 'action' => $action, 'name' => $list_name);
    153153        return $this->master->request('/list/' . $list_id, 'POST', $params);
    154154    }
     
    203203    public function edit($list_id, $data){
    204204       
    205         $params = ['list_details' => $data];
     205        $params = array('list_details' => $data);
    206206        return $this->master->request('/list/'.$list_id.'/details', 'POST', $params);
    207207    }
     
    247247    public function list_segments($list_id, $limit = 25, $offset = 0, $orderby = "adate", $sort = "desc") {
    248248
    249         $params = ['limit' => $limit, 'offset' => $offset, 'orderby' => $orderby, 'sort' => $sort];
     249        $params = array('limit' => $limit, 'offset' => $offset, 'orderby' => $orderby, 'sort' => $sort);
    250250        return $this->master->request('/list/'.$list_id.'/segment', 'GET', $params);
    251251    }
  • sendmachine/trunk/api/library/Sender.php

    r1226818 r1287956  
    3131    public function get($status = 'active', $type = 'email', $group = null, $limit = null, $offset = null) {
    3232
    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);
    3434        return $this->master->request('/sender', 'GET', $params);
    3535    }
     
    4949    public function add($email) {
    5050
    51         $params = ['type' => 'email', 'address' => $email];
     51        $params = array('type' => 'email', 'address' => $email);
    5252        return $this->master->request('/sender', 'POST', $params);
    5353    }
  • sendmachine/trunk/api/library/Templates.php

    r1226818 r1287956  
    2727    public function get($limit = 25, $offset = 0) {
    2828
    29         $params = ['limit' => $limit, 'offset' => $offset];
     29        $params = array('limit' => $limit, 'offset' => $offset);
    3030        return $this->master->request('/templates', 'GET', $params);
    3131    }
     
    5757    public function create($name, $body = "") {
    5858
    59         $params = ['name' => $name, 'body' => $body];
     59        $params = array('name' => $name, 'body' => $body);
    6060        return $this->master->request('/templates', 'POST', $params);
    6161    }
     
    7272    public function update($template_id, $body = "") {
    7373
    74         $params = ['body' => $body];
     74        $params = array('body' => $body);
    7575        return $this->master->request('/templates/' . $template_id, 'POST', $params);
    7676    }
  • sendmachine/trunk/includes/sendmachine_api.php

    r1226818 r1287956  
    149149    }
    150150   
    151     public function create_campaign($params = []){
     151    public function create_campaign($params = array()){
    152152       
    153153        if(!$params) return NULL;
  • sendmachine/trunk/includes/sendmachine_defaults.php

    r1226818 r1287956  
    11<?php
    22
    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'),
    66    "feed_delimiter" => "||%s||"
    7 ];
     7);
    88
    9 $sendmachine_defaults = [
    10     "list" => [
     9$sendmachine_defaults = array(
     10    "list" => array(
    1111        "hide_subscribed" => 0,
    1212        "redirect_subscribed" => "",
     
    1919        "checkbox_checked" => 0,
    2020        "simple_subscribe" => 1
    21     ],
    22     "email" => [
     21    ),
     22    "email" => array(
    2323        "enable_service" => 1,
    2424        "encryption" => "no_encryption",
     
    2727        "register_post_label" => "Register",
    2828        "comment_post_label" => "Comment"
    29     ],
    30     "feed" => [
     29    ),
     30    "feed" => array(
    3131        "post_nr" => 10,
    3232        "header_template" => "<h1>||SITENAME||</h1>",
     
    3535        "template_width" => "600px",
    3636        "template_bgcolor" => "#fff"
    37     ]
    38 ];
     37    )
     38);
  • sendmachine/trunk/includes/sendmachine_email_manager.php

    r1226818 r1287956  
    77    public function __construct() {
    88
    9         add_action('init', [$this, 'manage_email_requests']);
     9        add_action('init', array($this, 'manage_email_requests'));
    1010
    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'));
    1313
    14         add_action('phpmailer_init', [$this, 'configure_smtp']);
     14        add_action('phpmailer_init', array($this, 'configure_smtp'));
    1515    }
    1616
     
    3030        if (empty($sm->app['email']['enable_service']) || (empty($sm->app['email']['emailconfirmed']) && empty($sm->bypass_emailconfirmation))) return false;
    3131       
    32         $required_items = ['encryption','host','port','from_email'];
     32        $required_items = array('encryption','host','port','from_email');
    3333       
    3434        foreach($required_items as $k => $v) {
     
    9696            $ret = wp_mail($data['email'], 'Test email -'.$blogname, 'This is a test email from your wordpress site');
    9797
    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");
    100100           
    101101            Sm_wp::instance()->enqueue_admin_message($message);
  • sendmachine/trunk/includes/sendmachine_feed_manager.php

    r1226818 r1287956  
    1818        ) {
    1919
    20             $args = ['numberposts' => $feed['post_nr']];
     20            $args = array('numberposts' => $feed['post_nr']);
    2121
    2222            $body = $this->build_newsletter($feed);
    2323
    2424            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");
    2626               
    27             $res = $sm->create_campaign([
     27            $res = $sm->create_campaign(array(
    2828                "name" => $feed['sm_feed_campaign_name'],
    2929                "subject" => $feed['sm_feed_campaign_subject'],
     
    3131                "sender_email" => $feed['sender_email'],
    3232                "body_html" => $body
    33             ]);
     33            ));
    3434
    3535            if (isset($res['status']) && ($res['status'] == "created")) {
     
    3838
    3939                    $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");
    4141                }
    4242                elseif ($action == 'sm_feed_send_campaign') {
    4343
    4444                    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");
    4646
    4747                    if ($tested_cmp != "ok") {
     
    6161                        $reasons .= "</ul>";
    6262
    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");
    6464                    }
    6565
     
    6767
    6868                        $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");
    7070                    }
    7171                   
    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");
    7373                }
    7474            }
    7575           
    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");
    7777        }
    7878
    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");
    8080    }
    8181   
    8282    private function build_newsletter($feed_data = NULL) {
    8383
    84         $args = ['numberposts' => $feed_data['post_nr']];
     84        $args = array('numberposts' => $feed_data['post_nr']);
    8585
    8686        $rp = wp_get_recent_posts($args);
     
    119119    }
    120120   
    121     public function keywords($action, $args = []) {
     121    public function keywords($action, $args = array()) {
    122122
    123         $keywords = [
    124             "SITENAME" => [
     123        $keywords = array(
     124            "SITENAME" => array(
    125125                "value" => get_bloginfo('name'),
    126126                "description" => __("Your blog's title", SM_LANGUAGE_DOMAIN)
    127             ],
    128             "SITEDESCRIPTION" => [
     127            ),
     128            "SITEDESCRIPTION" => array(
    129129                "value" => get_option('blogdescription'),
    130130                "description" => __("Blog's description", SM_LANGUAGE_DOMAIN)
    131             ],
    132             "ADMINEMAIL" => [
     131            ),
     132            "ADMINEMAIL" => array(
    133133                "value" => get_option('admin_email'),
    134134                "description" => __("Administrator's email address", SM_LANGUAGE_DOMAIN)
    135             ],
    136             "SITEURL" => [
     135            ),
     136            "SITEURL" => array(
    137137                "value" => get_option('siteurl'),
    138138                "description" => __("Blog URL.", SM_LANGUAGE_DOMAIN)
    139             ],
    140             "POSTTITLE" => [
     139            ),
     140            "POSTTITLE" => array(
    141141                "value" => isset($args['post_title']) ? $args['post_title'] : "",
    142142                "description" => __("Display post title.Works only in template body", SM_LANGUAGE_DOMAIN)
    143             ],
    144             "POSTURL" => [
     143            ),
     144            "POSTURL" => array(
    145145                "value" => isset($args['guid']) ? $args['guid'] : "",
    146146                "description" => __("Post url. Works only in template body", SM_LANGUAGE_DOMAIN)
    147             ],
    148             "POSTCONTENTSUMMARY" => [
     147            ),
     148            "POSTCONTENTSUMMARY" => array(
    149149                "value" => isset($args['post_content']) ? substr($args['post_content'], 0, 300) . " [...]" : "",
    150150                "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(
    153153                "value" => isset($args['post_content']) ? $args['post_content'] : "",
    154154                "description" => __("Post's content (full content). Works only in template body", SM_LANGUAGE_DOMAIN)
    155             ],
    156             "POSTAUTHOR" => [
     155            ),
     156            "POSTAUTHOR" => array(
    157157                "value" => isset($args['post_author']) ? get_user_by('id', $args['post_author'])->data->user_nicename : "",
    158158                "description" => __("Who wrote post. Works only in template body", SM_LANGUAGE_DOMAIN)
    159             ],
    160             "POSTDATE" => [
     159            ),
     160            "POSTDATE" => array(
    161161                "value" => isset($args['post_date']) ? $args['post_date'] : "",
    162162                "description" => __("Post publish date. Works only in template body", SM_LANGUAGE_DOMAIN)
    163             ]
    164         ];
     163            )
     164        );
    165165
    166         $ret_arr = [];
     166        $ret_arr = array();
    167167       
    168168        foreach ($keywords as $keyword => $data) {
  • sendmachine/trunk/includes/sendmachine_subscribe_manager.php

    r1230263 r1287956  
    1111        $this->app = $app_config;
    1212       
    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'));
    1919    }
    2020
     
    8080            wp_enqueue_style('sm-wp-widget-styles', plugins_url('static/css/sm-widget.css', SM_PLUGIN_FILE));
    8181            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(
    8383                'loading_img' => plugin_dir_url(SM_PLUGIN_FILE) . 'static/images/loading.gif',
    8484                'redirect' => $this->app['list']['redirect_subscribed'],
    8585                'response_not_arrived' => $this->app['list']['message_not_subscribed']
    86             ]);
     86            ));
    8787        }
    8888
     
    103103                $list_fields .= $list_field['form_name'] . " $required<br>";
    104104
    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"))) {
    106106                    $placeholder = "";
    107107                   
     
    168168            $fields = $this->app['list']['fields'];
    169169           
    170             $fn = [];
     170            $fn = array();
    171171            foreach($fields as $f) $fn[] = $f['name'];
    172172
     
    176176           
    177177            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");
    179179            elseif ($resp = $sm_api->subscribe($this->app['list']['id'], $email, $data)) {
    180180
     
    183183                if (trim($this->app['list']['redirect_subscribed']) && !$is_ajax) wp_redirect($this->app['list']['redirect_subscribed']);
    184184
    185                 $msg = ["message" => $this->app['list']['message_success_subscribe'], "status" => "success"];
     185                $msg = array("message" => $this->app['list']['message_success_subscribe'], "status" => "success");
    186186            }
    187187            else
    188                 $msg = ["message" => $this->app['list']['message_not_subscribed'], "status" => "error"];
     188                $msg = array("message" => $this->app['list']['message_not_subscribed'], "status" => "error");
    189189
    190190            if ($is_ajax) { echo json_encode($msg); exit(); }
     
    217217           
    218218            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");
    220220                Sm_wp::instance()->enqueue_admin_message($message);
    221221                return NULL;
     
    226226            $users = get_users(array( 'fields' => array( 'user_email' ) ));
    227227           
    228             $recipients = [];
     228            $recipients = array();
    229229            foreach($users as $k => $u){
    230230                array_push($recipients, $u->user_email);
     
    235235            $ret = $sm_api->mass_subscribe($this->app['list']['id'], $recipients);
    236236           
    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");
    239239
    240240            Sm_wp::instance()->enqueue_admin_message($message);
  • sendmachine/trunk/includes/utils.php

    r1265625 r1287956  
    77    public static function add_notification($message = '', $section = 'general', $type = 'success') {
    88
    9         self::$notifications[$section] = ["message" => $message, "type" => $type];
     9        self::$notifications[$section] = array("message" => $message, "type" => $type);
    1010    }
    1111
  • sendmachine/trunk/readme.txt

    r1265625 r1287956  
    44Requires at least: 3.2.1
    55Tested up to: 4.3
    6 Stable tag: 1.0.3
     6Stable tag: 1.0.4
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    9696== Changelog ==
    9797
     98= 1.0.4 =
     99* added php 5.3 compatibility
     100
    98101= 1.0.3 =
    99102* array_column bugfix
  • sendmachine/trunk/sendmachine_widget.php

    r1230263 r1287956  
    55    function __construct() {
    66
    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));
    88        $title = __('Sendmachine list subscription', SM_LANGUAGE_DOMAIN);
    99
  • sendmachine/trunk/sendmachine_wp.php

    r1265625 r1287956  
    55  Plugin URI: https://www.sendmachine.com
    66  Description: The official Sendmachine plugin featuring subscribe forms, users sync, news feed, email sending and transactional campaigns.
    7   Version: 1.0.3
     7  Version: 1.0.4
    88  Author: Sendmachine team
    99  Author URI: http://developers.sendmachine.com/
     
    2222    define('SM_WP_DEV_MODE', false);
    2323}
     24
     25error_reporting(E_ALL);
    2426
    2527require_once SM_PLUGIN_DIR . 'includes/utils.php';
     
    5254        $this->api_connected = !empty($this->app['api_connected']) ? true : false;
    5355
    54         add_action('init', [$this, 'load_translations']);
     56        add_action('init', array($this, 'load_translations'));
    5557       
    5658        if ($this->api_connected) {
    5759
    58             add_action('widgets_init', [$this, 'load_widgets']);
     60            add_action('widgets_init', array($this, 'load_widgets'));
    5961        }
    6062    }
  • sendmachine/trunk/sendmachine_wp_admin.php

    r1226818 r1287956  
    33class Sm_wp_admin extends Sm_wp {
    44
    5     private $messages_queue = [];
     5    private $messages_queue = array();
    66   
    77    public function __construct() {
     
    1111        $this->load_admin_hooks();
    1212
    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'));
    1515    }
    1616
     
    1919        global $pagenow;
    2020
    21         add_action('admin_enqueue_scripts', [$this, 'styles_scripts']);
     21        add_action('admin_enqueue_scripts', array($this, 'styles_scripts'));
    2222       
    2323        if ($pagenow == "plugins.php") {
    2424
    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'));
    3030    }
    3131
     
    5252        wp_enqueue_style('sm-wp-admin-styles', plugins_url('static/css/sm-admin.css', SM_PLUGIN_FILE));
    5353        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(
    5555            '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        ));
    5757    }
    5858
     
    6666    public function sendmachine_settings_skeleton() {
    6767
    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'));
    7474    }
    7575
     
    111111   
    112112    public function sm_include($path = "", $display_notifications = true) {
    113 
     113       
    114114        if($display_notifications) settings_errors();
    115115        include(SM_PLUGIN_DIR . '/views/' . $path );
     
    134134        update_option(SM_OPTIONS_APP_NAME, $this->app);
    135135       
    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");
    137137        call_user_func_array("add_settings_error",$message);
    138138    }
    139139   
    140     private function manage_admin_actions($action = NULL, $data = []) {
     140    private function manage_admin_actions($action = NULL, $data = array()) {
    141141       
    142142        if(!$this->api_connected) $this->reset_app_data();
     
    175175                }
    176176
    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");
    178178            }
    179179        }
     
    188188
    189189                    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");
    191191                    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");
    193193                }
    194194            }
     
    209209                   
    210210                    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");
    212212                   
    213213                    if(!empty($this->app['email']['enable_service']) && empty($this->app['email']['emailpending'])) {
     
    218218                       
    219219                        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");
    221221                        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");
    223223                    }
    224224                }
     
    230230
    231231            $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']));
    233233           
    234234            return $this->feed_manager->manage_feed($feed, $this->sm, $action);
     
    251251        $keys_to_encode = $this->config["keys_to_encode"];
    252252       
    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) {
    254254           
    255255            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  
    11<?php
    2 $sm_feed_editor_settings = [
     2$sm_feed_editor_settings = array(
    33    'editor_height' => 150,
    44    'wpautop' => false
    5 ];
     5);
    66?>
    77<div class="wrap">
     
    100100                            <select class='sm_full' name="update[feed][post_nr]">
    101101                                <?php
    102                                 $nr = ['5', '10', '15', '20'];
     102                                $nr = array('5', '10', '15', '20');
    103103
    104104                                foreach ($nr as $k => $v) {
Note: See TracChangeset for help on using the changeset viewer.