Example #1
0
function jd_add_twitter_inner_box($post)
{
    if (current_user_can('wpt_can_tweet')) {
        $is_pro = function_exists('wpt_pro_exists') ? 'pro' : 'free';
        echo "<div class='wp-to-twitter {$is_pro}'>";
        global $wpt_donate_url;
        $tweet_status = '';
        $options = get_option('wpt_post_types');
        if (is_object($post)) {
            $type = $post->post_type;
            $status = $post->post_status;
            $post_id = $post->ID;
        }
        $jd_tweet_this = get_post_meta($post_id, '_jd_tweet_this', true);
        if (!$jd_tweet_this) {
            $jd_tweet_this = get_option('jd_tweet_default') == '1' ? 'no' : 'yes';
        }
        if (isset($_GET['action']) && $_GET['action'] == 'edit' && get_option('jd_tweet_default_edit') == '1') {
            $jd_tweet_this = 'no';
        }
        if (isset($_REQUEST['message']) && $_REQUEST['message'] != 10) {
            // don't display when draft is updated or if no message
            if (!($_REQUEST['message'] == 1 && ($status == 'publish' && $options[$type]['post-edited-update'] != 1))) {
                $log = wpt_log('wpt_status_message', $post_id);
                $class = $log != 'Tweet sent successfully.' ? 'error' : 'updated';
                if ($log != '') {
                    echo "<div class='{$class}'><p>" . wpt_log('wpt_status_message', $post_id) . "</p></div>";
                }
            }
        }
        $previous_tweets = get_post_meta($post_id, '_jd_wp_twitter', true);
        $failed_tweets = get_post_meta($post_id, '_wpt_failed');
        $tweet = esc_attr(stripcslashes(get_post_meta($post_id, '_jd_twitter', true)));
        $tweet = apply_filters('wpt_user_text', $tweet, $status);
        $jd_template = $status == 'publish' ? $options[$type]['post-edited-text'] : $options[$type]['post-published-text'];
        if ($status == 'publish' && $options[$type]['post-edited-update'] != 1) {
            $tweet_status = sprintf(__('Tweeting %s edits is disabled.', 'wp-to-twitter'), $type);
        }
        if (current_user_can('update_core') && function_exists('wpt_pro_exists')) {
            wpt_pro_compatibility();
        }
        if ($tweet_status != '') {
            echo "<p class='disabled'>{$tweet_status}</p>";
        }
        if (current_user_can('wpt_twitter_custom') || current_user_can('update_core')) {
            ?>
			<p class='jtw'>
			<label for="jtw"><?php 
            _e("Custom Twitter Post", 'wp-to-twitter', 'wp-to-twitter');
            ?>
</label><br /><textarea class="attachmentlinks" name="_jd_twitter" id="jtw" rows="2" cols="60"><?php 
            echo esc_attr($tweet);
            ?>
</textarea>
			</p>
			<?php 
            $jd_expanded = $jd_template;
            if (get_option('jd_twit_prepend') != "") {
                $jd_expanded = "<span title='" . __('Your prepended Tweet text; not part of your template.', 'wp-to-twitter') . "'>" . stripslashes(get_option('jd_twit_prepend')) . "</span> " . $jd_expanded;
            }
            if (get_option('jd_twit_append') != "") {
                $jd_expanded = $jd_expanded . " <span title='" . __('Your appended Tweet text; not part of your template.', 'wp-to-twitter') . "'>" . stripslashes(get_option('jd_twit_append')) . "</span>";
            }
            ?>
			<p class='template'><?php 
            _e('Your template:', 'wp-to-twitter');
            ?>
 <code><?php 
            echo stripcslashes($jd_expanded);
            ?>
</code></p>
			<?php 
            if (get_option('jd_keyword_format') == 2) {
                $custom_keyword = get_post_meta($post_id, '_yourls_keyword', true);
                echo "<label for='yourls_keyword'>" . __('YOURLS Custom Keyword', 'wp-to-twitter') . "</label> <input type='text' name='_yourls_keyword' id='yourls_keyword' value='{$custom_keyword}' />";
            }
        } else {
            ?>
			<input type="hidden" name='_jd_twitter' value='<?php 
            echo esc_attr($tweet);
            ?>
' />
			<?php 
        }
        if (current_user_can('wpt_twitter_switch') || current_user_can('update_core')) {
            // "no" means 'Don't Tweet' (is checked)
            $nochecked = $jd_tweet_this == 'no' ? ' checked="checked"' : '';
            $yeschecked = $jd_tweet_this == 'yes' ? ' checked="checked"' : '';
            ?>
			<p><input type="radio" name="_jd_tweet_this" value="no" id="jtn"<?php 
            echo $nochecked;
            ?>
 /> <label for="jtn"><?php 
            _e("Don't Tweet this post.", 'wp-to-twitter');
            ?>
</label> <input type="radio" name="_jd_tweet_this" value="yes" id="jty"<?php 
            echo $yeschecked;
            ?>
 /> <label for="jty"><?php 
            _e("Tweet this post.", 'wp-to-twitter');
            ?>
</label></p>
			<?php 
        } else {
            ?>
			<input type='hidden' name='_jd_tweet_this' value='<?php 
            echo $jd_tweet_this;
            ?>
' />
			<?php 
        }
        ?>
		<div class='wpt-options'>
			<?php 
        if ($is_pro == 'pro') {
            $pro_active = " class='active'";
            $free_active = '';
        } else {
            $free_active = " class='active'";
            $pro_active = '';
        }
        ?>
			<ul class='tabs'>
				<li><a href='#authors'<?php 
        echo $pro_active;
        ?>
>Tweet to</a></li>
				<li><a href='#custom'>Options</a></li>
				<li><a href='#notes'<?php 
        echo $free_active;
        ?>
>Notes</a></li>
			</ul>
			<?php 
        /* WPT PRO OPTIONS */
        if (current_user_can('edit_others_posts')) {
            echo "<div class='wptab' id='authors'>";
            if (get_option('jd_individual_twitter_users') == 1) {
                $selected = get_post_meta($post_id, '_wpt_authorized_users', true) ? get_post_meta($post_id, '_wpt_authorized_users', true) : array();
                if (function_exists('wpt_authorized_users')) {
                    echo wpt_authorized_users($selected);
                    do_action('wpt_authors_tab', $post_id, $selected);
                } else {
                    echo "<p>";
                    if (function_exists('wpt_pro_exists')) {
                        printf(__('WP Tweets PRO 1.5.2+ allows you to select Twitter accounts. <a href="%s">Log in and download now!</a>', 'wp-to-twitter'), 'http://www.joedolson.com/articles/account/');
                    } else {
                        printf(__('Upgrade to WP Tweets PRO to select Twitter accounts! <a href="%s">Upgrade now!</a>', 'wp-to-twitter'), 'http://www.joedolson.com/articles/wp-tweets-pro/');
                    }
                    echo "</p>";
                }
            }
            echo "</div>";
        }
        ?>
		<div class='wptab' id='custom'><?php 
        if (function_exists('wpt_pro_exists') && wpt_pro_exists() == true && (current_user_can('wpt_twitter_custom') || current_user_can('update_core'))) {
            wpt_schedule_values($post_id);
            do_action('wpt_custom_tab', $post_id, 'visible');
        } else {
            printf("<p>" . __('Upgrade to WP Tweets PRO to configure options! <a href="%s">Upgrade now!</a>' . "</p>", 'wp-to-twitter'), 'http://www.joedolson.com/articles/wp-tweets-pro/');
        }
        ?>
</div>
		<?php 
        /* WPT PRO */
        if (!current_user_can('wpt_twitter_custom') && !current_user_can('update_core')) {
            ?>
			<div class='wptab' id='custom'>
			<p><?php 
            _e('Access to customizing WP to Twitter values is not allowed for your user role.', 'wp-to-twitter');
            ?>
</p>
			<?php 
            if (function_exists('wpt_pro_exists') && wpt_pro_exists() == true) {
                wpt_schedule_values($post_id, 'hidden');
                do_action('wpt_custom_tab', $post_id, 'hidden');
            }
            ?>
			</div>
			<?php 
        }
        if (current_user_can('wpt_twitter_custom') || current_user_can('update_core')) {
            ?>
			<div class='wptab' id='notes'>
			<p>
			<?php 
            _e("Tweets must be less than 140 characters; Twitter counts URLs as 22 or 23 characters. Template Tags: <code>#url#</code>, <code>#title#</code>, <code>#post#</code>, <code>#category#</code>, <code>#date#</code>, <code>#modified#</code>, <code>#author#</code>, <code>#account#</code>, <code>#tags#</code>, or <code>#blog#</code>.", 'wp-to-twitter');
            do_action('wpt_notes_tab', $post_id);
            ?>
 
			</p>
			</div>
			<?php 
        }
        ?>
		</div>		
		<p class="wpt-support">
		<?php 
        if (!function_exists('wpt_pro_exists')) {
            ?>
			<a target="_blank" href="<?php 
            echo admin_url('options-general.php?page=wp-to-twitter/wp-to-twitter.php');
            ?>
#get-support"><?php 
            _e('Get Support', 'wp-to-twitter', 'wp-to-twitter');
            ?>
</a> &bull; <strong><a target="__blank" href="<?php 
            echo $wpt_donate_url;
            ?>
"><?php 
            _e('Upgrade to WP Tweets Pro', 'wp-to-twitter', 'wp-to-twitter');
            ?>
</a></strong> &raquo;
		<?php 
        } else {
            ?>
			<a target="_blank" href="<?php 
            echo admin_url('admin.php?page=wp-tweets-pro');
            ?>
#get-support"><?php 
            _e('Get Support', 'wp-to-twitter', 'wp-to-twitter');
            ?>
</a> &raquo;
		<?php 
        }
        ?>
		</p>
		<?php 
        wpt_show_tweets($previous_tweets, $failed_tweets);
        ?>
		</div>
		<?php 
    } else {
        // permissions: this user isn't allowed to Tweet;
        _e('Your role does not have the ability to Post Tweets from this site.', 'wp-to-twitter');
        ?>
 <input type='hidden' name='_jd_tweet_this' value='no' /> <?php 
    }
}
function wpt_update_settings()
{
    ?>
	<div class="wrap" id="wp-to-twitter">
	<?php 
    if (defined('WPT_STAGING_MODE') && WPT_STAGING_MODE == true) {
        echo "<div class='updated notice'><p>" . __('WP to Twitter is in staging mode. Tweets will be reported as if successfully sent to Twitter but will not be sent.', 'wp-to-twitter') . "</p></div>";
    }
    wpt_updated_settings();
    wpt_show_last_tweet();
    wpt_handle_errors();
    wpt_show_debug();
    ?>
	<?php 
    $elem = version_compare('4.3', get_option('version'), '>=') ? 'h1' : 'h2';
    ?>
	<<?php 
    echo $elem;
    ?>
><?php 
    _e("WP to Twitter Options", 'wp-to-twitter');
    ?>
</<?php 
    echo $elem;
    ?>
>
	
	<div class='nav-tab-wrapper'>
		<?php 
    wpt_settings_tabs();
    ?>
	</div>
	<div id="wpt_settings_page" class="postbox-container jcd-wide">
	<div class="metabox-holder">

	<?php 
    $default = get_option('wtt_twitter_username') == '' ? 'connection' : 'basic';
    $current = isset($_GET['tab']) ? $_GET['tab'] : $default;
    if ($current == 'connection') {
        if (function_exists('wtt_connect_oauth')) {
            wtt_connect_oauth();
        }
    }
    if ($current == 'pro') {
        if (function_exists('wpt_pro_functions')) {
            wpt_pro_functions();
            if (function_exists('wpt_notes')) {
                wpt_notes();
            }
        } else {
            if (!function_exists('wpt_pro_exists')) {
                ?>
				<div class="ui-sortable meta-box-sortables">
					<div class="postbox">
						<h3 class='wpt-upgrade'><span><strong><?php 
                _e('Upgrade Now!', 'wp-to-twitter');
                ?>
</strong></span>
						</h3>

						<div class="inside purchase">
							<p>
								<?php 
                _e('<strong>What can WP Tweets PRO do for you?</strong> It takes the great Tweeting abilities from WP to Twitter and puts them in high gear: publish to unique Twitter accounts for every site author; schedule up to 3 re-posts of Tweets at an interval of your choice; and, with a delay between publishing and Tweeting, verify your tweets before you share them with your followers.', 'wp-to-twitter');
                ?>
							</p>
							<p class='wpt-button'>
								<strong class='cta'><a href="https://www.joedolson.com/wp-tweets-pro/"><?php 
                _e('Upgrade to <strong>WP Tweets PRO</strong>!', 'wp-to-twitter');
                ?>
</a></strong>
							</p>	
							
							<h4><?php 
                _e('What does WP Tweets PRO do?', 'wp-to-twitter');
                ?>
</h4>
							
							<p>
								<?php 
                _e('WP Tweets PRO is packed with features to help you increase engagement with your Twitter followers. Upload images, support for Twitter Cards, and automated re-posting of your Tweets are just a few of the features available in the premium add-on to WP to Twitter.', 'wp-to-twitter');
                ?>
							</p>
							
							<h4><?php 
                _e('Guy Kawasaki recommends WP to Twitter', 'wp-to-twitter');
                ?>
</h4>
							
							<blockquote class="twitter-tweet" lang="en"><p>WP to Twitter = best Wordpress plugin according to <a href="https://twitter.com/GuyKawasaki">@GuyKawasaki</a> <a href="https://twitter.com/hashtag/SMMW15?src=hash">#SMMW15</a></p>&mdash; Cision (@Cision) <a href="https://twitter.com/Cision/status/581170603224371200">March 26, 2015</a></blockquote>
							<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>
							
							<p class='wpt-button'>
								<strong class='cta'><a href="https://www.joedolson.com/wp-tweets-pro/"><?php 
                _e('Buy WP Tweets PRO today!', 'wp-to-twitter');
                ?>
</a></strong>
							</p>
							
						</div>
					</div>
				</div>
			<?php 
            }
        }
    }
    if ($current == 'basic') {
        ?>
	<div class="ui-sortable meta-box-sortables">
		<div class="postbox">
			<h3><span><?php 
        _e('Status Update Templates', 'wp-to-twitter');
        ?>
</span></h3>

			<div class="inside wpt-settings">
				<form method="post" action="">
					<?php 
        $nonce = wp_nonce_field('wp-to-twitter-nonce', '_wpnonce', true, false) . wp_referer_field(false);
        echo "<div>{$nonce}</div>";
        ?>
					<div>
						<?php 
        echo apply_filters('wpt_pick_shortener', '');
        ?>
						<?php 
        $post_types = get_post_types(array('public' => true), 'objects');
        $wpt_settings = get_option('wpt_post_types');
        $tabs = "<ul class='tabs' role='tablist'>";
        foreach ($post_types as $type) {
            $name = $type->labels->name;
            $slug = $type->name;
            if ($slug == 'attachment' || $slug == 'nav_menu_item' || $slug == 'revision') {
            } else {
                $tabs .= "<li><a href='#wpt_{$slug}' role='tab' id='tab_wpt_{$slug}' aria-controls='wpt_{$slug}'>{$name}</a></li>";
            }
        }
        $tabs .= "<li><a href='#wpt_links' id='tab_wpt_links' aria-controls='wpt_links'>" . __('Links', 'wp-to-twitter') . "</a></li>\r\n\t\t\t</ul>";
        echo $tabs;
        foreach ($post_types as $type) {
            $name = $type->labels->name;
            $singular = $type->labels->singular_name;
            $slug = $type->name;
            if ($slug == 'attachment' || $slug == 'nav_menu_item' || $slug == 'revision') {
                continue;
            } else {
                $vowels = array('a', 'e', 'i', 'o', 'u');
                foreach ($vowels as $vowel) {
                    if (strpos($name, $vowel) === 0) {
                        $word = 'an';
                        break;
                    } else {
                        $word = 'a';
                    }
                }
                ?>
	
								<div class='wptab wpt_types wpt_<?php 
                echo $slug;
                ?>
' aria-labelledby='tab_wpt_<?php 
                echo $slug;
                ?>
' role="tabpanel" id='wpt_<?php 
                echo $slug;
                ?>
'>
									<?php 
                // share information about any usage of pre 2.8 category filters
                if (get_option('limit_categories') != '0' && $slug == 'post') {
                    $falseness = get_option('jd_twit_cats');
                    $categories = get_option('tweet_categories');
                    if ($falseness == 1) {
                        echo "<p>" . __('These categories are currently <strong>excluded</strong> by the deprecated WP to Twitter category filters.', 'wp-to-twitter') . "</p>";
                    } else {
                        echo "<p>" . __('These categories are currently <strong>allowed</strong> by the deprecated WP to Twitter category filters.', 'wp-to-twitter') . "</p>";
                    }
                    echo "<ul>";
                    if (is_array($categories)) {
                        foreach ($categories as $cat) {
                            $category = get_the_category_by_ID($cat);
                            echo "<li>{$category}</li>";
                        }
                    }
                    echo "</ul>";
                    if (!function_exists('wpt_pro_exists')) {
                        printf(__('<a href="%s">Upgrade to WP Tweets PRO</a> to filter posts in all custom post types on any taxonomy.', 'wp-to-twitter'), "https://www.joedolson.com/wp-tweets-pro/");
                    } else {
                        _e('Updating the WP Tweets PRO taxonomy filters will overwrite your old category filters.', 'wp-to-twitter');
                    }
                }
                ?>
									<fieldset>
										<legend><span><?php 
                echo $name;
                ?>
</span></legend>
										<p>
											<input type="checkbox"
											       name="wpt_post_types[<?php 
                echo $slug;
                ?>
][post-published-update]"
											       id="<?php 
                echo $slug;
                ?>
-post-published-update"
											       value="1" <?php 
                echo jd_checkCheckbox('wpt_post_types', $slug, 'post-published-update');
                ?>
 />
											<label
												for="<?php 
                echo $slug;
                ?>
-post-published-update"><strong><?php 
                printf(__('Update when %1$s %2$s is published', 'wp-to-twitter'), $word, $singular);
                ?>
</strong></label>
											<label
												for="<?php 
                echo $slug;
                ?>
-post-published-text"><br/><?php 
                printf(__('Template for new %1$s updates', 'wp-to-twitter'), $name);
                ?>
											</label><br/><textarea class="wpt-template"
											                       name="wpt_post_types[<?php 
                echo $slug;
                ?>
][post-published-text]"
											                       id="<?php 
                echo $slug;
                ?>
-post-published-text"
											                       cols="60"
											                       rows="3"><?php 
                if (isset($wpt_settings[$slug])) {
                    echo esc_attr(stripslashes($wpt_settings[$slug]['post-published-text']));
                }
                ?>
</textarea>
										</p>

										<p>
											<input type="checkbox"
											       name="wpt_post_types[<?php 
                echo $slug;
                ?>
][post-edited-update]"
											       id="<?php 
                echo $slug;
                ?>
-post-edited-update"
											       value="1" <?php 
                echo jd_checkCheckbox('wpt_post_types', $slug, 'post-edited-update');
                ?>
 />
											<label
												for="<?php 
                echo $slug;
                ?>
-post-edited-update"><strong><?php 
                printf(__('Update when %1$s %2$s is edited', 'wp-to-twitter'), $word, $singular);
                ?>
</strong></label><br/><label
												for="<?php 
                echo $slug;
                ?>
-post-edited-text"><?php 
                printf(__('Template for %1$s editing updates', 'wp-to-twitter'), $name);
                ?>
</label><br/><textarea
												class="wpt-template"
												name="wpt_post_types[<?php 
                echo $slug;
                ?>
][post-edited-text]"
												id="<?php 
                echo $slug;
                ?>
-post-edited-text" cols="60"
												rows="3"><?php 
                if (isset($wpt_settings[$slug])) {
                    echo esc_attr(stripslashes($wpt_settings[$slug]['post-edited-text']));
                }
                ?>
</textarea>
										</p>
									</fieldset>
									<?php 
                if (function_exists('wpt_list_terms')) {
                    wpt_list_terms($slug, $name);
                }
                ?>
								</div>
							<?php 
            }
        }
        ?>
						<div class='wptab wpt_types wpt_links' id="wpt_links">
							<fieldset>
								<legend><span><?php 
        _e('Links', 'wp-to-twitter');
        ?>
</span></legend>
								<p>
									<input type="checkbox" name="jd_twit_blogroll" id="jd_twit_blogroll"
									       value="1" <?php 
        echo jd_checkCheckbox('jd_twit_blogroll');
        ?>
 />
									<label
										for="jd_twit_blogroll"><strong><?php 
        _e("Update Twitter when you post a Blogroll link", 'wp-to-twitter');
        ?>
</strong></label><br/>
									<label
										for="newlink-published-text"><?php 
        _e("Text for new link updates:", 'wp-to-twitter');
        ?>
</label>
									<input aria-describedby="newlink-published-text-label" type="text"
									       class="wpt-template" name="newlink-published-text"
									       id="newlink-published-text" size="60" maxlength="120"
									       value="<?php 
        esc_attr_e(stripslashes(get_option('newlink-published-text')));
        ?>
"/><br/><span
										id="newlink-published-text-label"><?php 
        _e('Available shortcodes: <code>#url#</code>, <code>#title#</code>, and <code>#description#</code>.', 'wp-to-twitter');
        ?>
</span>
								</p>
							</fieldset>
						</div>
						<br class='clear'/>

						<div>
							<input type="hidden" name="submit-type" value="options"/>
						</div>
						<input type="submit" name="submit"
						       value="<?php 
        _e("Save WP to Twitter Options", 'wp-to-twitter');
        ?>
"
						       class="button-primary"/>
					</div>
				</form>
			</div>
		</div>
	</div>
	
	<div class="ui-sortable meta-box-sortables">
			<div class="postbox">
				<h3><span><?php 
        _e('Tweet Template Tags', 'wp-to-twitter');
        ?>
</span></h3>

				<div class="inside">
					<ul>
						<li><?php 
        _e("<code>#title#</code>: the title of your blog post", 'wp-to-twitter');
        ?>
</li>
						<li><?php 
        _e("<code>#blog#</code>: the title of your blog", 'wp-to-twitter');
        ?>
</li>
						<li><?php 
        _e("<code>#post#</code>: a short excerpt of the post content", 'wp-to-twitter');
        ?>
</li>
						<li><?php 
        _e("<code>#category#</code>: the first selected category for the post", 'wp-to-twitter');
        ?>
</li>
						<li><?php 
        _e("<code>#cat_desc#</code>: custom value from the category description field", 'wp-to-twitter');
        ?>
</li>
						<li><?php 
        _e("<code>#date#</code>: the post date", 'wp-to-twitter');
        ?>
</li>
						<li><?php 
        _e("<code>#modified#</code>: the post modified date", 'wp-to-twitter');
        ?>
</li>
						<li><?php 
        _e("<code>#url#</code>: the post URL", 'wp-to-twitter');
        ?>
</li>
						<li><?php 
        _e("<code>#longurl#</code>: the unshortened post URL", 'wp-to-twitter');
        ?>
</li>
						<li><?php 
        _e("<code>#author#</code>: the post author (@reference if available, otherwise display name)", 'wp-to-twitter');
        ?>
</li>
						<li><?php 
        _e("<code>#displayname#</code>: post author's display name", 'wp-to-twitter');
        ?>
</li>
						<li><?php 
        _e("<code>#account#</code>: the twitter @reference for the account (or the author, if author settings are enabled and set.)", 'wp-to-twitter');
        ?>
</li>
						<li><?php 
        _e("<code>#@#</code>: the twitter @reference for the author or blank, if not set", 'wp-to-twitter');
        ?>
</li>
						<li><?php 
        _e("<code>#tags#</code>: your tags modified into hashtags. See options in the Advanced Settings section, below.", 'wp-to-twitter');
        ?>
</li>
						<?php 
        if (function_exists('wpt_pro_exists') && wpt_pro_exists() == true) {
            ?>
							<li><?php 
            _e("<code>#reference#</code>: Used only in co-tweeting. @reference to main account when posted to author account, @reference to author account in post to main account.", 'wp-to-twitter');
            ?>
</li>
						<?php 
        }
        ?>
					</ul>
					<p>
					<?php 
        _e("Create custom shortcodes and access WordPress custom fields by using square brackets and the name of your custom field.", 'wp-to-twitter');
        ?>
					<br />
					<?php 
        _e("<strong>Example:</strong> <code>[[custom_field]]</code>", 'wp-to-twitter');
        ?>
					</p>
				</div>
			</div>
		</div>	
	<?php 
    }
    if ($current == 'shortener') {
        echo apply_filters('wpt_shortener_controls', '');
    }
    if ($current == 'advanced') {
        ?>
	<div class="ui-sortable meta-box-sortables">
		<div class="postbox">
			<h3><span><?php 
        _e('Advanced Settings', 'wp-to-twitter');
        ?>
</span></h3>

			<div class="inside">
				<form method="post" action="">
					<div>
						<?php 
        $nonce = wp_nonce_field('wp-to-twitter-nonce', '_wpnonce', true, false) . wp_referer_field(false);
        echo "<div>{$nonce}</div>";
        ?>

						<fieldset>
							<legend><?php 
        _e('Tags', 'wp-to-twitter');
        ?>
</legend>
							<p>
								<input type="checkbox" name="jd_strip_nonan" id="jd_strip_nonan"
								       value="1" <?php 
        echo jd_checkCheckbox('jd_strip_nonan');
        ?>
 /> <label
									for="jd_strip_nonan"><?php 
        _e("Strip nonalphanumeric characters from tags", 'wp-to-twitter');
        ?>
</label>
							</p>

							<p>
								<input type="checkbox" name="wpt_tag_source" id="wpt_tag_source"
								       value="slug" <?php 
        echo jd_checkSelect('wpt_tag_source', 'slug', 'checkbox');
        ?>
 />
								<label
									for="wpt_tag_source"><?php 
        _e("Use tag slug as hashtag value", 'wp-to-twitter');
        ?>
</label><br/>
							</p>

							<p>
								<label
									for="jd_replace_character"><?php 
        _e("Spaces in tags replaced with:", 'wp-to-twitter');
        ?>
</label>
								<input type="text" name="jd_replace_character" id="jd_replace_character"
								       value="<?php 
        esc_attr_e(get_option('jd_replace_character'));
        ?>
"
								       size="3"/>
							</p>

							<p>
								<label
									for="jd_max_tags"><?php 
        _e("Maximum number of tags to include:", 'wp-to-twitter');
        ?>
</label>
								<input aria-describedby="jd_max_characters_label" type="text" name="jd_max_tags"
								       id="jd_max_tags" value="<?php 
        esc_attr_e(get_option('jd_max_tags'));
        ?>
"
								       size="3"/>
								<label
									for="jd_max_characters"><?php 
        _e("Maximum length in characters for included tags:", 'wp-to-twitter');
        ?>
</label>
								<input type="text" name="jd_max_characters" id="jd_max_characters"
								       value="<?php 
        esc_attr_e(get_option('jd_max_characters'));
        ?>
" size="3"/>
							</p>
						</fieldset>
						<fieldset>
							<legend><?php 
        _e('Template Tag Settings', 'wp-to-twitter');
        ?>
</legend>
							<p>
								<label
									for="jd_post_excerpt"><?php 
        _e("Length of post excerpt (in characters):", 'wp-to-twitter');
        ?>
</label>
								<input type="text" name="jd_post_excerpt" id="jd_post_excerpt" size="3" maxlength="3" value="<?php 
        echo esc_attr(get_option('jd_post_excerpt'));
        ?>
"/>
							</p>

							<p>
								<label
									for="jd_date_format"><?php 
        _e("WP to Twitter Date Formatting:", 'wp-to-twitter');
        ?>
</label>
								<input type="text" aria-describedby="date_format_label" name="jd_date_format"
								       id="jd_date_format" size="12" maxlength="12"
								       value="<?php 
        if (get_option('jd_date_format') == '') {
            echo esc_attr(stripslashes(get_option('date_format')));
        } else {
            echo esc_attr(get_option('jd_date_format'));
        }
        ?>
"/> <?php 
        if (get_option('jd_date_format') != '') {
            echo date_i18n(get_option('jd_date_format'));
        } else {
            echo "<em>" . date_i18n(get_option('date_format')) . "</em>";
        }
        ?>
 (<em
									id="date_format_label"><a href='http://codex.wordpress.org/Formatting_Date_and_Time'><?php 
        _e("Date Formatting", 'wp-to-twitter');
        ?>
</a></em>)
							</p>

							<p>
								<label
									for="jd_twit_prepend"><?php 
        _e("Custom text before all Tweets:", 'wp-to-twitter');
        ?>
</label>
								<input type="text" name="jd_twit_prepend" id="jd_twit_prepend" size="20"
								       value="<?php 
        esc_attr_e(stripslashes(get_option('jd_twit_prepend')));
        ?>
"/>
							</p>

							<p>
								<label
									for="jd_twit_append"><?php 
        _e("Custom text after all Tweets:", 'wp-to-twitter');
        ?>
</label>
								<input type="text" name="jd_twit_append" id="jd_twit_append" size="20"
								       value="<?php 
        esc_attr_e(stripslashes(get_option('jd_twit_append')));
        ?>
"/>
							</p>

							<p>
								<label
									for="jd_twit_custom_url"><?php 
        _e("Custom field for an alternate URL to be shortened and Tweeted:", 'wp-to-twitter');
        ?>
</label>
								<input type="text" name="jd_twit_custom_url" id="jd_twit_custom_url" size="40"
								       maxlength="120"
								       value="<?php 
        esc_attr_e(stripslashes(get_option('jd_twit_custom_url')));
        ?>
"/>
							</p>
						</fieldset>

						<?php 
        $inputs = '';
        $default_order = array('excerpt' => 0, 'title' => 1, 'date' => 2, 'category' => 3, 'blogname' => 4, 'author' => 5, 'account' => 6, 'tags' => 7, 'modified' => 8, '@' => 9, 'cat_desc' => 10);
        $preferred_order = get_option('wpt_truncation_order');
        if (!$preferred_order) {
            $preferred_order = array();
        }
        $preferred_order = array_merge($default_order, $preferred_order);
        if (is_array($preferred_order)) {
            $default_order = $preferred_order;
        }
        asort($default_order);
        foreach ($default_order as $k => $v) {
            $label = '<code>#' . $k . '#</code>';
            $inputs .= "<div class='wpt-truncate'><label for='{$k}-{$v}'>{$label}</label><br /><input type='number' size='3' value='{$v}' name='wpt_truncation_order[{$k}]' /></div> ";
        }
        ?>
						<fieldset>
							<legend><?php 
        _e('Template tag priority order', 'wp-to-twitter');
        ?>
</legend>
							<p><?php 
        _e('The order in which items will be abbreviated or removed from your Tweet if the Tweet is too long to send to Twitter.', 'wp-to-twitter');
        ?>
 <?php 
        _e('Tags with lower values will be modified first.', 'wp-to-twitter');
        ?>
</p>
							<p>
								<?php 
        echo $inputs;
        ?>
							</p>
						</fieldset>
						<fieldset>
							<legend id="special_cases"><?php 
        _e("Special Cases", 'wp-to-twitter');
        ?>
</legend>
							<p>
								<input type="checkbox" name="jd_tweet_default" id="jd_tweet_default"
								       value="1" <?php 
        echo jd_checkCheckbox('jd_tweet_default');
        ?>
 />
								<label
									for="jd_tweet_default"><?php 
        _e("Do not post Tweets by default", 'wp-to-twitter');
        ?>
</label><br/>
								<input type="checkbox" name="jd_tweet_default_edit" id="jd_tweet_default_edit"
								       value="1" <?php 
        echo jd_checkCheckbox('jd_tweet_default_edit');
        ?>
 />
								<label
									for="jd_tweet_default_edit"><?php 
        _e("Do not post Tweets by default (editing only)", 'wp-to-twitter');
        ?>
</label><br/>
								<input type="checkbox" name="wpt_inline_edits" id="wpt_inline_edits"
								       value="1" <?php 
        echo jd_checkCheckbox('wpt_inline_edits');
        ?>
 />
								<label
									for="wpt_inline_edits"><?php 
        _e("Allow status updates from Quick Edit", 'wp-to-twitter');
        ?>
</label><br/>
								<input type="checkbox" name="wpt_rate_limiting" id="wpt_rate_limiting"
								       value="1" <?php 
        echo jd_checkCheckbox('wpt_rate_limiting');
        ?>
 />
								<label
									for="wpt_rate_limiting"><?php 
        _e("Enable Rate Limiting", 'wp-to-twitter');
        ?>
</label><br/>
								<?php 
        if (get_option('wpt_rate_limiting') == 1) {
            ?>
								<input type="number" name="wpt_default_rate_limit" min="1" id="wpt_default_rate_limit"
								       value="<?php 
            echo wpt_default_rate_limit();
            ?>
" />
								<label
									for="wpt_default_rate_limit"><?php 
            _e("Default Rate Limit per category per hour", 'wp-to-twitter');
            ?>
</label><br/>							
									<?php 
        }
        ?>
							</p>
						</fieldset>
						<fieldset>
							<legend><?php 
        _e("Google Analytics Settings", 'wp-to-twitter');
        ?>
</legend>

							<p>
								<input type="radio" name="twitter-analytics" id="use-twitter-analytics"
								       value="1" <?php 
        echo jd_checkCheckbox('use-twitter-analytics');
        ?>
 />
								<label
									for="use-twitter-analytics"><?php 
        _e("Use a Static Identifier", 'wp-to-twitter');
        ?>
</label><br/>
								<label
									for="twitter-analytics-campaign"><?php 
        _e("Static Campaign identifier", 'wp-to-twitter');
        ?>
</label>
								<input type="text" name="twitter-analytics-campaign" id="twitter-analytics-campaign"
								       size="40" maxlength="120"
								       value="<?php 
        esc_attr_e(get_option('twitter-analytics-campaign'));
        ?>
"/><br/>
							</p>

							<p>
								<input type="radio" name="twitter-analytics" id="use-dynamic-analytics"
								       value="2" <?php 
        echo jd_checkCheckbox('use_dynamic_analytics');
        ?>
 />
								<label
									for="use-dynamic-analytics"><?php 
        _e("Use a dynamic identifier", 'wp-to-twitter');
        ?>
</label><br/>
								<label
									for="jd-dynamic-analytics"><?php 
        _e("What dynamic identifier would you like to use?", "wp-to-twitter");
        ?>
</label>
								<select name="jd-dynamic-analytics" id="jd-dynamic-analytics">
									<option
										value="post_category"<?php 
        echo jd_checkSelect('jd_dynamic_analytics', 'post_category');
        ?>
><?php 
        _e("Category", "wp-to-twitter");
        ?>
</option>
									<option
										value="post_ID"<?php 
        echo jd_checkSelect('jd_dynamic_analytics', 'post_ID');
        ?>
><?php 
        _e("Post ID", "wp-to-twitter");
        ?>
</option>
									<option
										value="post_title"<?php 
        echo jd_checkSelect('jd_dynamic_analytics', 'post_title');
        ?>
><?php 
        _e("Post Title", "wp-to-twitter");
        ?>
</option>
									<option
										value="post_author"<?php 
        echo jd_checkSelect('jd_dynamic_analytics', 'post_author');
        ?>
><?php 
        _e("Author", "wp-to-twitter");
        ?>
</option>
								</select><br/>
							</p>
							<p>
								<input type="radio" name="twitter-analytics" id="no-analytics"
								       value="3" <?php 
        echo jd_checkCheckbox('no-analytics');
        ?>
 /> <label
									for="no-analytics"><?php 
        _e("No Analytics", 'wp-to-twitter');
        ?>
</label>
							</p>
						</fieldset>
						<fieldset id="indauthors">
							<legend><?php 
        _e('Author Settings', 'wp-to-twitter');
        ?>
</legend>
							<p>
								<input type="checkbox" name="jd_individual_twitter_users" id="jd_individual_twitter_users"
								       value="1" <?php 
        echo jd_checkCheckbox('jd_individual_twitter_users');
        ?>
 />
								<label
									for="jd_individual_twitter_users"><?php 
        _e("Authors have individual Twitter accounts", 'wp-to-twitter');
        ?>
</label>
							</p>

						</fieldset>
						<div class='wpt-permissions'>
							<fieldset>
								<legend><?php 
        _e('Permissions', 'wp-to-twitter');
        ?>
</legend>
								<?php 
        global $wp_roles;
        $roles = $wp_roles->get_names();
        $caps = array('wpt_can_tweet' => __('Can send Tweets', 'wp-to-twitter'), 'wpt_twitter_custom' => __('See Custom Tweet Field when creating a Post', 'wp-to-twitter'), 'wpt_twitter_switch' => __('Toggle the Tweet/Don\'t Tweet option', 'wp-to-twitter'), 'wpt_tweet_now' => __('Can see Tweet Now button', 'wp-to-twitter'), 'wpt_twitter_oauth' => __('Add Twitter Information to User Profile', 'wp-to-twitter'));
        $role_tabs = $role_container = '';
        foreach ($roles as $role => $rolename) {
            if ($role == 'administrator') {
                continue;
            }
            $role_tabs .= "<li><a href='#wpt_{$role}'>{$rolename}</a></li>\n";
            $role_container .= "<div class='wptab wpt_{$role}' id='wpt_{$role}' aria-live='assertive'><fieldset id='wpt_{$role}' class='roles'><legend>{$rolename}</legend>";
            $role_container .= "<input type='hidden' value='none' name='wpt_caps[" . $role . "][none]' />\r\n\t\t\t<ul class='wpt-settings checkboxes'>";
            foreach ($caps as $cap => $name) {
                $role_container .= wpt_cap_checkbox($role, $cap, $name);
            }
            $role_container .= "\r\n\t\t\t</ul></fieldset></div>\n";
        }
        echo "\r\n\t\t<ul class='tabs'>\r\n\t\t\t{$role_tabs}\r\n\t\t</ul>\r\n\t\t{$role_container}";
        ?>
							</fieldset>
						</div>
						<fieldset>
							<legend><?php 
        _e('Error Messages and Debugging', 'wp-to-twitter');
        ?>
</legend>
							<ul>
								<li><input type="checkbox" name="wpt_permit_feed_styles" id="wpt_permit_feed_styles"
								           value="1" <?php 
        echo jd_checkCheckbox('wpt_permit_feed_styles');
        ?>
 />
									<label
										for="wpt_permit_feed_styles"><?php 
        _e("Disable Twitter Feed Stylesheet", 'wp-to-twitter');
        ?>
</label>
								</li>
								<li><input type="checkbox" name="wp_debug_oauth" id="wp_debug_oauth"
								           value="1" <?php 
        echo jd_checkCheckbox('wp_debug_oauth');
        ?>
 /> <label
										for="wp_debug_oauth"><?php 
        _e("Get Debugging Data for OAuth Connection", 'wp-to-twitter');
        ?>
</label>
								</li>
								<li><input type="checkbox" name="jd_donations" id="jd_donations"
								           value="1" <?php 
        echo jd_checkCheckbox('jd_donations');
        ?>
 /> <label
										for="jd_donations"><strong><?php 
        _e("I made a donation, so stop whinging at me, please.", 'wp-to-twitter');
        ?>
</strong></label>
								</li>
							</ul>
						</fieldset>
						<div>
							<input type="hidden" name="submit-type" value="advanced"/>
						</div>
						<input type="submit" name="submit"
						       value="<?php 
        _e("Save Advanced WP to Twitter Options", 'wp-to-twitter');
        ?>
"
						       class="button-primary"/>
					</div>
				</form>
			</div>
		</div>
	</div>
	<?php 
    }
    if ($current == 'support') {
        ?>
	<div class="postbox" id="get-support">
		<h3><span><?php 
        _e('Get Plug-in Support', 'wp-to-twitter');
        ?>
</span></h3>

		<div class="inside">
			<?php 
        wpt_get_support_form();
        ?>
		</div>
	</div>
	<?php 
    }
    ?>
	<p>
		<?php 
    _e('Check whether WP to Twitter is setup correctly for Twitter and your URL Shortener. The test sends a status update to Twitter and shortens a URL using your chosen shortener.', 'wp-to-twitter');
    ?>
	</p>
	<form method="post" action="">
		<fieldset>
			<input type="hidden" name="submit-type" value="check-support"/>
			<?php 
    $nonce = wp_nonce_field('wp-to-twitter-nonce', '_wpnonce', true, false) . wp_referer_field(false);
    echo "<div>{$nonce}</div>";
    ?>
			<p>
				<input type="submit" name="submit" value="<?php 
    _e('Test WP to Twitter', 'wp-to-twitter');
    ?>
" class="button-primary" />
			</p>
		</fieldset>
	</form>
	</div>
	</div>
	<?php 
    wpt_sidebar();
    ?>
	</div>
	</div>
	<?php 
}
Example #3
0
/**
 * Handle Tweets sent via Ajax Tweet Now/Schedule Tweet buttons.
 *
 * @return string Confirmation message indicating success or failure of Tweeting.
 */
function wpt_ajax_tweet()
{
    if (!check_ajax_referer('wpt-tweet-nonce', 'security', false)) {
        echo "Invalid Security Check";
        die;
    }
    $action = $_REQUEST['tweet_action'] == 'tweet' ? 'tweet' : 'schedule';
    // This isn't used right now, because of time.
    $authors = isset($_REQUEST['tweet_auth']) && $_REQUEST['tweet_auth'] != null ? $_REQUEST['tweet_auth'] : false;
    $current_user = wp_get_current_user();
    if (function_exists('wpt_pro_exists') && wpt_pro_exists()) {
        if (wtt_oauth_test($current_user->ID, 'verify')) {
            $auth = $user_ID = $current_user->ID;
        } else {
            $auth = false;
            $user_ID = $current_user->ID;
        }
    } else {
        $auth = false;
        $user_ID = $current_user->ID;
    }
    if (current_user_can('wpt_can_tweet')) {
        $options = get_option('wpt_post_types');
        $post_ID = intval($_REQUEST['tweet_post_id']);
        $type = get_post_type($post_ID);
        $default = isset($options[$type]['post-edited-text']) ? $options[$type]['post-edited-text'] : '';
        $sentence = isset($_REQUEST['tweet_text']) && trim($_REQUEST['tweet_text']) != '' ? $_REQUEST['tweet_text'] : $default;
        $sentence = stripcslashes(trim($sentence));
        $post_info = wpt_post_info($post_ID);
        $sentence = jd_truncate_tweet($sentence, $post_info, $post_ID, false, $user_ID);
        $schedule = isset($_REQUEST['tweet_schedule']) ? strtotime($_REQUEST['tweet_schedule']) : rand(60, 240);
        $print_schedule = date_i18n(get_option('date_format') . ' @ ' . get_option('time_format'), $schedule);
        $offset = 60 * 60 * get_option('gmt_offset');
        $schedule = $schedule - $offset;
        $media = wpt_post_with_media($post_ID, $post_info);
        switch ($action) {
            case 'tweet':
                jd_doTwitterAPIPost($sentence, $auth, $post_ID, $media);
                break;
            case 'schedule':
                wp_schedule_single_event($schedule, 'wpt_schedule_tweet_action', array('id' => $auth, 'sentence' => $sentence, 'rt' => 0, 'post_id' => $post_ID));
                break;
        }
        $return = $action == 'tweet' ? wpt_log('wpt_status_message', $post_ID) : "Tweet scheduled: '{$sentence}' for {$print_schedule}";
        echo $return;
    } else {
        echo __('You are not authorized to perform this action', 'wp-to-twitter');
    }
    die;
}
function wpt_sidebar()
{
    ?>
<div class="postbox-container jcd-narrow">
<div class="metabox-holder">
	<div class="ui-sortable meta-box-sortables">
		<div class="postbox">
			<div class="handlediv"><span class="screen-reader-text">Click to toggle</span></div>
			<?php 
    if (!function_exists('wpt_pro_exists')) {
        ?>
			<h3 class='hndle'><span><strong><?php 
        _e('Support WP to Twitter', 'wp-to-twitter');
        ?>
</strong></span></h3>
			<?php 
    } else {
        ?>
			<h3 class='hndle'><span><strong><?php 
        _e('WP to Twitter Support', 'wp-to-twitter');
        ?>
</strong></span></h3>			
			<?php 
    }
    ?>
			<div class="inside resources">
			<p>
			<a href="https://twitter.com/intent/follow?screen_name=joedolson" class="twitter-follow-button" data-size="small" data-related="joedolson">Follow @joedolson</a>
			<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="https://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
			</p>
			<?php 
    if (function_exists('wpt_pro_exists')) {
        $support = admin_url('admin.php?page=wp-tweets-pro');
    } else {
        $support = admin_url('options-general.php?page=wp-to-twitter/wp-to-twitter.php');
    }
    ?>
			<a href="<?php 
    echo $support;
    ?>
#get-support"><?php 
    _e("Get Support", 'wp-to-twitter');
    ?>
</a>
			<?php 
    if (get_option('jd_donations') != 1 && !function_exists('wpt_pro_exists')) {
        ?>
			<p><?php 
        _e('<a href="http://www.joedolson.com/donate.php">Make a donation today!</a><br />Every donation matters - donate $5, $20, or $100 today!', 'wp-to-twitter');
        ?>
</p>
			<div class='donations'>
			<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
				<div>
				<input type="hidden" name="cmd" value="_s-xclick" />
				<input type="hidden" name="hosted_button_id" value="8490399" />
				<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donate_LG.gif" name="submit" alt="Donate" />
				<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1" />
				</div>
			</form>
			<a href="http://flattr.com/thing/559528/WP-to-Twitter"><img src="http://api.flattr.com/button/flattr-badge-large.png" alt="Flattr WP to Twitter" /></a>				
			</div>
		<?php 
    }
    ?>
			</div>
		</div>
	</div>
	<?php 
    if (!function_exists('wpt_pro_exists')) {
        ?>
	<div class="ui-sortable meta-box-sortables">
		<div class="postbox">
			<div class="handlediv"><span class="screen-reader-text">Click to toggle</span></div>
			<h3 class='wpt-upgrade hndle'><span><strong><?php 
        _e('Upgrade Now!', 'wp-to-twitter');
        ?>
</strong></span></h3>
			<div class="inside purchase">
				<strong><a href="http://www.joedolson.com/articles/wp-tweets-pro/"><?php 
        _e('Upgrade to <strong>WP Tweets PRO</strong>!', 'wp-to-twitter');
        ?>
</a></strong>
			<p><?php 
        _e('Bonuses in the PRO upgrade:', 'wp-to-twitter');
        ?>
</p>
			<ul>
				<li><?php 
        _e('Authors can post to their own Twitter accounts', 'wp-to-twitter');
        ?>
</li>
				<li><?php 
        _e('Delay Tweets minutes or hours after you publish', 'wp-to-twitter');
        ?>
</li>
				<li><?php 
        _e('Automatically schedule Tweets to post again later', 'wp-to-twitter');
        ?>
</li>
				<li><?php 
        _e('Send Tweets for approved comments', 'wp-to-twitter');
        ?>
</li>
				<li><?php 
        _e('Filter Tweets by category, tag, or custom taxonomy', 'wp-to-twitter');
        ?>
</li>
			</ul>
			
			</div>
		</div>
	</div>
	<?php 
    } else {
        if (function_exists('wpt_notes')) {
            wpt_notes();
        }
    }
    ?>
	<div class="ui-sortable meta-box-sortables">
		<div class="postbox">
			<div class="handlediv"><span class="screen-reader-text">Click to toggle</span></div>
			<h3 class='hndle'><span><?php 
    _e('Shortcodes', 'wp-to-twitter');
    ?>
</span></h3>
		<div class="inside">
			<p><?php 
    _e("Available in post update templates:", 'wp-to-twitter');
    ?>
</p>
			<ul>
			<li><?php 
    _e("<code>#title#</code>: the title of your blog post", 'wp-to-twitter');
    ?>
</li>
			<li><?php 
    _e("<code>#blog#</code>: the title of your blog", 'wp-to-twitter');
    ?>
</li>
			<li><?php 
    _e("<code>#post#</code>: a short excerpt of the post content", 'wp-to-twitter');
    ?>
</li>
			<li><?php 
    _e("<code>#category#</code>: the first selected category for the post", 'wp-to-twitter');
    ?>
</li>
			<li><?php 
    _e("<code>#cat_desc#</code>: custom value from the category description field", 'wp-to-twitter');
    ?>
</li>			
			<li><?php 
    _e("<code>#date#</code>: the post date", 'wp-to-twitter');
    ?>
</li>
			<li><?php 
    _e("<code>#modified#</code>: the post modified date", 'wp-to-twitter');
    ?>
</li>
			<li><?php 
    _e("<code>#url#</code>: the post URL", 'wp-to-twitter');
    ?>
</li>
			<li><?php 
    _e("<code>#author#</code>: the post author (@reference if available, otherwise display name)", 'wp-to-twitter');
    ?>
</li>
			<li><?php 
    _e("<code>#displayname#</code>: post author's display name", 'wp-to-twitter');
    ?>
</li>
			<li><?php 
    _e("<code>#account#</code>: the twitter @reference for the account (or the author, if author settings are enabled and set.)", 'wp-to-twitter');
    ?>
</li>
			<li><?php 
    _e("<code>#@#</code>: the twitter @reference for the author or blank, if not set", 'wp-to-twitter');
    ?>
</li>
			<li><?php 
    _e("<code>#tags#</code>: your tags modified into hashtags. See options in the Advanced Settings section, below.", 'wp-to-twitter');
    ?>
</li>
<?php 
    if (function_exists('wpt_pro_exists') && wpt_pro_exists() == true) {
        ?>
			<li><?php 
        _e("<code>#reference#</code>: Used only in co-tweeting. @reference to main account when posted to author account, @reference to author account in post to main account.", 'wp-to-twitter');
        ?>
</li> 
<?php 
    }
    ?>
			</ul>
			<p><?php 
    _e("You can also create custom shortcodes to access WordPress custom fields. Use doubled square brackets surrounding the name of your custom field to add the value of that custom field to your status update. Example: <code>[[custom_field]]</code></p>", 'wp-to-twitter');
    ?>
		</div>
		</div>
	</div>
</div>
<?php 
}
Example #5
0
function wpt_create_values($post, $post_ID, $ref)
{
    $shrink = $post['shortUrl'] != '' ? $post['shortUrl'] : apply_filters('wptt_shorten_link', $post['postLink'], $post['postTitle'], $post_ID, false);
    // generate template variable values
    $auth = $post['authId'];
    $title = trim(apply_filters('wpt_status', $post['postTitle'], $post_ID, 'title'));
    $blogname = trim($post['blogTitle']);
    $excerpt = trim(apply_filters('wpt_status', $post['postExcerpt'], $post_ID, 'post'));
    $thisposturl = trim($shrink);
    $category = trim($post['category']);
    $cat_desc = trim($post['cat_desc']);
    $user_account = get_user_meta($auth, 'wtt_twitter_username', true);
    $tags = wpt_generate_hash_tags($post_ID);
    $account = get_option('wtt_twitter_username');
    $date = trim($post['postDate']);
    $modified = trim($post['postModified']);
    if (get_option('jd_individual_twitter_users') == 1) {
        if ($user_account == '') {
            if (get_user_meta($auth, 'wp-to-twitter-enable-user', true) == 'mainAtTwitter') {
                $account = $user_account = stripcslashes(get_user_meta($auth, 'wp-to-twitter-user-username', true));
            } else {
                if (get_user_meta($auth, 'wp-to-twitter-enable-user', true) == 'mainAtTwitterPlus') {
                    $account = $user_account = stripcslashes(get_user_meta($auth, 'wp-to-twitter-user-username', true) . ' @' . get_option('wtt_twitter_username'));
                }
            }
        } else {
            $account = "{$user_account}";
        }
    }
    $display_name = get_the_author_meta('display_name', $auth);
    $author = $user_account != '' ? "@{$user_account}" : $display_name;
    // value of #author#
    $account = $account != '' ? "@{$account}" : '';
    // value of #account#
    $uaccount = $user_account != '' ? "@{$user_account}" : "{$account}";
    // value of #@#
    // clean up data if extra @ included in user data //
    $account = str_ireplace('@@', '@', $account);
    $uaccount = str_ireplace('@@', '@', $uaccount);
    $author = str_ireplace('@@', '@', $author);
    if (get_user_meta($auth, 'wpt-remove', true) == 'on') {
        $account = '';
    }
    if (function_exists('wpt_pro_exists') && wpt_pro_exists() == true) {
        $reference = $ref ? $account : '@' . get_option('wtt_twitter_username');
    } else {
        $reference = '';
    }
    return array('url' => $thisposturl, 'title' => $title, 'blog' => $blogname, 'post' => $excerpt, 'category' => $category, 'date' => $date, 'author' => $author, 'displayname' => $display_name, 'tags' => $tags, 'modified' => $modified, 'reference' => $reference, 'account' => $account, '@' => $uaccount, 'cat_desc' => $cat_desc, 'longurl' => $post['postLink']);
}
Example #6
0
function wpt_get_support_form()
{
    global $current_user, $wpt_version;
    get_currentuserinfo();
    $request = '';
    // send fields for WP to Twitter
    $license = get_option('wpt_license_key') != '' ? get_option('wpt_license_key') : 'none';
    $license = "License Key: " . $license;
    $version = $wpt_version;
    $wtt_twitter_username = get_option('wtt_twitter_username');
    // send fields for all plugins
    $wp_version = get_bloginfo('version');
    $home_url = home_url();
    $wp_url = site_url();
    $language = get_bloginfo('language');
    $charset = get_bloginfo('charset');
    // server
    $php_version = phpversion();
    // theme data
    if (function_exists('wp_get_theme')) {
        $theme = wp_get_theme();
        $theme_name = $theme->Name;
        $theme_uri = $theme->ThemeURI;
        $theme_parent = $theme->Template;
        $theme_version = $theme->Version;
    } else {
        $theme_path = get_stylesheet_directory() . '/style.css';
        $theme = get_theme_data($theme_path);
        $theme_name = $theme['Name'];
        $theme_uri = $theme['ThemeURI'];
        $theme_parent = $theme['Template'];
        $theme_version = $theme['Version'];
    }
    // plugin data
    $plugins = get_plugins();
    $plugins_string = '';
    foreach (array_keys($plugins) as $key) {
        if (is_plugin_active($key)) {
            $plugin =& $plugins[$key];
            $plugin_name = $plugin['Name'];
            $plugin_uri = $plugin['PluginURI'];
            $plugin_version = $plugin['Version'];
            $plugins_string .= "{$plugin_name}: {$plugin_version}; {$plugin_uri}\n";
        }
    }
    global $wpt_server_string;
    $wpt_server_string = trim(strip_tags($wpt_server_string));
    $data = "\r\n================ Installation Data ====================\r\n==WP to Twitter==\r\nVersion: {$version}\r\nTwitter username: http://twitter.com/{$wtt_twitter_username}\r\n{$license}\r\n{$wpt_server_string}\r\n\r\n==WordPress:==\r\nVersion: {$wp_version}\r\nURL: {$home_url}\r\nInstall: {$wp_url}\r\nLanguage: {$language}\r\nCharset: {$charset}\r\nAdmin Email: {$current_user->user_email}\r\n\r\n==Extra info:==\r\nPHP Version: {$php_version}\r\nServer Software: {$_SERVER['SERVER_SOFTWARE']}\r\nUser Agent: {$_SERVER['HTTP_USER_AGENT']}\r\n\r\n==Theme:==\r\nName: {$theme_name}\r\nURI: {$theme_uri}\r\nParent: {$theme_parent}\r\nVersion: {$theme_version}\r\n\r\n==Active Plugins:==\r\n{$plugins_string}\r\n";
    if (isset($_POST['wpt_support'])) {
        $nonce = $_REQUEST['_wpnonce'];
        if (!wp_verify_nonce($nonce, 'wp-to-twitter-nonce')) {
            die("Security check failed");
        }
        $request = !empty($_POST['support_request']) ? stripslashes($_POST['support_request']) : false;
        $has_donated = $_POST['has_donated'] == 'on' ? "Donor" : "No donation";
        $has_read_faq = $_POST['has_read_faq'] == 'on' ? "Read FAQ" : false;
        if (function_exists('wpt_pro_exists') && wpt_pro_exists() == true) {
            $pro = " PRO";
        } else {
            $pro = '';
        }
        $subject = "WP to Twitter{$pro} support request. {$has_donated}";
        $message = $request . "\n\n" . $data;
        $from = "From: \"{$current_user->display_name}\" <{$current_user->user_email}>\r\n";
        if (!$has_read_faq) {
            echo "<div class='message error'><p>" . __('Please read the FAQ and other Help documents before making a support request.', 'wp-to-twitter') . "</p></div>";
        } else {
            if (!$request) {
                echo "<div class='message error'><p>" . __('Please describe your problem. I\'m not psychic.', 'wp-to-twitter') . "</p></div>";
            } else {
                $sent = wp_mail("*****@*****.**", $subject, $message, $from);
                if ($sent) {
                    if ($has_donated == 'Donor' || $has_purchased == 'Purchaser') {
                        echo "<div class='message updated'><p>" . sprintf(__('Thank you for supporting the continuing development of this plug-in! I\'ll get back to you as soon as I can. Please ensure that you can receive email at <code>%s</code>.', 'wp-to-twitter'), $current_user->user_email) . "</p></div>";
                    } else {
                        echo "<div class='message updated'><p>" . sprintf(__("Thanks for using WP to Twitter. Please ensure that you can receive email at <code>%s</code>.", 'wp-to-twitter'), $current_user->user_email) . "</p></div>";
                    }
                } else {
                    echo "<div class='message error'><p>" . __("Sorry! I couldn't send that message. Here's the text of your message:", 'wp-to-twitter') . "</p><pre>{$request}</pre></div>";
                }
            }
        }
    }
    if (function_exists('wpt_pro_exists') && wpt_pro_exists() == true) {
        $checked = "checked='checked'";
    } else {
        $checked = '';
    }
    $admin_url = is_plugin_active('wp-tweets-pro/wpt-pro-functions.php') ? admin_url('admin.php?page=wp-tweets-pro') : admin_url('options-general.php?page=wp-to-twitter/wp-to-twitter.php');
    echo "\r\n\t<form method='post' action='{$admin_url}'>\r\n\t\t<div><input type='hidden' name='_wpnonce' value='" . wp_create_nonce('wp-to-twitter-nonce') . "' /></div>\r\n\t\t<div>";
    if (function_exists('wpt_pro_exists') && wpt_pro_exists() == true) {
    } else {
        echo "\r\n\t\t<p>" . __('<strong>Please note</strong>: I do keep records of those who have donated, but if your donation came from somebody other than your account at this web site, you must note this in your message.', 'wp-to-twitter') . "</p>";
        echo "\r\n\t\t<p>" . __("If you're having trouble with WP to Twitter, please try to answer these questions in your message:", 'wp-to-twitter') . "</p>";
        echo "<ul>";
        echo "<li>" . __('Did this error happen only once, or repeatedly?', 'wp-to-twitter') . "</li>";
        echo "<li>" . __('What was the Tweet, or an example Tweet, that produced this error?', 'wp-to-twitter') . "</li>";
        echo "<li>" . __('If there was an error message from WP to Twitter, what was it?', 'wp-to-twitter') . "</li>";
        echo "<li>" . __('What is the template you\'re using for your Tweets?', 'wp-to-twitter') . "</li>";
        echo "</ul>";
    }
    echo "\r\n\t\t<p>\r\n\t\t<code>" . __('Reply to:', 'wp-to-twitter') . " \"{$current_user->display_name}\" &lt;{$current_user->user_email}&gt;</code>\r\n\t\t</p>\r\n\t\t<p>\r\n\t\t<input type='checkbox' name='has_read_faq' id='has_read_faq' value='on' required='required' aria-required='true' /> <label for='has_read_faq'>" . sprintf(__('I have read <a href="%1$s">the FAQ for this plug-in</a> <span>(required)</span>', 'wp-to-twitter'), 'http://www.joedolson.com/articles/wp-to-twitter/support-2/') . "\r\n        </p>\r\n        <p>\r\n        <input type='checkbox' name='has_donated' id='has_donated' value='on' {$checked} /> <label for='has_donated'>" . sprintf(__('I have <a href="%1$s">made a donation to help support this plug-in</a>', 'wp-to-twitter'), 'http://www.joedolson.com/donate.php') . "</label>\r\n        </p>\r\n        <p>\r\n        <label for='support_request'>" . __('Support Request:', 'wp-to-twitter') . "</label><br /><textarea class='support-request' name='support_request' id='support_request' cols='80' rows='10'>" . stripslashes($request) . "</textarea>\r\n\t\t</p>\r\n\t\t<p>\r\n\t\t<input type='submit' value='" . __('Send Support Request', 'wp-to-twitter') . "' name='wpt_support' class='button-primary' />\r\n\t\t</p>\r\n\t\t<p>" . __('The following additional information will be sent with your support request:', 'wp-to-twitter') . "</p>\r\n\t\t<div class='mc_support'>\r\n\t\t" . wpautop($data) . "\r\n\t\t</div>\r\n\t\t</div>\r\n\t</form>";
}