WP to Twitter - Version 3.6.1

Version Description

  • Bug fix: Don't expect a nonce or attempt to handle post meta if post not submitted from WordPress admin.
Download this release

Release Info

Developer joedolson
Plugin Icon 128x128 WP to Twitter
Version 3.6.1
Comparing to
See all releases

Code changes from version 3.6.0 to 3.6.1

Files changed (2) hide show
  1. readme.txt +5 -1
  2. wp-to-twitter.php +47 -46
readme.txt CHANGED
@@ -7,7 +7,7 @@ Tested up to: 6.0
7
  Requires PHP: 5.6
8
  License: GPLv2 or later
9
  Text Domain: wp-to-twitter
10
- Stable tag: 3.6.0
11
 
12
  Posts a Twitter update when you update your WordPress blog or add a link, with your chosen URL shortening service.
13
 
@@ -64,6 +64,10 @@ Check out my <a href="https://github.com/joedolson/plugin-extensions/tree/master
64
 
65
  == Changelog ==
66
 
 
 
 
 
67
  = 3.6.0 =
68
 
69
  * Bug fix: Fix incorrect textdomains.
7
  Requires PHP: 5.6
8
  License: GPLv2 or later
9
  Text Domain: wp-to-twitter
10
+ Stable tag: 3.6.1
11
 
12
  Posts a Twitter update when you update your WordPress blog or add a link, with your chosen URL shortening service.
13
 
64
 
65
  == Changelog ==
66
 
67
+ = 3.6.1 =
68
+
69
+ * Bug fix: Don't expect a nonce or attempt to handle post meta if post not submitted from WordPress admin.
70
+
71
  = 3.6.0 =
72
 
73
  * Bug fix: Fix incorrect textdomains.
wp-to-twitter.php CHANGED
@@ -17,7 +17,7 @@
17
  * License: GPL-2.0+
18
  * License URI: http://www.gnu.org/license/gpl-2.0.txt
19
  * Domain Path: lang
20
- * Version: 3.6.0
21
  */
22
 
23
  /*
@@ -65,7 +65,7 @@ require_once( plugin_dir_path( __FILE__ ) . 'wpt-widget.php' );
65
  require_once( plugin_dir_path( __FILE__ ) . 'wpt-rate-limiting.php' );
66
 
67
  global $wpt_version;
68
- $wpt_version = '3.6.0';
69
 
70
  add_action( 'init', 'wpt_load_textdomain' );
71
  /**
@@ -1278,7 +1278,6 @@ function wpt_add_twitter_debug_box() {
1278
  }
1279
  }
1280
 
1281
-
1282
  /**
1283
  * Print post meta box
1284
  *
@@ -1287,7 +1286,10 @@ function wpt_add_twitter_debug_box() {
1287
  function wpt_add_twitter_inner_box( $post ) {
1288
  $nonce = wp_create_nonce( 'wp-to-twitter-nonce' );
1289
  ?>
1290
- <div><input type="hidden" name="wp_to_twitter_nonce" value="<?php echo $nonce; ?>"></div>
 
 
 
1291
  <?php
1292
  if ( current_user_can( 'wpt_can_tweet' ) ) {
1293
  $is_pro = ( function_exists( 'wpt_pro_exists' ) ) ? 'pro' : 'free';
@@ -1713,52 +1715,51 @@ function wpt_save_post( $id, $post ) {
1713
  if ( empty( $_POST ) || ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || wp_is_post_revision( $id ) || isset( $_POST['_inline_edit'] ) || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) || ! wpt_in_post_type( $id ) ) {
1714
  return $id;
1715
  }
1716
- $nonce = ( isset( $_POST['wp_to_twitter_nonce'] ) ) ? $_POST['wp_to_twitter_nonce'] : false;
1717
- if ( ! ( $nonce && wp_verify_nonce( $nonce, 'wp-to-twitter-nonce' ) ) ) {
1718
- die( 'Security check failed' );
1719
- }
1720
- if ( isset( $_POST['_yourls_keyword'] ) ) {
1721
- $yourls = sanitize_text_field( $_POST['_yourls_keyword'] );
1722
- $update = update_post_meta( $id, '_yourls_keyword', $yourls );
1723
- }
1724
- if ( isset( $_POST['_jd_twitter'] ) && '' !== $_POST['_jd_twitter'] ) {
1725
- $twitter = sanitize_textarea_field( $_POST['_jd_twitter'] );
1726
- $update = update_post_meta( $id, '_jd_twitter', $twitter );
1727
- } elseif ( isset( $_POST['_jd_twitter'] ) && '' === $_POST['_jd_twitter'] ) {
1728
- delete_post_meta( $id, '_jd_twitter' );
1729
- }
1730
- if ( isset( $_POST['_jd_wp_twitter'] ) && '' !== $_POST['_jd_wp_twitter'] ) {
1731
- $wp_twitter = sanitize_textarea_field( $_POST['_jd_wp_twitter'] );
1732
- $update = update_post_meta( $id, '_jd_wp_twitter', $wp_twitter );
1733
- }
1734
- if ( isset( $_POST['_jd_tweet_this'] ) ) {
1735
- $tweet_this = ( 'no' === $_POST['_jd_tweet_this'] ) ? 'no' : 'yes';
1736
- $update = update_post_meta( $id, '_jd_tweet_this', $tweet_this );
1737
- } else {
1738
- if ( isset( $_POST['_wpnonce'] ) ) {
1739
  $tweet_default = ( '1' === get_option( 'jd_tweet_default' ) ) ? 'no' : 'yes';
1740
  $update = update_post_meta( $id, '_jd_tweet_this', $tweet_default );
1741
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1742
  }
1743
- if ( isset( $_POST['wpt_clear_history'] ) && 'clear' === $_POST['wpt_clear_history'] ) {
1744
- delete_post_meta( $id, '_wpt_failed' );
1745
- delete_post_meta( $id, '_jd_wp_twitter' );
1746
- delete_post_meta( $id, '_wpt_short_url' );
1747
- delete_post_meta( $id, '_wp_jd_twitter' );
1748
- }
1749
- // WPT PRO.
1750
- $update = apply_filters( 'wpt_insert_post', $_POST, $id );
1751
- // WPT PRO.
1752
- // only send debug data if post meta is updated.
1753
- wpt_mail( 'Post Meta Processed', 'WP to Twitter post meta was updated' . "\n\n" . print_r( map_deep( $_POST, 'sanitize_textarea_field' ), 1 ), $id ); // DEBUG.
1754
-
1755
- if ( isset( $_POST['wpt-delete-debug'] ) && 'true' === $_POST['wpt-delete-debug'] ) {
1756
- delete_post_meta( $id, '_wpt_debug_log' );
1757
- }
1758
- if ( isset( $_POST['wpt-delete-all-debug'] ) && 'true' === $_POST['wpt-delete-all-debug'] ) {
1759
- delete_post_meta_by_key( '_wpt_debug_log' );
1760
- }
1761
-
1762
  return $id;
1763
  }
1764
 
17
  * License: GPL-2.0+
18
  * License URI: http://www.gnu.org/license/gpl-2.0.txt
19
  * Domain Path: lang
20
+ * Version: 3.6.1
21
  */
22
 
23
  /*
65
  require_once( plugin_dir_path( __FILE__ ) . 'wpt-rate-limiting.php' );
66
 
67
  global $wpt_version;
68
+ $wpt_version = '3.6.1';
69
 
70
  add_action( 'init', 'wpt_load_textdomain' );
71
  /**
1278
  }
1279
  }
1280
 
 
1281
  /**
1282
  * Print post meta box
1283
  *
1286
  function wpt_add_twitter_inner_box( $post ) {
1287
  $nonce = wp_create_nonce( 'wp-to-twitter-nonce' );
1288
  ?>
1289
+ <div>
1290
+ <input type="hidden" name="wp_to_twitter_nonce" value="<?php echo $nonce; ?>">
1291
+ <input type="hidden" name="wp_to_twitter_meta" value="true">
1292
+ </div>
1293
  <?php
1294
  if ( current_user_can( 'wpt_can_tweet' ) ) {
1295
  $is_pro = ( function_exists( 'wpt_pro_exists' ) ) ? 'pro' : 'free';
1715
  if ( empty( $_POST ) || ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || wp_is_post_revision( $id ) || isset( $_POST['_inline_edit'] ) || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) || ! wpt_in_post_type( $id ) ) {
1716
  return $id;
1717
  }
1718
+ if ( isset( $_POST['wp_to_twitter_meta'] ) ) {
1719
+ $nonce = ( isset( $_POST['wp_to_twitter_nonce'] ) ) ? $_POST['wp_to_twitter_nonce'] : false;
1720
+ if ( ! ( $nonce && wp_verify_nonce( $nonce, 'wp-to-twitter-nonce' ) ) ) {
1721
+ die( 'WP to Twitter: Security check failed' );
1722
+ }
1723
+ if ( isset( $_POST['_yourls_keyword'] ) ) {
1724
+ $yourls = sanitize_text_field( $_POST['_yourls_keyword'] );
1725
+ $update = update_post_meta( $id, '_yourls_keyword', $yourls );
1726
+ }
1727
+ if ( isset( $_POST['_jd_twitter'] ) && '' !== $_POST['_jd_twitter'] ) {
1728
+ $twitter = sanitize_textarea_field( $_POST['_jd_twitter'] );
1729
+ $update = update_post_meta( $id, '_jd_twitter', $twitter );
1730
+ } elseif ( isset( $_POST['_jd_twitter'] ) && '' === $_POST['_jd_twitter'] ) {
1731
+ delete_post_meta( $id, '_jd_twitter' );
1732
+ }
1733
+ if ( isset( $_POST['_jd_wp_twitter'] ) && '' !== $_POST['_jd_wp_twitter'] ) {
1734
+ $wp_twitter = sanitize_textarea_field( $_POST['_jd_wp_twitter'] );
1735
+ $update = update_post_meta( $id, '_jd_wp_twitter', $wp_twitter );
1736
+ }
1737
+ if ( isset( $_POST['_jd_tweet_this'] ) ) {
1738
+ $tweet_this = ( 'no' === $_POST['_jd_tweet_this'] ) ? 'no' : 'yes';
1739
+ $update = update_post_meta( $id, '_jd_tweet_this', $tweet_this );
1740
+ } else {
1741
  $tweet_default = ( '1' === get_option( 'jd_tweet_default' ) ) ? 'no' : 'yes';
1742
  $update = update_post_meta( $id, '_jd_tweet_this', $tweet_default );
1743
  }
1744
+ if ( isset( $_POST['wpt_clear_history'] ) && 'clear' === $_POST['wpt_clear_history'] ) {
1745
+ delete_post_meta( $id, '_wpt_failed' );
1746
+ delete_post_meta( $id, '_jd_wp_twitter' );
1747
+ delete_post_meta( $id, '_wpt_short_url' );
1748
+ delete_post_meta( $id, '_wp_jd_twitter' );
1749
+ }
1750
+ // WPT PRO.
1751
+ $update = apply_filters( 'wpt_insert_post', $_POST, $id );
1752
+ // WPT PRO.
1753
+ // only send debug data if post meta is updated.
1754
+ wpt_mail( 'Post Meta Processed', 'WP to Twitter post meta was updated' . "\n\n" . print_r( map_deep( $_POST, 'sanitize_textarea_field' ), 1 ), $id ); // DEBUG.
1755
+
1756
+ if ( isset( $_POST['wpt-delete-debug'] ) && 'true' === $_POST['wpt-delete-debug'] ) {
1757
+ delete_post_meta( $id, '_wpt_debug_log' );
1758
+ }
1759
+ if ( isset( $_POST['wpt-delete-all-debug'] ) && 'true' === $_POST['wpt-delete-all-debug'] ) {
1760
+ delete_post_meta_by_key( '_wpt_debug_log' );
1761
+ }
1762
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1763
  return $id;
1764
  }
1765