protected static function get_tweet_content()
 {
     ob_start();
     require dirname(__FILE__) . '/share-handler.php';
     ob_end_clean();
     $p = $_POST;
     $defaults = array('text' => '', 'custom_url' => '', 'custom_twitter_handles' => '', 'custom_hidden_hashtags' => '', 'custom_hidden_urls' => '', 'remove_twitter_handles' => '', 'remove_url' => '', 'remove_hidden_hashtags' => '', 'remove_hidden_urls' => '');
     //	Merge passed values with defaults
     $p = array_merge($defaults, $p);
     //	Convert empty values to boolean false to play along nicely with TT_Share_Handler
     $p = TT_Tools::empty_to_false($p);
     $SH = new TT_Share_Handler($p['text'], $p['custom_url'], $p['custom_twitter_handles'], $p['custom_hidden_hashtags'], $p['custom_hidden_urls'], $p['remove_twitter_handles'], $p['remove_url'], $p['remove_hidden_hashtags'], $p['remove_hidden_urls'], $p['post_id']);
     $data = $SH->generate_actual_text();
     //	Generate JSON response
     $json = json_encode(array('status' => true, 'data' => $data));
     echo $json;
 }
示例#2
0
 /**
  * Returns all the plugin settings needed for the dialog box as an associative array.
  *
  * @return   [array]   Array of plugin settings for dialog box.
  */
 public static function get_tinymce_dialog_settings()
 {
     //	Because this function is not necessarily called on the post/page editor screen,
     //	the post/page URL getting function TT_Share_Handler::generate_post_url()
     //	won't always work.  So, if and when it fails, we'll need a placeholder link that
     //	we can get without failure.
     try {
         //	post ID
         global $current_screen, $post;
         $type = $current_screen->post_type;
         if ($type == 'post' || $type == 'page') {
             $id = $post->ID;
         } else {
             throw new Exception('Unable to retrieve post ID.');
         }
         //	post URL
         $SH = new TT_Share_Handler();
         $urlarr = $SH->generate_post_url($id, true);
         if (is_array($urlarr)) {
             //	Shortlink w/ qualifying info in array
             $post_url = self::get_arr_value('shortlink', $urlarr, '');
             $is_placeholder = self::get_arr_value('is_placeholder', $urlarr, false);
         } else {
             //	Nothing fancy, just the URL as a string
             $post_url = $urlarr;
             $is_placeholder = false;
         }
     } catch (Exception $e) {
         $id = 0;
         $post_url = TT_Tools::placeholder_shortlink();
         $is_placeholder = false;
     }
     //	default Twitter handles and hidden hashtags
     $options = get_option('tt_plugin_options');
     $twits = self::get_arr_value('default_twitter_handles', $options, '');
     $hashtags = self::get_arr_value('default_hidden_hashtags', $options, '');
     $hidden_urls = self::get_arr_value('default_hidden_urls', $options, '');
     //	dialog customization options
     $insert_sc_behavior = self::get_arr_value('insert_shortcode_behavior', $options, '');
     $hide_preview = self::get_arr_value('disable_preview', $options, '');
     $hide_handles = self::get_arr_value('disable_handles', $options, '');
     $hide_post_url = self::get_arr_value('disable_post_url', $options, '');
     $hide_hidden = self::get_arr_value('disable_hidden', $options, '');
     $hide_char_count = self::get_arr_value('disable_char_count', $options, '');
     return array('post_id' => $id, 'post_url' => $post_url, 'post_url_is_placeholder' => $is_placeholder, 'default_twitter_handles' => $twits, 'default_hidden_hashtags' => $hashtags, 'default_hidden_urls' => $hidden_urls, 'disable_preview' => $hide_preview, 'disable_handles' => $hide_handles, 'disable_post_url' => $hide_post_url, 'disable_hidden' => $hide_hidden, 'disable_char_count' => $hide_char_count, 'insert_shortcode_behavior' => $insert_sc_behavior);
 }
示例#3
0
 public static function shortcodes_helper($atts, $enc_content = null)
 {
     extract(shortcode_atts(array('text' => '', 'url' => false, 'twitter_handles' => false, 'hidden_hashtags' => false, 'hidden_urls' => false, 'display_mode' => false, 'remove_twitter_handles' => false, 'remove_url' => false, 'remove_hidden_hashtags' => false, 'remove_hidden_urls' => false), $atts));
     //	Is this an enclosing or self-closing shortcode?
     //	http://codex.wordpress.org/Shortcode_API#Enclosing_vs_self-closing_shortcodes
     if (!is_null($enc_content) && $enc_content != '') {
         //	Enclosing shortcode. We want to use the text inside
         //	the shortcode instead of in the text attribute.
         $text = $enc_content;
     }
     $Share = new TT_Share_Handler($text, $url, $twitter_handles, $hidden_hashtags, $hidden_urls, $remove_twitter_handles, $remove_url, $remove_hidden_hashtags, $remove_hidden_urls);
     $options = get_option('tt_plugin_options');
     //	What display mode are we using?
     if ($display_mode === false) {
         //	None provided in shortcode
         if (!$options || !array_key_exists('display_mode', $options)) {
             $display_mode = 'box';
         } else {
             $display_mode = $options['display_mode'];
         }
     }
     switch ($display_mode) {
         case 'button_link':
             //	Do we include the icon?
             if (!array_key_exists('simple_link_include_icon', $options) || $options['simple_link_include_icon']) {
                 return $Share->display_link();
             } else {
                 return $Share->display_link(false);
             }
         default:
             return $Share->display_box();
     }
 }