Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename tenup-auto-tweet -> autotweet #42

Merged
merged 9 commits into from
Sep 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#tenup-auto-tweet_metabox p::before {
#autotweet_metabox p::before {
display: inline-block;
margin-left: -1px;
padding-right: 3px;
Expand All @@ -7,21 +7,21 @@
-moz-osx-font-smoothing: grayscale;
}

#tenup-auto-tweet_metabox pre {
#autotweet_metabox pre {
font-size: 11px;
white-space: normal;
}

#tenup-auto-tweet-icon.pending {
#autotweet-icon.pending {
animation: fadeIn 1s infinite alternate;
color: #00aced;
}

#tenup-auto-tweet-icon.enabled {
#autotweet-icon.enabled {
color: #00aced;
}

#tenup-auto-tweet-icon.disabled {
#autotweet-icon.disabled {
color: #72777c;
}

Expand All @@ -32,23 +32,23 @@
}
}

a#tenup-auto-tweet-edit{
a#autotweet-edit{
color: #0073aa;
text-decoration: underline;
transition-property: border, background, color;
transition-duration: .05s;
transition-timing-function: ease-in-out
}

#tenup-auto-tweet-override-body {
#autotweet-override-body {
margin: 4px 0;
}

textarea#tenup-auto-tweet-text {
textarea#autotweet-text {
margin: 4px 0 0;
width: 100%
}
span#tenup-auto-tweet-counter-wrap{
span#autotweet-counter-wrap{
background: rgba(0, 0, 0, 0.07);
font-family: Consolas, Monaco, monospace;
}
Expand Down
18 changes: 9 additions & 9 deletions assets/js/admin-auto_tweet.js → assets/js/admin-autotweet.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
/**
* Handles the 10up Auto Tweet JS.
* Handles the Autotweet JS.
*
* @todo soooo much dependency :facepalm:
*/
( function( $ ) {
'use strict';

var $tweetPost = $( '#tenup-auto-tweet-enable' ),
$icon = $( '#tenup-auto-tweet-icon' ),
$tweetText = $( '#tenup-auto-tweet-text' ),
$editLink = $( '#tenup-auto-tweet-edit' ),
$editBody = $( '#tenup-auto-tweet-override-body' ),
var $tweetPost = $( '#autotweet-enable' ),
$icon = $( '#autotweet-icon' ),
$tweetText = $( '#autotweet-text' ),
$editLink = $( '#autotweet-edit' ),
$editBody = $( '#autotweet-override-body' ),
$hideLink = $( '.cancel-tweet-text' ),
errorMessageContainer = document.getElementById( 'tenup-autotweet-error-message' ),
counterWrap = document.getElementById( 'tenup-auto-tweet-counter-wrap' ),
errorMessageContainer = document.getElementById( 'autotweet-error-message' ),
counterWrap = document.getElementById( 'autotweet-counter-wrap' ),
limit = 280;

// Add enabled class if checked
Expand All @@ -34,7 +34,7 @@
} );
$hideLink.on( 'click', function( e ) {
e.preventDefault();
$( '#tenup-auto-tweet-override-body' ).slideToggle();
$( '#autotweet-override-body' ).slideToggle();
$editLink.show();
} );

Expand Down
8 changes: 4 additions & 4 deletions tenup-auto-tweet.php → autotweet.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<?php
/**
* Plugin Name: 10up Auto Tweet
* Plugin Name: Autotweet
* Description: Adds the ability to automatically publish a status update to Twitter.
* Version: 0.1.0
* Author: 10up
* Author URI: https://10up.com
* License: GPLv2 or later
*
* @package TenUp\Auto_Tweet
* @package TenUp\AutoTweet
*/

if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}

define( 'TUAT', __FILE__ );
define( 'AUTOTWEET', __FILE__ );
define( 'TUAT_VERSION', '0.1.0' );
define( 'TUAT_URL', plugin_dir_url( __FILE__ ) );
define( 'TUAT_PATH', plugin_dir_path( __FILE__ ) );
Expand All @@ -35,4 +35,4 @@
/**
* Play nice with others.
*/
do_action( 'tenup_auto_tweet_loaded' );
do_action( 'tenup_autotweet_loaded' );
16 changes: 8 additions & 8 deletions includes/admin/assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
* Handles loading of JS and CSS.
*
* @since 1.0.0
* @package TenUp\Auto_Tweet
* @package TenUp\AutoTweet
*/

namespace TenUp\AutoTweet\Admin\Assets;

use function TenUp\Auto_Tweet\Utils\get_autotweet_meta;
use function TenUp\Auto_Tweet\Utils\opted_into_autotweet;
use const TenUp\Auto_Tweet\Core\Post_Meta\ENABLE_AUTOTWEET_KEY;
use const TenUp\Auto_Tweet\Core\Post_Meta\TWEET_BODY_KEY;
use function TenUp\AutoTweet\Utils\get_autotweet_meta;
use function TenUp\AutoTweet\Utils\opted_into_autotweet;
use const TenUp\AutoTweet\Core\Post_Meta\ENABLE_AUTOTWEET_KEY;
use const TenUp\AutoTweet\Core\Post_Meta\TWEET_BODY_KEY;
use function TenUp\AutoTweet\REST\post_autotweet_meta_rest_route;

/**
Expand Down Expand Up @@ -78,18 +78,18 @@ function maybe_enqueue_classic_editor_assets( $hook ) {
);
}

$handle = 'admin_tenup-auto-tweet';
$handle = 'admin_autotweet';
wp_enqueue_script(
$handle,
trailingslashit( TUAT_URL ) . 'assets/js/admin-auto_tweet.js',
trailingslashit( TUAT_URL ) . 'assets/js/admin-autotweet.js',
[ 'jquery', 'wp-api-fetch' ],
TUAT_VERSION,
true
);

wp_enqueue_style(
$handle,
trailingslashit( TUAT_URL ) . 'assets/css/admin-auto_tweet.css',
trailingslashit( TUAT_URL ) . 'assets/css/admin-autotweet.css',
[],
TUAT_VERSION
);
Expand Down
62 changes: 31 additions & 31 deletions includes/admin/post-meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,30 @@
/**
* Responsible for the registration and display of the metabox.
*
* @package TenUp\Auto_Tweet\Core
* @package TenUp\AutoTweet\Core
*/

namespace TenUp\Auto_Tweet\Core\Post_Meta;
namespace TenUp\AutoTweet\Core\Post_Meta;

/**
* Aliases
*/
use TenUp\Auto_Tweet\Utils as Utils;
use function TenUp\Auto_Tweet\Utils\update_autotweet_meta;
use function TenUp\Auto_Tweet\Utils\delete_autotweet_meta;
use TenUp\AutoTweet\Utils as Utils;
use function TenUp\AutoTweet\Utils\update_autotweet_meta;
use function TenUp\AutoTweet\Utils\delete_autotweet_meta;

/**
* The meta prefix that all meta related keys should have
*/
const META_PREFIX = 'tenup-auto-tweet';
const META_PREFIX = 'autotweet';

/**
* Enable auto-tweet checkbox
* Enable autotweet checkbox
*/
const ENABLE_AUTOTWEET_KEY = 'auto-tweet';
const ENABLE_AUTOTWEET_KEY = 'autotweet';

/**
* Holds the auto-tweet boddy
* Holds the autotweet boddy
*/
const TWEET_BODY_KEY = 'tweet-body';

Expand All @@ -43,7 +43,7 @@
*/
function setup() {
add_action( 'post_submitbox_misc_actions', __NAMESPACE__ . '\tweet_submitbox_callback', 15 );
add_action( 'tenup_auto_tweet_metabox', __NAMESPACE__ . '\render_tweet_submitbox', 10, 1 );
add_action( 'tenup_autotweet_metabox', __NAMESPACE__ . '\render_tweet_submitbox', 10, 1 );
add_action( 'save_post', __NAMESPACE__ . '\save_tweet_meta', 10, 1 );
}

Expand Down Expand Up @@ -133,15 +133,15 @@ function save_autotweet_meta_data( $post_id, $data ) {
function tweet_submitbox_callback( $post ) {

/**
* Don't bother enqueuing assets if the post type hasn't opted into auto-tweeting.
* Don't bother enqueuing assets if the post type hasn't opted into autotweeting.
*/
if ( ! Utils\opted_into_autotweet( $post->ID ) ) {
return;
}

?>
<div id="tenup-auto-tweet_metabox" class="misc-pub-section">
<?php do_action( 'tenup_auto_tweet_metabox', $post ); ?>
<div id="autotweet_metabox" class="misc-pub-section">
<?php do_action( 'tenup_autotweet_metabox', $post ); ?>
</div>
<?php
}
Expand Down Expand Up @@ -177,7 +177,7 @@ function render_tweet_submitbox( $post ) {
break;

default:
$output = __( 'This post was not tweeted.', 'tenup_auto_tweet' );
$output = __( 'This post was not tweeted.', 'tenup_autotweet' );
break;
}

Expand Down Expand Up @@ -205,10 +205,10 @@ function markup_published( $status_meta ) {

return sprintf(
'%s <span>%s</span> (<a href="%s" target="_blank">%s</a>)</p>',
esc_html__( 'Tweeted on', 'tenup_auto_tweet' ),
esc_html__( 'Tweeted on', 'tenup_autotweet' ),
esc_html( $date ),
esc_url( $twitter_url ),
esc_html__( 'View', 'tenup_auto_tweet' )
esc_html__( 'View', 'tenup_autotweet' )
);
}

Expand All @@ -224,7 +224,7 @@ function markup_error( $status_meta ) {

return sprintf(
'%s<br><pre>%s</pre></p>',
esc_html__( 'Failed to tweet', 'tenup_auto_tweet' ),
esc_html__( 'Failed to tweet', 'tenup_autotweet' ),
esc_html( $status_meta['message'] )
);
}
Expand All @@ -242,42 +242,42 @@ function markup_unknown( $status_meta ) {
}

/**
* Outputs the <input> markup required to set a post to auto-tweet.
* Outputs the <input> markup required to set a post to autotweet.
*
* @return string
*/
function _safe_markup_default() {

ob_start();
?>
<label for="tenup-auto-tweet-enable">
<label for="autotweet-enable">
<input
type="checkbox"
id="tenup-auto-tweet-enable"
id="autotweet-enable"
name="<?php echo esc_attr( sprintf( '%s[%s]', META_PREFIX, ENABLE_AUTOTWEET_KEY ) ); ?>"
value="1"
<?php checked( Utils\get_autotweet_meta( get_the_ID(), 'auto-tweet' ) ); ?>
<?php checked( Utils\get_autotweet_meta( get_the_ID(), ENABLE_AUTOTWEET_KEY ) ); ?>
>
<span id="tenup-auto-tweet-icon" class="dashicons-before dashicons-twitter"></span>
<?php esc_html_e( 'Tweet this post', 'tenup_auto_tweet' ); ?>
<a href="#edit_tweet_text" id="tenup-auto-tweet-edit"><?php esc_html_e( 'Edit', 'tenup_auto_tweet' ); ?></a>
<span id="autotweet-icon" class="dashicons-before dashicons-twitter"></span>
<?php esc_html_e( 'Tweet this post', 'tenup_autotweet' ); ?>
<a href="#edit_tweet_text" id="autotweet-edit"><?php esc_html_e( 'Edit', 'tenup_autotweet' ); ?></a>
</label>

<div id="tenup-auto-tweet-override-body" style="display: none;">
<div id="autotweet-override-body" style="display: none;">
<label for="<?php echo esc_attr( sprintf( '%s[%s]', META_PREFIX, TWEET_BODY_KEY ) ); ?>">
<?php esc_html_e( 'Custom Message', 'tenup_auto_tweet' ); ?>:
<?php esc_html_e( 'Custom Message', 'tenup_autotweet' ); ?>:
</label>
<span id="tenup-auto-tweet-counter-wrap" class="alignright">0</span>
<span id="autotweet-counter-wrap" class="alignright">0</span>
<textarea
id="tenup-auto-tweet-text"
id="autotweet-text"
name="<?php echo esc_attr( sprintf( '%s[%s]', META_PREFIX, TWEET_BODY_KEY ) ); ?>"
rows="3"
><?php echo esc_textarea( Utils\get_autotweet_meta( get_the_ID(), TWEET_BODY_KEY ) ); ?></textarea>

<p><a href="#" class="hide-if-no-js cancel-tweet-text">Hide</a></p>
</div>

<p id="tenup-autotweet-error-message"></p>
<p id="autotweet-error-message"></p>

<?php
return ob_get_clean();
Expand All @@ -286,6 +286,6 @@ function _safe_markup_default() {
/**
* Fire up the module.
*
* @uses auto_tweet_setup
* @uses autotweet_setup
*/
add_action( 'tenup_auto_tweet_setup', __NAMESPACE__ . '\setup' );
add_action( 'tenup_autotweet_setup', __NAMESPACE__ . '\setup' );
Loading