From 7dde62024ca0e6ade16e634b15db497c060f473d Mon Sep 17 00:00:00 2001
From: Siddharth Thevaril
Date: Mon, 5 Sep 2022 22:29:37 +0530
Subject: [PATCH 01/94] add img element
---
src/js/AutoshareForTwitterPrePublishPanel.js | 26 +++++++++++++++++---
1 file changed, 22 insertions(+), 4 deletions(-)
diff --git a/src/js/AutoshareForTwitterPrePublishPanel.js b/src/js/AutoshareForTwitterPrePublishPanel.js
index 13c35312..14fcb605 100644
--- a/src/js/AutoshareForTwitterPrePublishPanel.js
+++ b/src/js/AutoshareForTwitterPrePublishPanel.js
@@ -15,7 +15,7 @@ class AutoshareForTwitterPrePublishPanel extends Component {
// Although these values are delivered as props, we copy them into state so that we can check for changes
// and save data when they update.
- this.state = { autoshareEnabled: null, tweetText: null };
+ this.state = { autoshareEnabled: null, tweetText: null, featuredImageUrl: null };
this.saveData = debounce( this.saveData.bind( this ), 250 );
}
@@ -27,11 +27,11 @@ class AutoshareForTwitterPrePublishPanel extends Component {
}
componentDidUpdate() {
- const { autoshareEnabled, tweetText } = this.props;
+ const { autoshareEnabled, tweetText, featuredImageUrl } = this.props;
// Update if either of these values has changed in the data store.
if ( autoshareEnabled !== this.state.autoshareEnabled || tweetText !== this.state.tweetText ) {
- this.setState( { autoshareEnabled, tweetText }, () => {
+ this.setState( { autoshareEnabled, tweetText, featuredImageUrl }, () => {
this.props.setSaving( true );
this.saveData();
} );
@@ -80,6 +80,7 @@ class AutoshareForTwitterPrePublishPanel extends Component {
setOverriding,
setTweetText,
tweetText,
+ featuredImageUrl,
} = this.props;
const overrideLengthClass = () => {
@@ -135,7 +136,16 @@ class AutoshareForTwitterPrePublishPanel extends Component {
) }
-
+ { featuredImageUrl && (
+ <>
+
+
+ >
+ ) }
{ errorMessage }
>
);
@@ -156,6 +166,13 @@ const permalinkLength = ( select ) => {
return siteUrl.length;
};
+const featuredImageUrl = ( select ) => {
+ const imageId = select( 'core/editor' ).getEditedPostAttribute( 'featured_media' );
+ const imageUrl = select( 'core' ).getMedia( imageId );
+
+ return imageUrl ? imageUrl.source_url : false;
+};
+
export default compose(
withSelect( ( select ) => ( {
autoshareEnabled: select( STORE ).getAutoshareEnabled(),
@@ -164,6 +181,7 @@ export default compose(
permalinkLength: permalinkLength( select ),
saving: select( STORE ).getSaving(),
tweetText: select( STORE ).getTweetText(),
+ featuredImageUrl: featuredImageUrl( select ),
} ) ),
withDispatch( ( dispatch ) => ( {
setAutoshareEnabled: dispatch( STORE ).setAutoshareEnabled,
From f703893f1dec19890599696cda8d6a6bd569a3fb Mon Sep 17 00:00:00 2001
From: Siddharth Thevaril
Date: Tue, 6 Sep 2022 16:12:52 +0530
Subject: [PATCH 02/94] update rest route
---
includes/admin/assets.php | 2 ++
includes/admin/post-meta.php | 2 ++
includes/rest.php | 7 +++++++
3 files changed, 11 insertions(+)
diff --git a/includes/admin/assets.php b/includes/admin/assets.php
index f447aee6..a5fe23f8 100644
--- a/includes/admin/assets.php
+++ b/includes/admin/assets.php
@@ -16,6 +16,7 @@
use const TenUp\AutoshareForTwitter\Core\Post_Meta\ENABLE_AUTOSHARE_FOR_TWITTER_KEY;
use const TenUp\AutoshareForTwitter\Core\Post_Meta\TWEET_BODY_KEY;
use const TenUp\AutoshareForTwitter\Core\Post_Meta\TWITTER_STATUS_KEY;
+use const TenUp\AutoshareForTwitter\Core\Post_Meta\TWEET_ALLOW_IMAGE;
/**
* The handle used in registering plugin assets.
@@ -201,6 +202,7 @@ function localize_data( $handle = SCRIPT_HANDLE ) {
'status' => $status_meta && is_array( $status_meta ) ? $status_meta : null,
'unknownErrorText' => __( 'An unknown error occurred', 'autoshare-for-twitter' ),
'siteUrl' => home_url(),
+ 'tweetImageUrl' => TWEET_ALLOW_IMAGE,
];
wp_localize_script( $handle, 'adminAutoshareForTwitter', $localization );
diff --git a/includes/admin/post-meta.php b/includes/admin/post-meta.php
index fec044a3..f057c400 100644
--- a/includes/admin/post-meta.php
+++ b/includes/admin/post-meta.php
@@ -38,6 +38,8 @@
*/
const TWITTER_STATUS_KEY = 'status';
+const TWEET_ALLOW_IMAGE = 'tweet-allow-image';
+
/**
* The setup function
*
diff --git a/includes/rest.php b/includes/rest.php
index fbef3881..c6673d46 100644
--- a/includes/rest.php
+++ b/includes/rest.php
@@ -12,6 +12,7 @@
use WP_REST_Server;
use const TenUp\AutoshareForTwitter\Core\Post_Meta\TWEET_BODY_KEY;
use const TenUp\AutoshareForTwitter\Core\Post_Meta\ENABLE_AUTOSHARE_FOR_TWITTER_KEY;
+use const TenUp\AutoshareForTwitter\Core\Post_Meta\TWEET_ALLOW_IMAGE;
use const TenUp\AutoshareForTwitter\Core\POST_TYPE_SUPPORT_FEATURE;
use function TenUp\AutoshareForTwitter\Core\Post_Meta\get_tweet_status_message;
@@ -84,6 +85,12 @@ function register_post_autoshare_for_twitter_meta_rest_route() {
'type' => 'boolean',
'validate_callback' => 'rest_validate_request_arg',
],
+ TWEET_ALLOW_IMAGE => [
+ 'description' => __( 'Whether the tweet has an image.', 'autoshare-for-twitter' ),
+ 'required' => true,
+ 'type' => array( 'string', 'boolean' ),
+ 'validate_callback' => 'rest_validate_request_arg',
+ ],
],
]
);
From d6b90ab86209a43e5e80227c1f5b071ef1ca4fd0 Mon Sep 17 00:00:00 2001
From: Siddharth Thevaril
Date: Tue, 6 Sep 2022 16:58:18 +0530
Subject: [PATCH 03/94] submit form data
---
includes/admin/assets.php | 2 +-
includes/rest.php | 2 +-
src/js/AutoshareForTwitterPrePublishPanel.js | 28 ++++++++++++++------
src/js/store/actions.js | 6 +++++
src/js/store/constants.js | 1 +
src/js/store/reducer.js | 9 +++++++
src/js/store/selectors.js | 2 ++
7 files changed, 40 insertions(+), 10 deletions(-)
diff --git a/includes/admin/assets.php b/includes/admin/assets.php
index a5fe23f8..77848021 100644
--- a/includes/admin/assets.php
+++ b/includes/admin/assets.php
@@ -202,7 +202,7 @@ function localize_data( $handle = SCRIPT_HANDLE ) {
'status' => $status_meta && is_array( $status_meta ) ? $status_meta : null,
'unknownErrorText' => __( 'An unknown error occurred', 'autoshare-for-twitter' ),
'siteUrl' => home_url(),
- 'tweetImageUrl' => TWEET_ALLOW_IMAGE,
+ 'allowTweetImageKey' => TWEET_ALLOW_IMAGE,
];
wp_localize_script( $handle, 'adminAutoshareForTwitter', $localization );
diff --git a/includes/rest.php b/includes/rest.php
index c6673d46..85842478 100644
--- a/includes/rest.php
+++ b/includes/rest.php
@@ -88,7 +88,7 @@ function register_post_autoshare_for_twitter_meta_rest_route() {
TWEET_ALLOW_IMAGE => [
'description' => __( 'Whether the tweet has an image.', 'autoshare-for-twitter' ),
'required' => true,
- 'type' => array( 'string', 'boolean' ),
+ 'type' => 'boolean',
'validate_callback' => 'rest_validate_request_arg',
],
],
diff --git a/src/js/AutoshareForTwitterPrePublishPanel.js b/src/js/AutoshareForTwitterPrePublishPanel.js
index 14fcb605..e68610a1 100644
--- a/src/js/AutoshareForTwitterPrePublishPanel.js
+++ b/src/js/AutoshareForTwitterPrePublishPanel.js
@@ -4,7 +4,7 @@ import { withDispatch, withSelect } from '@wordpress/data';
import { compose } from '@wordpress/compose';
import { Component } from '@wordpress/element';
import { debounce } from 'lodash';
-import { enableAutoshareKey, errorText, restUrl, siteUrl, tweetBodyKey } from 'admin-autoshare-for-twitter';
+import { enableAutoshareKey, errorText, restUrl, siteUrl, tweetBodyKey, allowTweetImageKey } from 'admin-autoshare-for-twitter';
import { __ } from '@wordpress/i18n';
import { STORE } from './store';
@@ -15,23 +15,27 @@ class AutoshareForTwitterPrePublishPanel extends Component {
// Although these values are delivered as props, we copy them into state so that we can check for changes
// and save data when they update.
- this.state = { autoshareEnabled: null, tweetText: null, featuredImageUrl: null };
+ this.state = { autoshareEnabled: null, tweetText: null, featuredImageUrl: null, allowTweetImage: true };
this.saveData = debounce( this.saveData.bind( this ), 250 );
}
componentDidMount() {
- const { autoshareEnabled, tweetText } = this.props;
+ const { autoshareEnabled, tweetText, allowTweetImage } = this.props;
- this.setState( { autoshareEnabled, tweetText } );
+ this.setState( { autoshareEnabled, tweetText, allowTweetImage } );
}
componentDidUpdate() {
- const { autoshareEnabled, tweetText, featuredImageUrl } = this.props;
+ const { autoshareEnabled, tweetText, featuredImageUrl, allowTweetImage } = this.props;
// Update if either of these values has changed in the data store.
- if ( autoshareEnabled !== this.state.autoshareEnabled || tweetText !== this.state.tweetText ) {
- this.setState( { autoshareEnabled, tweetText, featuredImageUrl }, () => {
+ if (
+ autoshareEnabled !== this.state.autoshareEnabled ||
+ tweetText !== this.state.tweetText ||
+ allowTweetImage !== this.state.allowTweetImage
+ ) {
+ this.setState( { autoshareEnabled, tweetText, featuredImageUrl, allowTweetImage }, () => {
this.props.setSaving( true );
this.saveData();
} );
@@ -39,11 +43,12 @@ class AutoshareForTwitterPrePublishPanel extends Component {
}
async saveData() {
- const { autoshareEnabled, setErrorMessage, setSaving, tweetText } = this.props;
+ const { autoshareEnabled, setErrorMessage, setSaving, tweetText, allowTweetImage } = this.props;
const body = {};
body[ enableAutoshareKey ] = autoshareEnabled;
body[ tweetBodyKey ] = tweetText;
+ body[ allowTweetImageKey ] = allowTweetImage;
try {
const response = await apiFetch( {
@@ -76,9 +81,11 @@ class AutoshareForTwitterPrePublishPanel extends Component {
errorMessage,
overriding,
permalinkLength,
+ allowTweetImage,
setAutoshareEnabled,
setOverriding,
setTweetText,
+ setAllowTweetImage,
tweetText,
featuredImageUrl,
} = this.props;
@@ -141,6 +148,9 @@ class AutoshareForTwitterPrePublishPanel extends Component {
@@ -182,6 +192,7 @@ export default compose(
saving: select( STORE ).getSaving(),
tweetText: select( STORE ).getTweetText(),
featuredImageUrl: featuredImageUrl( select ),
+ allowTweetImage: select( STORE ).getAllowTweetImage(),
} ) ),
withDispatch( ( dispatch ) => ( {
setAutoshareEnabled: dispatch( STORE ).setAutoshareEnabled,
@@ -197,5 +208,6 @@ export default compose(
}
},
setTweetText: dispatch( STORE ).setTweetText,
+ setAllowTweetImage: dispatch( STORE ).setAllowTweetImage,
} ) ),
)( AutoshareForTwitterPrePublishPanel );
diff --git a/src/js/store/actions.js b/src/js/store/actions.js
index 1084ef32..d0cb9cdc 100644
--- a/src/js/store/actions.js
+++ b/src/js/store/actions.js
@@ -5,6 +5,7 @@ import {
SET_SAVING,
SET_LOADED,
SET_OVERRIDING,
+ SET_ALLOW_TWEET_IMAGE,
} from './constants';
export const setAutoshareEnabled = ( autoshareEnabled ) => ( {
@@ -35,3 +36,8 @@ export const setTweetText = ( tweetText ) => ( {
type: SET_TWEET_TEXT,
tweetText,
} );
+
+export const setAllowTweetImage = ( allowTweetImage ) => ( {
+ type: SET_ALLOW_TWEET_IMAGE,
+ allowTweetImage,
+} );
diff --git a/src/js/store/constants.js b/src/js/store/constants.js
index 34fa28b2..abe66ee3 100644
--- a/src/js/store/constants.js
+++ b/src/js/store/constants.js
@@ -4,3 +4,4 @@ export const SET_LOADED = 'SET_LOADED';
export const SET_OVERRIDING = 'SET_OVERRIDING';
export const SET_SAVING = 'SET_SAVING';
export const SET_TWEET_TEXT = 'SET_TWEET_TEXT';
+export const SET_ALLOW_TWEET_IMAGE = 'SET_ALLOW_TWEET_IMAGE';
diff --git a/src/js/store/reducer.js b/src/js/store/reducer.js
index 877ef20b..fd14c844 100644
--- a/src/js/store/reducer.js
+++ b/src/js/store/reducer.js
@@ -7,6 +7,7 @@ import {
SET_SAVING,
SET_LOADED,
SET_OVERRIDING,
+ SET_ALLOW_TWEET_IMAGE,
} from './constants';
export const DEFAULT_STATE = {
@@ -16,6 +17,7 @@ export const DEFAULT_STATE = {
overriding: false,
overrideLength: 0,
tweetText: '',
+ allowTweetImage: false,
};
export default function reducer( state = DEFAULT_STATE, action ) {
@@ -59,5 +61,12 @@ export default function reducer( state = DEFAULT_STATE, action ) {
tweetText: action.tweetText,
};
}
+
+ case SET_ALLOW_TWEET_IMAGE: {
+ return {
+ ...state,
+ allowTweetImage: action.allowTweetImage,
+ };
+ }
}
}
diff --git a/src/js/store/selectors.js b/src/js/store/selectors.js
index ab59d6c1..d0268c94 100644
--- a/src/js/store/selectors.js
+++ b/src/js/store/selectors.js
@@ -7,3 +7,5 @@ export const getOverriding = ( state ) => state.overriding;
export const getSaving = ( state ) => state.saving;
export const getTweetText = ( state ) => state.tweetText;
+
+export const getAllowTweetImage = ( state ) => state.allowTweetImage;
From f33855f1d92d5643cc73afbaa99cdb35db12eeb5 Mon Sep 17 00:00:00 2001
From: Siddharth Thevaril
Date: Tue, 6 Sep 2022 21:32:53 +0530
Subject: [PATCH 04/94] add meta to disallow image
---
includes/admin/post-meta.php | 9 +++++++++
includes/class-publish-tweet.php | 7 ++++++-
src/js/AutoshareForTwitterPrePublishPanel.js | 4 ++--
src/js/store/reducer.js | 2 +-
4 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/includes/admin/post-meta.php b/includes/admin/post-meta.php
index f057c400..a10497c9 100644
--- a/includes/admin/post-meta.php
+++ b/includes/admin/post-meta.php
@@ -163,6 +163,15 @@ function save_autoshare_for_twitter_meta_data( $post_id, $data ) {
} else {
delete_autoshare_for_twitter_meta( $post_id, TWEET_BODY_KEY );
}
+
+ break;
+
+ case TWEET_ALLOW_IMAGE:
+ update_autoshare_for_twitter_meta( $post_id, TWEET_ALLOW_IMAGE, $value ? 'yes' : 'no' );
+ break;
+
+ default:
+ break;
}
}
}
diff --git a/includes/class-publish-tweet.php b/includes/class-publish-tweet.php
index 255058fd..6ab99d1f 100644
--- a/includes/class-publish-tweet.php
+++ b/includes/class-publish-tweet.php
@@ -9,6 +9,7 @@
use TenUp\AutoshareForTwitter\Utils as Utils;
use Abraham\TwitterOAuth\TwitterOAuth as TwitterOAuth;
+use const \TenUp\AutoshareForTwitter\Core\Post_Meta\TWEET_ALLOW_IMAGE;
/**
* Publish tweets to twitter.
@@ -98,12 +99,16 @@ public function status_update( $body, $post ) {
if ( empty( $body ) ) {
return;
}
+
$update_data = array(
'status' => $body, // URL encoding handled by buildHttpQuery vai TwitterOAuth.
);
+ $is_image_allowed = Utils\get_autoshare_for_twitter_meta( $post->ID, TWEET_ALLOW_IMAGE );
+
$media_id = $this->get_upload_data_media_id( $post );
- if ( $media_id ) {
+
+ if ( $media_id && 'no' !== $is_image_allowed ) {
$update_data['media_ids'] = [ $media_id ];
}
diff --git a/src/js/AutoshareForTwitterPrePublishPanel.js b/src/js/AutoshareForTwitterPrePublishPanel.js
index e68610a1..54b6ec54 100644
--- a/src/js/AutoshareForTwitterPrePublishPanel.js
+++ b/src/js/AutoshareForTwitterPrePublishPanel.js
@@ -145,14 +145,14 @@ class AutoshareForTwitterPrePublishPanel extends Component {
) }
{ featuredImageUrl && (
<>
-
+
>
) }
diff --git a/src/js/store/reducer.js b/src/js/store/reducer.js
index fd14c844..4de575b8 100644
--- a/src/js/store/reducer.js
+++ b/src/js/store/reducer.js
@@ -17,7 +17,7 @@ export const DEFAULT_STATE = {
overriding: false,
overrideLength: 0,
tweetText: '',
- allowTweetImage: false,
+ allowTweetImage: true,
};
export default function reducer( state = DEFAULT_STATE, action ) {
From 77850fb83e5719b59c99459933ca893eaeecf6ce Mon Sep 17 00:00:00 2001
From: Siddharth Thevaril
Date: Thu, 8 Sep 2022 21:01:41 +0530
Subject: [PATCH 05/94] replace button link with form toggle
---
includes/rest.php | 2 +-
src/js/AutoshareForTwitterPrePublishPanel.js | 44 ++++++++++----------
2 files changed, 24 insertions(+), 22 deletions(-)
diff --git a/includes/rest.php b/includes/rest.php
index 85842478..5ab3b1e1 100644
--- a/includes/rest.php
+++ b/includes/rest.php
@@ -85,7 +85,7 @@ function register_post_autoshare_for_twitter_meta_rest_route() {
'type' => 'boolean',
'validate_callback' => 'rest_validate_request_arg',
],
- TWEET_ALLOW_IMAGE => [
+ TWEET_ALLOW_IMAGE => [
'description' => __( 'Whether the tweet has an image.', 'autoshare-for-twitter' ),
'required' => true,
'type' => 'boolean',
diff --git a/src/js/AutoshareForTwitterPrePublishPanel.js b/src/js/AutoshareForTwitterPrePublishPanel.js
index 54b6ec54..d80bc9b1 100644
--- a/src/js/AutoshareForTwitterPrePublishPanel.js
+++ b/src/js/AutoshareForTwitterPrePublishPanel.js
@@ -15,7 +15,7 @@ class AutoshareForTwitterPrePublishPanel extends Component {
// Although these values are delivered as props, we copy them into state so that we can check for changes
// and save data when they update.
- this.state = { autoshareEnabled: null, tweetText: null, featuredImageUrl: null, allowTweetImage: true };
+ this.state = { autoshareEnabled: null, tweetText: null, hasFeaturedImage: null, allowTweetImage: true };
this.saveData = debounce( this.saveData.bind( this ), 250 );
}
@@ -27,7 +27,7 @@ class AutoshareForTwitterPrePublishPanel extends Component {
}
componentDidUpdate() {
- const { autoshareEnabled, tweetText, featuredImageUrl, allowTweetImage } = this.props;
+ const { autoshareEnabled, tweetText, hasFeaturedImage, allowTweetImage } = this.props;
// Update if either of these values has changed in the data store.
if (
@@ -35,7 +35,7 @@ class AutoshareForTwitterPrePublishPanel extends Component {
tweetText !== this.state.tweetText ||
allowTweetImage !== this.state.allowTweetImage
) {
- this.setState( { autoshareEnabled, tweetText, featuredImageUrl, allowTweetImage }, () => {
+ this.setState( { autoshareEnabled, tweetText, hasFeaturedImage, allowTweetImage }, () => {
this.props.setSaving( true );
this.saveData();
} );
@@ -87,7 +87,7 @@ class AutoshareForTwitterPrePublishPanel extends Component {
setTweetText,
setAllowTweetImage,
tweetText,
- featuredImageUrl,
+ hasFeaturedImage,
} = this.props;
const overrideLengthClass = () => {
@@ -114,6 +114,17 @@ class AutoshareForTwitterPrePublishPanel extends Component {
className="autoshare-for-twitter-toggle-control"
/>
+ { hasFeaturedImage && (
+ {
+ setAllowTweetImage( ! allowTweetImage );
+ } }
+ className="autoshare-for-twitter-toggle-control"
+ />
+ ) }
+
{ autoshareEnabled && (
{ overriding && (
@@ -143,19 +154,6 @@ class AutoshareForTwitterPrePublishPanel extends Component {
) }
- { featuredImageUrl && (
- <>
-
-
- >
- ) }
{ errorMessage }
>
);
@@ -176,11 +174,15 @@ const permalinkLength = ( select ) => {
return siteUrl.length;
};
-const featuredImageUrl = ( select ) => {
+/**
+ * Returns true if the post has a featured image, false otherwise.
+ * @param {Function} select Data store selector function.
+ * @returns {boolean}
+ */
+const hasFeaturedImage = ( select ) => {
const imageId = select( 'core/editor' ).getEditedPostAttribute( 'featured_media' );
- const imageUrl = select( 'core' ).getMedia( imageId );
- return imageUrl ? imageUrl.source_url : false;
+ return imageId > 0;
};
export default compose(
@@ -191,7 +193,7 @@ export default compose(
permalinkLength: permalinkLength( select ),
saving: select( STORE ).getSaving(),
tweetText: select( STORE ).getTweetText(),
- featuredImageUrl: featuredImageUrl( select ),
+ hasFeaturedImage: hasFeaturedImage( select ),
allowTweetImage: select( STORE ).getAllowTweetImage(),
} ) ),
withDispatch( ( dispatch ) => ( {
From b4d5af03170feb50718a0d96153a6b140798849f Mon Sep 17 00:00:00 2001
From: Siddharth Thevaril
Date: Sat, 17 Sep 2022 17:45:44 +0530
Subject: [PATCH 06/94] merge develop
---
includes/admin/post-meta.php | 2 +-
src/js/AutoshareForTwitterPostStatusInfo.js | 5 +-
src/js/AutoshareForTwitterPrePublishPanel.js | 54 ++---------------
src/js/components/TweetTextField.js | 61 ++++++++++++++++++++
4 files changed, 72 insertions(+), 50 deletions(-)
create mode 100644 src/js/components/TweetTextField.js
diff --git a/includes/admin/post-meta.php b/includes/admin/post-meta.php
index a10497c9..144b9418 100644
--- a/includes/admin/post-meta.php
+++ b/includes/admin/post-meta.php
@@ -312,7 +312,7 @@ function markup_published( $status_meta ) {
return sprintf(
'%s %s (%s)
',
- esc_html__( 'Tweeted on', 'autoshare-for-twitter' ),
+ esc_html__( 'Tweetedd on', 'autoshare-for-twitter' ),
esc_html( $date ),
esc_url( $twitter_url ),
esc_html__( 'View', 'autoshare-for-twitter' )
diff --git a/src/js/AutoshareForTwitterPostStatusInfo.js b/src/js/AutoshareForTwitterPostStatusInfo.js
index d29d4109..a30f0749 100644
--- a/src/js/AutoshareForTwitterPostStatusInfo.js
+++ b/src/js/AutoshareForTwitterPostStatusInfo.js
@@ -3,7 +3,7 @@ import { compose } from '@wordpress/compose';
import { withSelect } from '@wordpress/data';
import { Dashicon } from '@wordpress/components';
-export function AutoshareForTwitterPostStatusInfo( { statusMessage } ) {
+export function AutoshareForTwitterPostStatusInfo( { statusMessage, allowRetweet } ) {
return (
statusMessage.message && (
@@ -18,6 +18,9 @@ export function AutoshareForTwitterPostStatusInfo( { statusMessage } ) {
{ ')' }
>
) }
+ { allowRetweet && (
+
Hello, you
+ ) }
)
);
diff --git a/src/js/AutoshareForTwitterPrePublishPanel.js b/src/js/AutoshareForTwitterPrePublishPanel.js
index d80bc9b1..6be121d0 100644
--- a/src/js/AutoshareForTwitterPrePublishPanel.js
+++ b/src/js/AutoshareForTwitterPrePublishPanel.js
@@ -1,12 +1,13 @@
import apiFetch from '@wordpress/api-fetch';
-import { Button, TextareaControl, ToggleControl } from '@wordpress/components';
+import { Button, ToggleControl } from '@wordpress/components';
import { withDispatch, withSelect } from '@wordpress/data';
import { compose } from '@wordpress/compose';
import { Component } from '@wordpress/element';
import { debounce } from 'lodash';
-import { enableAutoshareKey, errorText, restUrl, siteUrl, tweetBodyKey, allowTweetImageKey } from 'admin-autoshare-for-twitter';
+import { enableAutoshareKey, errorText, restUrl, tweetBodyKey, allowTweetImageKey } from 'admin-autoshare-for-twitter';
import { __ } from '@wordpress/i18n';
+import { TweetTextField } from './components/TweetTextField';
import { STORE } from './store';
class AutoshareForTwitterPrePublishPanel extends Component {
@@ -80,28 +81,13 @@ class AutoshareForTwitterPrePublishPanel extends Component {
autoshareEnabled,
errorMessage,
overriding,
- permalinkLength,
allowTweetImage,
setAutoshareEnabled,
setOverriding,
- setTweetText,
setAllowTweetImage,
- tweetText,
hasFeaturedImage,
} = this.props;
- const overrideLengthClass = () => {
- if ( 280 <= permalinkLength + tweetText.length ) {
- return 'over-limit';
- }
-
- if ( 240 <= permalinkLength + tweetText.length ) {
- return 'near-limit';
- }
-
- return null;
- };
-
return (
<>
{ overriding && (
- {
- setTweetText( value );
- } }
- label={
-
- { __( 'Custom message:', 'autoshare-for-twitter' ) }
-
-
- }
- />
+
) }