コード例 #1
0
ファイル: surname_widget.php プロジェクト: markc/rootspersona
 /**
  * How to display the widget on the screen.
  */
 function widget($args, $instance)
 {
     global $wpdb;
     extract($args);
     /* Our variables from the widget settings. */
     $title = apply_filters('widget_title', $instance['title']);
     $cnt = $instance['cnt'];
     /* Before widget (defined by themes). */
     echo $before_widget;
     /* Display the widget title if one was input (before and after defined by themes). */
     if ($title) {
         echo $before_title . $title . $after_title;
     }
     /* Display name from widget settings if one was input. */
     if ($cnt > 0) {
         $creds = new RP_Credentials();
         $creds->set_prefix($wpdb->prefix);
         $transaction = new RP_Transaction($creds, false);
         $rows = RP_Dao_Factory::get_rp_persona_dao($wpdb->prefix)->get_top_x_surnames($cnt);
         $rCnt = count($rows);
         if ($rCnt > 0) {
             for ($idx = 0; $idx < $rCnt; $idx++) {
                 //echo '<div style="margin-left:10px;">' . $rows[$idx]['surname'] . ' (' . $rows[$idx]['cnt'] . ')</div>';
                 echo '<div style="margin-left:10px;"><a href="' . get_home_url(null, '/?s=' . $rows[$idx]['surname'] . '&posttype=page&widget=advanced-search-widget-3') . '" rel="nofollow">' . $rows[$idx]['surname'] . '</a> (' . $rows[$idx]['cnt'] . ')</div>';
             }
         }
         $transaction->close();
     }
     /* After widget (defined by themes). */
     echo $after_widget;
 }
コード例 #2
0
 /**
  *
  * @param string $plugin_dir
  * @param string $version
  * @param array $options
  * @param string $prefix
  */
 function persona_upgrade($plugin_dir, $version, $options, $prefix)
 {
     global $wpdb;
     if ($options['version'] < '2.0.3') {
         unset($options['evidence_page']);
         unset($options['index_page']);
     }
     if ($options['version'] < '2.2.0') {
         $options['hide_descendancy'] = 0;
     }
     if ($options['version'] < '3.0.0') {
         $stmt = "CREATE TABLE IF NOT EXISTS rp_indi_seq (id INT NOT NULL)";
         if ($prefix != null) {
             $stmt = str_replace('rp_', $prefix . 'rp_', $stmt);
         }
         $result = $wpdb->query($stmt);
         if ($result === false) {
             $wpdb->print_error();
             throw new Exception($stmt);
         }
         $stmt = "INSERT INTO rp_indi_seq VALUES (100000)";
         if ($prefix != null) {
             $stmt = str_replace('INTO rp_', 'INTO ' . $prefix . 'rp_', $stmt);
         }
         $result = $wpdb->query($stmt);
         if ($result === false) {
             $wpdb->print_error();
             //throw new Exception( $stmt );
         }
         $stmt = "CREATE TABLE IF NOT EXISTS rp_fam_seq (id INT NOT NULL)";
         if ($prefix != null) {
             $stmt = str_replace('rp_', $prefix . 'rp_', $stmt);
         }
         $result = $wpdb->query($stmt);
         if ($result === false) {
             $wpdb->print_error();
             throw new Exception($stmt);
         }
         $stmt = "INSERT INTO rp_fam_seq VALUES (100000)";
         if ($prefix != null) {
             $stmt = str_replace('INTO rp_', 'INTO ' . $prefix . 'rp_', $stmt);
         }
         $result = $wpdb->query($stmt);
         if ($result === false) {
             $wpdb->print_error();
             //throw new Exception( $stmt );
         }
     }
     // support table recreation on activation
     try {
         $credentials = new RP_Credentials();
         $credentials->set_prefix($wpdb->prefix);
         $transaction = new RP_Transaction($credentials, true);
         RP_Dao_Factory::get_rp_persona_dao($credentials->prefix)->get_batch_ids();
         $transaction->close();
     } catch (Exception $e) {
         if (strpos($e->getMessage(), "doesn't exist") >= 0) {
             $creator = new RP_Table_Creator();
             $creator->update_tables($this->sql_file_to_create_tables, $prefix);
         } else {
             error_log($e->getMessage() . "::" . RP_Persona_Helper::trace_caller(), 0);
             throw $e;
         }
     }
     $options['version'] = $version;
     update_option('persona_plugin', $options);
 }
コード例 #3
0
ファイル: rootspersona.php プロジェクト: markc/rootspersona
 /**
  *
  * @global wpdb $wpdb
  */
 function __construct()
 {
     global $wpdb;
     $this->credentials = new RP_Credentials();
     $this->credentials->set_prefix($wpdb->prefix);
 }