File size: 2,348 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import { Card } from '@automattic/components';
import { localizeUrl } from '@automattic/i18n-utils';
import { localize } from 'i18n-calypso';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import QueryJetpackConnection from 'calypso/components/data/query-jetpack-connection';
import SupportInfo from 'calypso/components/support-info';
import JetpackModuleToggle from 'calypso/my-sites/site-settings/jetpack-module-toggle';
import isJetpackModuleUnavailableInDevelopmentMode from 'calypso/state/selectors/is-jetpack-module-unavailable-in-development-mode';
import isJetpackSiteInDevelopmentMode from 'calypso/state/selectors/is-jetpack-site-in-development-mode';
import { getSelectedSiteId } from 'calypso/state/ui/selectors';

function Shortcodes( {
	isRequestingSettings,
	isSavingSettings,
	moduleUnavailable,
	selectedSiteId,
	translate,
	isAtomic,
} ) {
	return (
		<Card className="composing__card site-settings__card">
			<QueryJetpackConnection siteId={ selectedSiteId } />
			<SupportInfo
				text={ translate(
					'Shortcodes are WordPress-specific markup that let you add media from popular sites. This feature is no longer necessary as the editor now handles media embeds rather gracefully.'
				) }
				link={
					isAtomic
						? localizeUrl( 'https://wordpress.com/support/shortcodes/' )
						: 'https://jetpack.com/support/shortcode-embeds/'
				}
				privacyLink={ ! isAtomic }
			/>
			<JetpackModuleToggle
				siteId={ selectedSiteId }
				moduleSlug="shortcodes"
				label={ translate( 'Compose using shortcodes to embed media from popular sites' ) }
				disabled={ isRequestingSettings || isSavingSettings || moduleUnavailable }
			/>
		</Card>
	);
}

Shortcodes.defaultProps = {
	isSavingSettings: false,
	isRequestingSettings: true,
};

Shortcodes.propTypes = {
	isAtomic: PropTypes.bool,
	isSavingSettings: PropTypes.bool,
	isRequestingSettings: PropTypes.bool,
};

export default connect( ( state ) => {
	const selectedSiteId = getSelectedSiteId( state );
	const siteInDevMode = isJetpackSiteInDevelopmentMode( state, selectedSiteId );
	const moduleUnavailableInDevMode = isJetpackModuleUnavailableInDevelopmentMode(
		state,
		selectedSiteId,
		'shortcodes'
	);

	return {
		selectedSiteId,
		moduleUnavailable: siteInDevMode && moduleUnavailableInDevMode,
	};
} )( localize( Shortcodes ) );