/** * 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); }