Plugin Directory

Changeset 1461999


Ignore:
Timestamp:
07/28/2016 08:07:58 AM (10 years ago)
Author:
O-Zone
Message:

Moving to version 0.5

Location:
wp-allaround/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • wp-allaround/trunk/README.txt

    r1456305 r1461999  
    55Requires at least: 4.0.0
    66Tested up to: 4.5.3
    7 Stable tag: 0.4
     7Stable tag: 0.5
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    1414
    1515WP-AllAround is the connector plugin for AllAroundSiena Telegram Bot service, that let you to spread via Telegram channels new posts of your blog.
    16 To connect your blog to the Telegram Channel, you simply need an API key to get freely on http://www.allaroundsiena.com/.
     16To connect your blog to the Telegram Channel, you simply need an API key to get freely on http://www.allaroundsiena.com
    1717
    1818== Installation ==
     
    20201. Upload the plugin files to the `/wp-content/plugins/` directory, or install the plugin through the WordPress plugins screen directly.
    21212. Activate the plugin through the 'Plugins' screen in WordPress
    22 3. Use the Settings->AllAround Options screen to configure the plugins and add the AllAround API key (get for free on www.allaroundsiena.com/bot)
     223. Use the Settings->AllAround Options screen to configure the plugins and add the AllAround API key (get for free on www.allaroundsiena.com)
    23234. Click on "Connect this blog" button to validate the API key and connect your blog to the AllAroundSiena Telegram Bot service
    24 5. You're done ! Now you need to create you Telegram Channel and configure it as explained on http://www.allaroundsiena.com/ pages
     245. You're done ! Now you need to create you Telegram Channel and configure it as explained on http://www.allaroundsiena.com pages
    2525
    2626== Frequently Asked Questions ==
     
    3232= How does it costs ? =
    3333
    34 The "blog plan" it's for free: 1 blog and 1 post every 12 hours free...for ever !
     34The "blog plan" it's free, forever, and include 1 blog and 1 post every 12 hours.
    3535
    3636== Changelog ==
     37
     38= 0.5 =
     39* Minor bug fixes
    3740
    3841= 0.4 =
  • wp-allaround/trunk/wp-allaround-admin.php

    r1453957 r1461999  
    8686                        <label class="description" for="allaround_api_key"><?php _e('Type here your AllAround BOT Api Key', 'wp-allaround' ); ?></label>
    8787                    </td>
     88                    </tr><tr><th scope="row"><?php _e('Default is to publish new articles', 'wp-allaround' ); ?></th>
     89                    <td>
     90                        <input type="checkbox" name="allaround_default_publish" id="allaround_default_publish" checked>
     91                    </td>
     92                    </tr>
    8893                    </tr><tr>
    8994                    <td>
     
    96101        </div> <!-- end post-body -->
    97102    </div> <!-- end poststuff -->
     103<?php
     104    $option_api_key = get_option( 'allaround_api_key' );
     105    if(isset($option_api_key)) {
     106?>
     107
    98108    <div>
    99         <p><?php echo _e('After setting BOT Api Key (get one for free at <a href=\'http://www.allaroundsiena.com\'>www.allaroundsiena.com</a>) click on the following button to start broadcasting:'); ?></p>
     109        <p><?php _e("Click on the following button to connect this blog and start broadcasting:"); ?></p>
    100110        <button class="btn btn-large" id="allaround_connect"><?php _e('Connect this blog', 'wp-allaround'); ?></button>
    101111        <span id="allaround_connect_result">&nbsp;</span>
     
    103113     </div>
    104114<?php
     115    }
     116?>
     117    <p>
     118    <?php _e("Before you start, please visit <a href='http://www.allaroundsiena.com'>allaroundsiena.com</a> to get an API key for your blog"); ?>
     119    </p>
     120<?php
    105121}
    106122?>
  • wp-allaround/trunk/wp-allaround.php

    r1456305 r1461999  
    44Plugin URI:     http://www.allaroundsiena.com/plugin
    55Description:    This plugin let you to connect a Telegram Bot with your blog
    6 Version:    0.4
     6Version:    0.5
    77Author:     Michele Pinassi
    88Author URI: http://www.zerozone.it
     
    6363    if($check_is_publish) {
    6464    $publish_date = get_post_meta($post->ID, 'allaround_post_publish_date', true);
    65     echo _("Post published");
     65
     66    $t_date = date_i18n( get_option( 'date_format' ),strtotime($publish_date));
     67
     68    $string = sprintf( __('Post published on %s', 'wp-allaround'), $t_date);
     69
     70    echo $string;
    6671    } else {
    67     echo _("This post was not published on AllAround");
    68     }
    69 
    70     if(!isset($check_is_publish)) {
    71     $check_is_publish = true; /* Default action is PUBLISH */
    72     }
     72    echo __("This post was not published on AllAround",'wp-allaround');
    7373?>
    74     <p>
    75     <input type="checkbox" name="allaround_post_publish" id="allaround_post_publish" <?php checked($check_is_publish); ?> />
    76     <label class="description" for="allaround_post_publish"><?php _e('Publish this post on AllAround', 'wp-allaround' ); ?></label>
    77     </p>
    78 <?php
     74    <p>
     75        <input type="checkbox" name="allaround_post_publish" id="allaround_post_publish" checked />
     76        <label class="description" for="allaround_post_publish"><?php _e('Publish this post on AllAround', 'wp-allaround' ); ?></label>
     77    </p>
     78<?php
     79    }
    7980}
    8081
     
    101102}
    102103
     104function allaround_do_publish($post) {
     105    $option_api_key = get_option( 'allaround_api_key' );
     106
     107//  if(($option_api_key) && ('publish' === $new_status && 'publish' !== $old_status)) {
     108
     109    if($option_api_key) {
     110        /* Get the post properties */
     111
     112        $author = $post->post_author;
     113
     114    $post_title = $post->post_title;
     115    $post_excerpt = allaround_excerpt($post->post_content);
     116    $post_author = get_the_author_meta('display_name', $author);
     117    $post_date = $post->post_date_gmt;
     118    $post_url = get_permalink($post->ID);
     119    /* Post have an image ? */
     120    if(has_post_thumbnail($post->ID)) {
     121        $post_image_url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'medium')[0];
     122    } else {
     123        $post_image_url = '';
     124    }
     125
     126    /* Get post TAGS */
     127    $tags_array = array();
     128    $tags = wp_get_post_tags($post->ID);
     129       
     130    foreach($tags as $tag) {
     131        $tags_array[] = $tag->name;
     132    }
     133
     134    $post_tags = implode(",",$tags_array);
     135
     136    /* Build REST query */
     137
     138    $data = array('key' => $option_api_key,
     139        'title' => $post_title,
     140        'excerpt' => $post_excerpt,
     141        'author' => $post_author,
     142        'date' => $post_date,
     143        'image_url' => $post_image_url,
     144        'tags' => $post_tags,
     145        'url' => $post_url,
     146    );
     147
     148    $headers = array('Accept' => 'application/json');
     149
     150    $body = Unirest\Request\Body::multipart($data);
     151
     152    error_log(print_r($body, true));
     153
     154    $result = Unirest\Request::post('https://www.allaroundsiena.com/rest/publish', $headers, $body);
     155    error_log(print_r($result, true));
     156
     157    return $result->code;
     158    }
     159}
     160
    103161add_action('transition_post_status', 'allaround_post_publish', 10, 3);
    104162
     
    107165    /* Check if this post was already published to avoid duplicates */
    108166    $check_is_publish = get_post_meta($post->ID,'allaround_post_publish', true);
    109    
     167
    110168    if($check_is_publish) {
    111     $is_publish = false;
     169    $do_publish = false;
    112170    } else {
    113         $is_publish = $_POST['allaround_post_publish'];
     171    $do_publish = false;
     172   
     173    if(isset($_POST['allaround_post_publish'])) {
     174            $do_publish = true;
     175    }
    114176    }
    115177   
    116     if($is_publish) {
    117     $option_api_key = get_option( 'allaround_api_key' );
    118 
    119     if(($option_api_key) && ('publish' === $new_status && 'publish' !== $old_status)) {
    120    
    121         /* Get the post properties */
    122 
    123         $author = $post->post_author;
    124 
    125         $post_title = $post->post_title;
    126         $post_excerpt = allaround_excerpt($post->post_content);
    127         $post_author = get_the_author_meta('display_name', $author);
    128         $post_date = $post->post_date_gmt;
    129         $post_url = get_permalink($post->ID);
    130 
    131         /* Post have an image ? */
    132         if(has_post_thumbnail($post->ID)) {
    133         $post_image_url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'medium')[0];
    134         } else {
    135         $post_image_url = '';
    136         }
    137 
    138         /* Get post TAGS */
    139         $tags_array = array();
    140         $tags = wp_get_post_tags($post->ID);
    141        
    142         foreach($tags as $tag) {
    143         $tags_array[] = $tag->name;
    144         }
    145 
    146         $post_tags = implode(",",$tags_array);
    147 
    148         /* Build REST query */
    149 
    150         $data = array('key' => $option_api_key,
    151         'title' => $post_title,
    152         'excerpt' => $post_excerpt,
    153         'author' => $post_author,
    154         'date' => $post_date,
    155         'image_url' => $post_image_url,
    156         'tags' => $post_tags,
    157         'url' => $post_url,
    158         );
    159 
    160         $headers = array('Accept' => 'application/json');
    161 
    162         $body = Unirest\Request\Body::multipart($data);
    163 
    164         error_log(print_r($body, true));
    165 
    166         $result = Unirest\Request::post('https://www.allaroundsiena.com/rest/publish', $headers, $body);
    167 
    168         error_log(print_r($result, true));
    169 
    170         /* Got the result */
    171 
    172         if($result->code == "200") { /* Success */
    173 
    174         $post_publish_date = current_time('mysql');
    175 
    176         update_post_meta($post->ID, "allaround_post_publish",true);
    177         update_post_meta($post->ID, "allaround_post_publish_date","$post_publish_date");
    178 
    179         add_action( 'admin_notices', 'allaround_notice_publish_success' );
    180         } else {
    181         update_post_meta($post->ID, "allaround_post_publish",false);
    182         add_action( 'admin_notices', 'allaround_notice_publish_error' );
    183         }
     178    /* Need to publish ? */
     179    if($do_publish) {
     180    /* Publish and get the result */
     181    $result = allaround_do_publish($post);
     182
     183    if($result == "200") { /* Success */
     184        $post_publish_date = current_time('mysql');
     185
     186        update_post_meta($post->ID, "allaround_post_publish",true);
     187        update_post_meta($post->ID, "allaround_post_publish_date","$post_publish_date");
     188
     189        add_action( 'admin_notices', 'allaround_notice_publish_success' );
     190    } else {
     191        update_post_meta($post->ID, "allaround_post_publish",false);
     192        add_action( 'admin_notices', 'allaround_notice_publish_error' );
    184193    }
    185194    } else {
Note: See TracChangeset for help on using the changeset viewer.