Plugin Directory

Changeset 1898992


Ignore:
Timestamp:
06/26/2018 07:18:32 AM (8 years ago)
Author:
sarbacanesoftware
Message:

sarbacane 1.4.11

Location:
sarbacane-desktop
Files:
1 deleted
14 edited
1 copied

Legend:

Unmodified
Added
Removed
  • sarbacane-desktop/tags/1.4.11/class.sarbacane-content.php

    r1681123 r1898992  
    6262        $query = new WP_Query ( 'post_type=post&p=' . $post_id );
    6363        if ( $query->have_posts() ) {
    64             echo $this->get_rss_header() . $this->get_rss_content( 'post', $post_id ) . $this->get_rss_footer();
     64            return $this->get_rss_header() . $this->get_rss_content( 'post', $post_id ) . $this->get_rss_footer();
    6565        } else {
    66             header( 'HTTP/1.1 404 Bad item' );
    67             header( 'Content-Type: application/json; charset=utf-8' );
    68             die( 'FAILED_ID' );
     66            return false;
    6967        }
    7068    }
    7169
    7270    public function get_articles_rss( $limit ) {
    73         echo $this->get_rss_header() . $this->get_rss_content( 'posts', $limit ) . $this->get_rss_footer();
     71        return $this->get_rss_header() . $this->get_rss_content( 'posts', $limit ) . $this->get_rss_footer();
    7472    }
    7573
  • sarbacane-desktop/tags/1.4.11/class.sarbacane-medias.php

    r1681123 r1898992  
    2020        }
    2121        $medias = implode( ',', $medias );
    22         echo '{"medias":[' . $medias . "\n\t" . ']' . "\n" . '}';
     22        return '{"medias":[' . $medias . "\n\t" . ']' . "\n" . '}';
    2323    }
    2424
  • sarbacane-desktop/tags/1.4.11/class.sarbacane-newsletterwidget.php

    r1817959 r1898992  
    6464            }
    6565        }
    66         $this->display_registration_message($valid);
     66        return $this->display_registration_message($valid);
    6767    }
    6868
     
    7373            $message = json_encode( array( 'message' => __( 'Email isn\'t valid.', 'sarbacane-desktop' ) ) );
    7474        }
    75         echo '
     75        return '
    7676        <script type="text/javascript">
    7777            var registration_message = ' . $message . ';
  • sarbacane-desktop/tags/1.4.11/class.sarbacane-settings.php

    r1681123 r1898992  
    1212        $rss_url = get_feed_link( 'rss2' );
    1313        $posts_per_rss = get_option( 'posts_per_rss', 10 );
    14         //forcing boolean to display as int to get 0 when false. Impossible otherwise
    15         echo '{
     14        return '{
    1615    "settings":{
    1716        "general_settings":{
  • sarbacane-desktop/tags/1.4.11/class.sarbacane.php

    r1817959 r1898992  
    33class Sarbacane {
    44
    5     /**
    6      * Method called on plugin activation.
    7      */
    85    public static function activation() {
    96        update_option( 'sarbacane_version', '1.4.9', false );
     
    3734    }
    3835
    39     /**
    40      * Method called on plugin deactivation.
    41      */
    4236    public static function deactivation() {
    4337        delete_option( 'sarbacane_version' );
     
    145139    }
    146140
    147     /**
    148      * Called on menu generation (admin_menu hook).
    149      */
    150141    public function add_admin_menu() {
    151142        add_submenu_page( 'sarbacane', __( 'Connection', 'sarbacane-desktop' ), __( 'Connection', 'sarbacane-desktop' ), 'administrator', 'wp_interconnection', array(
     
    155146    }
    156147
    157     /**
    158      * Loads this plugin locale
    159      */
    160148    public function sarbacane_load_locales() {
    161149        load_plugin_textdomain( 'sarbacane-desktop', false, dirname( plugin_basename( __FILE__ ) ) . '/locales' );
    162150    }
    163151
    164     /**
    165      * Display message when key generated
    166      */
    167152    private function sarbacane_params_saved() {
    168         echo '<div class="updated">' . __( 'A new key has been generated', 'sarbacane-desktop' ) . '</div>';
    169     }
    170 
    171     /**
    172      * Get new subscribers
    173      *
    174      * @param string $sd_id
    175      * @param string $sd_list_id
    176      *            If empty, get lists vide else get email for the list
    177      *
    178      * @throws WP_Error
    179      */
     153        return '<div class="updated">' . __( 'A new key has been generated', 'sarbacane-desktop' ) . '</div>';
     154    }
     155
    180156    private function sarbacane_get_list( $sd_id, $sd_list_id ) {
    181157
     
    191167        if ( $sd_list_id != '' ) {
    192168            if ( $sd_list_id == 'U' ) {
    193                 $this->get_users_list( $sd_id );
     169                return $this->get_users_list( $sd_id );
    194170            } else if ( $sd_list_id == 'N' ) {
    195                 $this->get_newsletter_list( $sd_id );
     171                return $this->get_newsletter_list( $sd_id );
    196172            }
    197173        } else {
    198             $this->generate_available_lists( $sd_id, $sd_list_users, $sd_list_news );
     174            return $this->generate_available_lists( $sd_id, $sd_list_users, $sd_list_news );
    199175        }
    200176    }
    201177
    202178    private function generate_available_lists( $sd_id, $user_sync, $newsletter_sync ) {
    203         echo 'list_id;name;reset;is_updated;type;version' . "\n";
     179        $content = 'list_id;name;reset;is_updated;type;version' . "\n";
    204180        $last_call_date_N = get_option( 'sarbacane_news_call_' . $sd_id );
    205181        $last_call_date_C = get_option( 'sarbacane_user_call_' . $sd_id );
     
    229205        $name = $this->d_quote( str_replace( '&#039;', '\'', $name ) );
    230206        if ( $user_sync ) {
    231             echo 'U;' . $name . ';' . $sd_list_users_reset . ';' . $user_updated . ';Wordpress;' . get_bloginfo( 'version' ) . "\n";
     207            $content .= 'U;' . $name . ';' . $sd_list_users_reset . ';' . $user_updated . ';Wordpress;' . get_bloginfo( 'version' ) . "\n";
    232208        }
    233209        if ( $newsletter_sync ) {
    234             echo 'N;' . $name . ';' . $sd_list_news_reset . ';' . $newsletter_updated . ';Wordpress;' . get_bloginfo( 'version' ) . "\n";
    235         }
    236     }
    237 
    238     /**
    239      * Check new users since last call
    240      *
    241      * @param string $last_call_date
    242      *
    243      * @return boolean
    244      */
     210            $content .= 'N;' . $name . ';' . $sd_list_news_reset . ';' . $newsletter_updated . ';Wordpress;' . get_bloginfo( 'version' ) . "\n";
     211        }
     212        return $content;
     213    }
     214
    245215    private function check_users_list( $last_call_date ) {
    246216        global $wpdb;
     
    252222    }
    253223
    254     /**
    255      * Check new newsletter subcribers since last call
    256      *
    257      * @param string $last_call_date
    258      *
    259      * @return boolean
    260      */
    261224    private function check_newsletter_list( $last_call_date = '' ) {
    262225        global $wpdb;
     
    274237    }
    275238
    276     /**
    277      * Generate newsletter subscribers CSV
    278      *
    279      * @param string $sd_id
    280      */
    281239    private function get_newsletter_list( $sd_id ) {
    282240        if ( ! get_option( 'sarbacane_news_list' ) ) {
    283             echo $this->generate_csv( array(), array(), 'N' );
    284             return;
     241            return $this->generate_csv( array(), array(), 'N' );
    285242        }
    286243        $last_call_date = get_option( 'sarbacane_news_call_' . $sd_id, '' );
     
    288245        $new_or_updated_users = $this->get_subscribers( $last_call_date );
    289246        $this->clear_update_history();
    290         echo $this->generate_csv( $new_or_updated_users, array(), 'N' );
    291     }
    292 
    293     /**
    294      * Generate users CSV
    295      *
    296      * @param string $sd_id
    297      */
     247        return $this->generate_csv( $new_or_updated_users, array(), 'N' );
     248    }
     249
    298250    private function get_users_list( $sd_id ) {
    299251        if ( ! get_option( 'sarbacane_users_list' ) ) {
    300             echo $this->generate_csv( array(), array(), 'U' );
    301             return;
     252            return $this->generate_csv( array(), array(), 'U' );
    302253        }
    303254        $last_call_date = get_option( 'sarbacane_user_call_' . $sd_id, '' );
     
    307258        $deleted_users = $this->sarbacanedesktop_get_all_deleted_users( $last_call_date );
    308259        $this->clear_update_history();
    309         echo $this->generate_csv( $all_users, $deleted_users, 'U' );
    310     }
    311 
    312     /**
    313      * Generate CSV
    314      *
    315      * @param array $new_or_updated_users
    316      * @param array $deleted_users
    317      * @param string $list_type
    318      *
    319      * @return CSV
    320      */
     260        return $this->generate_csv( $all_users, $deleted_users, 'U' );
     261    }
     262
    321263    private function generate_csv( $new_or_updated_users, $deleted_users = array(), $list_type ) {
    322264        if ( "N" == $list_type ) {
     
    383325    }
    384326
    385     /**
    386      * Get users
    387      *
    388      * @return array
    389      */
    390327    private function sarbacanedesktop_get_all_users( $last_call_date ) {
    391328        global $wpdb;
     
    415352    }
    416353
    417     /**
    418      * Get newsletter subscribers
    419      *
    420      * @return array
    421      */
    422354    private function get_subscribers( $last_call_date ) {
    423355        global $wpdb;
     
    463395    }
    464396
    465     /**
    466      * Called on user update.
    467      */
    468397    public function trigger_user_update( $user_id ) {
    469398        if ( get_option( 'sarbacane_users_list' ) ) {
     
    483412    }
    484413
    485     /**
    486      * Called on user delete.
    487      */
    488414    public function trigger_user_delete( $user_id ) {
    489415        if ( get_option( 'sarbacane_users_list' ) ) {
     
    549475            global $wpdb;
    550476            $wpdb->query( "TRUNCATE TABLE `{$wpdb->prefix}sd_updates`" );
    551             $this->sarbacane_params_saved();
     477            echo $this->sarbacane_params_saved();
    552478        }
    553479        $sd_token = get_option( 'sarbacane_sd_token', false );
     
    629555            $this->update_data_1_4_5();
    630556            $widget = new SarbacaneNewsWidget();
    631             $widget->sarbacane_save_widget();
     557            echo $widget->sarbacane_save_widget();
    632558            exit;
    633559        }
    634560        if ( ! isset ( $sd_id ) ) {
    635             header( 'HTTP/1.1 400 Bad request' );
    636             header( 'Content-type: application/json; charset=utf-8' );
    637             die( 'FAILED_SDID' );
     561            header( 'HTTP/1.1 404 Not Found' );
     562            header( 'Content-type: text/plain; charset=utf-8' );
     563            exit( 'FAILED_ID' );
    638564        }
    639565        if ( ! isset ( $sd_token ) ) {
    640             header( 'HTTP/1.1 400 Bad request' );
    641             header( 'Content-type: application/json; charset=utf-8' );
    642             die( 'FAILED_SDTOKEN' );
     566            header( 'HTTP/1.1 403 Forbidden' );
     567            header( 'Content-type: text/plain; charset=utf-8' );
     568            exit( 'FAILED' );
    643569        }
    644570        $failed = (int) get_option( 'sarbacane_failed', 0 );
     
    649575                update_option( 'sarbacane_failed', $failed + 1, false );
    650576            }
    651             header( 'HTTP/1.1 403 Unauthorized' );
    652             header( 'Content-type: application/json; charset=utf-8' );
    653             die( 'FAILED_SDTOKEN' );
    654         } else {
    655             // Content retrieving
     577            header( 'HTTP/1.1 403 Forbidden' );
     578            header( 'Content-type: text/plain; charset=utf-8' );
     579            exit( 'FAILED' );
     580        } else if ( $sd_token == $sd_token_saved && strlen( $sd_token_saved ) > 20 && ! $is_failed ) {
    656581            if ( isset ( $type ) ) {
    657582                if ( $type == 'posts' ) {
    658                     header( 'Content-Type: application/rss+xml; charset=utf-8' );
    659583                    $content = new SarbacaneContent();
    660584                    if ( isset ( $id ) ) {
    661                         $content->get_article_rss( $id );
     585                        $text = $content->get_article_rss( $id );
     586                        if ($text === false) {
     587                            header( 'HTTP/1.1 404 Not Found' );
     588                            header( 'Content-Type: text/plain; charset=utf-8' );
     589                            exit( 'FAILED_ID' );
     590                        } else {
     591                            header( 'Content-Type: application/rss+xml; charset=utf-8' );
     592                            echo $text;
     593                        }
    662594                    } else {
    663                         $content->get_articles_rss( $limit );
     595                        header( 'Content-Type: application/rss+xml; charset=utf-8' );
     596                        echo $content->get_articles_rss( $limit );
    664597                    }
    665598                } else if ( $type == 'settings' ) {
    666599                    header( 'Content-Type: application/json; charset=utf-8' );
    667                     header( 'Content-Transfer-Encoding: binary' );
    668600                    $settings = new SarbacaneSettings();
    669                     $settings->get_settings();
     601                    echo $settings->get_settings();
    670602                } else if ( $type == 'medias' ) {
    671603                    header( 'Content-Type: application/json; charset=utf-8' );
    672604                    $medias = new SarbacaneMedias();
    673                     $medias->get_medias();
     605                    echo $medias->get_medias();
    674606                }
    675607            } else {
    676608                $this->update_data_1_4_5();
    677                 // List retrieving
    678609                header( 'Content-Type: text/plain; charset=utf-8' );
    679                 header( 'Content-Transfer-Encoding: binary' );
    680610                if ( $action == 'delete' ) {
    681611                    $this->sarbacane_delete_sdid( $sd_id );
     
    683613                    if ( $sd_list_id != '' && $sd_list_id != 'N' && $sd_list_id != 'U' ) {
    684614                        header( 'HTTP/1.1 404 Not found' );
    685                         header( 'Content-type: application/json; charset=utf-8' );
    686                         die( 'FAILED_ID' );
     615                        exit( 'FAILED_ID' );
    687616                    }
    688                     $this->sarbacane_get_list( $sd_id, $sd_list_id );
     617                    echo $this->sarbacane_get_list( $sd_id, $sd_list_id );
    689618                }
    690619            }
  • sarbacane-desktop/tags/1.4.11/readme.txt

    r1886659 r1898992  
    55Tested up to: 4.9
    66License: GPLv2 or later
    7 Stable tag: 1.4.10
     7Stable tag: 1.4.11
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
    99
     
    7979== Changelog ==
    8080
    81 = 1.4.10 =
     81= 1.4.10 & 1.4.11 =
    8282Modification du widget.
    8383
     
    132132= English =
    133133
    134 = 1.4.10 =
     134= 1.4.10 & 1.4.11 =
    135135Widget modifications.
    136136
  • sarbacane-desktop/tags/1.4.11/sarbacane.php

    r1886659 r1898992  
    55Description: This plugin allows you to synchronize your WordPress data in Sarbacane
    66Author: Sarbacane Software
    7 Version: 1.4.10
     7Version: 1.4.11
    88Author URI: http://sarbacane.com/?utm_source=module-wordpress&utm_medium=plugin&utm_content=lien-sarbacane&utm_campaign=wordpress
    99Text Domain: sarbacane-desktop
  • sarbacane-desktop/trunk/class.sarbacane-content.php

    r1681123 r1898992  
    6262        $query = new WP_Query ( 'post_type=post&p=' . $post_id );
    6363        if ( $query->have_posts() ) {
    64             echo $this->get_rss_header() . $this->get_rss_content( 'post', $post_id ) . $this->get_rss_footer();
     64            return $this->get_rss_header() . $this->get_rss_content( 'post', $post_id ) . $this->get_rss_footer();
    6565        } else {
    66             header( 'HTTP/1.1 404 Bad item' );
    67             header( 'Content-Type: application/json; charset=utf-8' );
    68             die( 'FAILED_ID' );
     66            return false;
    6967        }
    7068    }
    7169
    7270    public function get_articles_rss( $limit ) {
    73         echo $this->get_rss_header() . $this->get_rss_content( 'posts', $limit ) . $this->get_rss_footer();
     71        return $this->get_rss_header() . $this->get_rss_content( 'posts', $limit ) . $this->get_rss_footer();
    7472    }
    7573
  • sarbacane-desktop/trunk/class.sarbacane-medias.php

    r1681123 r1898992  
    2020        }
    2121        $medias = implode( ',', $medias );
    22         echo '{"medias":[' . $medias . "\n\t" . ']' . "\n" . '}';
     22        return '{"medias":[' . $medias . "\n\t" . ']' . "\n" . '}';
    2323    }
    2424
  • sarbacane-desktop/trunk/class.sarbacane-newsletterwidget.php

    r1817959 r1898992  
    6464            }
    6565        }
    66         $this->display_registration_message($valid);
     66        return $this->display_registration_message($valid);
    6767    }
    6868
     
    7373            $message = json_encode( array( 'message' => __( 'Email isn\'t valid.', 'sarbacane-desktop' ) ) );
    7474        }
    75         echo '
     75        return '
    7676        <script type="text/javascript">
    7777            var registration_message = ' . $message . ';
  • sarbacane-desktop/trunk/class.sarbacane-settings.php

    r1681123 r1898992  
    1212        $rss_url = get_feed_link( 'rss2' );
    1313        $posts_per_rss = get_option( 'posts_per_rss', 10 );
    14         //forcing boolean to display as int to get 0 when false. Impossible otherwise
    15         echo '{
     14        return '{
    1615    "settings":{
    1716        "general_settings":{
  • sarbacane-desktop/trunk/class.sarbacane.php

    r1817959 r1898992  
    33class Sarbacane {
    44
    5     /**
    6      * Method called on plugin activation.
    7      */
    85    public static function activation() {
    96        update_option( 'sarbacane_version', '1.4.9', false );
     
    3734    }
    3835
    39     /**
    40      * Method called on plugin deactivation.
    41      */
    4236    public static function deactivation() {
    4337        delete_option( 'sarbacane_version' );
     
    145139    }
    146140
    147     /**
    148      * Called on menu generation (admin_menu hook).
    149      */
    150141    public function add_admin_menu() {
    151142        add_submenu_page( 'sarbacane', __( 'Connection', 'sarbacane-desktop' ), __( 'Connection', 'sarbacane-desktop' ), 'administrator', 'wp_interconnection', array(
     
    155146    }
    156147
    157     /**
    158      * Loads this plugin locale
    159      */
    160148    public function sarbacane_load_locales() {
    161149        load_plugin_textdomain( 'sarbacane-desktop', false, dirname( plugin_basename( __FILE__ ) ) . '/locales' );
    162150    }
    163151
    164     /**
    165      * Display message when key generated
    166      */
    167152    private function sarbacane_params_saved() {
    168         echo '<div class="updated">' . __( 'A new key has been generated', 'sarbacane-desktop' ) . '</div>';
    169     }
    170 
    171     /**
    172      * Get new subscribers
    173      *
    174      * @param string $sd_id
    175      * @param string $sd_list_id
    176      *            If empty, get lists vide else get email for the list
    177      *
    178      * @throws WP_Error
    179      */
     153        return '<div class="updated">' . __( 'A new key has been generated', 'sarbacane-desktop' ) . '</div>';
     154    }
     155
    180156    private function sarbacane_get_list( $sd_id, $sd_list_id ) {
    181157
     
    191167        if ( $sd_list_id != '' ) {
    192168            if ( $sd_list_id == 'U' ) {
    193                 $this->get_users_list( $sd_id );
     169                return $this->get_users_list( $sd_id );
    194170            } else if ( $sd_list_id == 'N' ) {
    195                 $this->get_newsletter_list( $sd_id );
     171                return $this->get_newsletter_list( $sd_id );
    196172            }
    197173        } else {
    198             $this->generate_available_lists( $sd_id, $sd_list_users, $sd_list_news );
     174            return $this->generate_available_lists( $sd_id, $sd_list_users, $sd_list_news );
    199175        }
    200176    }
    201177
    202178    private function generate_available_lists( $sd_id, $user_sync, $newsletter_sync ) {
    203         echo 'list_id;name;reset;is_updated;type;version' . "\n";
     179        $content = 'list_id;name;reset;is_updated;type;version' . "\n";
    204180        $last_call_date_N = get_option( 'sarbacane_news_call_' . $sd_id );
    205181        $last_call_date_C = get_option( 'sarbacane_user_call_' . $sd_id );
     
    229205        $name = $this->d_quote( str_replace( '&#039;', '\'', $name ) );
    230206        if ( $user_sync ) {
    231             echo 'U;' . $name . ';' . $sd_list_users_reset . ';' . $user_updated . ';Wordpress;' . get_bloginfo( 'version' ) . "\n";
     207            $content .= 'U;' . $name . ';' . $sd_list_users_reset . ';' . $user_updated . ';Wordpress;' . get_bloginfo( 'version' ) . "\n";
    232208        }
    233209        if ( $newsletter_sync ) {
    234             echo 'N;' . $name . ';' . $sd_list_news_reset . ';' . $newsletter_updated . ';Wordpress;' . get_bloginfo( 'version' ) . "\n";
    235         }
    236     }
    237 
    238     /**
    239      * Check new users since last call
    240      *
    241      * @param string $last_call_date
    242      *
    243      * @return boolean
    244      */
     210            $content .= 'N;' . $name . ';' . $sd_list_news_reset . ';' . $newsletter_updated . ';Wordpress;' . get_bloginfo( 'version' ) . "\n";
     211        }
     212        return $content;
     213    }
     214
    245215    private function check_users_list( $last_call_date ) {
    246216        global $wpdb;
     
    252222    }
    253223
    254     /**
    255      * Check new newsletter subcribers since last call
    256      *
    257      * @param string $last_call_date
    258      *
    259      * @return boolean
    260      */
    261224    private function check_newsletter_list( $last_call_date = '' ) {
    262225        global $wpdb;
     
    274237    }
    275238
    276     /**
    277      * Generate newsletter subscribers CSV
    278      *
    279      * @param string $sd_id
    280      */
    281239    private function get_newsletter_list( $sd_id ) {
    282240        if ( ! get_option( 'sarbacane_news_list' ) ) {
    283             echo $this->generate_csv( array(), array(), 'N' );
    284             return;
     241            return $this->generate_csv( array(), array(), 'N' );
    285242        }
    286243        $last_call_date = get_option( 'sarbacane_news_call_' . $sd_id, '' );
     
    288245        $new_or_updated_users = $this->get_subscribers( $last_call_date );
    289246        $this->clear_update_history();
    290         echo $this->generate_csv( $new_or_updated_users, array(), 'N' );
    291     }
    292 
    293     /**
    294      * Generate users CSV
    295      *
    296      * @param string $sd_id
    297      */
     247        return $this->generate_csv( $new_or_updated_users, array(), 'N' );
     248    }
     249
    298250    private function get_users_list( $sd_id ) {
    299251        if ( ! get_option( 'sarbacane_users_list' ) ) {
    300             echo $this->generate_csv( array(), array(), 'U' );
    301             return;
     252            return $this->generate_csv( array(), array(), 'U' );
    302253        }
    303254        $last_call_date = get_option( 'sarbacane_user_call_' . $sd_id, '' );
     
    307258        $deleted_users = $this->sarbacanedesktop_get_all_deleted_users( $last_call_date );
    308259        $this->clear_update_history();
    309         echo $this->generate_csv( $all_users, $deleted_users, 'U' );
    310     }
    311 
    312     /**
    313      * Generate CSV
    314      *
    315      * @param array $new_or_updated_users
    316      * @param array $deleted_users
    317      * @param string $list_type
    318      *
    319      * @return CSV
    320      */
     260        return $this->generate_csv( $all_users, $deleted_users, 'U' );
     261    }
     262
    321263    private function generate_csv( $new_or_updated_users, $deleted_users = array(), $list_type ) {
    322264        if ( "N" == $list_type ) {
     
    383325    }
    384326
    385     /**
    386      * Get users
    387      *
    388      * @return array
    389      */
    390327    private function sarbacanedesktop_get_all_users( $last_call_date ) {
    391328        global $wpdb;
     
    415352    }
    416353
    417     /**
    418      * Get newsletter subscribers
    419      *
    420      * @return array
    421      */
    422354    private function get_subscribers( $last_call_date ) {
    423355        global $wpdb;
     
    463395    }
    464396
    465     /**
    466      * Called on user update.
    467      */
    468397    public function trigger_user_update( $user_id ) {
    469398        if ( get_option( 'sarbacane_users_list' ) ) {
     
    483412    }
    484413
    485     /**
    486      * Called on user delete.
    487      */
    488414    public function trigger_user_delete( $user_id ) {
    489415        if ( get_option( 'sarbacane_users_list' ) ) {
     
    549475            global $wpdb;
    550476            $wpdb->query( "TRUNCATE TABLE `{$wpdb->prefix}sd_updates`" );
    551             $this->sarbacane_params_saved();
     477            echo $this->sarbacane_params_saved();
    552478        }
    553479        $sd_token = get_option( 'sarbacane_sd_token', false );
     
    629555            $this->update_data_1_4_5();
    630556            $widget = new SarbacaneNewsWidget();
    631             $widget->sarbacane_save_widget();
     557            echo $widget->sarbacane_save_widget();
    632558            exit;
    633559        }
    634560        if ( ! isset ( $sd_id ) ) {
    635             header( 'HTTP/1.1 400 Bad request' );
    636             header( 'Content-type: application/json; charset=utf-8' );
    637             die( 'FAILED_SDID' );
     561            header( 'HTTP/1.1 404 Not Found' );
     562            header( 'Content-type: text/plain; charset=utf-8' );
     563            exit( 'FAILED_ID' );
    638564        }
    639565        if ( ! isset ( $sd_token ) ) {
    640             header( 'HTTP/1.1 400 Bad request' );
    641             header( 'Content-type: application/json; charset=utf-8' );
    642             die( 'FAILED_SDTOKEN' );
     566            header( 'HTTP/1.1 403 Forbidden' );
     567            header( 'Content-type: text/plain; charset=utf-8' );
     568            exit( 'FAILED' );
    643569        }
    644570        $failed = (int) get_option( 'sarbacane_failed', 0 );
     
    649575                update_option( 'sarbacane_failed', $failed + 1, false );
    650576            }
    651             header( 'HTTP/1.1 403 Unauthorized' );
    652             header( 'Content-type: application/json; charset=utf-8' );
    653             die( 'FAILED_SDTOKEN' );
    654         } else {
    655             // Content retrieving
     577            header( 'HTTP/1.1 403 Forbidden' );
     578            header( 'Content-type: text/plain; charset=utf-8' );
     579            exit( 'FAILED' );
     580        } else if ( $sd_token == $sd_token_saved && strlen( $sd_token_saved ) > 20 && ! $is_failed ) {
    656581            if ( isset ( $type ) ) {
    657582                if ( $type == 'posts' ) {
    658                     header( 'Content-Type: application/rss+xml; charset=utf-8' );
    659583                    $content = new SarbacaneContent();
    660584                    if ( isset ( $id ) ) {
    661                         $content->get_article_rss( $id );
     585                        $text = $content->get_article_rss( $id );
     586                        if ($text === false) {
     587                            header( 'HTTP/1.1 404 Not Found' );
     588                            header( 'Content-Type: text/plain; charset=utf-8' );
     589                            exit( 'FAILED_ID' );
     590                        } else {
     591                            header( 'Content-Type: application/rss+xml; charset=utf-8' );
     592                            echo $text;
     593                        }
    662594                    } else {
    663                         $content->get_articles_rss( $limit );
     595                        header( 'Content-Type: application/rss+xml; charset=utf-8' );
     596                        echo $content->get_articles_rss( $limit );
    664597                    }
    665598                } else if ( $type == 'settings' ) {
    666599                    header( 'Content-Type: application/json; charset=utf-8' );
    667                     header( 'Content-Transfer-Encoding: binary' );
    668600                    $settings = new SarbacaneSettings();
    669                     $settings->get_settings();
     601                    echo $settings->get_settings();
    670602                } else if ( $type == 'medias' ) {
    671603                    header( 'Content-Type: application/json; charset=utf-8' );
    672604                    $medias = new SarbacaneMedias();
    673                     $medias->get_medias();
     605                    echo $medias->get_medias();
    674606                }
    675607            } else {
    676608                $this->update_data_1_4_5();
    677                 // List retrieving
    678609                header( 'Content-Type: text/plain; charset=utf-8' );
    679                 header( 'Content-Transfer-Encoding: binary' );
    680610                if ( $action == 'delete' ) {
    681611                    $this->sarbacane_delete_sdid( $sd_id );
     
    683613                    if ( $sd_list_id != '' && $sd_list_id != 'N' && $sd_list_id != 'U' ) {
    684614                        header( 'HTTP/1.1 404 Not found' );
    685                         header( 'Content-type: application/json; charset=utf-8' );
    686                         die( 'FAILED_ID' );
     615                        exit( 'FAILED_ID' );
    687616                    }
    688                     $this->sarbacane_get_list( $sd_id, $sd_list_id );
     617                    echo $this->sarbacane_get_list( $sd_id, $sd_list_id );
    689618                }
    690619            }
  • sarbacane-desktop/trunk/readme.txt

    r1886659 r1898992  
    55Tested up to: 4.9
    66License: GPLv2 or later
    7 Stable tag: 1.4.10
     7Stable tag: 1.4.11
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
    99
     
    7979== Changelog ==
    8080
    81 = 1.4.10 =
     81= 1.4.10 & 1.4.11 =
    8282Modification du widget.
    8383
     
    132132= English =
    133133
    134 = 1.4.10 =
     134= 1.4.10 & 1.4.11 =
    135135Widget modifications.
    136136
  • sarbacane-desktop/trunk/sarbacane.php

    r1886659 r1898992  
    55Description: This plugin allows you to synchronize your WordPress data in Sarbacane
    66Author: Sarbacane Software
    7 Version: 1.4.10
     7Version: 1.4.11
    88Author URI: http://sarbacane.com/?utm_source=module-wordpress&utm_medium=plugin&utm_content=lien-sarbacane&utm_campaign=wordpress
    99Text Domain: sarbacane-desktop
Note: See TracChangeset for help on using the changeset viewer.