Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
… into php8-compat
  • Loading branch information
iamdharmesh committed Apr 8, 2022
2 parents 0cc8eb9 + e44fc2c commit 7b8d269
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 13 deletions.
25 changes: 25 additions & 0 deletions assets/css/admin-autoshare-for-twitter-settings.css
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,31 @@
display: none;
}

.autoshare-settings p.copy-container {
position: relative;
border: 2px #ccc solid;
padding: 10px;
padding-right: 36px;
font-family: monospace;
font-weight: bold;
}

.autoshare-settings p.copy-container a {
position: absolute;
top: 0;
right: 0;
border: 0;
background: #ccc;
padding: 8px;
font-weight: 100;
text-decoration: none;
color: inherit;
}

.autoshare-settings p.copy-container a:hover {
background: #bbb;
}

@media (min-width: 1024px) {
.autoshare-settings {
display: flex;
Expand Down
24 changes: 24 additions & 0 deletions assets/js/admin-autoshare-for-twitter-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,28 @@

} );

jQuery( document ).ready(function() {
jQuery( document ).on( 'click', ".astCopyToClipCard", function( e ) {
e.preventDefault();
$el = jQuery(this);
var text = $el.closest("p.copy-container").find("span.copy-content").first().text();
const $temp_input = jQuery( '<textarea style="opacity:0">' );
jQuery( 'body' ).append( $temp_input );
$temp_input.val( text ).trigger( 'select' );
try {
document.execCommand( 'copy' );
const copyIcon = $el.html();
$el.attr("disabled", "disabled");
$el.text("Copied!");
setTimeout(function(){
$el.html(copyIcon);
$el.removeAttr("disabled");
}, 1000);
} catch ( err ) {
alert("Copy to clipboard failed");
}

$temp_input.remove();
});
});
} )();
78 changes: 66 additions & 12 deletions includes/admin/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,28 +325,82 @@ function cred_section_cb() {
</p>
<?php endif; ?>
<section class="credentials-instructions">
<h4><a href="https://developer.twitter.com/en/apply/user.html" target="_blank"><?php esc_html_e( '1. Apply for a Twitter developer account', 'autoshare-for-twitter' ); ?></a></h4>
<h4><?php esc_html_e( '2. Create a Twitter app for your website', 'autoshare-for-twitter' ); ?></h4>
<h4><a href="https://developer.twitter.com/en/portal/petition/essential/basic-info" target="_blank"><?php esc_html_e( '1. Sign up for a Twitter developer account', 'autoshare-for-twitter' ); ?></a></h4>
<p><?php echo wp_kses_data( 'Once you complete the sign-up onboarding process, you will get your API keys. Copy the <code>API key</code> and <code>API secret key</code> values and paste them below. In case you skipped the onboarding process, you can create a project and an app by following Step 2. Otherwise, please skip Step 2.', 'autoshare-for-twitter' ); ?></p>

<h4><?php esc_html_e( '2. Create a project and create an app for your website.', 'autoshare-for-twitter' ); ?></h4>
<ul>
<li><?php echo wp_kses_data( __( 'Click the <code>Create an app</code> button on the', 'autoshare-for-twitter' ) ); ?> <a href="https://developer.twitter.com/en/apps" title="<?php esc_html_e( 'Twitter develop apps page.', 'autoshare-for-twitter' ); ?>" target="_blank"><?php esc_html_e( 'Twitter developer apps page.', 'autoshare-for-twitter' ); ?></a></li>
<li><?php echo wp_kses_data( __( 'Fill out the <code>App name</code> and <code>Application description</code> fields.', 'autoshare-for-twitter' ) ); ?></li>
<li><?php echo wp_kses_data( __( 'Set the <code>Website URL</code> and <code>Callback URLs</code> fields to https://yourdomain.yourdomainextension.', 'autoshare-for-twitter' ) ); ?></li>
<li><?php echo wp_kses_data( __( 'Fill out the <code>Tell us how this app will be used</code> field. No other fields or URLs are required or necessary.', 'autoshare-for-twitter' ) ); ?></li>
<li><?php echo wp_kses_data( __( 'Click the <code>+ New Project</code> button in the', 'autoshare-for-twitter' ) ); ?> <a href="https://developer.twitter.com/en/portal/dashboard" title="<?php esc_html_e( 'Twitter developer portal', 'autoshare-for-twitter' ); ?>" target="_blank"><?php esc_html_e( 'Twitter developer portal.', 'autoshare-for-twitter' ); ?></a></li>
<li><?php echo wp_kses_data( __( 'Fill out the project name, select the appropriate use-case, and provide a project description to create the project.', 'autoshare-for-twitter' ) ); ?></li>
<li><?php echo wp_kses_data( __( 'Next, you can either create a new App or connect an existing App. Click <code>create a new App instead</code> in order to create a new App.', 'autoshare-for-twitter' ) ); ?></li>
<li><?php echo wp_kses_data( __( 'Fill out the App name. Once you click "complete", you will get your API keys. Copy the <code>API key</code> and <code>API secret key</code> values and paste them below. you can Regenerate these keys any time from the Twitter developer portal.', 'autoshare-for-twitter' ) ); ?></li>
</ul>
<h4><?php esc_html_e( '3. Configure access to your Twitter app API keys', 'autoshare-for-twitter' ); ?></h4>

<h4><?php esc_html_e( '3. Configure access to your Twitter app access tokens', 'autoshare-for-twitter' ); ?></h4>
<ul>
<li><?php echo wp_kses_data( __( 'Click on the <code>Keys and tokens</code> tab within your newly created Twitter developer app.', 'autoshare-for-twitter' ) ); ?></li>
<li><?php echo wp_kses_data( __( 'Copy the <code>API key</code> and <code>API secret key</code> values from your Twitter app <code>Consumer API keys</code> section and paste them below.', 'autoshare-for-twitter' ) ); ?></li>
<li>
<?php
printf(
/* translators: Placeholders %1$s - opening HTML <a> link tag, closing HTML </a> link tag */
wp_kses_data( __( 'Go to the %1$sTwitter developer portal%2$s', 'autoshare-for-twitter' ) ),
'<a href="https://developer.twitter.com/en/portal/dashboard" target="_blank">',
'</a>'
);
?>
</li>
<li><?php esc_html_e( 'Click on Projects & Apps on the left navigation menu.', 'autoshare-for-twitter' ); ?></li>
<li><?php esc_html_e( 'Find the App and click it to show the Settings page for the App.', 'autoshare-for-twitter' ); ?></li>
<li><?php esc_html_e( 'Click "Setup" under User authentication settings to setup Authentication.', 'autoshare-for-twitter' ); ?></li>
<li><?php echo wp_kses_data( 'Enable <code>OAuth 1.0a</code> and Set App permissions to <strong>Read and write</strong>.', 'autoshare-for-twitter' ); ?></li>
<li><?php echo wp_kses_data( 'Set the <code>Website URL</code> and <code>Callback URLs</code> fields to https://yourdomain.yourdomainextension and click <code>Save</code>.', 'autoshare-for-twitter' ); ?></li>
<li><?php esc_html_e( 'Switch from the "Settings" tab to the "Keys and tokens" tab.', 'autoshare-for-twitter' ); ?></li>
<li><?php echo wp_kses_data( __( 'Click on the <code>Generate</code> button in the <code>Access Token and Secret</code> section.', 'autoshare-for-twitter' ) ); ?></li>
<li><?php echo wp_kses_data( __( 'Copy the <code>Access token</code> and <code>Access token secret</code> values and paste them below.', 'autoshare-for-twitter' ) ); ?></li>
</ul>
<h4><?php esc_html_e( '4. Configure access to your Twitter app access tokens', 'autoshare-for-twitter' ); ?></h4>

<h4><?php esc_html_e( '4. Apply for Elevated access.', 'autoshare-for-twitter' ); ?></h4>
<p><?php esc_html_e( 'Twitter has introduced new access levels with Twitter API v2 release which provides quick onboarding to the Essential access level. Optionally, you can apply for additional access levels such as Elevated, Elevated+ and Academic Research access. This plugin, however, requires a minimum accesss level of the Elevated level to work.', 'autoshare-for-twitter' ); ?>
<a href="https://developer.twitter.com/en/docs/twitter-api/getting-started/about-twitter-api#Access" target="_blank"><?php esc_html_e( 'More information.', 'autoshare-for-twitter' ); ?></a></p>
<p><?php esc_html_e( 'To apply for the Elevated access level, you have to perform the following steps:', 'autoshare-for-twitter' ); ?></p>
<ul>
<li><?php echo wp_kses_data( __( 'Click on the <code>Generate</code> button from your Twitter app <code>Access token & access token secret</code> section.', 'autoshare-for-twitter' ) ); ?></li>
<li><?php echo wp_kses_data( __( 'Copy the <code>Access token</code> and <code>Access token secret</code> values and paste them below.', 'autoshare-for-twitter' ) ); ?></li>
<li>
<?php
printf(
/* translators: Placeholders %1$s - opening HTML <a> link tag, closing HTML </a> link tag */
esc_html__( 'Go to Project Page, click on the %1$sApply for Elevated%2$s button.', 'autoshare-for-twitter' ),
'<a href="https://developer.twitter.com/en/portal/petition/standard/basic-info" target="_blank">',
'</a>'
);
?>
</li>
<li><?php echo wp_kses_data( __( 'Fill out the Basic info and click <code>Next</code>', 'autoshare-for-twitter' ) ); ?></li>
<li><?php echo wp_kses_data( __( 'Fill out the <code>In your words</code> field within the <code>How will you use the Twitter API or Twitter Data?</code> section. You can find an example response below.', 'autoshare-for-twitter' ) ); ?>
</li>
<div class="copy-container-wrap">
<p class="copy-container">
<span class="copy-content"><?php esc_html_e( 'I am planning to add an auto-tweet feature on my WordPress website with the help of the Autoshare for Twitter, WordPress plugin. Whenever a new post will be published on the website, this plugin will use the post data to curate and trigger a Tweet.', 'autoshare-for-twitter' ); ?></span>
<a href="#" class="astCopyToClipCard"><span class="dashicons dashicons-clipboard"></span></a>
</p>
</div>
<li><?php echo wp_kses_data( __( 'Choose <strong>No</strong> for <code>Are you planning to analyze Twitter data?</code>', 'autoshare-for-twitter' ) ); ?></li>
<li><?php echo wp_kses_data( __( 'Choose <strong>Yes</strong> for <code>Will your App use Tweet, Retweet, Like, Follow, or Direct Message functionality?</code> and fill out the <code>Please describe your planned use of these features.</code> field. You can find the example response below.', 'autoshare-for-twitter' ) ); ?></li>
<div class="copy-container-wrap">
<p class="copy-container">
<span class="copy-content"><?php esc_html_e( 'Yes, The app will use Tweet functionality to Publish a tweet on Twitter whenever I publish a new post or article on my website.', 'autoshare-for-twitter' ); ?></span>
<a href="#" class="astCopyToClipCard"><span class="dashicons dashicons-clipboard"></span></a>
</p>
</div>
<li><?php echo wp_kses_data( __( 'Choose <strong>No</strong> for <code>Do you plan to display Tweets or aggregate data about Twitter content outside Twitter?</code>', 'autoshare-for-twitter' ) ); ?></li>
<li><?php echo wp_kses_data( __( 'Choose <strong>No</strong> for <code>Will your product, service, or analysis make Twitter content or derived information available to a government entity?</code>', 'autoshare-for-twitter' ) ); ?></li>
<li><?php esc_html_e( 'Review and accept the developer agreement and submit.' ); ?></li>
<li><?php esc_html_e( 'You will be notified with updates about your application on your email address.' ); ?></li>
</ul>

<h4><?php esc_html_e( '5. Confirm Twitter handle', 'autoshare-for-twitter' ); ?></h4>
<ul>
<li><?php esc_html_e( 'Fill out your Twitter handle that will be used to tweet your posts, pages, etc.', 'autoshare-for-twitter' ); ?></li>
</ul>

<h4><?php esc_html_e( '6. Connect your Twitter developer app with this site', 'autoshare-for-twitter' ); ?></h4>
<ul>
<li><?php echo wp_kses_data( __( 'Click the <code>Save Changes</code> button below.', 'autoshare-for-twitter' ) ); ?></li>
Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Contributors: 10up, johnwatkins0, adamsilverstein, scottlee, dinhtungdu
Tags: twitter, tweet, autoshare, auto-share, auto share, share, social media
Requires at least: 4.9
Tested up to: 5.8
Tested up to: 5.9
Requires PHP: 7.2
Stable tag: 1.0.6
License: GPL-2.0-or-later
Expand Down

0 comments on commit 7b8d269

Please sign in to comment.