Skip to content

Commit

Permalink
Merge branch 'develop' into dependabot/npm_and_yarn/npm_and_yarn-1d3c…
Browse files Browse the repository at this point in the history
…33138b
  • Loading branch information
iamdharmesh authored Aug 23, 2024
2 parents 539bec7 + 45045bb commit 089548a
Show file tree
Hide file tree
Showing 5 changed files with 288 additions and 22 deletions.
60 changes: 60 additions & 0 deletions assets/css/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,66 @@
width: 20px;
}

.distributor-panel span {
display: inline-block;
margin-bottom: 15px;
}

#distributed-unlink {
margin: 0;
}

#distributed-unlink .dashicons-editor-unlink {
color: #b50909;
margin-right: 7px;
text-decoration: none;
}

.distributed-modal-popup .components-modal__icon-container svg {
width: 25px;
}

.distributed-modal-popup h1 {
margin-left: 8px;
margin-top: -3px;
}

.distributed-modal-popup span {display: inline-block;}

.distributed-modal-popup .actions {
margin-top: 20px;
}

body .distributed-modal-popup button,
body .distributed-modal-popup .button {
opacity: 1;
pointer-events: initial;
cursor: pointer;
}

.distributed-modal-popup .actions a {
margin-right: 10px;
}

.distributed-modal-popup .actions a span {
display: inline-block;
margin-top: 5px;
margin-right: 5px;
color: #b50909;
}

.distributed-modal-popup .actions a span.dashicons-admin-links {
color: #046e04;
}

.distributed-modal-popup .actions #close {
margin-top: 5px;
}

.distributed-modal-popup {
max-width: 380px;
}

.distributor-toggle {
margin-bottom: 8px;
}
Expand Down
11 changes: 11 additions & 0 deletions assets/css/gutenberg-syndicated-post.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ body.dt-linked-post {
cursor: default;
}

.distributed-modal-popup {
& * {
pointer-events: auto;
opacity: 1;
}

a, button {
cursor: pointer;
}
}

/* Allow clicks on confirmation dialog buttons */
.components-confirm-dialog button {
opacity: 1;
Expand Down
152 changes: 143 additions & 9 deletions assets/js/gutenberg-plugin.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { pluginIcon } from './components/plugin-icon';

import { Icon } from '@wordpress/components';
import { Icon, Modal, Button, Flex } from '@wordpress/components';
import { select, useSelect } from '@wordpress/data';
import { PluginDocumentSettingPanel } from '@wordpress/edit-post';
import { __, _n, _x, sprintf } from '@wordpress/i18n';
import { registerPlugin } from '@wordpress/plugins';
import { useState } from '@wordpress/element';

const { document, dt, dtGutenberg, MouseEvent } = window;

Expand Down Expand Up @@ -131,14 +132,136 @@ const RenderDistributedTo = () => {
* Render the distributed from component
*/
const RenderDistributedFrom = () => {
const [ isOpen, setOpen ] = useState( false );
const openModal = () => setOpen( true );
const closeModal = () => setOpen( false );

if ( ! parseInt( dtGutenberg.unlinked ) ) {
return (
<div>
<span id="distributed-from">
{ sprintf(
/* translators: 1: Syndication date and time. */
__(
'Pulled & linked on %1$s from %2$s',
'distributor'
),
dtGutenberg.syndicationTime,
dtGutenberg.originalLocationName
) }
</span>
<span id="distributed-data">
{ __( 'Updating the ', 'distributor' ) }
<a href={ dtGutenberg.postUrl }>
{ __( 'Original Content', 'distributor' ) }
</a>
{ ', ' }
{ __(
'will update this post automatically.',
'distributor'
) }
</span>
<span id="distributed-unlink" onClick={ openModal }> {/* eslint-disable-line */}
<a href='javascript:void(0);'> {/* eslint-disable-line */}
<span className="dashicons dashicons-editor-unlink"></span>
{ __( 'Unlink from Original', 'distributor' ) }
</a>
</span>
{ isOpen && (
<Modal
title="Unlink from Original"
icon={ pluginIcon }
size={ 50 }
onRequestClose={ closeModal }
className="distributed-modal-popup"
overlayClassName="distributed-modal-overlay"
>
<p
dangerouslySetInnerHTML={ {
__html: sprintf(
/* translators: %1$s: Original Content URL Opening Tag, %2$s: Original Content URL Closing Tag */
__(
'Unlinking from the %1$sOriginal Content%2$s will stop updating this post automatically.',
'distributor'
),
'<a href="' + dtGutenberg.postUrl + '">',
'</a>'
),
} }
/>
<Flex justify="flex-start" className={ 'actions' }>
<Button
icon={ <Icon icon="editor-unlink" /> }
variant="secondary"
href={ dtGutenberg.unlinkNonceUrl }
>
{ __( 'Unlink', 'distributor' ) }
</Button>
<Button variant="link" onClick={ closeModal }>
{ __( 'Cancel', 'distributor' ) }
</Button>
</Flex>
</Modal>
) }
</div>
);
}
return (
<span id="distributed-from">
{ sprintf(
/* translators: 1: Syndication date and time. */
__( 'Distributed on: %1$s', 'distributor' ),
dtGutenberg.syndicationTime
<div>
<span id="distributed-from">
{ sprintf(
/* translators: 1: Syndication date and time. */
__( 'Pulled on %1$s from %2$s', 'distributor' ),
dtGutenberg.syndicationTime,
dtGutenberg.originalLocationName
) }
</span>
<span id="distributed-data">
{ __( 'This post has been unlinked from the ', 'distributor' ) }
<a href={ dtGutenberg.postUrl }>
{ __( 'Original Content', 'distributor' ) }
</a>
{ '.' }
</span>
<span id="distributed-restorelink" onClick={ openModal }> {/* eslint-disable-line */}
<span className="dashicons dashicons-admin-links"></span>
<a href='javascript:void(0);'> {/* eslint-disable-line */}
{ __( 'Restore link to Original', 'distributor' ) }
</a>
</span>
{ isOpen && (
<Modal
title="Restore link to Original"
icon={ pluginIcon }
size={ 50 }
onRequestClose={ closeModal }
className="distributed-modal-popup"
overlayClassName="distributed-modal-overlay"
>
<span id="distributed-data">
{ __( 'Restoring the link to the ', 'distributor' ) }
<a href={ dtGutenberg.postUrl }>
{ __( 'Original Content', 'distributor' ) }
</a>
{ __(
' will start updating this post automatically from the Original, overwriting current content.',
'distributor'
) }
</span>
<div className="actions">
<a href={ dtGutenberg.linkNonceUrl } className="button">
<span className="dashicons dashicons-admin-links"></span>
{ __( 'Restore link', 'distributor' ) }
</a>
<span id="close" onClick={ closeModal } aria-label="Cancel"> {/* eslint-disable-line */}
<a href='javascript:void(0);'> {/* eslint-disable-line */}
{ __( 'Cancel', 'distributor' ) }
</a>
</span>
</div>
</Modal>
) }
</span>
</div>
);
};

Expand All @@ -149,6 +272,17 @@ const DistributorIcon = () => (
<Icon className="components-panel__icon" icon={ pluginIcon } size={ 20 } />
);

/**
* Create the Distributor title
*/
const isUnlinkedContent = parseInt( dtGutenberg.unlinked ) !== 0;

const DistributorTitle = () => {
return isUnlinkedContent
? __( 'Unlinked Content', 'distributor' )
: __( 'Pulled Content', 'distributor' );
};

/**
* Add the Distributor panel to Gutenberg
*/
Expand Down Expand Up @@ -201,7 +335,7 @@ const DistributorPlugin = () => {
distributorTopMenu?.classList.add( 'hide' );
return (
<PluginDocumentSettingPanel
title={ __( 'Distributor', 'distributor' ) }
title={ <DistributorTitle /> }
icon={ DistributorIcon }
className="distributor-panel"
>
Expand All @@ -214,7 +348,7 @@ const DistributorPlugin = () => {
distributorTopMenu?.classList.remove( 'hide' );
return (
<PluginDocumentSettingPanel
title={ __( 'Distributor', 'distributor' ) }
title={ <DistributorTitle /> }
icon={ DistributorIcon }
className="distributor-panel"
>
Expand Down
56 changes: 56 additions & 0 deletions includes/classes/Authentications/WordPressBasicAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,62 @@ class WordPressBasicAuth extends Authentication {
*/
public static $label = 'Username/Password';

/**
* Site URL
*
* @var string
*/
public $site_url;

/**
* Username
*
* @var string
*/
public $username;

/**
* Password
*
* @var string
*/
public $password;

/**
* API Key
*
* @var string
*/
public $client_id;

/**
* API Secret
*
* @var string
*/
public $client_secret;

/**
* Redirect URI
*
* @var string
*/
public $redirect_uri;

/**
* Access Token
*
* @var string
*/
public $base64_encoded;

/**
* Created Post ID
*
* @var string
*/
public $dt_created_post_id;

/**
* Setup class
*
Expand Down
Loading

0 comments on commit 089548a

Please sign in to comment.