Changeset 1466742
- Timestamp:
- 08/03/2016 09:28:13 AM (10 years ago)
- Location:
- wp-allaround
- Files:
-
- 3 added
- 3 deleted
- 5 edited
- 12 copied
-
assets/banner-772x250.png (added)
-
assets/icon-128x128.png (added)
-
assets/icon-256x256.png (added)
-
tags/0.7.0 (copied) (copied from wp-allaround/trunk)
-
tags/0.7.0/LICENSE.txt (copied) (copied from wp-allaround/trunk/LICENSE.txt)
-
tags/0.7.0/README.txt (copied) (copied from wp-allaround/trunk/README.txt) (2 diffs)
-
tags/0.7.0/Unirest (copied) (copied from wp-allaround/trunk/Unirest)
-
tags/0.7.0/Unirest.php (copied) (copied from wp-allaround/trunk/Unirest.php)
-
tags/0.7.0/css (copied) (copied from wp-allaround/trunk/css)
-
tags/0.7.0/css/wp-allaround.css (modified) (1 diff)
-
tags/0.7.0/js (copied) (copied from wp-allaround/trunk/js)
-
tags/0.7.0/languages (copied) (copied from wp-allaround/trunk/languages)
-
tags/0.7.0/languages/default.mo (deleted)
-
tags/0.7.0/languages/default.po (deleted)
-
tags/0.7.0/languages/default.pot (deleted)
-
tags/0.7.0/languages/wp-allaround-it_IT.mo (copied) (copied from wp-allaround/trunk/languages/wp-allaround-it_IT.mo)
-
tags/0.7.0/languages/wp-allaround-it_IT.po (copied) (copied from wp-allaround/trunk/languages/wp-allaround-it_IT.po)
-
tags/0.7.0/wp-allaround-admin.php (copied) (copied from wp-allaround/trunk/wp-allaround-admin.php) (1 diff)
-
tags/0.7.0/wp-allaround.php (copied) (copied from wp-allaround/trunk/wp-allaround.php) (6 diffs)
-
trunk/README.txt (modified) (2 diffs)
-
trunk/css/wp-allaround.css (modified) (1 diff)
-
trunk/wp-allaround-admin.php (modified) (1 diff)
-
trunk/wp-allaround.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-allaround/tags/0.7.0/README.txt
r1462090 r1466742 5 5 Requires at least: 4.0.0 6 6 Tested up to: 4.6.0 7 Stable tag: 0. 67 Stable tag: 0.7.0 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 36 36 == Changelog == 37 37 38 = 0.7.0 = 39 * A lot of bug fixes: now plugin works as expected 40 * Added error messages display when post publish fail 41 * Minor code cleanups 42 38 43 = 0.6 = 39 44 * Plugin internationalization now works -
wp-allaround/tags/0.7.0/css/wp-allaround.css
r1462090 r1466742 1 1 2 .allaround-score-icon.na { 2 background-color: #888;3 background-color:#888888; 3 4 } 4 5 5 .allaround-score-icon. error {6 background-color: #dc3232;6 .allaround-score-icon.iserror { 7 background-color:#dc3232; 7 8 } 8 9 9 10 .allaround-score-icon.published { 10 background-color:#7ad03a 11 background-color:#7ad03a; 11 12 } 12 13 -
wp-allaround/tags/0.7.0/wp-allaround-admin.php
r1462090 r1466742 100 100 </tr><tr> 101 101 <td> 102 <input type="submit" value="<?php _e('Submit'); ?> >102 <input type="submit" value="<?php _e('Submit'); ?>"> 103 103 </td> 104 104 </tr> -
wp-allaround/tags/0.7.0/wp-allaround.php
r1464978 r1466742 4 4 Plugin URI: http://www.allaroundsiena.com/plugin 5 5 Description: This plugin let you to connect a Telegram Bot with your blog 6 Version: 0. 66 Version: 0.7.0 7 7 Author: Michele Pinassi 8 8 Author URI: http://www.zerozone.it … … 63 63 function allaround_metabox_callback( $post, $metabox ) { 64 64 65 $check_is_publish = get_post_meta($post->ID,'allaround_post_publish', true); 66 67 if($check_is_publish) { 68 $publish_date = get_post_meta($post->ID, 'allaround_post_publish_date', true); 69 70 $t_date = date_i18n( get_option( 'date_format' ),strtotime($publish_date)); 71 72 $string = sprintf( __('Post published on %s', 'wp-allaround'), $t_date); 73 74 echo $string; 65 $post_status = get_post_meta($post->ID,'allaround_post_status', true); 66 $post_date = get_post_meta($post->ID, 'allaround_post_date', true); 67 $post_message = get_post_meta($post->ID,'allaround_post_message', true); 68 69 $t_date = date_i18n( get_option( 'date_format' ),strtotime($post_date)); 70 71 if($post_status == 'published') { 72 printf( __('Post published on %s', 'wp-allaround'), $t_date); 75 73 } else { 76 echo __("This post was not published on AllAround",'wp-allaround'); 77 ?> 78 <p> 79 <input type="checkbox" name="allaround_post_do_publish" id="allaround_post_do_publish" value="1" checked/> 80 <label class="description" for="allaround_post_do_publish"><?php _e('Publish this post on AllAround', 'wp-allaround' ); ?></label> 81 </p> 82 <?php 74 if($post_status == 'error') { /* Error */ 75 printf( __('Error %s while publishing on %s', 'wp-allaround'), $post_message, $t_date); 76 ?> 77 <p> 78 <input type="checkbox" name="allaround_post_do_publish" id="allaround_post_do_publish" value="1"/> 79 <label class="description" for="allaround_post_do_publish"><?php _e('Try again', 'wp-allaround' ); ?></label> 80 </p> 81 <?php 82 83 } else { 84 echo __("This post was not published on AllAround",'wp-allaround'); 85 ?> 86 <p> 87 <input type="checkbox" name="allaround_post_do_publish" id="allaround_post_do_publish" value="1" checked/> 88 <label class="description" for="allaround_post_do_publish"><?php _e('Publish this post on AllAround', 'wp-allaround' ); ?></label> 89 </p> 90 <?php 91 } 83 92 } 84 93 } … … 93 102 function allaround_display_column( $column, $post_id ) { 94 103 if ($column == 'allaround'){ 95 /* Check if this post was already published to avoid duplicates */ 96 $is_publish = get_post_meta($post_id,'allaround_post_publish', true); 97 ?> 98 <div aria-hidden="true" title="" class="allaround-score-icon <?php echo ($is_publish ? "published" : "na"); ?>"></div><span class="screen-reader-text"><?php echo ($is_publish ? __("Published") : __("Not published")); ?></span></td> 104 $post_status = get_post_meta($post_id,'allaround_post_status', true); 105 106 switch($post_status) { 107 case "error": 108 $icon_status = "iserror"; 109 break; 110 case "published": 111 $icon_status = "published"; 112 break; 113 default: 114 $icon_status = "na"; 115 break; 116 } 117 ?> 118 <div aria-hidden="true" title="AllAround Post Status" class="allaround-score-icon <?php echo $icon_status; ?>"></div><span class="screen-reader-text"><?php echo $publish_status; ?></span></td> 99 119 <?php 100 120 } … … 183 203 error_log(print_r($result, true)); 184 204 185 return $result->code; 186 } 187 } 188 189 add_action('publish_post','allaround_action_publish',10,2); 190 191 function allaround_action_publish($ID, $post) { 192 /* Check if this post was already published to avoid duplicates */ 193 $check_is_publish = get_post_meta($post->ID,'allaround_post_publish', true); 194 195 if($check_is_publish) { 196 $do_publish = false; 197 } else { 198 $do_publish = false; 199 200 if(isset($_POST['allaround_post_do_publish'])) { 201 $do_publish = true; 202 } 203 } 204 205 /* [code] => 403 206 [raw_body] => { 207 "error": { 208 "code": 403, 209 "message": "Error: this POST seems to be a duplicate" 210 } 211 */ 212 213 return $result; 214 } 215 } 216 217 /* ============================================================ */ 218 /* */ 219 /* PUBLISH HOOK */ 220 /* */ 221 /* =============================================================*/ 222 223 function allaround_action_publish($new_status, $old_status, $post) { 224 $do_publish = false; 225 226 error_log("FIRED: allaround_action_publish($new_status,$old_status,$post->ID)"); 227 228 if ($new_status == 'publish') { 229 230 /* Check if this post was already published to avoid duplicates */ 231 $post_status = get_post_meta($post->ID,'allaround_post_status', true); 232 233 if($post_status == 'published') { 234 /* If already published, do nothing... */ 235 } else { 236 if(isset($_POST['allaround_post_do_publish'])) { 237 $do_publish = true; 238 } 239 } 240 } 241 205 242 /* Need to publish ? */ 206 243 if($do_publish) { … … 208 245 $result = allaround_do_publish($post); 209 246 210 if($result == "200") { /* Success */ 211 $post_publish_date = current_time('mysql'); 212 213 update_post_meta($post->ID, "allaround_post_publish",true); 214 update_post_meta($post->ID, "allaround_post_publish_date","$post_publish_date"); 215 247 $post_date = current_time('mysql'); 248 249 $post_result = json_decode($result->raw_body,true); 250 251 error_log(print_r($post_result, true)); 252 253 if(isset($post_result['error'])) { 254 $post_result_code = $result->code; 255 $post_result_message = $post_result['error']['message']; 256 $post_is_published = false; 257 } else { 258 $post_result_code = $result->code; 259 $post_result_message = $post_result['success']; 260 $post_is_published = true; 261 } 262 263 update_post_meta($post->ID, "allaround_post_date","$post_date"); 264 update_post_meta($post->ID, "allaround_post_message", $post_result_message); 265 266 if($post_is_published) { /* Success */ 267 update_post_meta($post->ID, "allaround_post_status","published"); 216 268 add_action( 'admin_notices', 'allaround_notice_publish_success' ); 217 269 } else { 218 update_post_meta($post->ID, "allaround_post_ publish",false);270 update_post_meta($post->ID, "allaround_post_status","error"); 219 271 add_action( 'admin_notices', 'allaround_notice_publish_error' ); 220 272 } 221 } else { 222 update_post_meta($post->ID, "allaround_post_publish",false); 223 } 224 } 273 } 274 } 275 276 add_action('transition_post_status', 'allaround_action_publish', 10, 3); 277 278 /* ============================================================ */ 279 /* */ 280 /* NOTICES */ 281 /* */ 282 /* =============================================================*/ 283 225 284 226 285 function allaround_notice_publish_success() { 227 286 ?> 228 <div class= "updated notice">229 <p><?php _e('Post published successfully on your BOT!', 'wp-allaround' ); ?></p>287 <div class='notice notice-success'> 288 <p><?php _e('Post published successfully on AllAround !', 'wp-allaround' ); ?></p> 230 289 </div> 231 290 <?php … … 234 293 function allaround_notice_publish_error() { 235 294 ?> 236 <div class= "error notice">237 <p><?php _e('Ooops ! Something wrong happens while publish your post on AllAround BOT: try again in few minutes', 'wp-allaround' ); ?></p>295 <div class='notice notice-error'> 296 <p><?php _e('Ooops ! Something wrong happens while publish your post on AllAround: try again in few minutes', 'wp-allaround' ); ?></p> 238 297 </div> 239 298 <?php -
wp-allaround/trunk/README.txt
r1462090 r1466742 5 5 Requires at least: 4.0.0 6 6 Tested up to: 4.6.0 7 Stable tag: 0. 67 Stable tag: 0.7.0 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 36 36 == Changelog == 37 37 38 = 0.7.0 = 39 * A lot of bug fixes: now plugin works as expected 40 * Added error messages display when post publish fail 41 * Minor code cleanups 42 38 43 = 0.6 = 39 44 * Plugin internationalization now works -
wp-allaround/trunk/css/wp-allaround.css
r1462090 r1466742 1 1 2 .allaround-score-icon.na { 2 background-color: #888;3 background-color:#888888; 3 4 } 4 5 5 .allaround-score-icon. error {6 background-color: #dc3232;6 .allaround-score-icon.iserror { 7 background-color:#dc3232; 7 8 } 8 9 9 10 .allaround-score-icon.published { 10 background-color:#7ad03a 11 background-color:#7ad03a; 11 12 } 12 13 -
wp-allaround/trunk/wp-allaround-admin.php
r1462090 r1466742 100 100 </tr><tr> 101 101 <td> 102 <input type="submit" value="<?php _e('Submit'); ?> >102 <input type="submit" value="<?php _e('Submit'); ?>"> 103 103 </td> 104 104 </tr> -
wp-allaround/trunk/wp-allaround.php
r1464978 r1466742 4 4 Plugin URI: http://www.allaroundsiena.com/plugin 5 5 Description: This plugin let you to connect a Telegram Bot with your blog 6 Version: 0. 66 Version: 0.7.0 7 7 Author: Michele Pinassi 8 8 Author URI: http://www.zerozone.it … … 63 63 function allaround_metabox_callback( $post, $metabox ) { 64 64 65 $check_is_publish = get_post_meta($post->ID,'allaround_post_publish', true); 66 67 if($check_is_publish) { 68 $publish_date = get_post_meta($post->ID, 'allaround_post_publish_date', true); 69 70 $t_date = date_i18n( get_option( 'date_format' ),strtotime($publish_date)); 71 72 $string = sprintf( __('Post published on %s', 'wp-allaround'), $t_date); 73 74 echo $string; 65 $post_status = get_post_meta($post->ID,'allaround_post_status', true); 66 $post_date = get_post_meta($post->ID, 'allaround_post_date', true); 67 $post_message = get_post_meta($post->ID,'allaround_post_message', true); 68 69 $t_date = date_i18n( get_option( 'date_format' ),strtotime($post_date)); 70 71 if($post_status == 'published') { 72 printf( __('Post published on %s', 'wp-allaround'), $t_date); 75 73 } else { 76 echo __("This post was not published on AllAround",'wp-allaround'); 77 ?> 78 <p> 79 <input type="checkbox" name="allaround_post_do_publish" id="allaround_post_do_publish" value="1" checked/> 80 <label class="description" for="allaround_post_do_publish"><?php _e('Publish this post on AllAround', 'wp-allaround' ); ?></label> 81 </p> 82 <?php 74 if($post_status == 'error') { /* Error */ 75 printf( __('Error %s while publishing on %s', 'wp-allaround'), $post_message, $t_date); 76 ?> 77 <p> 78 <input type="checkbox" name="allaround_post_do_publish" id="allaround_post_do_publish" value="1"/> 79 <label class="description" for="allaround_post_do_publish"><?php _e('Try again', 'wp-allaround' ); ?></label> 80 </p> 81 <?php 82 83 } else { 84 echo __("This post was not published on AllAround",'wp-allaround'); 85 ?> 86 <p> 87 <input type="checkbox" name="allaround_post_do_publish" id="allaround_post_do_publish" value="1" checked/> 88 <label class="description" for="allaround_post_do_publish"><?php _e('Publish this post on AllAround', 'wp-allaround' ); ?></label> 89 </p> 90 <?php 91 } 83 92 } 84 93 } … … 93 102 function allaround_display_column( $column, $post_id ) { 94 103 if ($column == 'allaround'){ 95 /* Check if this post was already published to avoid duplicates */ 96 $is_publish = get_post_meta($post_id,'allaround_post_publish', true); 97 ?> 98 <div aria-hidden="true" title="" class="allaround-score-icon <?php echo ($is_publish ? "published" : "na"); ?>"></div><span class="screen-reader-text"><?php echo ($is_publish ? __("Published") : __("Not published")); ?></span></td> 104 $post_status = get_post_meta($post_id,'allaround_post_status', true); 105 106 switch($post_status) { 107 case "error": 108 $icon_status = "iserror"; 109 break; 110 case "published": 111 $icon_status = "published"; 112 break; 113 default: 114 $icon_status = "na"; 115 break; 116 } 117 ?> 118 <div aria-hidden="true" title="AllAround Post Status" class="allaround-score-icon <?php echo $icon_status; ?>"></div><span class="screen-reader-text"><?php echo $publish_status; ?></span></td> 99 119 <?php 100 120 } … … 183 203 error_log(print_r($result, true)); 184 204 185 return $result->code; 186 } 187 } 188 189 add_action('publish_post','allaround_action_publish',10,2); 190 191 function allaround_action_publish($ID, $post) { 192 /* Check if this post was already published to avoid duplicates */ 193 $check_is_publish = get_post_meta($post->ID,'allaround_post_publish', true); 194 195 if($check_is_publish) { 196 $do_publish = false; 197 } else { 198 $do_publish = false; 199 200 if(isset($_POST['allaround_post_do_publish'])) { 201 $do_publish = true; 202 } 203 } 204 205 /* [code] => 403 206 [raw_body] => { 207 "error": { 208 "code": 403, 209 "message": "Error: this POST seems to be a duplicate" 210 } 211 */ 212 213 return $result; 214 } 215 } 216 217 /* ============================================================ */ 218 /* */ 219 /* PUBLISH HOOK */ 220 /* */ 221 /* =============================================================*/ 222 223 function allaround_action_publish($new_status, $old_status, $post) { 224 $do_publish = false; 225 226 error_log("FIRED: allaround_action_publish($new_status,$old_status,$post->ID)"); 227 228 if ($new_status == 'publish') { 229 230 /* Check if this post was already published to avoid duplicates */ 231 $post_status = get_post_meta($post->ID,'allaround_post_status', true); 232 233 if($post_status == 'published') { 234 /* If already published, do nothing... */ 235 } else { 236 if(isset($_POST['allaround_post_do_publish'])) { 237 $do_publish = true; 238 } 239 } 240 } 241 205 242 /* Need to publish ? */ 206 243 if($do_publish) { … … 208 245 $result = allaround_do_publish($post); 209 246 210 if($result == "200") { /* Success */ 211 $post_publish_date = current_time('mysql'); 212 213 update_post_meta($post->ID, "allaround_post_publish",true); 214 update_post_meta($post->ID, "allaround_post_publish_date","$post_publish_date"); 215 247 $post_date = current_time('mysql'); 248 249 $post_result = json_decode($result->raw_body,true); 250 251 error_log(print_r($post_result, true)); 252 253 if(isset($post_result['error'])) { 254 $post_result_code = $result->code; 255 $post_result_message = $post_result['error']['message']; 256 $post_is_published = false; 257 } else { 258 $post_result_code = $result->code; 259 $post_result_message = $post_result['success']; 260 $post_is_published = true; 261 } 262 263 update_post_meta($post->ID, "allaround_post_date","$post_date"); 264 update_post_meta($post->ID, "allaround_post_message", $post_result_message); 265 266 if($post_is_published) { /* Success */ 267 update_post_meta($post->ID, "allaround_post_status","published"); 216 268 add_action( 'admin_notices', 'allaround_notice_publish_success' ); 217 269 } else { 218 update_post_meta($post->ID, "allaround_post_ publish",false);270 update_post_meta($post->ID, "allaround_post_status","error"); 219 271 add_action( 'admin_notices', 'allaround_notice_publish_error' ); 220 272 } 221 } else { 222 update_post_meta($post->ID, "allaround_post_publish",false); 223 } 224 } 273 } 274 } 275 276 add_action('transition_post_status', 'allaround_action_publish', 10, 3); 277 278 /* ============================================================ */ 279 /* */ 280 /* NOTICES */ 281 /* */ 282 /* =============================================================*/ 283 225 284 226 285 function allaround_notice_publish_success() { 227 286 ?> 228 <div class= "updated notice">229 <p><?php _e('Post published successfully on your BOT!', 'wp-allaround' ); ?></p>287 <div class='notice notice-success'> 288 <p><?php _e('Post published successfully on AllAround !', 'wp-allaround' ); ?></p> 230 289 </div> 231 290 <?php … … 234 293 function allaround_notice_publish_error() { 235 294 ?> 236 <div class= "error notice">237 <p><?php _e('Ooops ! Something wrong happens while publish your post on AllAround BOT: try again in few minutes', 'wp-allaround' ); ?></p>295 <div class='notice notice-error'> 296 <p><?php _e('Ooops ! Something wrong happens while publish your post on AllAround: try again in few minutes', 'wp-allaround' ); ?></p> 238 297 </div> 239 298 <?php
Note: See TracChangeset
for help on using the changeset viewer.