Example #1
0
 /**
  * Returns a string to be used as the name for our nonce fields.
  *
  * For more information on nonce fields:
  * http://codex.wordpress.org/Function_Reference/wp_nonce_field
  *
  * @return str md5 hash of the unique identifier to use as a nonce.
  */
 public static function nonceName()
 {
     return md5(ThinkUpWordPressPlugin::uniqueIdentifier());
 }
    public static function displayHelpFaqContents($title, $files) {
        $title = __($title, ThinkUpWordPressPlugin::uniqueIdentifier());

        ?>
<div id="poststuff" class="ui-sortable meta-box-sortable"
	style="max-width: 700px">
<div class="postbox" id="contents">
<h3><?php echo $title; ?></h3>
<div class="inside" style="line-height: 1.5"><?php
foreach ($files as $name => $contents) {
    $name = __($name, ThinkUpWordPressPlugin::uniqueIdentifier());
    echo '<a href="#'.$name.'">'.$name.'</a><br />';
}
?></div>
</div>
</div>
<?php

    }
Example #3
0
    /**
     * Return an object (as returned by $wpdb->get_row()) of this post's database record.
     *
     * @return Object Post's database record.
     */
    public function getPostInfo() {
        if (!isset($this->post_info)) {
            $wpdb = ThinkUpWordPressPlugin::getDatabaseConnection();

            if (!isset($this->get_post_info_sql)) {
                $options_array = ThinkUpWordPressPlugin::getOptionsArray();

                // database may be on same server but not same db as wordpress
                $db = $wpdb->escape($options_array['thinkup_db']['value']);
                $prefix = $options_array['thinkup_table_prefix']['value'];

                $this->get_post_info_sql = $wpdb->prepare("
                     SELECT *
                     FROM
                     `$db`.`".$prefix."posts`
                     WHERE
                         post_id = {$wpdb->escape($this->post_id)}
                         AND network = %s;", $this->network);
            }
            $this->post_info = $wpdb->get_row($this->get_post_info_sql);
        }

        return $this->post_info;
    }
Example #4
0
 /**
  * Returns an array of objects (as returned by $wpdb->get_results()) of this user's recent posts.
  *
  * @param int $count Amount of rows to return.
  * @return ObjectArray
  */
 public function getRecentPosts($count = 15, $order = 'DESC')
 {
     $wpdb = ThinkUpWordPressPlugin::getDatabaseConnection();
     $options_array = ThinkUpWordPressPlugin::getOptionsArray();
     // database may be on same server but not same db as wordpress
     $db = $wpdb->escape($options_array['thinkup_db']['value']);
     $prefix = $options_array['thinkup_table_prefix']['value'];
     if ($count >= 0) {
         $sql = $wpdb->prepare("\n                SELECT *\n                FROM {$db}." . $prefix . "posts\n                WHERE author_username='******'\n                    AND in_reply_to_user_id is null\n                    AND network='%s'\n                ORDER BY pub_date {$wpdb->escape($order)}\n                LIMIT %d", $this->username, $this->network, $count);
     } else {
         $sql = $wpdb->prepare("\n                SELECT *\n                FROM {$db}." . $prefix . "posts\n                WHERE author_username='******'\n                    AND in_reply_to_user_id is null\n                    AND network='%s'\n                ORDER BY pub_date {$wpdb->escape($order)}", $this->username, $this->network);
     }
     return $wpdb->get_results($sql);
 }
Example #5
0
 /**
  * This function is used to display the FAQ page in the ThinkUp plugin
  * menu. It uses files in /faq to display its content.
  */
 public static function faq()
 {
     $questions = self::fetchTxtFiles(ThinkUpWordPressPlugin::pluginDirectory() . '/faq');
     $title = __('Frequently Asked Questions', 'thinkup-wp-plugin');
     self::displayHelpFaqContents($title, $questions, true);
     self::displayTxtFiles($questions, $question = true);
 }