Plugin Directory

Changeset 1681124


Ignore:
Timestamp:
06/19/2017 12:40:02 PM (9 years ago)
Author:
sarbacanesoftware
Message:

mailify 1.4.7

Location:
mailify
Files:
28 edited
1 copied

Legend:

Unmodified
Added
Removed
  • mailify/tags/1.4.7/class.sarbacane-about.php

    r1677274 r1681124  
    1414            return;
    1515        }
    16         wp_enqueue_style ( "sarbacane_global.css", plugins_url ( "css/sarbacane_global.css", __FILE__ ), array(), '1.4.6' );
    17         wp_enqueue_style ( "sarbacane_about.css", plugins_url ( "css/sarbacane_about.css", __FILE__ ), array(), '1.4.6' );
    18         require_once( "views/sarbacane-about.php" );
     16        wp_enqueue_style ( 'sarbacane_global.css', plugins_url ( 'css/sarbacane_global.css', __FILE__ ), array(), '1.4.7' );
     17        wp_enqueue_style ( 'sarbacane_about.css', plugins_url ( 'css/sarbacane_about.css', __FILE__ ), array(), '1.4.7' );
     18        require_once( 'views/sarbacane-about.php' );
    1919    }
    2020
  • mailify/tags/1.4.7/class.sarbacane-content.php

    r1576277 r1681124  
    55    private function get_rss_header() {
    66        return '<?xml version="1.0" encoding="UTF-8"?>
    7     <rss version="2.0"  xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/"
    8     xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/">
     7<rss version="2.0"
     8xmlns:content="http://purl.org/rss/1.0/modules/content/"
     9xmlns:wfw="http://wellformedweb.org/CommentAPI/"
     10xmlns:dc="http://purl.org/dc/elements/1.1/"
     11xmlns:atom="http://www.w3.org/2005/Atom"
     12xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
     13xmlns:slash="http://purl.org/rss/1.0/modules/slash/">
    914    <channel>
    1015        <title>' . get_bloginfo_rss( 'name' ) . '</title>
     
    1419
    1520    private function get_rss_footer() {
    16         return '</channel></rss>';
     21        return '
     22    </channel>
     23</rss>';
    1724    }
    1825
     
    2734        while ( $query->have_posts() ) {
    2835            $query->the_post();
    29             $items .= '<item>
     36            if ( post_password_required() ) {
     37                continue;
     38            }
     39            $items .= "\n\t\t" . '<item>
    3040            <title>' . get_the_title_rss() . '</title>
    3141            <link>' . esc_url( apply_filters( 'the_permalink_rss', get_permalink() ) ) . '</link>
    3242            <id>' . get_the_ID() . '</id>
    3343            <pubDate>' . mysql2date( 'D, d M Y H:i:s +0000', get_post_time( 'Y-m-d H:i:s', true ), false ) . '</pubDate>
    34             <dc:creator><![CDATA[' . get_the_author() . ']]></dc:creator>
    35             ' . get_the_category_rss( 'rss2' );
     44            <dc:creator><![CDATA[' . get_the_author() . ']]></dc:creator>' .
     45            "\n\t" . get_the_category_rss( 'rss2' );
    3646            if ( $option === 'posts' ) {
    37                 $items .= '<description><![CDATA[' . apply_filters( 'the_excerpt_rss', get_the_excerpt() ) . ']]></description>';
     47                $items .= "\t\t\t" . '<description><![CDATA[' . apply_filters( 'the_excerpt_rss', get_the_excerpt() ) . ']]></description>' . "\n";
    3848            }
    39             $content = get_the_content_feed( 'rss2' );
    40             $items .= '<content:encoded><![CDATA[' . $content . ']]></content:encoded>';
    41             $items .= '<slash:comments>' . get_comments_number() . '</slash:comments>';
     49            $items .= "\t\t\t" . '<content:encoded><![CDATA[' . get_the_content_feed( 'rss2' ) . ']]></content:encoded>
     50            <slash:comments>' . get_comments_number() . '</slash:comments>';
    4251            $media = get_attached_media( 'image' );
    4352            if ( is_array( $media ) && count( $media ) > 0 ) {
    4453                $all_medias_key = array_keys( $media );
    45                 $items .= '<enclosure url="' . $media [ $all_medias_key [0] ]->guid . '" type="' . $media [ $all_medias_key [0] ]->post_mime_type . '" />';
     54                $items .= "\n\t\t\t" . '<enclosure url="' . $media [ $all_medias_key [0] ]->guid . '" type="' . $media [ $all_medias_key [0] ]->post_mime_type . '" />';
    4655            }
    47             $items .= rss_enclosure();
    48             do_action( 'rss2_item' );
    49             $items .= '</item>';
     56            $items .= "\n\t\t" . '</item>';
    5057        }
    5158        return $items;
     
    5764            echo $this->get_rss_header() . $this->get_rss_content( 'post', $post_id ) . $this->get_rss_footer();
    5865        } else {
    59             header( "HTTP/1.1 404 Bad item" );
    60             header( "Content-Type: application/json ; charset=utf-8" );
    61             die ( 'FAILED_ID' );
     66            header( 'HTTP/1.1 404 Bad item' );
     67            header( 'Content-Type: application/json; charset=utf-8' );
     68            die( 'FAILED_ID' );
    6269        }
    6370    }
  • mailify/tags/1.4.7/class.sarbacane-lists-sync.php

    r1677274 r1681124  
    3131                }
    3232                global $wpdb;
    33                 $table_name = $wpdb->prefix . 'sd_updates';
    34                 $wpdb->query( "TRUNCATE TABLE `$table_name`" );
     33                $wpdb->query( "TRUNCATE TABLE `{$wpdb->prefix}sd_updates`" );
    3534            }
    3635
    37             if ( isset( $_POST['sarbacane_news_list'] ) && "true" == $_POST['sarbacane_news_list'] ) {
     36            if ( isset( $_POST['sarbacane_news_list'] ) && $_POST['sarbacane_news_list'] == 'true' ) {
    3837                update_option( 'sarbacane_news_list', true, false );
    3938                $fields = get_option( 'sarbacane_news_fields' );
    4039                if ( ! is_array( $fields ) || count( $fields ) == 0 ) {
    41                     $default_email = new stdClass ();
     40                    $default_email = new stdClass();
    4241                    $default_email->label = 'email';
    4342                    $default_email->placeholder = '';
     
    5352            }
    5453
    55             if ( isset( $_POST['sarbacane_theme_sync'] ) && "true" == $_POST['sarbacane_theme_sync'] ) {
     54            if ( isset( $_POST['sarbacane_theme_sync'] ) && $_POST['sarbacane_theme_sync'] == 'true' ) {
    5655                update_option( 'sarbacane_theme_sync', true, false );
    5756            } else {
     
    5958            }
    6059
    61             if ( isset( $_POST['sarbacane_blog_content'] ) && "true" == $_POST['sarbacane_blog_content'] ) {
     60            if ( isset( $_POST['sarbacane_blog_content'] ) && $_POST['sarbacane_blog_content'] == 'true' ) {
    6261                update_option( 'sarbacane_blog_content', true, false );
    6362            } else {
     
    6564            }
    6665
    67             if ( isset( $_POST['sarbacane_media_content'] ) && "true" == $_POST['sarbacane_media_content'] ) {
     66            if ( isset( $_POST['sarbacane_media_content'] ) && $_POST['sarbacane_media_content'] == 'true' ) {
    6867                update_option( 'sarbacane_media_content', true, false );
    6968            } else {
     
    7170            }
    7271
    73             if ( isset( $_POST['sarbacane_rss_data'] ) && "true" == $_POST['sarbacane_rss_data'] ) {
     72            if ( isset( $_POST['sarbacane_rss_data'] ) && $_POST['sarbacane_rss_data'] == 'true' ) {
    7473                update_option( 'sarbacane_rss_data', true, false );
    7574            } else {
     
    7776            }
    7877        }
    79         wp_enqueue_style ( "sarbacane_global.css", plugins_url ( "css/sarbacane_global.css" , __FILE__ ), array(), '1.4.6' );
    80         wp_enqueue_style ( "sarbacane_lists_config.css", plugins_url ( "css/sarbacane_lists_config.css", __FILE__ ), array(), '1.4.6' );
    81         wp_enqueue_script( "sarbacane-lists-sync.js", plugins_url( "js/sarbacane-lists-sync.js", __FILE__ ), array( 'jquery' ), '1.4.6' );
     78        wp_enqueue_style ( 'sarbacane_global.css', plugins_url ( 'css/sarbacane_global.css', __FILE__ ), array(), '1.4.7' );
     79        wp_enqueue_style ( 'sarbacane_lists_config.css', plugins_url ( 'css/sarbacane_lists_config.css', __FILE__ ), array(), '1.4.7' );
     80        wp_enqueue_script( 'sarbacane-lists-sync.js', plugins_url( 'js/sarbacane-lists-sync.js', __FILE__ ), array( 'jquery' ), '1.4.7' );
    8281        $sarbacane_news_list = get_option( 'sarbacane_news_list', false );
    8382        $sarbacane_users_list = get_option( 'sarbacane_users_list', false );
     
    8887        $sarbacane_rss_data = get_option( 'sarbacane_rss_data', false );
    8988
    90         require_once( "views/sarbacane-lists-sync.php" );
     89        require_once( 'views/sarbacane-lists-sync.php' );
    9190    }
    9291
  • mailify/tags/1.4.7/class.sarbacane-medias.php

    r1576277 r1681124  
    55    public function get_medias() {
    66        $wp_query = new WP_Query( array( 'post_type' => 'attachment', 'post_status' => 'inherit' ) );
    7         $return_string = '{"medias":[';
     7        $medias = array();
    88        if ( $wp_query->have_posts() ) {
    99            while ( $wp_query->have_posts() ) {
    1010                $wp_query->the_post();
    1111                $thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id(), 'thumbnail' );
    12                 $return_string .= '
    13     {"name":"' . get_the_title() . '",
    14     "url":"' . get_the_guid() . '",
    15     "mime_type":"' . get_post_mime_type() . '",
    16     "thumbnail":"' . $thumbnail[0] . '"},';
     12                $medias[] = '
     13    {
     14        "name":"' . get_the_title() . '",
     15        "url":"' . get_the_guid() . '",
     16        "mime_type":"' . get_post_mime_type() . '",
     17        "thumbnail":"' . $thumbnail[0] . '"
     18    }';
    1719            }
    1820        }
    19         $return_string = rtrim( $return_string, ',' );
    20         $return_string .= '
    21     ]
    22 }';
    23         echo $return_string;
     21        $medias = implode( ',', $medias );
     22        echo '{"medias":[' . $medias . "\n\t" . ']' . "\n" . '}';
    2423    }
    2524
  • mailify/tags/1.4.7/class.sarbacane-newsletterwidget.php

    r1677274 r1681124  
    2424    public function sarbacane_save_widget() {
    2525        $valid = false;
    26         if ( isset ( $_POST ['email'] ) ) {
    27             $user_registring = new stdClass ();
    28             $user_registring->email = sanitize_email( $_POST ['email'] );
    29             if ( is_email( $user_registring->email ) ) {
    30                 $fields = get_option( 'sarbacane_news_fields', array() );
    31                 $columns = array();
    32                 foreach ( $fields as $field ) {
    33                     if ( strtolower( $field->label ) == 'email' ) {
    34                         continue;
    35                     }
    36                     $field_label = $field->label;
    37                     $field_label_html = str_replace( ' ', '_', $field->label );
    38                     $field_label = strtolower( $field_label );
    39                     if ( isset ( $_POST [ $field_label_html ] ) ) {
    40                         $fieldValue = stripslashes( sanitize_text_field( $_POST [ $field_label_html ] ) );
    41                     } else {
    42                         $fieldValue = '';
    43                     }
    44                     $user_registring->$field_label = $fieldValue;
    45                     $columns [ $field_label ] = $fieldValue;
     26        if ( isset ( $_POST ['sarbacane_form_value'] ) && isset ( $_POST ['email'] ) ) {
     27            $sarbacane_form_value = sanitize_text_field( $_POST ['sarbacane_form_value'] );
     28            if ($sarbacane_form_value == 'sarbacane_desktop_widget' ) {
     29                $user_registering = new stdClass();
     30                $user_registering->email = sanitize_email( $_POST ['email'] );
     31                if ( is_email( $user_registering->email ) ) {
     32                    $fields = get_option( 'sarbacane_news_fields', array() );
     33                    $columns = array();
     34                    foreach ( $fields as $field ) {
     35                        if ( strtolower( $field->label ) == 'email' ) {
     36                            continue;
     37                        }
     38                        $field_label = $field->label;
     39                        $field_label_html = str_replace( ' ', '_', $field->label );
     40                        $field_label = strtolower( $field_label );
     41                        if ( isset ( $_POST [ $field_label_html ] ) ) {
     42                            $fieldValue = stripslashes( sanitize_text_field( $_POST [ $field_label_html ] ) );
     43                        } else {
     44                            $fieldValue = '';
     45                        }
     46                        $user_registering->$field_label = $fieldValue;
     47                        $columns [ $field_label ] = $fieldValue;
     48                    }
     49                    $user_registering->registration_date = gmdate( 'Y-m-d H:i:s' );
     50                    $version = get_option( 'sarbacane_version' );
     51                    $result = true;
     52                    if ( $version !== false ) {
     53                        global $wpdb;
     54                        $sql = "INSERT INTO `{$wpdb->prefix}sd_subscribers` (`email`, `columns`, `registration_date`) VALUES (%s, %s, %s);";
     55                        $result = $wpdb->query( $wpdb->prepare( $sql, $user_registering->email, json_encode( $columns ), $user_registering->registration_date ) );
     56                    }
     57                    if ( $version === false || $result === false ) {
     58                        $users_registered = get_option( 'sarbacane_newsletter_list', array() );
     59                        $users_registered[] = $user_registering;
     60                        update_option( 'sarbacane_newsletter_list', $users_registered, false );
     61                    }
     62                    $valid = true;
    4663                }
    47                 $user_registring->registration_date = gmdate( 'Y-m-d H:i:s' );
    48                 $version = get_option( 'sarbacane_version' );
    49                 $result = true;
    50                 if ( $version !== false ) {
    51                     global $wpdb;
    52                     $table_name = $wpdb->prefix . 'sd_subscribers';
    53                     $sql = "INSERT INTO `$table_name` (`email`, `columns`, `registration_date`) VALUES (%s, %s, %s);";
    54                     $result = $wpdb->query( $wpdb->prepare( $sql, $user_registring->email, json_encode( $columns ), $user_registring->registration_date ) );
    55                 }
    56                 if ( $version === false || $result === false ) {
    57                     $users_registred = get_option( 'sarbacane_newsletter_list', array() );
    58                     $users_registred[] = $user_registring;
    59                     update_option( 'sarbacane_newsletter_list', $users_registred, false );
    60                 }
    61                 $valid = true;
    6264            }
    6365        }
     
    8486        $fields = get_option( 'sarbacane_news_fields', array() );
    8587        if ( ! is_array( $fields ) || count( $fields ) == 0 ) {
    86             $default_email = new stdClass ();
     88            $default_email = new stdClass();
    8789            $default_email->label = 'email';
    8890            $default_email->placeholder = '';
     
    9597        $list_type = 'N';
    9698        $rand = mt_rand( 0, 1000000 );
    97         wp_enqueue_script( "sarbacane-widget.js", plugins_url( "js/sarbacane-widget.js", __FILE__ ), array( 'jquery' ), '1.4.6' );
    98         wp_enqueue_style( "sarbacane_widget.css", plugins_url( "css/sarbacane_widget.css", __FILE__ ), array(), '1.4.6' );
    99         include( "views/sarbacane-widget.php" );
     99        wp_enqueue_script( 'sarbacane-widget.js', plugins_url( 'js/sarbacane-widget.js', __FILE__ ), array( 'jquery' ), '1.4.7' );
     100        wp_enqueue_style( 'sarbacane_widget.css', plugins_url( 'css/sarbacane_widget.css', __FILE__ ), array(), '1.4.7' );
     101        include( 'views/sarbacane-widget.php' );
    100102    }
    101103
     
    119121            return;
    120122        }
    121         wp_enqueue_style( "sarbacane_global.css", plugins_url( "css/sarbacane_global.css", __FILE__ ), array( 'wp-admin' ), '1.4.6' );
    122         wp_enqueue_style( "sarbacane_widget_admin_panel.css", plugins_url( "css/sarbacane_widget_admin_panel.css", __FILE__ ), array( 'wp-admin' ), '1.4.6' );
    123         wp_enqueue_script( "sarbacane-widget-adminpanel.js", plugins_url( "js/sarbacane-widget-adminpanel.js", __FILE__ ), array( 'jquery', 'underscore' ), '1.4.6' );
     123        wp_enqueue_style( 'sarbacane_global.css', plugins_url( 'css/sarbacane_global.css', __FILE__ ), array( 'wp-admin' ), '1.4.7' );
     124        wp_enqueue_style( 'sarbacane_widget_admin_panel.css', plugins_url( 'css/sarbacane_widget_admin_panel.css', __FILE__ ), array( 'wp-admin' ), '1.4.7' );
     125        wp_enqueue_script( 'sarbacane-widget-adminpanel.js', plugins_url( 'js/sarbacane-widget-adminpanel.js', __FILE__ ), array( 'jquery', 'underscore' ), '1.4.7' );
    124126        $nonce_ok = false;
    125127        if ( isset( $_POST ['sarbacane_token'] ) ) {
     
    148150        $fields = get_option( 'sarbacane_news_fields', array() );
    149151        if ( ! is_array( $fields ) || count( $fields ) == 0 ) {
    150             $default_email = new stdClass ();
     152            $default_email = new stdClass();
    151153            $default_email->label = 'email';
    152154            $default_email->placeholder = '';
     
    156158        }
    157159
    158         require_once 'views/sarbacane-widget-adminpanel.php';
     160        require_once( 'views/sarbacane-widget-adminpanel.php' );
    159161    }
    160162
     
    173175        if ( isset ( $field_number ) && $field_number > 0 ) {
    174176            for ( $i = 0; $i < $field_number; $i ++ ) {
    175                 $field_config = new stdClass ();
     177                $field_config = new stdClass();
    176178                if ( isset ( $sanitized_post [ 'sarbacane_label_' . $i ] ) && '' != $sanitized_post [ 'sarbacane_label_' . $i ] ) {
    177179                    $field_config->label = $sanitized_post [ 'sarbacane_label_' . $i ];
  • mailify/tags/1.4.7/class.sarbacane-settings.php

    r1576277 r1681124  
    1010        $media_content = get_option( 'sarbacane_media_content', false );
    1111        $rss_data = get_option( 'sarbacane_rss_data', false );
    12         $rss_url = get_feed_link( "rss2" );
     12        $rss_url = get_feed_link( 'rss2' );
    1313        $posts_per_rss = get_option( 'posts_per_rss', 10 );
    1414        //forcing boolean to display as int to get 0 when false. Impossible otherwise
  • mailify/tags/1.4.7/class.sarbacane.php

    r1677274 r1681124  
    88    /**
    99     * Method called on plugin activation.
    10      * Initiate some options, creates the sd updates table
    1110     */
    1211    public static function activation() {
    13         update_option( 'sarbacane_version', '1.4.6', false );
     12        update_option( 'sarbacane_version', '1.4.7', false );
    1413        update_option( 'sarbacane_sd_token', '', false );
    1514        update_option( 'sarbacane_sd_id_list', array(), false );
     
    1716
    1817        global $wpdb;
    19         $table_name = $wpdb->prefix . 'sd_updates';
    20         $sql = "DROP TABLE IF EXISTS `$table_name`";
     18        $sql = "DROP TABLE IF EXISTS `{$wpdb->prefix}sd_updates`";
    2119        $wpdb->query( $sql );
    2220        $charset_collate = $wpdb->get_charset_collate();
    23         $sql = "CREATE TABLE IF NOT EXISTS `$table_name` (
     21        $sql = "CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}sd_updates` (
    2422            `id` mediumint(9) NOT NULL AUTO_INCREMENT,
    2523            `time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
     
    2826            `action` text NOT NULL,
    2927            UNIQUE KEY `id` (`id`)
    30         ) $charset_collate;";
     28        ) {$charset_collate};";
    3129        $wpdb->query( $sql );
    32         $table_name = $wpdb->prefix . 'sd_subscribers';
    33         //$sql = "DROP TABLE IF EXISTS `$table_name`";
     30        //$sql = "DROP TABLE IF EXISTS `{$wpdb->prefix}sd_subscribers`";
    3431        //$wpdb->query( $sql );
    35         $charset_collate = $wpdb->get_charset_collate();
    36         $sql = "CREATE TABLE IF NOT EXISTS `$table_name` (
     32        $sql = "CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}sd_subscribers` (
    3733            `id` mediumint(9) NOT NULL AUTO_INCREMENT,
    3834            `email` varchar(255) DEFAULT NULL,
     
    4036            `registration_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
    4137            UNIQUE KEY `id` (`id`)
    42         ) $charset_collate;";
     38        ) {$charset_collate};";
    4339        $wpdb->query( $sql );
    4440    }
     
    4642    /**
    4743     * Method called on plugin deactivation.
    48      * Deletes all options created by the plugin and drops the sd_updates table
    4944     */
    5045    public static function deactivation() {
     
    8075
    8176        global $wpdb;
    82         $table_name = $wpdb->prefix . 'sd_updates';
    83         $sql = "DROP TABLE IF EXISTS `$table_name`";
     77        $sql = "DROP TABLE IF EXISTS `{$wpdb->prefix}sd_updates`";
    8478        $wpdb->query( $sql );
    85         //$table_name = $wpdb->prefix . 'sd_subscribers';
    86         //$sql = "DROP TABLE IF EXISTS `$table_name`";
     79        //$sql = "DROP TABLE IF EXISTS `{$wpdb->prefix}sd_subscribers`";
    8780        //$wpdb->query( $sql );
    8881    }
     
    9083    public function update_data_1_4_5() {
    9184        if ( get_option( 'sarbacane_version' ) === false ) {
    92             update_option( 'sarbacane_version', '1.4.6', false );
     85            update_option( 'sarbacane_version', '1.4.7', false );
    9386            try {
    9487                global $wpdb;
    95                 $table_name = $wpdb->prefix . 'sd_subscribers';
    9688                $charset_collate = $wpdb->get_charset_collate();
    97                 $sql = "CREATE TABLE IF NOT EXISTS `$table_name` (
     89                $sql = "CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}sd_subscribers` (
    9890                    `id` mediumint(9) NOT NULL AUTO_INCREMENT,
    9991                    `email` varchar(255) DEFAULT NULL,
     
    10193                    `registration_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
    10294                    UNIQUE KEY `id` (`id`)
    103                 ) $charset_collate;";
     95                ) {$charset_collate};";
    10496                $result = $wpdb->query( $sql );
    10597                if ( $result !== false ) {
     
    109101                        $insert_request = array();
    110102                        $insert_data = array();
    111                         $sql = "SELECT COUNT(*) FROM `$table_name`";
     103                        $sql = "SELECT COUNT(*) FROM `{$wpdb->prefix}sd_subscribers`";
    112104                        $count = $wpdb->get_var( $sql );
    113105                        if ( $count == 0) {
     
    129121                                    $insert_data[] = $registration_date;
    130122                                    if ( $key % 1000 == 0 || $key + 1 == $nb_subscribers ) {
    131                                         $sql = "INSERT INTO `$table_name` (`email`, `columns`, `registration_date`) VALUES " . implode( ',', $insert_request ) . ";";
     123                                        $sql = "INSERT INTO `{$wpdb->prefix}sd_subscribers` (`email`, `columns`, `registration_date`) VALUES " . implode( ',', $insert_request ) . ";";
    132124                                        $wpdb->query( $wpdb->prepare( $sql, $insert_data ) );
    133125                                        $insert_request = array();
     
    146138                    }
    147139                    update_option( 'sarbacane_sd_id_list', array(), false );
    148                     $table_name = $wpdb->prefix . 'sd_updates';
    149                     $wpdb->query( "TRUNCATE TABLE `$table_name`" );
     140                    $wpdb->query( "TRUNCATE TABLE `{$wpdb->prefix}sd_updates`" );
    150141                } else {
    151142                    delete_option( 'sarbacane_version' );
     
    202193        }
    203194        if ( $sd_list_id != '' ) {
    204             if ( "U" == $sd_list_id ) {
     195            if ( $sd_list_id == 'U' ) {
    205196                $this->get_users_list( $sd_id );
    206             } else if ( "N" == $sd_list_id ) {
     197            } else if ( $sd_list_id == 'N' ) {
    207198                $this->get_newsletter_list( $sd_id );
    208199            }
     
    213204
    214205    private function generate_available_lists( $sd_id, $user_sync, $newsletter_sync ) {
    215         echo 'list_id;name;reset;is_updated;type;version' . "\r\n";
    216 
     206        echo 'list_id;name;reset;is_updated;type;version' . "\n";
    217207        $last_call_date_N = get_option( 'sarbacane_news_call_' . $sd_id );
    218208        $last_call_date_C = get_option( 'sarbacane_user_call_' . $sd_id );
     
    240230        }
    241231        if ( $user_sync ) {
    242             echo 'U;' . get_bloginfo( 'name' ) . ';' . $sd_list_users_reset . ';' . $user_updated . ';Wordpress;' . get_bloginfo( 'version' ) . "\r\n";
     232            echo 'U;' . get_bloginfo( 'name' ) . ';' . $sd_list_users_reset . ';' . $user_updated . ';Wordpress;' . get_bloginfo( 'version' ) . "\n";
    243233        }
    244234        if ( $newsletter_sync ) {
    245             echo 'N;' . get_bloginfo( 'name' ) . ';' . $sd_list_news_reset . ';' . $newsletter_updated . ';Wordpress;' . get_bloginfo( 'version' ) . "\r\n";
     235            echo 'N;' . get_bloginfo( 'name' ) . ';' . $sd_list_news_reset . ';' . $newsletter_updated . ';Wordpress;' . get_bloginfo( 'version' ) . "\n";
    246236        }
    247237    }
     
    256246    private function check_users_list( $last_call_date ) {
    257247        global $wpdb;
    258         $wp_prefix = $wpdb->prefix;
    259         $table_name = $wpdb->prefix . 'sd_updates';
    260 
    261         $new_users_since_last_call = $wpdb->get_var( $wpdb->prepare( 'SELECT COUNT(*) FROM `' . $wp_prefix . 'users` AS `wu` WHERE `wu`.`user_registered` >= %s', $last_call_date ) );
    262         $update_users_since_last_call = $wpdb->get_var( $wpdb->prepare( 'SELECT COUNT(*) FROM `' . $table_name . '` AS `wsu` WHERE `wsu`.`time` >= %s', $last_call_date ) );
     248        $sql = "SELECT COUNT(*) FROM `{$wpdb->prefix}users` AS `wu` WHERE `wu`.`user_registered` >= %s";
     249        $new_users_since_last_call = $wpdb->get_var( $wpdb->prepare( $sql, $last_call_date ) );
     250        $sql = "SELECT COUNT(*) FROM `{$wpdb->prefix}sd_updates` AS `wsu` WHERE `wsu`.`time` >= %s";
     251        $update_users_since_last_call = $wpdb->get_var( $wpdb->prepare( $sql, $last_call_date ) );
    263252        return $new_users_since_last_call > 0 || $update_users_since_last_call > 0;
    264253    }
     
    273262    private function check_newsletter_list( $last_call_date = '' ) {
    274263        global $wpdb;
    275         $table_name = $wpdb->prefix . 'sd_subscribers';
    276         $sql_subscribers = 'SELECT COUNT(*) FROM `' . $table_name . '`';
     264        $sql_subscribers = "SELECT COUNT(*) FROM `{$wpdb->prefix}sd_subscribers`";
    277265        if ( $last_call_date != '' ) {
    278             $sql_subscribers .= ' WHERE `registration_date` > %s';
     266            $sql_subscribers .= " WHERE `registration_date` > %s";
    279267            $count = $wpdb->get_var( $wpdb->prepare( $sql_subscribers, $last_call_date ) );
    280268        } else {
     
    335323        if ( "N" == $list_type ) {
    336324            $fields = get_option( 'sarbacane_news_fields', array() );
    337             $csv_string = "email;";
     325            $csv_string = 'email;';
    338326            foreach ( $fields as $field ) {
    339327                if ( strtolower( $field->label ) != 'email' ) {
     
    341329                }
    342330            }
    343             $csv_string .= "action\r\n";
     331            $csv_string .= 'action' . "\n";
    344332            foreach ( $new_or_updated_users as $one_user_updated ) {
    345333                if ( isset( $one_user_updated->email ) ) {
     
    358346                    }
    359347                }
    360                 $csv_string .= 'S' . "\r\n";
    361             }
    362         } else {
    363             $csv_string = 'email;lastname;firstname;login;role;post_count;action' . "\r\n";
     348                $csv_string .= 'S' . "\n";
     349            }
     350        } else {
     351            $csv_string = 'email;lastname;firstname;login;role;post_count;action' . "\n";
    364352            if ( count( $new_or_updated_users ) > 0 ) {
    365353                foreach ( $new_or_updated_users as $one_user_updated ) {
     
    376364                    $csv_string .= $this->d_quote( $one_user_updated->email ) . ';' . $this->d_quote( $one_user_updated->lastname ) . ';';
    377365                    $csv_string .= $this->d_quote( $one_user_updated->firstname ) . ';' . $this->d_quote( $one_user_updated->user_login ) . ';';
    378                     $csv_string .= $this->d_quote( $role ) . ';' . $this->d_quote( $one_user_updated->user_posts ) . ';S' . "\r\n";
     366                    $csv_string .= $this->d_quote( $role ) . ';' . $this->d_quote( $one_user_updated->user_posts ) . ';S' . "\n";
    379367                }
    380368            }
    381369            if ( count( $deleted_users ) > 0 ) {
    382370                foreach ( $deleted_users as $deleted_user ) {
    383                     $csv_string .= $deleted_user->user_email . ';;;;;;U' . "\r\n";
     371                    $csv_string .= $deleted_user->user_email . ';;;;;;U' . "\n";
    384372                }
    385373            }
     
    403391    private function sarbacanedesktop_get_all_users( $last_call_date ) {
    404392        global $wpdb;
    405         $wp_prefix = $wpdb->prefix;
    406         $table_name = $wpdb->prefix . 'sd_updates';
    407         $sql = 'SELECT `wu`.`id` AS `user_id`, `wu`.`user_login` AS `user_login`, `wu`.`user_email` AS `email`, `wmf`.`meta_value` AS `firstname`, `wml`.`meta_value` AS `lastname`, `wum`.`meta_value` AS `user_role`
    408         FROM `' . $wp_prefix . 'users` AS `wu` LEFT JOIN `' . $wp_prefix . 'usermeta` AS `wmf` ON `wu`.`id` = `wmf`.`user_id` AND `wmf`.`meta_key` = "first_name"
    409         LEFT JOIN `' . $wp_prefix . 'usermeta` AS `wml` ON `wu`.`id` = `wml`.`user_id` AND `wml`.`meta_key` = "last_name"
    410         LEFT JOIN `' . $wp_prefix . 'usermeta` AS `wum` ON `wu`.`id` = `wum`.`user_id` AND `wum`.`meta_key` = "' . $wp_prefix . 'capabilities"';
     393        $sql = "SELECT `wu`.`id` AS `user_id`, `wu`.`user_login` AS `user_login`, `wu`.`user_email` AS `email`, `wmf`.`meta_value` AS `firstname`, `wml`.`meta_value` AS `lastname`, `wum`.`meta_value` AS `user_role`
     394        FROM `{$wpdb->prefix}users` AS `wu` LEFT JOIN `{$wpdb->prefix}usermeta` AS `wmf` ON `wu`.`id` = `wmf`.`user_id` AND `wmf`.`meta_key` = 'first_name'
     395        LEFT JOIN `{$wpdb->prefix}usermeta` AS `wml` ON `wu`.`id` = `wml`.`user_id` AND `wml`.`meta_key` = 'last_name'
     396        LEFT JOIN `{$wpdb->prefix}usermeta` AS `wum` ON `wu`.`id` = `wum`.`user_id` AND `wum`.`meta_key` = '{$wpdb->prefix}capabilities'";
    411397        if ( $last_call_date == '' ) {
    412398            $all_users = $wpdb->get_results( $sql );
    413399        } else {
    414             $sql = $sql . ' LEFT JOIN `' . $table_name . '` AS `wsu` ON `wsu`.`user_id` = `wu`.`id` AND `wsu`.`action` = "S" WHERE `wu`.`user_registered` >= %s OR `wsu`.`time` >= %s';
     400            $sql = $sql . " LEFT JOIN `{$wpdb->prefix}sd_updates` AS `wsu` ON `wsu`.`user_id` = `wu`.`id` AND `wsu`.`action` = 'S' WHERE `wu`.`user_registered` >= %s OR `wsu`.`time` >= %s";
    415401            $all_users = $wpdb->get_results( $wpdb->prepare( $sql, $last_call_date, $last_call_date ) );
    416402        }
     
    425411    private function sarbacanedesktop_get_all_deleted_users( $last_call_date ) {
    426412        global $wpdb;
    427         $table_name = $wpdb->prefix . 'sd_updates';
    428         $deleted_users = $wpdb->get_results( $wpdb->prepare( 'SELECT `user_email` FROM `' . $table_name . '` AS `wsu` WHERE `wsu`.`action` = "U" AND `wsu`.`time` >= %s', $last_call_date ) );
     413        $sql = "SELECT `user_email` FROM `{$wpdb->prefix}sd_updates` AS `wsu` WHERE `wsu`.`action` = 'U' AND `wsu`.`time` >= %s";
     414        $deleted_users = $wpdb->get_results( $wpdb->prepare( $sql, $last_call_date ) );
    429415        return $deleted_users;
    430416    }
     
    437423    private function get_subscribers( $last_call_date ) {
    438424        global $wpdb;
    439         $table_name = $wpdb->prefix . 'sd_subscribers';
    440425        if ( $last_call_date != '' ) {
    441             $sql_subscribers = 'SELECT * FROM `' . $table_name . '` WHERE `registration_date` > %s ORDER BY `registration_date` ASC';
    442             $all_subscribers = $wpdb->get_results( $wpdb->prepare( $sql_subscribers, $last_call_date ) );
    443         } else {
    444             $sql_subscribers = 'SELECT * FROM `' . $table_name . '` ORDER BY `registration_date` ASC';
    445             $all_subscribers = $wpdb->get_results( $sql_subscribers );
     426            $sql = "SELECT * FROM `{$wpdb->prefix}sd_subscribers` WHERE `registration_date` > %s ORDER BY `registration_date` ASC";
     427            $all_subscribers = $wpdb->get_results( $wpdb->prepare( $sql, $last_call_date ) );
     428        } else {
     429            $sql = "SELECT * FROM `{$wpdb->prefix}sd_subscribers` ORDER BY `registration_date` ASC";
     430            $all_subscribers = $wpdb->get_results( $sql );
    446431        }
    447432        $new_or_updated_users = array();
    448433        foreach ( $all_subscribers as $one_subscriber ) {
    449434            if ( isset( $one_subscriber->email ) ) {
    450                 $values =  new stdClass();
     435                $values = new stdClass();
    451436                $values->email = $one_subscriber->email;
    452437                $columns = json_decode( $one_subscriber->columns );
     
    471456        delete_option( 'sarbacane_news_call_' . $sd_id );
    472457
    473         $sdid_array = get_option( 'sarbacane_sd_id_list' );
    474         $index = array_search( $sd_id, $sdid_array );
     458        $sd_ids_saved = get_option( 'sarbacane_sd_id_list' );
     459        $index = array_search( $sd_id, $sd_ids_saved );
    475460        if ( $index !== false ) {
    476             unset ( $sdid_array [ $index ] );
    477             update_option( 'sarbacane_sd_id_list', $sdid_array, false );
     461            unset( $sd_ids_saved [ $index ] );
     462            update_option( 'sarbacane_sd_id_list', $sd_ids_saved, false );
    478463        }
    479464    }
     
    524509    private function clear_update_history() {
    525510        global $wpdb;
    526         $table_name = $wpdb->prefix . 'sd_updates';
    527         $option_table = $wpdb->prefix . 'options';
    528         $sql = "DELETE FROM `$table_name` WHERE `time` <= (SELECT MIN(`option_value`) FROM `$option_table` WHERE `option_name` LIKE 'sarbacane_%_call_%')";
     511        $sql = "DELETE FROM `{$wpdb->prefix}sd_updates` WHERE `time` <= (
     512            SELECT MIN(`option_value`) FROM `{$wpdb->prefix}options` WHERE `option_name` LIKE 'sarbacane_%_call_%'
     513        )";
    529514        $wpdb->query( $sql );
    530515    }
     
    564549            update_option( 'sarbacane_sd_id_list', array(), false );
    565550            global $wpdb;
    566             $table_name = $wpdb->prefix . 'sd_updates';
    567             $wpdb->query( "TRUNCATE TABLE `$table_name`" );
     551            $wpdb->query( "TRUNCATE TABLE `{$wpdb->prefix}sd_updates`" );
    568552            $this->sarbacane_params_saved();
    569553        }
     
    574558        }
    575559        $sd_list_news = get_option( 'sarbacane_news_list', false );
    576         $sdid_array = get_option( 'sarbacane_sd_id_list', array() );
     560        $is_connected = false;
     561        if ( count( get_option( 'sarbacane_sd_id_list', array() ) ) > 0 ) {
     562            $is_connected = true;
     563        }
    577564        $is_failed = (int) get_option( 'sarbacane_failed', 0 ) < 1000000 ? false : true;
    578         wp_enqueue_style ( "sarbacane_global.css", plugins_url ( "css/sarbacane_global.css", __FILE__ ), array(), '1.4.6' );
    579         wp_enqueue_style ( "sarbacane_admin_panel.css", plugins_url ( "css/sarbacane_admin_panel.css", __FILE__ ), array(), '1.4.6' );
     565        wp_enqueue_style ( 'sarbacane_global.css', plugins_url ( 'css/sarbacane_global.css', __FILE__ ), array(), '1.4.7' );
     566        wp_enqueue_style ( 'sarbacane_admin_panel.css', plugins_url ( 'css/sarbacane_admin_panel.css', __FILE__ ), array(), '1.4.7' );
    580567        require_once( 'views/sarbacane-adminpanel.php' );
    581568    }
     
    612599            return;
    613600        }
    614         if ( isset ( $wp->query_vars ['sarbacane_form_token'] ) && '' != $wp->query_vars ['sarbacane_form_token'] && wp_verify_nonce( $wp->query_vars['sarbacane_form_token'], 'newsletter_registration' ) ) {
     601        if ( isset ( $wp->query_vars ['sarbacane_form_token'] ) && $wp->query_vars ['sarbacane_form_token'] != '' && wp_verify_nonce( $wp->query_vars['sarbacane_form_token'], 'newsletter_registration' ) ) {
    615602            $save_widget = true;
    616603        }
    617         if ( isset ( $wp->query_vars ['sdid'] ) && '' != $wp->query_vars ['sdid'] ) {
     604        if ( isset ( $wp->query_vars ['sdid'] ) && $wp->query_vars ['sdid'] != '' ) {
    618605            $sd_id = sanitize_text_field( $wp->query_vars ['sdid'] );
    619606        }
    620         if ( isset ( $wp->query_vars ['sd_token'] ) && '' != $wp->query_vars ['sd_token'] ) {
     607        if ( isset ( $wp->query_vars ['sd_token'] ) && $wp->query_vars ['sd_token'] != '' ) {
    621608            $sd_token = sanitize_text_field( $wp->query_vars ['sd_token'] );
    622609        }
    623610        $sd_list_id = '';
    624         if ( isset ( $wp->query_vars ['list'] ) && '' != $wp->query_vars ['list'] ) {
     611        if ( isset ( $wp->query_vars ['list'] ) && $wp->query_vars ['list'] != '' ) {
    625612            $sd_list_id = sanitize_text_field( $wp->query_vars ['list'] );
    626613        }
    627614        $action = '';
    628         if ( isset ( $wp->query_vars ['action'] ) && '' != $wp->query_vars ['action'] ) {
     615        if ( isset ( $wp->query_vars ['action'] ) && $wp->query_vars ['action'] != '' ) {
    629616            $action = sanitize_text_field( $wp->query_vars ['action'] );
    630617        }
    631         if ( isset ( $wp->query_vars ['type'] ) && '' != $wp->query_vars ['type'] ) {
     618        if ( isset ( $wp->query_vars ['type'] ) && $wp->query_vars ['type'] != '' ) {
    632619            $type = sanitize_text_field( $wp->query_vars ['type'] );
    633620        }
    634         if ( isset ( $wp->query_vars ['id'] ) && '' != $wp->query_vars ['id'] ) {
     621        if ( isset ( $wp->query_vars ['id'] ) && $wp->query_vars ['id'] != '' ) {
    635622            $id = sanitize_text_field( $wp->query_vars ['id'] );
    636623        }
    637624        $limit = - 1;
    638         if ( isset ( $wp->query_vars ['limit'] ) && '' != $wp->query_vars ['limit'] ) {
     625        if ( isset ( $wp->query_vars ['limit'] ) && $wp->query_vars ['limit'] != '' ) {
    639626            $limit = $wp->query_vars ['limit'];
    640627        }
    641628        if ( isset( $save_widget ) ) {
    642             header( "Content-Type: text/html; charset=utf-8" );
     629            header( 'Content-Type: text/html; charset=utf-8' );
    643630            $this->update_data_1_4_5();
    644631            $widget = new SarbacaneNewsWidget();
     
    647634        }
    648635        if ( ! isset ( $sd_id ) ) {
    649             header( "HTTP/1.1 400 Bad request" );
    650             header( "Content-type: application/json; charset=utf-8" );
    651             die ( 'FAILED_SDID' );
     636            header( 'HTTP/1.1 400 Bad request' );
     637            header( 'Content-type: application/json; charset=utf-8' );
     638            die( 'FAILED_SDID' );
    652639        }
    653640        if ( ! isset ( $sd_token ) ) {
    654             header( "HTTP/1.1 400 Bad request" );
    655             header( "Content-type: application/json; charset=utf-8" );
    656             die ( 'FAILED_SDTOKEN' );
     641            header( 'HTTP/1.1 400 Bad request' );
     642            header( 'Content-type: application/json; charset=utf-8' );
     643            die( 'FAILED_SDTOKEN' );
    657644        }
    658645        $failed = (int) get_option( 'sarbacane_failed', 0 );
     
    663650                update_option( 'sarbacane_failed', $failed + 1, false );
    664651            }
    665             header( "HTTP/1.1 403 Unauthorized" );
    666             header( "Content-type: application/json; charset=utf-8" );
    667             die ( 'FAILED_SDTOKEN' );
     652            header( 'HTTP/1.1 403 Unauthorized' );
     653            header( 'Content-type: application/json; charset=utf-8' );
     654            die( 'FAILED_SDTOKEN' );
    668655        } else {
    669656            // Content retrieving
    670657            if ( isset ( $type ) ) {
    671                 if ( "posts" == $type ) {
    672                     header( "Content-Type: application/rss+xml ; charset=utf-8" );
     658                if ( $type == 'posts' ) {
     659                    header( 'Content-Type: application/rss+xml; charset=utf-8' );
    673660                    $content = new SarbacaneContent();
    674661                    if ( isset ( $id ) ) {
     
    677664                        $content->get_articles_rss( $limit );
    678665                    }
    679                 } else if ( "settings" == $type ) {
    680                     header( "Content-Type: application/json ; charset=utf-8" );
    681                     header( "Content-Transfer-Encoding: binary" );
     666                } else if ( $type == 'settings' ) {
     667                    header( 'Content-Type: application/json; charset=utf-8' );
     668                    header( 'Content-Transfer-Encoding: binary' );
    682669                    $settings = new SarbacaneSettings();
    683670                    $settings->get_settings();
    684                 } else if ( "medias" == $type ) {
    685                     header( "Content-Type: application/json ; charset=utf-8" );
     671                } else if ( $type == 'medias' ) {
     672                    header( 'Content-Type: application/json; charset=utf-8' );
    686673                    $medias = new SarbacaneMedias();
    687674                    $medias->get_medias();
     
    690677                $this->update_data_1_4_5();
    691678                // List retrieving
    692                 header( "Content-Type: text/plain ; charset=utf-8" );
    693                 header( "Content-Transfer-Encoding: binary" );
    694                 if ( "delete" == $action ) {
     679                header( 'Content-Type: text/plain; charset=utf-8' );
     680                header( 'Content-Transfer-Encoding: binary' );
     681                if ( $action == 'delete' ) {
    695682                    $this->sarbacane_delete_sdid( $sd_id );
    696683                } else {
    697                     if ( $sd_list_id != '' && $sd_list_id != "N" && $sd_list_id != "U" ) {
    698                         header( "HTTP/1.1 404 Not found" );
    699                         header( "Content-type: application/json ; charset=utf-8" );
    700                         die ( 'FAILED_ID' );
     684                    if ( $sd_list_id != '' && $sd_list_id != 'N' && $sd_list_id != 'U' ) {
     685                        header( 'HTTP/1.1 404 Not found' );
     686                        header( 'Content-type: application/json; charset=utf-8' );
     687                        die( 'FAILED_ID' );
    701688                    }
    702689                    $this->sarbacane_get_list( $sd_id, $sd_list_id );
  • mailify/tags/1.4.7/js/sarbacane-widget.js

    r1629810 r1681124  
    1616    }
    1717    if ( isSubmitable ) {
     18        jQuery( "#sarbacane_desktop_widget_form_" + list_type + " .sarbacane_form_value" ).val( "sarbacane_desktop_widget" );
    1819        jQuery( "#sarbacane_desktop_widget_form_" + list_type ).submit();
    1920    }
  • mailify/tags/1.4.7/readme.txt

    r1677274 r1681124  
    33Tags: marketing, mail, email, mailing
    44Requires at least: 4.0
    5 Tested up to: 4.7
     5Tested up to: 4.8
    66License: GPLv2 or later
    7 Stable tag: 1.4.6
     7Stable tag: 1.4.7
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
    99
     
    8585== Changelog ==
    8686
     87= 1.4.7 =
     88Widget optimizations.
     89
    8790= 1.4.6 =
    8891Customize widget mandatory fields message.
     
    129132= Spanish =
    130133
     134= 1.4.7 =
     135Widget Optimización.
     136
    131137= 1.4.6 =
    132138Personalizar el mensaje de los campos obligatorios del widget.
  • mailify/tags/1.4.7/sarbacane.php

    r1677274 r1681124  
    55Description: This plugin allows you to synchronize your WordPress data in Mailify
    66Author: Sarbacane Software
    7 Version: 1.4.6
     7Version: 1.4.7
    88Author URI: http://mailify.com/?utm_source=module-wordpress&utm_medium=plugin&utm_content=lien-sarbacane&utm_campaign=wordpress
    99Text Domain: mailify
  • mailify/tags/1.4.7/views/sarbacane-adminpanel.php

    r1629810 r1681124  
    1717                    <?php _e( 'Synchronization key to enter in Mailify', 'mailify' ) ?> :
    1818                    <span class="sarbacane_desktop_connection_status">
    19                         <?php if ( is_array( $sdid_array ) && count( $sdid_array ) > 0 ) { ?>
     19                        <?php if ( $is_connected ) { ?>
    2020                        <span class='sarbacane_desktop_connection_ok'><?php _e( 'Connected', 'mailify' ) ?></span>
    2121                        <?php } else { ?>
  • mailify/tags/1.4.7/views/sarbacane-lists-sync.php

    r1629810 r1681124  
    1313                </p>
    1414                <p class="sarbacane_desktop_config_label">
    15                     <input type="checkbox" name="sarbacane_users_list" id="sarbacane_users_list" value="true" <?php if ( $sarbacane_users_list ) { echo 'checked="checked"' ; } ?> />
     15                    <input type="checkbox" name="sarbacane_users_list" id="sarbacane_users_list" value="true"<?php if ( $sarbacane_users_list ) { ?> checked="checked"<?php } ?>/>
    1616                    <label for="sarbacane_users_list"><?php _e( 'Synchronize a \'\'WordPress Users\'\' list', 'mailify' ) ?></label>
    1717                    <br />
     
    1919                </p>
    2020                <p class="sarbacane_desktop_config_label">
    21                     <input type="checkbox" name="sarbacane_news_list" onclick="sarbacaneNewsListChangePopup()" id="sarbacane_news_list" value="true" <?php if ( $sarbacane_news_list ) { echo 'checked="checked"'; } ?> />
     21                    <input type="checkbox" name="sarbacane_news_list" onclick="sarbacaneNewsListChangePopup()" id="sarbacane_news_list" value="true" <?php if ( $sarbacane_news_list ) { ?> checked="checked"<?php } ?>/>
    2222                    <label for="sarbacane_news_list"><?php _e( 'Automatically synchronize your subscriber list', 'mailify' ) ?></label>
    2323                    <br />
     
    3131                </p>
    3232                <p class="sarbacane_desktop_config_label">
    33                     <input type="checkbox" name="sarbacane_theme_sync" id="sarbacane_theme_sync" value="true" <?php if ( $sarbacane_theme_sync ) { echo 'checked="checked"'; } ?> />
     33                    <input type="checkbox" name="sarbacane_theme_sync" id="sarbacane_theme_sync" value="true"<?php if ( $sarbacane_theme_sync ) { ?> checked="checked"<?php } ?>/>
    3434                    <label for="sarbacane_theme_sync"><?php _e( 'Synchronize your WordPress theme', 'mailify' ) ?></label>
    3535                    <br />
     
    3737                </p>
    3838                <p class="sarbacane_desktop_config_label">
    39                     <input type="checkbox" name="sarbacane_blog_content" id="sarbacane_blog_content" value="true" <?php if ( $sarbacane_blog_content ) { echo 'checked="checked"'; } ?> />
     39                    <input type="checkbox" name="sarbacane_blog_content" id="sarbacane_blog_content" value="true"<?php if ( $sarbacane_blog_content ) { ?> checked="checked"<?php } ?>/>
    4040                    <label for="sarbacane_blog_content"><?php _e( 'Synchronize blog content', 'mailify' ) ?></label>
    4141                    <br />
     
    4343                </p>
    4444                <p class="sarbacane_desktop_config_label" style="display:none;">
    45                     <input type="checkbox" name="sarbacane_media_content" id="sarbacane_media_content" value="true" <?php if ( $sarbacane_media_content ) { echo 'checked="checked"'; } ?> />
     45                    <input type="checkbox" name="sarbacane_media_content" id="sarbacane_media_content" value="true"<?php if ( $sarbacane_media_content ) { ?> checked="checked"<?php } ?>/>
    4646                    <label for="sarbacane_media_content"><?php _e( 'Synchronize media library', 'mailify' ) ?></label>
    4747                    <br />
     
    4949                </p>
    5050                <p class="sarbacane_desktop_config_label">
    51                     <input type="checkbox" name="sarbacane_rss_data" id="sarbacane_rss_data" value="true" <?php if ( $sarbacane_rss_data ) { echo 'checked="checked"'; } ?> />
     51                    <input type="checkbox" name="sarbacane_rss_data" id="sarbacane_rss_data" value="true"<?php if ( $sarbacane_rss_data ) { ?> checked="checked"<?php } ?>/>
    5252                    <label for="sarbacane_rss_data"><?php _e( 'Synchronize RSS data', 'mailify' ) ?></label>
    5353                    <br />
  • mailify/tags/1.4.7/views/sarbacane-widget-adminpanel.php

    r1677274 r1681124  
    5050                    <label class="sarbacane_desktop_field_number"><?php echo __( 'Field', 'mailify' ) . ' ' . ( $i + 1 ) ?></label>
    5151                    <ul class="sarbacane_widget_menu">
    52                         <li class="sarbacane_desktop_menu_item sarbacane_desktop_trash <?php if ( $isEmail ) { echo "sarbacane_desktop_menu_item_disabled_email";} ?>" <?php if ( !$isEmail ) { ?> onclick="sarbacaneDeleteField( <?php echo $i ?> )" <?php } ?>></li>
     52                        <li class="sarbacane_desktop_menu_item sarbacane_desktop_trash<?php if ( $isEmail ) { ?> sarbacane_desktop_menu_item_disabled_email<?php } ?>"<?php if ( !$isEmail ) { ?> onclick="sarbacaneDeleteField( <?php echo $i ?> )" <?php } ?>></li>
    5353                        <li class="sarbacane_desktop_menu_item sarbacane_desktop_down" onclick="sarbacaneMoveDown( <?php echo $i ?> )"></li>
    5454                        <li class="sarbacane_desktop_menu_item sarbacane_desktop_up" onclick="sarbacaneMoveUp( <?php echo $i ?> )"></li>
     
    6767                    <br />
    6868                    <label class="sarbacane_desktop_inline_configuration_label " for="sarbacane_desktop_mandatory_<?php echo $i ?>"><?php _e( 'Mandatory', 'mailify' ) ?>&nbsp;:&nbsp;</label>
    69                     <input type="radio" name="sarbacane_mandatory_<?php echo $i ?>" id="sarbacane_desktop_mandatory_true_<?php echo $i ?>" value="true" <?php if ( $field->mandatory ) { echo ' checked="checked" '; } ?> <?php if ( $isEmail ) { echo 'disabled="disabled"'; } ?> onclick="sarbacaneDisplayPreview()"/>
     69                    <input type="radio" name="sarbacane_mandatory_<?php echo $i ?>" id="sarbacane_desktop_mandatory_true_<?php echo $i ?>" value="true"<?php if ( $field->mandatory ) { ?> checked="checked"<?php } ?><?php if ( $isEmail ) { ?> disabled="disabled"<?php } ?> onclick="sarbacaneDisplayPreview()"/>
    7070                    <label class="sarbacane_desktop_yes_no_label" for="sarbacane_desktop_mandatory_true_<?php echo $i ?>"><?php _e( 'Yes', 'mailify' ) ?></label>
    71                     <input type="radio" name="sarbacane_mandatory_<?php echo $i ?>" id="sarbacane_desktop_mandatory_false_<?php echo $i ?>" value="false" <?php if ( !$field->mandatory ) { echo ' checked="checked" '; } ?> <?php if ( $isEmail ) { echo 'disabled="disabled"'; } ?> onclick="sarbacaneDisplayPreview()"/>
     71                    <input type="radio" name="sarbacane_mandatory_<?php echo $i ?>" id="sarbacane_desktop_mandatory_false_<?php echo $i ?>" value="false"<?php if ( !$field->mandatory ) { ?> checked="checked"<?php } ?><?php if ( $isEmail ) { ?> disabled="disabled"<?php } ?> onclick="sarbacaneDisplayPreview()"/>
    7272                    <label class="sarbacane_desktop_yes_no_label" for="sarbacane_desktop_mandatory_false_<?php echo $i ?>"><?php _e( 'No', 'mailify' ) ?></label>
    7373                </p>
     
    116116    <div id="sarbacane_widget_preview">
    117117        <p class="sarbacane_widget_configuration_title"><?php _e( 'Preview', 'mailify' ) ?></p>
    118         <div id="sarbacane_preview"><?php _e( 'Fields marked with * are mandatory', 'mailify' ) ?></div>
     118        <div id="sarbacane_preview"></div>
    119119    </div>
    120120    <div id="sarbacane_desktop_vertical_splitter"></div>
  • mailify/tags/1.4.7/views/sarbacane-widget.php

    r1677274 r1681124  
    2222            ?>
    2323            <p>
    24                 <label><?php echo $label ?> <?php if ( $field->mandatory ) { echo '*'; } ?></label>
     24                <label><?php echo $label ?><?php if ( $field->mandatory ) { ?> *<?php } ?></label>
    2525                <br />
    26                 <input type="<?php echo $field_type ?>" id="<?php echo $id ?>" name="<?php echo $name ?>" placeholder="<?php esc_attr_e( $field->placeholder ) ?>" <?php if ( $field->mandatory ) { echo 'required class="required"'; } ?> />
     26                <input type="<?php echo $field_type ?>" id="<?php echo $id ?>" name="<?php echo $name ?>" placeholder="<?php esc_attr_e( $field->placeholder ) ?>"<?php if ( $field->mandatory ) { ?> required class="required"<?php } ?>/>
    2727            </p>
    2828        <?php } ?>
    2929        <p><?php esc_html_e( $registration_mandatory_fields ) ?></p>
    3030        <?php wp_nonce_field( 'newsletter_registration', 'sarbacane_form_token' ) ?>
    31         <input type="button" value="<?php esc_attr_e( $registration_button ) ?>" onclick="sarbacaneSubmitWidget( '<?php echo $list_type . $rand ?>' )" />
     31        <input type="hidden" name="sarbacane_form_value" class="sarbacane_form_value" value=""/>
     32        <input type="button" value="<?php esc_attr_e( $registration_button ) ?>" onclick="sarbacaneSubmitWidget( '<?php echo $list_type . $rand ?>' )"/>
    3233    </form>
    3334</aside>
  • mailify/trunk/class.sarbacane-about.php

    r1677274 r1681124  
    1414            return;
    1515        }
    16         wp_enqueue_style ( "sarbacane_global.css", plugins_url ( "css/sarbacane_global.css", __FILE__ ), array(), '1.4.6' );
    17         wp_enqueue_style ( "sarbacane_about.css", plugins_url ( "css/sarbacane_about.css", __FILE__ ), array(), '1.4.6' );
    18         require_once( "views/sarbacane-about.php" );
     16        wp_enqueue_style ( 'sarbacane_global.css', plugins_url ( 'css/sarbacane_global.css', __FILE__ ), array(), '1.4.7' );
     17        wp_enqueue_style ( 'sarbacane_about.css', plugins_url ( 'css/sarbacane_about.css', __FILE__ ), array(), '1.4.7' );
     18        require_once( 'views/sarbacane-about.php' );
    1919    }
    2020
  • mailify/trunk/class.sarbacane-content.php

    r1576277 r1681124  
    55    private function get_rss_header() {
    66        return '<?xml version="1.0" encoding="UTF-8"?>
    7     <rss version="2.0"  xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/"
    8     xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/">
     7<rss version="2.0"
     8xmlns:content="http://purl.org/rss/1.0/modules/content/"
     9xmlns:wfw="http://wellformedweb.org/CommentAPI/"
     10xmlns:dc="http://purl.org/dc/elements/1.1/"
     11xmlns:atom="http://www.w3.org/2005/Atom"
     12xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
     13xmlns:slash="http://purl.org/rss/1.0/modules/slash/">
    914    <channel>
    1015        <title>' . get_bloginfo_rss( 'name' ) . '</title>
     
    1419
    1520    private function get_rss_footer() {
    16         return '</channel></rss>';
     21        return '
     22    </channel>
     23</rss>';
    1724    }
    1825
     
    2734        while ( $query->have_posts() ) {
    2835            $query->the_post();
    29             $items .= '<item>
     36            if ( post_password_required() ) {
     37                continue;
     38            }
     39            $items .= "\n\t\t" . '<item>
    3040            <title>' . get_the_title_rss() . '</title>
    3141            <link>' . esc_url( apply_filters( 'the_permalink_rss', get_permalink() ) ) . '</link>
    3242            <id>' . get_the_ID() . '</id>
    3343            <pubDate>' . mysql2date( 'D, d M Y H:i:s +0000', get_post_time( 'Y-m-d H:i:s', true ), false ) . '</pubDate>
    34             <dc:creator><![CDATA[' . get_the_author() . ']]></dc:creator>
    35             ' . get_the_category_rss( 'rss2' );
     44            <dc:creator><![CDATA[' . get_the_author() . ']]></dc:creator>' .
     45            "\n\t" . get_the_category_rss( 'rss2' );
    3646            if ( $option === 'posts' ) {
    37                 $items .= '<description><![CDATA[' . apply_filters( 'the_excerpt_rss', get_the_excerpt() ) . ']]></description>';
     47                $items .= "\t\t\t" . '<description><![CDATA[' . apply_filters( 'the_excerpt_rss', get_the_excerpt() ) . ']]></description>' . "\n";
    3848            }
    39             $content = get_the_content_feed( 'rss2' );
    40             $items .= '<content:encoded><![CDATA[' . $content . ']]></content:encoded>';
    41             $items .= '<slash:comments>' . get_comments_number() . '</slash:comments>';
     49            $items .= "\t\t\t" . '<content:encoded><![CDATA[' . get_the_content_feed( 'rss2' ) . ']]></content:encoded>
     50            <slash:comments>' . get_comments_number() . '</slash:comments>';
    4251            $media = get_attached_media( 'image' );
    4352            if ( is_array( $media ) && count( $media ) > 0 ) {
    4453                $all_medias_key = array_keys( $media );
    45                 $items .= '<enclosure url="' . $media [ $all_medias_key [0] ]->guid . '" type="' . $media [ $all_medias_key [0] ]->post_mime_type . '" />';
     54                $items .= "\n\t\t\t" . '<enclosure url="' . $media [ $all_medias_key [0] ]->guid . '" type="' . $media [ $all_medias_key [0] ]->post_mime_type . '" />';
    4655            }
    47             $items .= rss_enclosure();
    48             do_action( 'rss2_item' );
    49             $items .= '</item>';
     56            $items .= "\n\t\t" . '</item>';
    5057        }
    5158        return $items;
     
    5764            echo $this->get_rss_header() . $this->get_rss_content( 'post', $post_id ) . $this->get_rss_footer();
    5865        } else {
    59             header( "HTTP/1.1 404 Bad item" );
    60             header( "Content-Type: application/json ; charset=utf-8" );
    61             die ( 'FAILED_ID' );
     66            header( 'HTTP/1.1 404 Bad item' );
     67            header( 'Content-Type: application/json; charset=utf-8' );
     68            die( 'FAILED_ID' );
    6269        }
    6370    }
  • mailify/trunk/class.sarbacane-lists-sync.php

    r1677274 r1681124  
    3131                }
    3232                global $wpdb;
    33                 $table_name = $wpdb->prefix . 'sd_updates';
    34                 $wpdb->query( "TRUNCATE TABLE `$table_name`" );
     33                $wpdb->query( "TRUNCATE TABLE `{$wpdb->prefix}sd_updates`" );
    3534            }
    3635
    37             if ( isset( $_POST['sarbacane_news_list'] ) && "true" == $_POST['sarbacane_news_list'] ) {
     36            if ( isset( $_POST['sarbacane_news_list'] ) && $_POST['sarbacane_news_list'] == 'true' ) {
    3837                update_option( 'sarbacane_news_list', true, false );
    3938                $fields = get_option( 'sarbacane_news_fields' );
    4039                if ( ! is_array( $fields ) || count( $fields ) == 0 ) {
    41                     $default_email = new stdClass ();
     40                    $default_email = new stdClass();
    4241                    $default_email->label = 'email';
    4342                    $default_email->placeholder = '';
     
    5352            }
    5453
    55             if ( isset( $_POST['sarbacane_theme_sync'] ) && "true" == $_POST['sarbacane_theme_sync'] ) {
     54            if ( isset( $_POST['sarbacane_theme_sync'] ) && $_POST['sarbacane_theme_sync'] == 'true' ) {
    5655                update_option( 'sarbacane_theme_sync', true, false );
    5756            } else {
     
    5958            }
    6059
    61             if ( isset( $_POST['sarbacane_blog_content'] ) && "true" == $_POST['sarbacane_blog_content'] ) {
     60            if ( isset( $_POST['sarbacane_blog_content'] ) && $_POST['sarbacane_blog_content'] == 'true' ) {
    6261                update_option( 'sarbacane_blog_content', true, false );
    6362            } else {
     
    6564            }
    6665
    67             if ( isset( $_POST['sarbacane_media_content'] ) && "true" == $_POST['sarbacane_media_content'] ) {
     66            if ( isset( $_POST['sarbacane_media_content'] ) && $_POST['sarbacane_media_content'] == 'true' ) {
    6867                update_option( 'sarbacane_media_content', true, false );
    6968            } else {
     
    7170            }
    7271
    73             if ( isset( $_POST['sarbacane_rss_data'] ) && "true" == $_POST['sarbacane_rss_data'] ) {
     72            if ( isset( $_POST['sarbacane_rss_data'] ) && $_POST['sarbacane_rss_data'] == 'true' ) {
    7473                update_option( 'sarbacane_rss_data', true, false );
    7574            } else {
     
    7776            }
    7877        }
    79         wp_enqueue_style ( "sarbacane_global.css", plugins_url ( "css/sarbacane_global.css" , __FILE__ ), array(), '1.4.6' );
    80         wp_enqueue_style ( "sarbacane_lists_config.css", plugins_url ( "css/sarbacane_lists_config.css", __FILE__ ), array(), '1.4.6' );
    81         wp_enqueue_script( "sarbacane-lists-sync.js", plugins_url( "js/sarbacane-lists-sync.js", __FILE__ ), array( 'jquery' ), '1.4.6' );
     78        wp_enqueue_style ( 'sarbacane_global.css', plugins_url ( 'css/sarbacane_global.css', __FILE__ ), array(), '1.4.7' );
     79        wp_enqueue_style ( 'sarbacane_lists_config.css', plugins_url ( 'css/sarbacane_lists_config.css', __FILE__ ), array(), '1.4.7' );
     80        wp_enqueue_script( 'sarbacane-lists-sync.js', plugins_url( 'js/sarbacane-lists-sync.js', __FILE__ ), array( 'jquery' ), '1.4.7' );
    8281        $sarbacane_news_list = get_option( 'sarbacane_news_list', false );
    8382        $sarbacane_users_list = get_option( 'sarbacane_users_list', false );
     
    8887        $sarbacane_rss_data = get_option( 'sarbacane_rss_data', false );
    8988
    90         require_once( "views/sarbacane-lists-sync.php" );
     89        require_once( 'views/sarbacane-lists-sync.php' );
    9190    }
    9291
  • mailify/trunk/class.sarbacane-medias.php

    r1576277 r1681124  
    55    public function get_medias() {
    66        $wp_query = new WP_Query( array( 'post_type' => 'attachment', 'post_status' => 'inherit' ) );
    7         $return_string = '{"medias":[';
     7        $medias = array();
    88        if ( $wp_query->have_posts() ) {
    99            while ( $wp_query->have_posts() ) {
    1010                $wp_query->the_post();
    1111                $thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id(), 'thumbnail' );
    12                 $return_string .= '
    13     {"name":"' . get_the_title() . '",
    14     "url":"' . get_the_guid() . '",
    15     "mime_type":"' . get_post_mime_type() . '",
    16     "thumbnail":"' . $thumbnail[0] . '"},';
     12                $medias[] = '
     13    {
     14        "name":"' . get_the_title() . '",
     15        "url":"' . get_the_guid() . '",
     16        "mime_type":"' . get_post_mime_type() . '",
     17        "thumbnail":"' . $thumbnail[0] . '"
     18    }';
    1719            }
    1820        }
    19         $return_string = rtrim( $return_string, ',' );
    20         $return_string .= '
    21     ]
    22 }';
    23         echo $return_string;
     21        $medias = implode( ',', $medias );
     22        echo '{"medias":[' . $medias . "\n\t" . ']' . "\n" . '}';
    2423    }
    2524
  • mailify/trunk/class.sarbacane-newsletterwidget.php

    r1677274 r1681124  
    2424    public function sarbacane_save_widget() {
    2525        $valid = false;
    26         if ( isset ( $_POST ['email'] ) ) {
    27             $user_registring = new stdClass ();
    28             $user_registring->email = sanitize_email( $_POST ['email'] );
    29             if ( is_email( $user_registring->email ) ) {
    30                 $fields = get_option( 'sarbacane_news_fields', array() );
    31                 $columns = array();
    32                 foreach ( $fields as $field ) {
    33                     if ( strtolower( $field->label ) == 'email' ) {
    34                         continue;
    35                     }
    36                     $field_label = $field->label;
    37                     $field_label_html = str_replace( ' ', '_', $field->label );
    38                     $field_label = strtolower( $field_label );
    39                     if ( isset ( $_POST [ $field_label_html ] ) ) {
    40                         $fieldValue = stripslashes( sanitize_text_field( $_POST [ $field_label_html ] ) );
    41                     } else {
    42                         $fieldValue = '';
    43                     }
    44                     $user_registring->$field_label = $fieldValue;
    45                     $columns [ $field_label ] = $fieldValue;
     26        if ( isset ( $_POST ['sarbacane_form_value'] ) && isset ( $_POST ['email'] ) ) {
     27            $sarbacane_form_value = sanitize_text_field( $_POST ['sarbacane_form_value'] );
     28            if ($sarbacane_form_value == 'sarbacane_desktop_widget' ) {
     29                $user_registering = new stdClass();
     30                $user_registering->email = sanitize_email( $_POST ['email'] );
     31                if ( is_email( $user_registering->email ) ) {
     32                    $fields = get_option( 'sarbacane_news_fields', array() );
     33                    $columns = array();
     34                    foreach ( $fields as $field ) {
     35                        if ( strtolower( $field->label ) == 'email' ) {
     36                            continue;
     37                        }
     38                        $field_label = $field->label;
     39                        $field_label_html = str_replace( ' ', '_', $field->label );
     40                        $field_label = strtolower( $field_label );
     41                        if ( isset ( $_POST [ $field_label_html ] ) ) {
     42                            $fieldValue = stripslashes( sanitize_text_field( $_POST [ $field_label_html ] ) );
     43                        } else {
     44                            $fieldValue = '';
     45                        }
     46                        $user_registering->$field_label = $fieldValue;
     47                        $columns [ $field_label ] = $fieldValue;
     48                    }
     49                    $user_registering->registration_date = gmdate( 'Y-m-d H:i:s' );
     50                    $version = get_option( 'sarbacane_version' );
     51                    $result = true;
     52                    if ( $version !== false ) {
     53                        global $wpdb;
     54                        $sql = "INSERT INTO `{$wpdb->prefix}sd_subscribers` (`email`, `columns`, `registration_date`) VALUES (%s, %s, %s);";
     55                        $result = $wpdb->query( $wpdb->prepare( $sql, $user_registering->email, json_encode( $columns ), $user_registering->registration_date ) );
     56                    }
     57                    if ( $version === false || $result === false ) {
     58                        $users_registered = get_option( 'sarbacane_newsletter_list', array() );
     59                        $users_registered[] = $user_registering;
     60                        update_option( 'sarbacane_newsletter_list', $users_registered, false );
     61                    }
     62                    $valid = true;
    4663                }
    47                 $user_registring->registration_date = gmdate( 'Y-m-d H:i:s' );
    48                 $version = get_option( 'sarbacane_version' );
    49                 $result = true;
    50                 if ( $version !== false ) {
    51                     global $wpdb;
    52                     $table_name = $wpdb->prefix . 'sd_subscribers';
    53                     $sql = "INSERT INTO `$table_name` (`email`, `columns`, `registration_date`) VALUES (%s, %s, %s);";
    54                     $result = $wpdb->query( $wpdb->prepare( $sql, $user_registring->email, json_encode( $columns ), $user_registring->registration_date ) );
    55                 }
    56                 if ( $version === false || $result === false ) {
    57                     $users_registred = get_option( 'sarbacane_newsletter_list', array() );
    58                     $users_registred[] = $user_registring;
    59                     update_option( 'sarbacane_newsletter_list', $users_registred, false );
    60                 }
    61                 $valid = true;
    6264            }
    6365        }
     
    8486        $fields = get_option( 'sarbacane_news_fields', array() );
    8587        if ( ! is_array( $fields ) || count( $fields ) == 0 ) {
    86             $default_email = new stdClass ();
     88            $default_email = new stdClass();
    8789            $default_email->label = 'email';
    8890            $default_email->placeholder = '';
     
    9597        $list_type = 'N';
    9698        $rand = mt_rand( 0, 1000000 );
    97         wp_enqueue_script( "sarbacane-widget.js", plugins_url( "js/sarbacane-widget.js", __FILE__ ), array( 'jquery' ), '1.4.6' );
    98         wp_enqueue_style( "sarbacane_widget.css", plugins_url( "css/sarbacane_widget.css", __FILE__ ), array(), '1.4.6' );
    99         include( "views/sarbacane-widget.php" );
     99        wp_enqueue_script( 'sarbacane-widget.js', plugins_url( 'js/sarbacane-widget.js', __FILE__ ), array( 'jquery' ), '1.4.7' );
     100        wp_enqueue_style( 'sarbacane_widget.css', plugins_url( 'css/sarbacane_widget.css', __FILE__ ), array(), '1.4.7' );
     101        include( 'views/sarbacane-widget.php' );
    100102    }
    101103
     
    119121            return;
    120122        }
    121         wp_enqueue_style( "sarbacane_global.css", plugins_url( "css/sarbacane_global.css", __FILE__ ), array( 'wp-admin' ), '1.4.6' );
    122         wp_enqueue_style( "sarbacane_widget_admin_panel.css", plugins_url( "css/sarbacane_widget_admin_panel.css", __FILE__ ), array( 'wp-admin' ), '1.4.6' );
    123         wp_enqueue_script( "sarbacane-widget-adminpanel.js", plugins_url( "js/sarbacane-widget-adminpanel.js", __FILE__ ), array( 'jquery', 'underscore' ), '1.4.6' );
     123        wp_enqueue_style( 'sarbacane_global.css', plugins_url( 'css/sarbacane_global.css', __FILE__ ), array( 'wp-admin' ), '1.4.7' );
     124        wp_enqueue_style( 'sarbacane_widget_admin_panel.css', plugins_url( 'css/sarbacane_widget_admin_panel.css', __FILE__ ), array( 'wp-admin' ), '1.4.7' );
     125        wp_enqueue_script( 'sarbacane-widget-adminpanel.js', plugins_url( 'js/sarbacane-widget-adminpanel.js', __FILE__ ), array( 'jquery', 'underscore' ), '1.4.7' );
    124126        $nonce_ok = false;
    125127        if ( isset( $_POST ['sarbacane_token'] ) ) {
     
    148150        $fields = get_option( 'sarbacane_news_fields', array() );
    149151        if ( ! is_array( $fields ) || count( $fields ) == 0 ) {
    150             $default_email = new stdClass ();
     152            $default_email = new stdClass();
    151153            $default_email->label = 'email';
    152154            $default_email->placeholder = '';
     
    156158        }
    157159
    158         require_once 'views/sarbacane-widget-adminpanel.php';
     160        require_once( 'views/sarbacane-widget-adminpanel.php' );
    159161    }
    160162
     
    173175        if ( isset ( $field_number ) && $field_number > 0 ) {
    174176            for ( $i = 0; $i < $field_number; $i ++ ) {
    175                 $field_config = new stdClass ();
     177                $field_config = new stdClass();
    176178                if ( isset ( $sanitized_post [ 'sarbacane_label_' . $i ] ) && '' != $sanitized_post [ 'sarbacane_label_' . $i ] ) {
    177179                    $field_config->label = $sanitized_post [ 'sarbacane_label_' . $i ];
  • mailify/trunk/class.sarbacane-settings.php

    r1576277 r1681124  
    1010        $media_content = get_option( 'sarbacane_media_content', false );
    1111        $rss_data = get_option( 'sarbacane_rss_data', false );
    12         $rss_url = get_feed_link( "rss2" );
     12        $rss_url = get_feed_link( 'rss2' );
    1313        $posts_per_rss = get_option( 'posts_per_rss', 10 );
    1414        //forcing boolean to display as int to get 0 when false. Impossible otherwise
  • mailify/trunk/class.sarbacane.php

    r1677274 r1681124  
    88    /**
    99     * Method called on plugin activation.
    10      * Initiate some options, creates the sd updates table
    1110     */
    1211    public static function activation() {
    13         update_option( 'sarbacane_version', '1.4.6', false );
     12        update_option( 'sarbacane_version', '1.4.7', false );
    1413        update_option( 'sarbacane_sd_token', '', false );
    1514        update_option( 'sarbacane_sd_id_list', array(), false );
     
    1716
    1817        global $wpdb;
    19         $table_name = $wpdb->prefix . 'sd_updates';
    20         $sql = "DROP TABLE IF EXISTS `$table_name`";
     18        $sql = "DROP TABLE IF EXISTS `{$wpdb->prefix}sd_updates`";
    2119        $wpdb->query( $sql );
    2220        $charset_collate = $wpdb->get_charset_collate();
    23         $sql = "CREATE TABLE IF NOT EXISTS `$table_name` (
     21        $sql = "CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}sd_updates` (
    2422            `id` mediumint(9) NOT NULL AUTO_INCREMENT,
    2523            `time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
     
    2826            `action` text NOT NULL,
    2927            UNIQUE KEY `id` (`id`)
    30         ) $charset_collate;";
     28        ) {$charset_collate};";
    3129        $wpdb->query( $sql );
    32         $table_name = $wpdb->prefix . 'sd_subscribers';
    33         //$sql = "DROP TABLE IF EXISTS `$table_name`";
     30        //$sql = "DROP TABLE IF EXISTS `{$wpdb->prefix}sd_subscribers`";
    3431        //$wpdb->query( $sql );
    35         $charset_collate = $wpdb->get_charset_collate();
    36         $sql = "CREATE TABLE IF NOT EXISTS `$table_name` (
     32        $sql = "CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}sd_subscribers` (
    3733            `id` mediumint(9) NOT NULL AUTO_INCREMENT,
    3834            `email` varchar(255) DEFAULT NULL,
     
    4036            `registration_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
    4137            UNIQUE KEY `id` (`id`)
    42         ) $charset_collate;";
     38        ) {$charset_collate};";
    4339        $wpdb->query( $sql );
    4440    }
     
    4642    /**
    4743     * Method called on plugin deactivation.
    48      * Deletes all options created by the plugin and drops the sd_updates table
    4944     */
    5045    public static function deactivation() {
     
    8075
    8176        global $wpdb;
    82         $table_name = $wpdb->prefix . 'sd_updates';
    83         $sql = "DROP TABLE IF EXISTS `$table_name`";
     77        $sql = "DROP TABLE IF EXISTS `{$wpdb->prefix}sd_updates`";
    8478        $wpdb->query( $sql );
    85         //$table_name = $wpdb->prefix . 'sd_subscribers';
    86         //$sql = "DROP TABLE IF EXISTS `$table_name`";
     79        //$sql = "DROP TABLE IF EXISTS `{$wpdb->prefix}sd_subscribers`";
    8780        //$wpdb->query( $sql );
    8881    }
     
    9083    public function update_data_1_4_5() {
    9184        if ( get_option( 'sarbacane_version' ) === false ) {
    92             update_option( 'sarbacane_version', '1.4.6', false );
     85            update_option( 'sarbacane_version', '1.4.7', false );
    9386            try {
    9487                global $wpdb;
    95                 $table_name = $wpdb->prefix . 'sd_subscribers';
    9688                $charset_collate = $wpdb->get_charset_collate();
    97                 $sql = "CREATE TABLE IF NOT EXISTS `$table_name` (
     89                $sql = "CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}sd_subscribers` (
    9890                    `id` mediumint(9) NOT NULL AUTO_INCREMENT,
    9991                    `email` varchar(255) DEFAULT NULL,
     
    10193                    `registration_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
    10294                    UNIQUE KEY `id` (`id`)
    103                 ) $charset_collate;";
     95                ) {$charset_collate};";
    10496                $result = $wpdb->query( $sql );
    10597                if ( $result !== false ) {
     
    109101                        $insert_request = array();
    110102                        $insert_data = array();
    111                         $sql = "SELECT COUNT(*) FROM `$table_name`";
     103                        $sql = "SELECT COUNT(*) FROM `{$wpdb->prefix}sd_subscribers`";
    112104                        $count = $wpdb->get_var( $sql );
    113105                        if ( $count == 0) {
     
    129121                                    $insert_data[] = $registration_date;
    130122                                    if ( $key % 1000 == 0 || $key + 1 == $nb_subscribers ) {
    131                                         $sql = "INSERT INTO `$table_name` (`email`, `columns`, `registration_date`) VALUES " . implode( ',', $insert_request ) . ";";
     123                                        $sql = "INSERT INTO `{$wpdb->prefix}sd_subscribers` (`email`, `columns`, `registration_date`) VALUES " . implode( ',', $insert_request ) . ";";
    132124                                        $wpdb->query( $wpdb->prepare( $sql, $insert_data ) );
    133125                                        $insert_request = array();
     
    146138                    }
    147139                    update_option( 'sarbacane_sd_id_list', array(), false );
    148                     $table_name = $wpdb->prefix . 'sd_updates';
    149                     $wpdb->query( "TRUNCATE TABLE `$table_name`" );
     140                    $wpdb->query( "TRUNCATE TABLE `{$wpdb->prefix}sd_updates`" );
    150141                } else {
    151142                    delete_option( 'sarbacane_version' );
     
    202193        }
    203194        if ( $sd_list_id != '' ) {
    204             if ( "U" == $sd_list_id ) {
     195            if ( $sd_list_id == 'U' ) {
    205196                $this->get_users_list( $sd_id );
    206             } else if ( "N" == $sd_list_id ) {
     197            } else if ( $sd_list_id == 'N' ) {
    207198                $this->get_newsletter_list( $sd_id );
    208199            }
     
    213204
    214205    private function generate_available_lists( $sd_id, $user_sync, $newsletter_sync ) {
    215         echo 'list_id;name;reset;is_updated;type;version' . "\r\n";
    216 
     206        echo 'list_id;name;reset;is_updated;type;version' . "\n";
    217207        $last_call_date_N = get_option( 'sarbacane_news_call_' . $sd_id );
    218208        $last_call_date_C = get_option( 'sarbacane_user_call_' . $sd_id );
     
    240230        }
    241231        if ( $user_sync ) {
    242             echo 'U;' . get_bloginfo( 'name' ) . ';' . $sd_list_users_reset . ';' . $user_updated . ';Wordpress;' . get_bloginfo( 'version' ) . "\r\n";
     232            echo 'U;' . get_bloginfo( 'name' ) . ';' . $sd_list_users_reset . ';' . $user_updated . ';Wordpress;' . get_bloginfo( 'version' ) . "\n";
    243233        }
    244234        if ( $newsletter_sync ) {
    245             echo 'N;' . get_bloginfo( 'name' ) . ';' . $sd_list_news_reset . ';' . $newsletter_updated . ';Wordpress;' . get_bloginfo( 'version' ) . "\r\n";
     235            echo 'N;' . get_bloginfo( 'name' ) . ';' . $sd_list_news_reset . ';' . $newsletter_updated . ';Wordpress;' . get_bloginfo( 'version' ) . "\n";
    246236        }
    247237    }
     
    256246    private function check_users_list( $last_call_date ) {
    257247        global $wpdb;
    258         $wp_prefix = $wpdb->prefix;
    259         $table_name = $wpdb->prefix . 'sd_updates';
    260 
    261         $new_users_since_last_call = $wpdb->get_var( $wpdb->prepare( 'SELECT COUNT(*) FROM `' . $wp_prefix . 'users` AS `wu` WHERE `wu`.`user_registered` >= %s', $last_call_date ) );
    262         $update_users_since_last_call = $wpdb->get_var( $wpdb->prepare( 'SELECT COUNT(*) FROM `' . $table_name . '` AS `wsu` WHERE `wsu`.`time` >= %s', $last_call_date ) );
     248        $sql = "SELECT COUNT(*) FROM `{$wpdb->prefix}users` AS `wu` WHERE `wu`.`user_registered` >= %s";
     249        $new_users_since_last_call = $wpdb->get_var( $wpdb->prepare( $sql, $last_call_date ) );
     250        $sql = "SELECT COUNT(*) FROM `{$wpdb->prefix}sd_updates` AS `wsu` WHERE `wsu`.`time` >= %s";
     251        $update_users_since_last_call = $wpdb->get_var( $wpdb->prepare( $sql, $last_call_date ) );
    263252        return $new_users_since_last_call > 0 || $update_users_since_last_call > 0;
    264253    }
     
    273262    private function check_newsletter_list( $last_call_date = '' ) {
    274263        global $wpdb;
    275         $table_name = $wpdb->prefix . 'sd_subscribers';
    276         $sql_subscribers = 'SELECT COUNT(*) FROM `' . $table_name . '`';
     264        $sql_subscribers = "SELECT COUNT(*) FROM `{$wpdb->prefix}sd_subscribers`";
    277265        if ( $last_call_date != '' ) {
    278             $sql_subscribers .= ' WHERE `registration_date` > %s';
     266            $sql_subscribers .= " WHERE `registration_date` > %s";
    279267            $count = $wpdb->get_var( $wpdb->prepare( $sql_subscribers, $last_call_date ) );
    280268        } else {
     
    335323        if ( "N" == $list_type ) {
    336324            $fields = get_option( 'sarbacane_news_fields', array() );
    337             $csv_string = "email;";
     325            $csv_string = 'email;';
    338326            foreach ( $fields as $field ) {
    339327                if ( strtolower( $field->label ) != 'email' ) {
     
    341329                }
    342330            }
    343             $csv_string .= "action\r\n";
     331            $csv_string .= 'action' . "\n";
    344332            foreach ( $new_or_updated_users as $one_user_updated ) {
    345333                if ( isset( $one_user_updated->email ) ) {
     
    358346                    }
    359347                }
    360                 $csv_string .= 'S' . "\r\n";
    361             }
    362         } else {
    363             $csv_string = 'email;lastname;firstname;login;role;post_count;action' . "\r\n";
     348                $csv_string .= 'S' . "\n";
     349            }
     350        } else {
     351            $csv_string = 'email;lastname;firstname;login;role;post_count;action' . "\n";
    364352            if ( count( $new_or_updated_users ) > 0 ) {
    365353                foreach ( $new_or_updated_users as $one_user_updated ) {
     
    376364                    $csv_string .= $this->d_quote( $one_user_updated->email ) . ';' . $this->d_quote( $one_user_updated->lastname ) . ';';
    377365                    $csv_string .= $this->d_quote( $one_user_updated->firstname ) . ';' . $this->d_quote( $one_user_updated->user_login ) . ';';
    378                     $csv_string .= $this->d_quote( $role ) . ';' . $this->d_quote( $one_user_updated->user_posts ) . ';S' . "\r\n";
     366                    $csv_string .= $this->d_quote( $role ) . ';' . $this->d_quote( $one_user_updated->user_posts ) . ';S' . "\n";
    379367                }
    380368            }
    381369            if ( count( $deleted_users ) > 0 ) {
    382370                foreach ( $deleted_users as $deleted_user ) {
    383                     $csv_string .= $deleted_user->user_email . ';;;;;;U' . "\r\n";
     371                    $csv_string .= $deleted_user->user_email . ';;;;;;U' . "\n";
    384372                }
    385373            }
     
    403391    private function sarbacanedesktop_get_all_users( $last_call_date ) {
    404392        global $wpdb;
    405         $wp_prefix = $wpdb->prefix;
    406         $table_name = $wpdb->prefix . 'sd_updates';
    407         $sql = 'SELECT `wu`.`id` AS `user_id`, `wu`.`user_login` AS `user_login`, `wu`.`user_email` AS `email`, `wmf`.`meta_value` AS `firstname`, `wml`.`meta_value` AS `lastname`, `wum`.`meta_value` AS `user_role`
    408         FROM `' . $wp_prefix . 'users` AS `wu` LEFT JOIN `' . $wp_prefix . 'usermeta` AS `wmf` ON `wu`.`id` = `wmf`.`user_id` AND `wmf`.`meta_key` = "first_name"
    409         LEFT JOIN `' . $wp_prefix . 'usermeta` AS `wml` ON `wu`.`id` = `wml`.`user_id` AND `wml`.`meta_key` = "last_name"
    410         LEFT JOIN `' . $wp_prefix . 'usermeta` AS `wum` ON `wu`.`id` = `wum`.`user_id` AND `wum`.`meta_key` = "' . $wp_prefix . 'capabilities"';
     393        $sql = "SELECT `wu`.`id` AS `user_id`, `wu`.`user_login` AS `user_login`, `wu`.`user_email` AS `email`, `wmf`.`meta_value` AS `firstname`, `wml`.`meta_value` AS `lastname`, `wum`.`meta_value` AS `user_role`
     394        FROM `{$wpdb->prefix}users` AS `wu` LEFT JOIN `{$wpdb->prefix}usermeta` AS `wmf` ON `wu`.`id` = `wmf`.`user_id` AND `wmf`.`meta_key` = 'first_name'
     395        LEFT JOIN `{$wpdb->prefix}usermeta` AS `wml` ON `wu`.`id` = `wml`.`user_id` AND `wml`.`meta_key` = 'last_name'
     396        LEFT JOIN `{$wpdb->prefix}usermeta` AS `wum` ON `wu`.`id` = `wum`.`user_id` AND `wum`.`meta_key` = '{$wpdb->prefix}capabilities'";
    411397        if ( $last_call_date == '' ) {
    412398            $all_users = $wpdb->get_results( $sql );
    413399        } else {
    414             $sql = $sql . ' LEFT JOIN `' . $table_name . '` AS `wsu` ON `wsu`.`user_id` = `wu`.`id` AND `wsu`.`action` = "S" WHERE `wu`.`user_registered` >= %s OR `wsu`.`time` >= %s';
     400            $sql = $sql . " LEFT JOIN `{$wpdb->prefix}sd_updates` AS `wsu` ON `wsu`.`user_id` = `wu`.`id` AND `wsu`.`action` = 'S' WHERE `wu`.`user_registered` >= %s OR `wsu`.`time` >= %s";
    415401            $all_users = $wpdb->get_results( $wpdb->prepare( $sql, $last_call_date, $last_call_date ) );
    416402        }
     
    425411    private function sarbacanedesktop_get_all_deleted_users( $last_call_date ) {
    426412        global $wpdb;
    427         $table_name = $wpdb->prefix . 'sd_updates';
    428         $deleted_users = $wpdb->get_results( $wpdb->prepare( 'SELECT `user_email` FROM `' . $table_name . '` AS `wsu` WHERE `wsu`.`action` = "U" AND `wsu`.`time` >= %s', $last_call_date ) );
     413        $sql = "SELECT `user_email` FROM `{$wpdb->prefix}sd_updates` AS `wsu` WHERE `wsu`.`action` = 'U' AND `wsu`.`time` >= %s";
     414        $deleted_users = $wpdb->get_results( $wpdb->prepare( $sql, $last_call_date ) );
    429415        return $deleted_users;
    430416    }
     
    437423    private function get_subscribers( $last_call_date ) {
    438424        global $wpdb;
    439         $table_name = $wpdb->prefix . 'sd_subscribers';
    440425        if ( $last_call_date != '' ) {
    441             $sql_subscribers = 'SELECT * FROM `' . $table_name . '` WHERE `registration_date` > %s ORDER BY `registration_date` ASC';
    442             $all_subscribers = $wpdb->get_results( $wpdb->prepare( $sql_subscribers, $last_call_date ) );
    443         } else {
    444             $sql_subscribers = 'SELECT * FROM `' . $table_name . '` ORDER BY `registration_date` ASC';
    445             $all_subscribers = $wpdb->get_results( $sql_subscribers );
     426            $sql = "SELECT * FROM `{$wpdb->prefix}sd_subscribers` WHERE `registration_date` > %s ORDER BY `registration_date` ASC";
     427            $all_subscribers = $wpdb->get_results( $wpdb->prepare( $sql, $last_call_date ) );
     428        } else {
     429            $sql = "SELECT * FROM `{$wpdb->prefix}sd_subscribers` ORDER BY `registration_date` ASC";
     430            $all_subscribers = $wpdb->get_results( $sql );
    446431        }
    447432        $new_or_updated_users = array();
    448433        foreach ( $all_subscribers as $one_subscriber ) {
    449434            if ( isset( $one_subscriber->email ) ) {
    450                 $values =  new stdClass();
     435                $values = new stdClass();
    451436                $values->email = $one_subscriber->email;
    452437                $columns = json_decode( $one_subscriber->columns );
     
    471456        delete_option( 'sarbacane_news_call_' . $sd_id );
    472457
    473         $sdid_array = get_option( 'sarbacane_sd_id_list' );
    474         $index = array_search( $sd_id, $sdid_array );
     458        $sd_ids_saved = get_option( 'sarbacane_sd_id_list' );
     459        $index = array_search( $sd_id, $sd_ids_saved );
    475460        if ( $index !== false ) {
    476             unset ( $sdid_array [ $index ] );
    477             update_option( 'sarbacane_sd_id_list', $sdid_array, false );
     461            unset( $sd_ids_saved [ $index ] );
     462            update_option( 'sarbacane_sd_id_list', $sd_ids_saved, false );
    478463        }
    479464    }
     
    524509    private function clear_update_history() {
    525510        global $wpdb;
    526         $table_name = $wpdb->prefix . 'sd_updates';
    527         $option_table = $wpdb->prefix . 'options';
    528         $sql = "DELETE FROM `$table_name` WHERE `time` <= (SELECT MIN(`option_value`) FROM `$option_table` WHERE `option_name` LIKE 'sarbacane_%_call_%')";
     511        $sql = "DELETE FROM `{$wpdb->prefix}sd_updates` WHERE `time` <= (
     512            SELECT MIN(`option_value`) FROM `{$wpdb->prefix}options` WHERE `option_name` LIKE 'sarbacane_%_call_%'
     513        )";
    529514        $wpdb->query( $sql );
    530515    }
     
    564549            update_option( 'sarbacane_sd_id_list', array(), false );
    565550            global $wpdb;
    566             $table_name = $wpdb->prefix . 'sd_updates';
    567             $wpdb->query( "TRUNCATE TABLE `$table_name`" );
     551            $wpdb->query( "TRUNCATE TABLE `{$wpdb->prefix}sd_updates`" );
    568552            $this->sarbacane_params_saved();
    569553        }
     
    574558        }
    575559        $sd_list_news = get_option( 'sarbacane_news_list', false );
    576         $sdid_array = get_option( 'sarbacane_sd_id_list', array() );
     560        $is_connected = false;
     561        if ( count( get_option( 'sarbacane_sd_id_list', array() ) ) > 0 ) {
     562            $is_connected = true;
     563        }
    577564        $is_failed = (int) get_option( 'sarbacane_failed', 0 ) < 1000000 ? false : true;
    578         wp_enqueue_style ( "sarbacane_global.css", plugins_url ( "css/sarbacane_global.css", __FILE__ ), array(), '1.4.6' );
    579         wp_enqueue_style ( "sarbacane_admin_panel.css", plugins_url ( "css/sarbacane_admin_panel.css", __FILE__ ), array(), '1.4.6' );
     565        wp_enqueue_style ( 'sarbacane_global.css', plugins_url ( 'css/sarbacane_global.css', __FILE__ ), array(), '1.4.7' );
     566        wp_enqueue_style ( 'sarbacane_admin_panel.css', plugins_url ( 'css/sarbacane_admin_panel.css', __FILE__ ), array(), '1.4.7' );
    580567        require_once( 'views/sarbacane-adminpanel.php' );
    581568    }
     
    612599            return;
    613600        }
    614         if ( isset ( $wp->query_vars ['sarbacane_form_token'] ) && '' != $wp->query_vars ['sarbacane_form_token'] && wp_verify_nonce( $wp->query_vars['sarbacane_form_token'], 'newsletter_registration' ) ) {
     601        if ( isset ( $wp->query_vars ['sarbacane_form_token'] ) && $wp->query_vars ['sarbacane_form_token'] != '' && wp_verify_nonce( $wp->query_vars['sarbacane_form_token'], 'newsletter_registration' ) ) {
    615602            $save_widget = true;
    616603        }
    617         if ( isset ( $wp->query_vars ['sdid'] ) && '' != $wp->query_vars ['sdid'] ) {
     604        if ( isset ( $wp->query_vars ['sdid'] ) && $wp->query_vars ['sdid'] != '' ) {
    618605            $sd_id = sanitize_text_field( $wp->query_vars ['sdid'] );
    619606        }
    620         if ( isset ( $wp->query_vars ['sd_token'] ) && '' != $wp->query_vars ['sd_token'] ) {
     607        if ( isset ( $wp->query_vars ['sd_token'] ) && $wp->query_vars ['sd_token'] != '' ) {
    621608            $sd_token = sanitize_text_field( $wp->query_vars ['sd_token'] );
    622609        }
    623610        $sd_list_id = '';
    624         if ( isset ( $wp->query_vars ['list'] ) && '' != $wp->query_vars ['list'] ) {
     611        if ( isset ( $wp->query_vars ['list'] ) && $wp->query_vars ['list'] != '' ) {
    625612            $sd_list_id = sanitize_text_field( $wp->query_vars ['list'] );
    626613        }
    627614        $action = '';
    628         if ( isset ( $wp->query_vars ['action'] ) && '' != $wp->query_vars ['action'] ) {
     615        if ( isset ( $wp->query_vars ['action'] ) && $wp->query_vars ['action'] != '' ) {
    629616            $action = sanitize_text_field( $wp->query_vars ['action'] );
    630617        }
    631         if ( isset ( $wp->query_vars ['type'] ) && '' != $wp->query_vars ['type'] ) {
     618        if ( isset ( $wp->query_vars ['type'] ) && $wp->query_vars ['type'] != '' ) {
    632619            $type = sanitize_text_field( $wp->query_vars ['type'] );
    633620        }
    634         if ( isset ( $wp->query_vars ['id'] ) && '' != $wp->query_vars ['id'] ) {
     621        if ( isset ( $wp->query_vars ['id'] ) && $wp->query_vars ['id'] != '' ) {
    635622            $id = sanitize_text_field( $wp->query_vars ['id'] );
    636623        }
    637624        $limit = - 1;
    638         if ( isset ( $wp->query_vars ['limit'] ) && '' != $wp->query_vars ['limit'] ) {
     625        if ( isset ( $wp->query_vars ['limit'] ) && $wp->query_vars ['limit'] != '' ) {
    639626            $limit = $wp->query_vars ['limit'];
    640627        }
    641628        if ( isset( $save_widget ) ) {
    642             header( "Content-Type: text/html; charset=utf-8" );
     629            header( 'Content-Type: text/html; charset=utf-8' );
    643630            $this->update_data_1_4_5();
    644631            $widget = new SarbacaneNewsWidget();
     
    647634        }
    648635        if ( ! isset ( $sd_id ) ) {
    649             header( "HTTP/1.1 400 Bad request" );
    650             header( "Content-type: application/json; charset=utf-8" );
    651             die ( 'FAILED_SDID' );
     636            header( 'HTTP/1.1 400 Bad request' );
     637            header( 'Content-type: application/json; charset=utf-8' );
     638            die( 'FAILED_SDID' );
    652639        }
    653640        if ( ! isset ( $sd_token ) ) {
    654             header( "HTTP/1.1 400 Bad request" );
    655             header( "Content-type: application/json; charset=utf-8" );
    656             die ( 'FAILED_SDTOKEN' );
     641            header( 'HTTP/1.1 400 Bad request' );
     642            header( 'Content-type: application/json; charset=utf-8' );
     643            die( 'FAILED_SDTOKEN' );
    657644        }
    658645        $failed = (int) get_option( 'sarbacane_failed', 0 );
     
    663650                update_option( 'sarbacane_failed', $failed + 1, false );
    664651            }
    665             header( "HTTP/1.1 403 Unauthorized" );
    666             header( "Content-type: application/json; charset=utf-8" );
    667             die ( 'FAILED_SDTOKEN' );
     652            header( 'HTTP/1.1 403 Unauthorized' );
     653            header( 'Content-type: application/json; charset=utf-8' );
     654            die( 'FAILED_SDTOKEN' );
    668655        } else {
    669656            // Content retrieving
    670657            if ( isset ( $type ) ) {
    671                 if ( "posts" == $type ) {
    672                     header( "Content-Type: application/rss+xml ; charset=utf-8" );
     658                if ( $type == 'posts' ) {
     659                    header( 'Content-Type: application/rss+xml; charset=utf-8' );
    673660                    $content = new SarbacaneContent();
    674661                    if ( isset ( $id ) ) {
     
    677664                        $content->get_articles_rss( $limit );
    678665                    }
    679                 } else if ( "settings" == $type ) {
    680                     header( "Content-Type: application/json ; charset=utf-8" );
    681                     header( "Content-Transfer-Encoding: binary" );
     666                } else if ( $type == 'settings' ) {
     667                    header( 'Content-Type: application/json; charset=utf-8' );
     668                    header( 'Content-Transfer-Encoding: binary' );
    682669                    $settings = new SarbacaneSettings();
    683670                    $settings->get_settings();
    684                 } else if ( "medias" == $type ) {
    685                     header( "Content-Type: application/json ; charset=utf-8" );
     671                } else if ( $type == 'medias' ) {
     672                    header( 'Content-Type: application/json; charset=utf-8' );
    686673                    $medias = new SarbacaneMedias();
    687674                    $medias->get_medias();
     
    690677                $this->update_data_1_4_5();
    691678                // List retrieving
    692                 header( "Content-Type: text/plain ; charset=utf-8" );
    693                 header( "Content-Transfer-Encoding: binary" );
    694                 if ( "delete" == $action ) {
     679                header( 'Content-Type: text/plain; charset=utf-8' );
     680                header( 'Content-Transfer-Encoding: binary' );
     681                if ( $action == 'delete' ) {
    695682                    $this->sarbacane_delete_sdid( $sd_id );
    696683                } else {
    697                     if ( $sd_list_id != '' && $sd_list_id != "N" && $sd_list_id != "U" ) {
    698                         header( "HTTP/1.1 404 Not found" );
    699                         header( "Content-type: application/json ; charset=utf-8" );
    700                         die ( 'FAILED_ID' );
     684                    if ( $sd_list_id != '' && $sd_list_id != 'N' && $sd_list_id != 'U' ) {
     685                        header( 'HTTP/1.1 404 Not found' );
     686                        header( 'Content-type: application/json; charset=utf-8' );
     687                        die( 'FAILED_ID' );
    701688                    }
    702689                    $this->sarbacane_get_list( $sd_id, $sd_list_id );
  • mailify/trunk/js/sarbacane-widget.js

    r1629810 r1681124  
    1616    }
    1717    if ( isSubmitable ) {
     18        jQuery( "#sarbacane_desktop_widget_form_" + list_type + " .sarbacane_form_value" ).val( "sarbacane_desktop_widget" );
    1819        jQuery( "#sarbacane_desktop_widget_form_" + list_type ).submit();
    1920    }
  • mailify/trunk/readme.txt

    r1677274 r1681124  
    33Tags: marketing, mail, email, mailing
    44Requires at least: 4.0
    5 Tested up to: 4.7
     5Tested up to: 4.8
    66License: GPLv2 or later
    7 Stable tag: 1.4.6
     7Stable tag: 1.4.7
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
    99
     
    8585== Changelog ==
    8686
     87= 1.4.7 =
     88Widget optimizations.
     89
    8790= 1.4.6 =
    8891Customize widget mandatory fields message.
     
    129132= Spanish =
    130133
     134= 1.4.7 =
     135Widget Optimización.
     136
    131137= 1.4.6 =
    132138Personalizar el mensaje de los campos obligatorios del widget.
  • mailify/trunk/sarbacane.php

    r1677274 r1681124  
    55Description: This plugin allows you to synchronize your WordPress data in Mailify
    66Author: Sarbacane Software
    7 Version: 1.4.6
     7Version: 1.4.7
    88Author URI: http://mailify.com/?utm_source=module-wordpress&utm_medium=plugin&utm_content=lien-sarbacane&utm_campaign=wordpress
    99Text Domain: mailify
  • mailify/trunk/views/sarbacane-adminpanel.php

    r1629810 r1681124  
    1717                    <?php _e( 'Synchronization key to enter in Mailify', 'mailify' ) ?> :
    1818                    <span class="sarbacane_desktop_connection_status">
    19                         <?php if ( is_array( $sdid_array ) && count( $sdid_array ) > 0 ) { ?>
     19                        <?php if ( $is_connected ) { ?>
    2020                        <span class='sarbacane_desktop_connection_ok'><?php _e( 'Connected', 'mailify' ) ?></span>
    2121                        <?php } else { ?>
  • mailify/trunk/views/sarbacane-lists-sync.php

    r1629810 r1681124  
    1313                </p>
    1414                <p class="sarbacane_desktop_config_label">
    15                     <input type="checkbox" name="sarbacane_users_list" id="sarbacane_users_list" value="true" <?php if ( $sarbacane_users_list ) { echo 'checked="checked"' ; } ?> />
     15                    <input type="checkbox" name="sarbacane_users_list" id="sarbacane_users_list" value="true"<?php if ( $sarbacane_users_list ) { ?> checked="checked"<?php } ?>/>
    1616                    <label for="sarbacane_users_list"><?php _e( 'Synchronize a \'\'WordPress Users\'\' list', 'mailify' ) ?></label>
    1717                    <br />
     
    1919                </p>
    2020                <p class="sarbacane_desktop_config_label">
    21                     <input type="checkbox" name="sarbacane_news_list" onclick="sarbacaneNewsListChangePopup()" id="sarbacane_news_list" value="true" <?php if ( $sarbacane_news_list ) { echo 'checked="checked"'; } ?> />
     21                    <input type="checkbox" name="sarbacane_news_list" onclick="sarbacaneNewsListChangePopup()" id="sarbacane_news_list" value="true" <?php if ( $sarbacane_news_list ) { ?> checked="checked"<?php } ?>/>
    2222                    <label for="sarbacane_news_list"><?php _e( 'Automatically synchronize your subscriber list', 'mailify' ) ?></label>
    2323                    <br />
     
    3131                </p>
    3232                <p class="sarbacane_desktop_config_label">
    33                     <input type="checkbox" name="sarbacane_theme_sync" id="sarbacane_theme_sync" value="true" <?php if ( $sarbacane_theme_sync ) { echo 'checked="checked"'; } ?> />
     33                    <input type="checkbox" name="sarbacane_theme_sync" id="sarbacane_theme_sync" value="true"<?php if ( $sarbacane_theme_sync ) { ?> checked="checked"<?php } ?>/>
    3434                    <label for="sarbacane_theme_sync"><?php _e( 'Synchronize your WordPress theme', 'mailify' ) ?></label>
    3535                    <br />
     
    3737                </p>
    3838                <p class="sarbacane_desktop_config_label">
    39                     <input type="checkbox" name="sarbacane_blog_content" id="sarbacane_blog_content" value="true" <?php if ( $sarbacane_blog_content ) { echo 'checked="checked"'; } ?> />
     39                    <input type="checkbox" name="sarbacane_blog_content" id="sarbacane_blog_content" value="true"<?php if ( $sarbacane_blog_content ) { ?> checked="checked"<?php } ?>/>
    4040                    <label for="sarbacane_blog_content"><?php _e( 'Synchronize blog content', 'mailify' ) ?></label>
    4141                    <br />
     
    4343                </p>
    4444                <p class="sarbacane_desktop_config_label" style="display:none;">
    45                     <input type="checkbox" name="sarbacane_media_content" id="sarbacane_media_content" value="true" <?php if ( $sarbacane_media_content ) { echo 'checked="checked"'; } ?> />
     45                    <input type="checkbox" name="sarbacane_media_content" id="sarbacane_media_content" value="true"<?php if ( $sarbacane_media_content ) { ?> checked="checked"<?php } ?>/>
    4646                    <label for="sarbacane_media_content"><?php _e( 'Synchronize media library', 'mailify' ) ?></label>
    4747                    <br />
     
    4949                </p>
    5050                <p class="sarbacane_desktop_config_label">
    51                     <input type="checkbox" name="sarbacane_rss_data" id="sarbacane_rss_data" value="true" <?php if ( $sarbacane_rss_data ) { echo 'checked="checked"'; } ?> />
     51                    <input type="checkbox" name="sarbacane_rss_data" id="sarbacane_rss_data" value="true"<?php if ( $sarbacane_rss_data ) { ?> checked="checked"<?php } ?>/>
    5252                    <label for="sarbacane_rss_data"><?php _e( 'Synchronize RSS data', 'mailify' ) ?></label>
    5353                    <br />
  • mailify/trunk/views/sarbacane-widget-adminpanel.php

    r1677274 r1681124  
    5050                    <label class="sarbacane_desktop_field_number"><?php echo __( 'Field', 'mailify' ) . ' ' . ( $i + 1 ) ?></label>
    5151                    <ul class="sarbacane_widget_menu">
    52                         <li class="sarbacane_desktop_menu_item sarbacane_desktop_trash <?php if ( $isEmail ) { echo "sarbacane_desktop_menu_item_disabled_email";} ?>" <?php if ( !$isEmail ) { ?> onclick="sarbacaneDeleteField( <?php echo $i ?> )" <?php } ?>></li>
     52                        <li class="sarbacane_desktop_menu_item sarbacane_desktop_trash<?php if ( $isEmail ) { ?> sarbacane_desktop_menu_item_disabled_email<?php } ?>"<?php if ( !$isEmail ) { ?> onclick="sarbacaneDeleteField( <?php echo $i ?> )" <?php } ?>></li>
    5353                        <li class="sarbacane_desktop_menu_item sarbacane_desktop_down" onclick="sarbacaneMoveDown( <?php echo $i ?> )"></li>
    5454                        <li class="sarbacane_desktop_menu_item sarbacane_desktop_up" onclick="sarbacaneMoveUp( <?php echo $i ?> )"></li>
     
    6767                    <br />
    6868                    <label class="sarbacane_desktop_inline_configuration_label " for="sarbacane_desktop_mandatory_<?php echo $i ?>"><?php _e( 'Mandatory', 'mailify' ) ?>&nbsp;:&nbsp;</label>
    69                     <input type="radio" name="sarbacane_mandatory_<?php echo $i ?>" id="sarbacane_desktop_mandatory_true_<?php echo $i ?>" value="true" <?php if ( $field->mandatory ) { echo ' checked="checked" '; } ?> <?php if ( $isEmail ) { echo 'disabled="disabled"'; } ?> onclick="sarbacaneDisplayPreview()"/>
     69                    <input type="radio" name="sarbacane_mandatory_<?php echo $i ?>" id="sarbacane_desktop_mandatory_true_<?php echo $i ?>" value="true"<?php if ( $field->mandatory ) { ?> checked="checked"<?php } ?><?php if ( $isEmail ) { ?> disabled="disabled"<?php } ?> onclick="sarbacaneDisplayPreview()"/>
    7070                    <label class="sarbacane_desktop_yes_no_label" for="sarbacane_desktop_mandatory_true_<?php echo $i ?>"><?php _e( 'Yes', 'mailify' ) ?></label>
    71                     <input type="radio" name="sarbacane_mandatory_<?php echo $i ?>" id="sarbacane_desktop_mandatory_false_<?php echo $i ?>" value="false" <?php if ( !$field->mandatory ) { echo ' checked="checked" '; } ?> <?php if ( $isEmail ) { echo 'disabled="disabled"'; } ?> onclick="sarbacaneDisplayPreview()"/>
     71                    <input type="radio" name="sarbacane_mandatory_<?php echo $i ?>" id="sarbacane_desktop_mandatory_false_<?php echo $i ?>" value="false"<?php if ( !$field->mandatory ) { ?> checked="checked"<?php } ?><?php if ( $isEmail ) { ?> disabled="disabled"<?php } ?> onclick="sarbacaneDisplayPreview()"/>
    7272                    <label class="sarbacane_desktop_yes_no_label" for="sarbacane_desktop_mandatory_false_<?php echo $i ?>"><?php _e( 'No', 'mailify' ) ?></label>
    7373                </p>
     
    116116    <div id="sarbacane_widget_preview">
    117117        <p class="sarbacane_widget_configuration_title"><?php _e( 'Preview', 'mailify' ) ?></p>
    118         <div id="sarbacane_preview"><?php _e( 'Fields marked with * are mandatory', 'mailify' ) ?></div>
     118        <div id="sarbacane_preview"></div>
    119119    </div>
    120120    <div id="sarbacane_desktop_vertical_splitter"></div>
  • mailify/trunk/views/sarbacane-widget.php

    r1677274 r1681124  
    2222            ?>
    2323            <p>
    24                 <label><?php echo $label ?> <?php if ( $field->mandatory ) { echo '*'; } ?></label>
     24                <label><?php echo $label ?><?php if ( $field->mandatory ) { ?> *<?php } ?></label>
    2525                <br />
    26                 <input type="<?php echo $field_type ?>" id="<?php echo $id ?>" name="<?php echo $name ?>" placeholder="<?php esc_attr_e( $field->placeholder ) ?>" <?php if ( $field->mandatory ) { echo 'required class="required"'; } ?> />
     26                <input type="<?php echo $field_type ?>" id="<?php echo $id ?>" name="<?php echo $name ?>" placeholder="<?php esc_attr_e( $field->placeholder ) ?>"<?php if ( $field->mandatory ) { ?> required class="required"<?php } ?>/>
    2727            </p>
    2828        <?php } ?>
    2929        <p><?php esc_html_e( $registration_mandatory_fields ) ?></p>
    3030        <?php wp_nonce_field( 'newsletter_registration', 'sarbacane_form_token' ) ?>
    31         <input type="button" value="<?php esc_attr_e( $registration_button ) ?>" onclick="sarbacaneSubmitWidget( '<?php echo $list_type . $rand ?>' )" />
     31        <input type="hidden" name="sarbacane_form_value" class="sarbacane_form_value" value=""/>
     32        <input type="button" value="<?php esc_attr_e( $registration_button ) ?>" onclick="sarbacaneSubmitWidget( '<?php echo $list_type . $rand ?>' )"/>
    3233    </form>
    3334</aside>
Note: See TracChangeset for help on using the changeset viewer.