Example #1
0
 /**
 Install our table
 */
 function install()
 {
     // load our translations and strings
     $this->load_translations();
     // include upgrade-functions for maybe_create_table;
     if (!function_exists('maybe_create_table')) {
         require_once ABSPATH . 'wp-admin/install-helper.php';
     }
     $date = date('Y-m-d');
     $sql = "CREATE TABLE {$this->public} (\n\t\t\tid int(11) NOT NULL auto_increment,\n\t\t\temail varchar(64) NOT NULL default '',\n\t\t\tactive tinyint(1) default 0,\n\t\t\tdate DATE default '{$date}' NOT NULL,\n\t\t\ttime TIME DEFAULT '00:00:00' NOT NULL,\n\t\t\tip char(64) NOT NULL default 'admin',\n\t\t\tconf_date DATE,\n\t\t\tconf_time TIME,\n\t\t\tconf_ip char(64),\n\t\t\tPRIMARY KEY (id) )";
     // create the table, as needed
     maybe_create_table($this->public, $sql);
     // create table entries for registered users
     $users = $this->get_all_registered('ID');
     if (!empty($users)) {
         foreach ($users as $user_ID) {
             $check_format = get_user_meta($user_ID, $this->get_usermeta_keyname('s2_format'), true);
             if (empty($check_format)) {
                 // no prior settings so create them
                 $this->register($user_ID);
             }
         }
     }
     // option to store ReadyGraph API Key
     add_option('readygraph_api', "include your api_key");
     // safety check if options exist and if not create them
     if (!is_array($this->subscribe2_options)) {
         $this->reset();
     }
 }
/**
 * This function is called when the plugin is activated, it allow to create the SQL table.
 *
 * @return void
 * @author Amaury Balmer
 */
function install_table_termmeta()
{
    global $wpdb;
    if (!empty($wpdb->charset)) {
        $charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}";
    }
    if (!empty($wpdb->collate)) {
        $charset_collate .= " COLLATE {$wpdb->collate}";
    }
    // Add one library admin function for next function
    require_once ABSPATH . 'wp-admin/includes/upgrade.php';
    // Try to create the meta table
    return maybe_create_table($wpdb->term_taxometa, "CREATE TABLE " . $wpdb->term_taxometa . " (\n\t\t\t`meta_id` int(20) NOT NULL auto_increment,\n\t\t\t`term_taxo_id` INT( 20 ) NOT NULL ,\n\t\t\t`meta_key` VARCHAR( 255 ) NOT NULL ,\n\t\t\t`meta_value` LONGTEXT NOT NULL,\n\t\t\tPRIMARY KEY  (`meta_id`),\n\t\t\tKEY `term_taxo_id` (`term_taxo_id`),\n\t\t\tKEY `meta_key` (`meta_key`)\n\t\t) {$charset_collate};");
}
 /**
  * Try to create the table during the installation
  *
  * @return void
  * @author Amaury Balmer
  */
 public static function activate()
 {
     global $wpdb;
     if (!empty($wpdb->charset)) {
         $charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}";
     }
     if (!empty($wpdb->collate)) {
         $charset_collate .= " COLLATE {$wpdb->collate}";
     }
     // Add one library admin function for next function
     require_once ABSPATH . 'wp-admin/includes/upgrade.php';
     // Try to create the meta table
     return maybe_create_table($wpdb->posts_relations, "CREATE TABLE {$wpdb->posts_relations} (\n\t\t\t\t`id` int(20) NOT NULL auto_increment,\n\t\t\t\t`object_id_1` INT( 20 ) NOT NULL,\n\t\t\t\t`object_id_2` INT( 20 ) NOT NULL,\n\t\t\t\tPRIMARY KEY (`id`),\n\t\t\t\tUNIQUE KEY `object_ids` (`object_id_1`,`object_id_2`)\n\t\t\t) {$charset_collate};");
 }
Example #4
0
 /**
 Install our table
 */
 function install()
 {
     // include upgrade-functions for maybe_create_table;
     if (!function_exists('maybe_create_table')) {
         require_once ABSPATH . 'wp-admin/install-helper.php';
     }
     $date = date('Y-m-d');
     $sql = "CREATE TABLE {$this->public} (\n\t\t\tid int(11) NOT NULL auto_increment,\n\t\t\temail varchar(64) NOT NULL default '',\n\t\t\tactive tinyint(1) default 0,\n\t\t\tdate DATE default '{$date}' NOT NULL,\n\t\t\tip char(64) NOT NULL default 'admin',\n\t\t\tPRIMARY KEY (id) )";
     // create the table, as needed
     maybe_create_table($this->public, $sql);
     // safety check if options exist and if not create them
     if (!is_array($this->subscribe2_options)) {
         $this->reset();
     }
 }
Example #5
0
function create_membership_table()
{
    global $wpdb;
    include_once ABSPATH . '/wp-admin/includes/upgrade.php';
    $table_charset = '';
    $prefix = $wpdb->prefix;
    $users_table = $prefix . 'um_vip_users';
    if ($wpdb->has_cap('collation')) {
        if (!empty($wpdb->charset)) {
            $table_charset = "DEFAULT CHARACTER SET {$wpdb->charset}";
        }
        if (!empty($wpdb->collate)) {
            $table_charset .= " COLLATE {$wpdb->collate}";
        }
    }
    $create_vip_users_sql = "CREATE TABLE {$users_table} (id int(11) NOT NULL auto_increment,user_id int(11) NOT NULL,user_type tinyint(4) NOT NULL default 0,startTime datetime NOT NULL default '0000-00-00 00:00:00',endTime datetime NOT NULL default '0000-00-00 00:00:00',PRIMARY KEY (id),INDEX uid_index(user_id),INDEX utype_index(user_type)) ENGINE = MyISAM {$table_charset};";
    maybe_create_table($users_table, $create_vip_users_sql);
}
Example #6
0
function create_withdraw_table()
{
    global $wpdb;
    include_once ABSPATH . '/wp-admin/includes/upgrade.php';
    $table_charset = '';
    $prefix = $wpdb->prefix;
    $withdraw_table = $prefix . 'um_withdraw';
    if ($wpdb->has_cap('collation')) {
        if (!empty($wpdb->charset)) {
            $table_charset = "DEFAULT CHARACTER SET {$wpdb->charset}";
        }
        if (!empty($wpdb->collate)) {
            $table_charset .= " COLLATE {$wpdb->collate}";
        }
    }
    $create_withdraw_sql = "CREATE TABLE {$withdraw_table} (id int(11) NOT NULL auto_increment,user_id int(11) NOT NULL,time datetime NOT NULL default '0000-00-00 00:00:00',money double(10,2) NOT NULL default 0,balance double(10,2) NOT NULL default 0,status int(1) NOT NULL default 0,PRIMARY KEY (id)) ENGINE = MyISAM {$table_charset};";
    maybe_create_table($withdraw_table, $create_withdraw_sql);
}
 /**
  * Active the plugin action...
  *
  * @return void
  * @author Amaury Balmer
  */
 function activate()
 {
     global $locale, $wpdb;
     // Add option ?
     $new_options = array();
     $new_options['custom-types'] = array('post');
     $new_options['language'] = substr($locale, 0, 2);
     $new_options['region'] = substr($locale, 3, 2);
     $new_options['tooltip'] = SGM_TOOLTIP;
     add_option(SGM_OPTION, $new_options);
     // Create table ?
     if (!empty($wpdb->charset)) {
         $charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}";
     }
     if (!empty($wpdb->collate)) {
         $charset_collate .= " COLLATE {$wpdb->collate}";
     }
     // Add one library admin function for next function
     require_once ABSPATH . 'wp-admin/includes/upgrade.php';
     // Try to create the meta table
     maybe_create_table($wpdb->simple_post_gmaps, "CREATE TABLE " . $wpdb->simple_post_gmaps . " (\n\t\t\t`post_id` INT(20) NOT NULL ,\n\t\t\t`long` DECIMAL( 11,8 ) NOT NULL,\n\t\t\t`lat` DECIMAL( 11,8 ) NOT NULL,\n\t\t\tUNIQUE KEY ( `post_id` )\n\t\t) {$charset_collate};");
 }
Example #8
0
function create_orders_table()
{
    if (ot_get_option('shop_system') == 'on') {
        global $wpdb;
        include_once ABSPATH . '/wp-admin/includes/upgrade.php';
        $table_charset = '';
        $prefix = $wpdb->prefix;
        $orders_table = $prefix . 'tin_orders';
        $promotes_table = $prefix . 'tin_promotes';
        if ($wpdb->has_cap('collation')) {
            if (!empty($wpdb->charset)) {
                $table_charset = "DEFAULT CHARACTER SET {$wpdb->charset}";
            }
            if (!empty($wpdb->collate)) {
                $table_charset .= " COLLATE {$wpdb->collate}";
            }
        }
        $create_orders_sql = "CREATE TABLE {$orders_table} (id int(11) NOT NULL auto_increment,order_id varchar(30) NOT NULL,trade_no varchar(30) NOT NULL,product_id int(20) NOT NULL,product_name varchar(250),order_time datetime NOT NULL default '0000-00-00 00:00:00',order_success_time datetime NOT NULL default '0000-00-00 00:00:00',order_price double(10,2) NOT NULL,order_currency varchar(20) NOT NULL default 'credit',order_quantity int(11) NOT NULL,order_total_price double(10,2) NOT NULL,order_status tinyint(4) NOT NULL default 0,order_note text,user_id int(11) NOT NULL,user_name varchar(60),user_email varchar(100),user_address varchar(250),user_zip varchar(10),user_phone varchar(20),user_cellphone varchar(20),user_message text,user_alipay varchar(100),PRIMARY KEY (id),INDEX orderid_index(order_id),INDEX tradeno_index(trade_no),INDEX productid_index(product_id),INDEX uid_index(user_id)) ENGINE = MyISAM {$table_charset};";
        maybe_create_table($orders_table, $create_orders_sql);
        $create_promotes_sql = "CREATE TABLE {$promotes_table} (id int(11) NOT NULL auto_increment,promote_code varchar(20) NOT NULL,promote_type varchar(20) NOT NULL default 'once',promote_status int(11) NOT NULL default 1,discount_value double(10,2) NOT NULL default 0.90,expire_date datetime NOT NULL default '0000-00-00 00:00:00',PRIMARY KEY (id),INDEX promotecode_index(promote_code)) ENGINE = MyISAM {$table_charset};";
        maybe_create_table($promotes_table, $create_promotes_sql);
    }
}
Example #9
0
 /**
  * Create the tables if needed
  *
  * @param void
  * @return void
  * @author Nicolas Juen
  */
 public static function activation()
 {
     /* @var $wpdb wpdb */
     global $wpdb;
     // Charset
     if (!empty($wpdb->charset)) {
         $charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}";
     }
     if (!empty($wpdb->collate)) {
         $charset_collate .= " COLLATE {$wpdb->collate}";
     }
     // Add one library admin function for next function
     require_once ABSPATH . 'wp-admin/includes/upgrade.php';
     // Campaign Table
     maybe_create_table($wpdb->bea_s_campaigns, "CREATE TABLE " . $wpdb->bea_s_campaigns . " (\n\t\t\t`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY,\n\t\t\t`add_date` datetime NOT NULL,\n\t\t\t`scheduled_from` datetime NOT NULL,\n\t\t\t`current_status` varchar(10) NOT NULL,\n\t\t\t`from_name` varchar(255) NOT NULL,\n\t\t\t`from` varchar(255) NOT NULL,\n\t\t\t`subject` text NOT NULL\n\t\t) {$charset_collate};");
     add_clean_index($wpdb->bea_s_campaigns, 'id');
     add_clean_index($wpdb->bea_s_campaigns, 'current_status');
     // Receiver Table
     maybe_create_table($wpdb->bea_s_receivers, "CREATE TABLE " . $wpdb->bea_s_receivers . " (\n\t\t\t`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY,\n\t\t\t`email` varchar(255) NOT NULL,\n\t\t\t`current_status` varchar(10) NOT NULL,\n\t\t\t`bounce_cat` varchar(20) NOT NULL,\n\t\t\t`bounce_type` varchar(20) NOT NULL,\n\t\t\t`bounce_no` varchar(10) NOT NULL\n\t\t) {$charset_collate};");
     maybe_add_column($wpdb->bea_s_receivers, 'bounce_cat', "ALTER TABLE {$wpdb->bea_s_receivers} ADD bounce_cat char(20)");
     maybe_add_column($wpdb->bea_s_receivers, 'bounce_type', "ALTER TABLE {$wpdb->bea_s_receivers} ADD bounce_type char(20)");
     maybe_add_column($wpdb->bea_s_receivers, 'bounce_no', "ALTER TABLE {$wpdb->bea_s_receivers} ADD bounce_no char(10)");
     add_clean_index($wpdb->bea_s_receivers, 'email');
     add_clean_index($wpdb->bea_s_receivers, 'current_status');
     // Recesiver/campaign link table
     maybe_create_table($wpdb->bea_s_re_ca, "CREATE TABLE " . $wpdb->bea_s_re_ca . " (\n\t\t\t`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY,\n\t\t\t`id_campaign` int NOT NULL,\n\t\t\t`id_receiver` int NOT NULL,\n\t\t\t`id_content` int NOT NULL,\n\t\t\t`current_status` varchar(10) NOT NULL,\n\t\t\t`response` varchar(10) NOT NULL\n\t\t) {$charset_collate};");
     add_clean_index($wpdb->bea_s_re_ca, 'current_status');
     add_clean_index($wpdb->bea_s_re_ca, 'id_campaign');
     add_clean_index($wpdb->bea_s_re_ca, 'id_receiver');
     // Content Table
     maybe_create_table($wpdb->bea_s_contents, "CREATE TABLE " . $wpdb->bea_s_contents . " (\n\t\t\t`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY,\n\t\t\t`html` longtext NOT NULL,\n\t\t\t`text` longtext NOT NULL\n\t\t) {$charset_collate};");
     add_clean_index($wpdb->bea_s_contents, 'id');
     // Attachment Table
     maybe_create_table($wpdb->bea_s_attachments, "CREATE TABLE " . $wpdb->bea_s_attachments . " (\n\t\t\t`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY,\n\t\t\t`campaign_id` int NOT NULL,\n\t\t\t`path` longtext NOT NULL\n\t\t) {$charset_collate};");
     add_clean_index($wpdb->bea_s_attachments, 'id');
     add_clean_index($wpdb->bea_s_attachments, 'campaign_id');
 }
Example #10
0
function post_notification_install()
{
    global $wpdb;
    $t_emails = $wpdb->prefix . 'post_notification_emails';
    $t_posts = $wpdb->prefix . 'post_notification_posts';
    $t_cats = $wpdb->prefix . 'post_notification_cats';
    //******************************************//
    //**  Create WPPRAEFIX_post_notification table   **//
    //******************************************//
    if (!function_exists('maybe_create_table')) {
        require_once ABSPATH . 'wp-admin/install-helper.php';
    }
    $sql = "CREATE TABLE {$t_emails} (\r\n\t\t\t\t  id int( 11 ) NOT NULL auto_increment,\r\n\t\t\t\t  email_addr varchar( 255 ) default NULL,\r\n\t\t\t\t  gets_mail int( 11 ) default NULL,\r\n\t\t\t\t  last_modified timestamp( 14 ) NOT NULL,\r\n\t\t\t\t  date_subscribed datetime default NULL,\r\n\t\t\t\t  act_code varchar( 32 ) default NULL,\r\n\t\t\t\t  PRIMARY KEY  ( id )   \r\n\t\t   )";
    maybe_create_table($t_posts, $sql);
    $sql = "ALTER TABLE {$t_emails} ADD subscribe_ip INT UNSIGNED NOT NULL default 0";
    maybe_add_column($t_emails, 'subscribe_ip', $sql);
    //************************************************//
    //**  Create WPPRAEFIX_post_notification_posts table **//
    //************************************************//
    # Add new table
    $sql = "CREATE TABLE {$t_posts} (\r\n\t\t\t\tpost_id bigint(20) NOT NULL default '0',\r\n\t\t\t\tnotification_sent int NOT NULL default '-1',\r\n\t\t\t\tPRIMARY KEY  (post_ID)\r\n\t\t   )";
    maybe_create_table($t_posts, $sql);
    //Always adding this later keeps the code simple..... (Added in 2.2)
    $sql = "ALTER TABLE {$t_posts} ADD date_saved datetime NOT NULL default  '0000-00-00 00:00:00'";
    maybe_add_column($t_posts, 'date_saved', $sql);
    //This is in an if-statement, because auf the insert-statement.
    if ($wpdb->get_var("SHOW TABLES LIKE '{$t_cats}'") == NULL) {
        $sql = "CREATE TABLE {$t_cats} (\r\n\t\t\t\t\tid int( 11 ) NOT NULL,\r\n\t\t\t\t\tcat_id bigint(20) NOT NULL \r\n\t\t\t   )";
        maybe_create_table($t_cats, $sql);
        // Thanks to Karsten Tinnefeld for this nice query
        $wpdb->query("INSERT\r\n\t\t\t\t\tINTO    {$t_cats} (id, cat_id)\r\n\t\t\t\t\tSELECT  id, 0\r\n\t\t\t\t\tFROM    {$t_emails} e\r\n\t\t\t\t\tWHERE   NOT EXISTS (SELECT 1 \r\n\t\t\t\t\t\t\t\t\t\tFROM   {$t_cats} c \r\n\t\t\t\t\t\t\t\t\t\tWHERE c.id = e.id )");
    }
    //This actually belongs into the create statement but it's easyer to maintain this way
    $index = array();
    $indexlist = $wpdb->get_results("SHOW INDEX FROM {$t_cats}");
    foreach ($indexlist as $indexrow) {
        $index[] = $indexrow->Column_name;
    }
    if (!in_array('id', $index)) {
        $wpdb->query(" ALTER TABLE {$t_cats} ADD INDEX ( id )");
    }
    if (!in_array('cat_id', $index)) {
        $wpdb->query(" ALTER TABLE {$t_cats} ADD INDEX ( cat_id )");
    }
    $index = array();
    $indexlist = $wpdb->get_results("SHOW INDEX FROM {$t_emails}");
    foreach ($indexlist as $indexrow) {
        $index[] = $indexrow->Column_name;
    }
    if (!in_array('gets_mail', $index)) {
        $wpdb->query(" ALTER TABLE {$t_emails} ADD INDEX ( id , gets_mail )");
    }
    if (!in_array('email_addr', $index)) {
        $wpdb->query(" ALTER TABLE {$t_emails} ADD INDEX ( email_addr )");
    }
    $index = array();
    $indexlist = $wpdb->get_results("SHOW INDEX FROM {$t_posts}");
    foreach ($indexlist as $indexrow) {
        $index[] = $indexrow->Column_name;
    }
    if (!in_array('notification_sent', $index)) {
        $wpdb->query(" ALTER TABLE {$t_posts} ADD INDEX ( notification_sent )");
    }
    //}
    //************************************************//
    //**         Add Options
    //************************************************//
    load_plugin_textdomain('post_notification', POST_NOTIFICATION_PATH_REL);
    add_option('post_notification_show_content', 'no', 'Whether to mail the content', 'no');
    add_option('post_notification_read_more', '...', 'What to put in more-tag-text', 'no');
    add_option('post_notification_send_default', 'yes', 'Whether to send normal posts', 'no');
    add_option('post_notification_send_private', 'no', 'Whether to send private posts', 'no');
    add_option('post_notification_send_page', 'no', 'Whether to send private posts', 'no');
    add_option('post_notification_hdr_nl', "n", 'What kind of header', 'no');
    add_option('post_notification_from_email', get_option('admin_email'), 'The adress used as sender', 'no');
    add_option('post_notification_from_name', '@@blogname', 'The name used as sender', 'no');
    add_option('post_notification_subject', '@@blogname: @@title', 'The subject of the mail', 'no');
    add_option('post_notification_url', '', 'The URl to the main page', 'no');
    add_option('post_notification_template', "email_template.txt", 'The Template to use', 'no');
    add_option('post_notification_maxsend', "20", 'Number of Mails to send at once.', 'no');
    add_option('post_notification_pause', "10", 'Time between bursts of Mails', 'no');
    add_option('post_notification_nervous', "360", 'Nervous finger option');
    add_option('post_notification_nextsend', time(), 'When to send the next mail', 'yes');
    add_option('post_notification_lastsend', time(), 'When to send the last mail was sent.', 'no');
    add_option('post_notification_lastpost', time(), 'When the last post was published.', 'no');
    add_option('post_notification_page_meta', 'no', 'Whether to add a link to Meta', 'yes');
    //autoload is set to yes, because meta might need it.
    add_option('post_notification_page_name', __('Subscribe to Posts', 'post_notification'), 'Name of the Post Notification page.', 'yes');
    add_option('post_notification_uninstall', 'no', 'Uninstall on deaktivation', 'no');
    add_option('post_notification_captcha', '0', 'Number of captcha-cahars', 'no');
    add_option('post_notification_lock', 'file', 'Lockingtype', 'yes');
    add_option('post_notification_filter_include', 'yes', 'Include PN via filters', 'yes');
    add_option('post_notification_selected_cats', '0', 'The category preselection list.', 'no');
    add_option('post_notification_debug', 'no', 'Turn debugging on.', 'no');
    add_option('post_notification_the_content_exclude', serialize(array()), 'Include PN via filters', 'no');
    add_option('post_notification_empty_cats', 'no', 'Whether to show empty cats', 'no');
    add_option('post_notification_show_cats', 'yes', 'Whether to show cats', 'no');
    add_option('post_notification_subscribers', '0', 'Number of Subscibers', 'yes');
    add_option('post_notification_auto_subscribe', 'yes', 'Auto Subscribe when regist new user', 'no');
    if (is_dir(POST_NOTIFICATION_PATH . WPLANG)) {
        $profile = WPLANG;
    } else {
        $profile = 'en_US';
    }
    add_option('post_notification_profile', $profile, 'The Profile-dir to use');
}
Example #11
0
function create_ratinglogs_table()
{
    global $wpdb;
    postratings_textdomain();
    if (@is_file(ABSPATH . '/wp-admin/includes/upgrade.php')) {
        include_once ABSPATH . '/wp-admin/includes/upgrade.php';
    } else {
        die('We have problem finding your \'/wp-admin/upgrade-functions.php\' and \'/wp-admin/includes/upgrade.php\'');
    }
    $charset_collate = '';
    if ($wpdb->has_cap('collation')) {
        if (!empty($wpdb->charset)) {
            $charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}";
        }
        if (!empty($wpdb->collate)) {
            $charset_collate .= " COLLATE {$wpdb->collate}";
        }
    }
    // Create Post Ratings Table
    $create_ratinglogs_sql = "CREATE TABLE {$wpdb->ratings} (" . "rating_id INT(11) NOT NULL auto_increment," . "rating_postid INT(11) NOT NULL ," . "rating_posttitle TEXT NOT NULL," . "rating_rating INT(2) NOT NULL ," . "rating_timestamp VARCHAR(15) NOT NULL ," . "rating_ip VARCHAR(40) NOT NULL ," . "rating_host VARCHAR(200) NOT NULL," . "rating_username VARCHAR(50) NOT NULL," . "rating_userid int(10) NOT NULL default '0'," . "PRIMARY KEY (rating_id)) {$charset_collate};";
    maybe_create_table($wpdb->ratings, $create_ratinglogs_sql);
    // Add In Options (4 Records)
    add_option('postratings_image', 'stars');
    add_option('postratings_max', '5');
    add_option('postratings_template_vote', '%RATINGS_IMAGES_VOTE% (<strong>%RATINGS_USERS%</strong> ' . __('votes', 'wp-postratings') . __(',', 'wp-postratings') . ' ' . __('average', 'wp-postratings') . ': <strong>%RATINGS_AVERAGE%</strong> ' . __('out of', 'wp-postratings') . ' %RATINGS_MAX%)<br />%RATINGS_TEXT%');
    add_option('postratings_template_text', '%RATINGS_IMAGES% (<em><strong>%RATINGS_USERS%</strong> ' . __('votes', 'wp-postratings') . __(',', 'wp-postratings') . ' ' . __('average', 'wp-postratings') . ': <strong>%RATINGS_AVERAGE%</strong> ' . __('out of', 'wp-postratings') . ' %RATINGS_MAX%' . __(',', 'wp-postratings') . ' <strong>' . __('rated', 'wp-postratings') . '</strong></em>)');
    add_option('postratings_template_none', '%RATINGS_IMAGES_VOTE% (' . __('No Ratings Yet', 'wp-postratings') . ')<br />%RATINGS_TEXT%');
    // Database Upgrade For WP-PostRatings 1.02
    add_option('postratings_logging_method', '3');
    add_option('postratings_allowtorate', '2');
    // Database Uprade For WP-PostRatings 1.04
    maybe_add_column($wpdb->ratings, 'rating_userid', "ALTER TABLE {$wpdb->ratings} ADD rating_userid INT( 10 ) NOT NULL DEFAULT '0';");
    // Database Uprade For WP-PostRatings 1.05
    add_option('postratings_ratingstext', array(__('1 Star', 'wp-postratings'), __('2 Stars', 'wp-postratings'), __('3 Stars', 'wp-postratings'), __('4 Stars', 'wp-postratings'), __('5 Stars', 'wp-postratings')));
    add_option('postratings_template_highestrated', '<li><a href="%POST_URL%" title="%POST_TITLE%">%POST_TITLE%</a> %RATINGS_IMAGES% (%RATINGS_AVERAGE% ' . __('out of', 'wp-postratings') . ' %RATINGS_MAX%)</li>');
    // Database Upgrade For WP-PostRatings 1.11
    add_option('postratings_ajax_style', array('loading' => 1, 'fading' => 1));
    // Database Upgrade For WP-PostRatings 1.20
    add_option('postratings_ratingsvalue', array(1, 2, 3, 4, 5));
    add_option('postratings_customrating', 0);
    add_option('postratings_template_permission', '%RATINGS_IMAGES% (<em><strong>%RATINGS_USERS%</strong> ' . __('votes', 'wp-postratings') . __(',', 'wp-postratings') . ' ' . __('average', 'wp-postratings') . ': <strong>%RATINGS_AVERAGE%</strong> ' . __('out of', 'wp-postratings') . ' %RATINGS_MAX%</em>)<br /><em>' . __('You need to be a registered member to rate this post.', 'wp-postratings') . '</em>');
    // Database Upgrade For WP-PostRatings 1.30
    add_option('postratings_template_mostrated', '<li><a href="%POST_URL%"  title="%POST_TITLE%">%POST_TITLE%</a> - %RATINGS_USERS% ' . __('votes', 'wp-postratings') . '</li>');
    // Database Upgrade For WP-PostRatings 1.50
    delete_option('widget_ratings_highest_rated');
    delete_option('widget_ratings_most_rated');
    // Set 'manage_ratings' Capabilities To Administrator
    $role = get_role('administrator');
    if (!$role->has_cap('manage_ratings')) {
        $role->add_cap('manage_ratings');
    }
}
Example #12
0
function eme_create_payments_table($charset, $collate)
{
    global $wpdb;
    $db_version = get_option('eme_version');
    $table_name = $wpdb->prefix . PAYMENTS_TBNAME;
    if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") != $table_name) {
        $sql = "CREATE TABLE " . $table_name . " (\n         id int(11) NOT NULL auto_increment,\n         creation_date_gmt datetime NOT NULL DEFAULT '0000-00-00 00:00:00', \n         booking_ids text NOT NULL,\n         random_id tinytext NOT NULL,\n         UNIQUE KEY  (id)\n         ) {$charset} {$collate};";
        maybe_create_table($table_name, $sql);
    } else {
        maybe_add_column($table_name, 'random_id', "alter table {$table_name} add random_id tinytext NOT NULL;");
        if ($db_version < 80) {
            $payment_ids = $wpdb->get_col("SELECT id FROM {$table_name}");
            foreach ($payment_ids as $payment_id) {
                $random_id = eme_payment_random_id();
                $sql = $wpdb->prepare("UPDATE {$table_name} SET random_id = %s WHERE id = %d", $random_id, $payment_id);
                $wpdb->query($sql);
            }
        }
    }
}
Example #13
0
 function create_tables()
 {
     global $wpdb;
     $dbv = get_option('spec_comment_dbv', 0);
     $comment_log = $this->get_table_names();
     // If the table changes in the future this'll get a little more work
     if (version_compare($dbv, SPEC_COMMENT_DBV, 'ge')) {
         return true;
     }
     // Make sure maybe_create_table is to hand.
     if ((!function_exists('maybe_create_table') || !function_exists('check_column')) && file_exists(ABSPATH . '/wp-admin/install-helper.php')) {
         require_once ABSPATH . '/wp-admin/install-helper.php';
     }
     $table = "CREATE TABLE {$comment_log}  (\r\n\t\t\t\t\t\tid BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT, INDEX USING BTREE ( id ), PRIMARY KEY ( id ),\r\n\t\t\t\t\t\tdate TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, INDEX USING BTREE ( date ),\r\n\t\t\t\t\t\tpost_id BIGINT( 20 ) UNSIGNED NOT NULL, INDEX USING BTREE ( post_id ),\r\n\t\t\t\t\t\tcomment_id BIGINT( 20 ) UNSIGNED NOT NULL, INDEX USING BTREE ( comment_id ),\r\n\t\t\t\t\t\taction_taken varchar( 64 )\r\n\t\t\t\t\t  ) ENGINE = MEMORY;";
     // Create the tables if needed.
     if (!maybe_create_table($comment_log, $table)) {
         return false;
     }
     // Drop out if we fail, will mean we keep trying as the toggle won't get set
     if (!update_option('spec_comment_dbv', SPEC_COMMENT_DBV)) {
         add_option('spec_comment_dbv', SPEC_COMMENT_DBV);
     }
 }
Example #14
0
/**
 *Handles the creation of the table needed to store all the data
 */
function SetupConfiguration()
{
    if (!function_exists('maybe_create_table')) {
        require_once ABSPATH . DIRECTORY_SEPARATOR . 'wp-admin' . DIRECTORY_SEPARATOR . 'upgrade-functions.php';
    }
    $create_table_sql = "CREATE TABLE " . POSTIE_TABLE . " (\n         label text NOT NULL,\n         value text not NULL\n             );";
    maybe_create_table(POSTIE_TABLE, $create_table_sql);
}
Example #15
0
 public function __invoke()
 {
     require_once ABSPATH . 'wp-admin/install-helper.php';
     return maybe_create_table($this->schema->getName(), $this->getSql());
 }
Example #16
0
 /**
  * Import form settings.
  *
  * @since 1.0
  * @access public
  */
 public function importFormPhp()
 {
     if (strtolower(pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION)) == "php") {
         include_once $_FILES['file']['tmp_name'];
         global $wpdb, $guiform;
         if (@is_file(ABSPATH . '/wp-admin/includes/upgrade.php')) {
             include_once ABSPATH . '/wp-admin/includes/upgrade.php';
         } elseif (@is_file(ABSPATH . '/wp-admin/upgrade-functions.php')) {
             include_once ABSPATH . '/wp-admin/upgrade-functions.php';
         } else {
             die('We have problem finding your \'/wp-admin/upgrade-functions.php\' and \'/wp-admin/includes/upgrade.php\'');
         }
         if (sizeof($data)) {
             foreach ($data as $id => $row) {
                 if (isset($row['drop']) && $row['function'] == 'replace') {
                     $wpdb->query($row['drop']);
                 }
                 if ($row['function'] == 'insert') {
                     $old_id = $id;
                     $id = $wpdb->get_var($wpdb->prepare("SELECT `id` FROM {$wpdb->guiform} ORDER BY `id` DESC")) + 1;
                     $row['schema'] = str_replace($wpdb->guiform_form . $old_id, $wpdb->guiform_form . $id, $row['schema']);
                     $row['form']['id'] = $id;
                     $wpdb->insert($wpdb->guiform, $row['form']);
                 } else {
                     $wpdb->replace($wpdb->guiform, $row['form']);
                 }
                 maybe_create_table($wpdb->guiform_form . $id, $row['schema']);
                 if (sizeof($row['data'])) {
                     $values = array();
                     $esc = array();
                     $index = 0;
                     $column = implode("`, `", array_keys($row['data'][0]));
                     $query = "INSERT INTO " . $wpdb->guiform_form . $id . " (`" . $column . "`) VALUES ";
                     foreach ($row['data'] as $key => $entry) {
                         $values[$index++] = "('" . implode("', '", array_values($entry)) . "')";
                     }
                     $query .= implode(", ", $values) . ";";
                     $wpdb->query($query);
                 }
             }
         }
     }
     exit;
 }
function rs_install()
{
    global $wpdb;
    if (@is_file(ABSPATH . '/wp-admin/upgrade-functions.php')) {
        include_once ABSPATH . '/wp-admin/upgrade-functions.php';
    } elseif (@is_file(ABSPATH . '/wp-admin/includes/upgrade.php')) {
        include_once ABSPATH . '/wp-admin/includes/upgrade.php';
    } else {
        die('Problem finding \'/wp-admin/upgrade-functions.php\' and \'/wp-admin/includes/upgrade.php\'');
    }
    update_option('rs_reorder', true);
    $categories = get_option('rs_categories');
    if (empty($categories)) {
        update_option('rs_categories', array(0 => 'Overall Rating'));
    }
    $css = <<<EOD
table.ratings {
\tmargin: 0;
\tpadding: 0;
\tborder: 0;
\tborder-collapse: collapse;
}

ul.ratings {
\tmargin: 0;
\tpadding: 0;
}

ul.ratings li {
\tdisplay: inline;
\tlist-style: none;
}

.rating_label {
\twhite-space: nowrap;
\tbackground: #eee;
\tfont-family: Arial;
\tfont-size: 8pt;
\tpadding: 1px 4px;
}

.rating_value {
\twhite-space: nowrap;
\tpadding: 1px 3px;
\tfont-family: Arial;
\tfont-size: 8pt;
}

.rating_value .no_ratings {
\tcolor: #666;
}
EOD;
    update_option('rs_css', $css);
    $create_table_sql = "CREATE TABLE " . $wpdb->ratings . " (" . "comment_id INT, " . "rating_id INT, " . "rating_value DOUBLE, " . "PRIMARY KEY (comment_id, rating_id))";
    maybe_create_table($wpdb->ratings, $create_table_sql);
    //Check for WP Review Site 1.1 Tables and Upgrade
    $table_name = $wpdb->prefix . 'dgrs_cats';
    if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") == $table_name) {
        //Restore rating categories
        $query = "SELECT * FROM {$table_name} ORDER BY display_order";
        $result = $wpdb->get_results($query);
        $categories = array();
        $scale_max = 0;
        foreach ($result as $row) {
            $categories[$row->id] = $row->cat;
            $scale_max = $row->scale_max;
        }
        update_option('rs_categories', $categories);
        //Restore rating values
        $table_name = $wpdb->prefix . 'dgrs_ratings';
        $query = "INSERT IGNORE INTO " . $wpdb->ratings . " (comment_id, rating_id, rating_value) ";
        $query .= "SELECT comment_id, rating_cat_id, ((rating_value / {$scale_max}) * 5) FROM {$table_name}";
        $wpdb->query($query);
    }
}
 /**
 Install our table
 */
 function install()
 {
     // include upgrade-functions for maybe_create_table;
     if (!function_exists('maybe_create_table')) {
         require_once ABSPATH . '/wp-admin/upgrade-functions.php';
     }
     $date = date('Y-m-d');
     $sql = "CREATE TABLE {$this->public} (\n\t\t\tid int(11) NOT NULL auto_increment, \n\t\t\temail varchar(64) NOT NULL default '', \n\t\t\tactive tinyint(1) default 0, \n\t\t\tdate DATE default '{$date}' NOT NULL,\n\t\t\tPRIMARY KEY (id) )";
     // create the table, as needed
     maybe_create_table($this->public, $sql);
     $this->reset();
 }
/**
 *Handles the creation of the table needed to store all the data
 */
function SetupConfiguration()
{
    if (!function_exists('maybe_create_table')) {
        function maybe_create_table($table_name, $create_ddl)
        {
            global $wpdb;
            foreach ($wpdb->get_col("SHOW TABLES", 0) as $table) {
                if ($table == $table_name) {
                    return true;
                }
            }
            //didn't find it try to create it.
            $wpdb->query($create_ddl);
            // we cannot directly tell that whether this succeeded!
            foreach ($wpdb->get_col("SHOW TABLES", 0) as $table) {
                if ($table == $table_name) {
                    return true;
                }
            }
            return false;
        }
    }
    $create_table_sql = "CREATE TABLE " . POSTIE_TABLE . " (\n         label text NOT NULL,\n         value text not NULL\n             );";
    maybe_create_table(POSTIE_TABLE, $create_table_sql);
}
function upgrade_100()
{
    global $wpdb, $tableposts, $tablecomments, $tablecategories, $tableoptionvalues, $tableoptiongroups, $tableoptiongroup_options, $tableoptions, $tablepost2cat, $tablelinks, $tableusers;
    maybe_add_column($tableposts, 'post_name', "ALTER TABLE `{$tableposts}` ADD `post_name` VARCHAR(200) NOT NULL");
    maybe_add_column($tableposts, 'to_ping', "ALTER TABLE {$tableposts} ADD `to_ping` TEXT NOT NULL");
    maybe_add_column($tableposts, 'pinged', "ALTER TABLE {$tableposts} ADD `pinged` TEXT NOT NULL");
    maybe_add_column($tableposts, 'post_modified', "ALTER TABLE {$tableposts} ADD `post_modified` DATETIME NOT NULL");
    maybe_add_column($tableposts, 'post_content_filtered', "ALTER TABLE {$tableposts} ADD `post_content_filtered` TEXT NOT NULL");
    maybe_add_column($tablecategories, 'category_nicename', "ALTER TABLE `{$tablecategories}` ADD `category_nicename` VARCHAR(200) NOT NULL");
    maybe_add_column($tablecategories, 'category_description', "ALTER TABLE `{$tablecategories}` ADD `category_description` TEXT NOT NULL");
    maybe_add_column($tablecategories, 'category_parent', "ALTER TABLE `{$tablecategories}` ADD `category_parent` INT(4) NOT NULL");
    maybe_add_column($tablelinks, 'link_rss', "ALTER TABLE `{$tablelinks}` ADD `link_rss` VARCHAR( 255 ) NOT NULL;");
    maybe_add_column($tableusers, 'user_description', "ALTER TABLE `{$tableusers}` ADD `user_description` TEXT NOT NULL");
    maybe_add_column($tablecomments, 'comment_approved', "ALTER TABLE {$tablecomments} ADD COLUMN comment_approved ENUM('0', '1') DEFAULT '1' NOT NULL");
    // Create indicies
    add_clean_index($tableposts, 'post_name');
    add_clean_index($tablecategories, 'category_nicename');
    add_clean_index($tablecomments, 'comment_approved');
    // Options stuff
    if (!$wpdb->get_var("SELECT option_id FROM {$tableoptions} WHERE option_name = 'comment_moderation'")) {
        $wpdb->query("INSERT INTO {$tableoptions}\n\t\t\t(option_id, blog_id, option_name, option_can_override, option_type, option_value, option_width, option_height, option_description, option_admin_level)\n\t\t\tVALUES\n\t\t\t('0', '0', 'comment_moderation', 'Y', '5',' none', 20, 8, '_LANG_INST_BASE_VALUE88', 8)");
    }
    $oid = $wpdb->get_var("SELECT option_id FROM {$tableoptions} WHERE option_name = 'comment_moderation'");
    $gid = $wpdb->get_var("SELECT group_id FROM {$tableoptiongroups} WHERE group_name = 'General blog settings'");
    $seq = $wpdb->get_var("SELECT MAX(seq) FROM {$tableoptiongroup_options} WHERE group_id = '{$gid}'");
    ++$seq;
    if (!$wpdb->get_row("SELECT * FROM {$tableoptiongroup_options} WHERE group_id = '{$gid}' AND option_id = '{$oid}'")) {
        $wpdb->query("INSERT INTO {$tableoptiongroup_options}\n\t\t(group_id, option_id, seq)\n\t\tVALUES\n\t\t('{$gid}', '{$oid}', '{$seq}')");
    }
    if (!$wpdb->get_row("SELECT * FROM {$tableoptionvalues} WHERE option_id = {$oid} AND optionvalue = 'auto'")) {
        $wpdb->query("INSERT INTO {$tableoptionvalues}\n\t\t(option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq)\n\t\tVALUES\n\t\t('{$oid}','auto', 'Automatic', NULL, NULL, 3)");
    }
    if (!$wpdb->get_row("SELECT * FROM {$tableoptionvalues} WHERE option_id = {$oid} AND optionvalue = 'none'")) {
        $wpdb->query("INSERT INTO {$tableoptionvalues}\n\t\t(option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq)\n\t\tVALUES\n\t\t('{$oid}', 'none', 'None', NULL, NULL, 1)");
    }
    if (!$wpdb->get_row("SELECT * FROM {$tableoptionvalues} WHERE option_id = {$oid} AND optionvalue = 'manual'")) {
        $wpdb->query("INSERT INTO {$tableoptionvalues}\n\t\t(option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq)\n\t\tVALUES\n\t\t('{$oid}', 'manual', 'Manual', NULL, NULL, 2)");
    }
    if (!$wpdb->get_var("SELECT option_id FROM {$tableoptions} WHERE option_name = 'moderation_notify'")) {
        $wpdb->query("INSERT INTO {$tableoptions}\n\t\t\t(option_id, blog_id, option_name, option_can_override, option_type, option_value, option_width, option_height, option_description, option_admin_level)\n\t\t\tVALUES\n\t\t\t('0', '0', 'moderation_notify' , 'Y', '2', '1', 20, 8, '_LANG_INST_BASE_VALUE89', 8)");
    }
    $oid = $wpdb->get_var("SELECT option_id FROM {$tableoptions} WHERE option_name = 'moderation_notify'");
    $seq = $wpdb->get_var("SELECT MAX(seq) FROM {$tableoptiongroup_options} WHERE group_id = '{$gid}'");
    ++$seq;
    if (!$wpdb->get_row("SELECT * FROM {$tableoptiongroup_options} WHERE group_id = '{$gid}' AND option_id = '{$oid}'")) {
        $wpdb->query("INSERT INTO {$tableoptiongroup_options}\n\t\t\t(group_id, option_id, seq)\n\t\t\tVALUES\n\t\t\t('{$gid}', '{$oid}', '{$seq}')");
    }
    // Get the title and ID of every post, post_name to check if it already has a value
    $posts = $wpdb->get_results("SELECT ID, post_title, post_name FROM {$tableposts}");
    foreach ($posts as $post) {
        if ('' == $post->post_name) {
            $newtitle = sanitize_title($post->post_title);
            $wpdb->query("UPDATE {$tableposts} SET post_name = '{$newtitle}' WHERE ID = '{$post->ID}'");
        }
    }
    $categories = $wpdb->get_results("SELECT cat_ID, cat_name, category_nicename FROM {$tablecategories}");
    foreach ($categories as $category) {
        if ('' == $category->category_nicename) {
            $newtitle = sanitize_title($category->cat_name);
            $wpdb->query("UPDATE {$tablecategories} SET category_nicename = '{$newtitle}' WHERE cat_ID = '{$category->cat_ID}'");
        }
    }
    if (!$wpdb->get_var("SELECT option_name FROM {$tableoptions} WHERE option_name = 'permalink_structure'")) {
        // If it's not already there
        $wpdb->query("INSERT INTO `{$tableoptions}`\n\t\t\t(`option_id`, `blog_id`, `option_name`, `option_can_override`, `option_type`, `option_value`, `option_width`, `option_height`, `option_description`, `option_admin_level`)\n\t\t\tVALUES\n\t\t\t('', '0', 'permalink_structure', 'Y', '3', '', '20', '8', '_LANG_INST_BASE_VALUE90', '8');");
    }
    if (!$wpdb->get_var("SELECT option_name FROM {$tableoptions} WHERE option_name = 'gzipcompression'")) {
        // If it's not already there
        $wpdb->query("INSERT INTO `{$tableoptions}`\n\t\t\t(`option_id`, `blog_id`, `option_name`, `option_can_override`, `option_type`, `option_value`, `option_width`, `option_height`, `option_description`, `option_admin_level`)\n\t\t\tVALUES\n\t\t\t('', '0', 'gzipcompression', 'Y', '2', '0', '20', '8', '_LANG_INST_BASE_VALUE91', '8');");
        $optionid = $wpdb->get_var("SELECT option_id FROM {$tableoptions} WHERE option_name = 'gzipcompression'");
        $wpdb->query("INSERT INTO {$tableoptiongroup_options}\n\t\t\t(group_id, option_id, seq)\n\t\t\tVALUES\n\t\t\t(2, {$optionid}, 5)");
    }
    if (!$wpdb->get_var("SELECT option_id FROM {$tableoptions} WHERE option_name = 'hack_file'")) {
        $wpdb->query("INSERT INTO `{$tableoptions}`\n\t\t\t( `option_id` , `blog_id` , `option_name` , `option_can_override` , `option_type` , `option_value` , `option_width` , `option_height` , `option_description` , `option_admin_level` )\n\t\t\tVALUES\n\t\t\t('', '0', 'hack_file', 'Y', '2', '0', '20', '8', '_LANG_INST_BASE_VALUE92', '8')");
        $optionid = $wpdb->get_var("SELECT option_id FROM {$tableoptions} WHERE option_name = 'hack_file'");
        $wpdb->query("INSERT INTO {$tableoptiongroup_options}\n\t\t\t(group_id, option_id, seq)\n\t\t\tVALUES\n\t\t\t(2, {$optionid}, 5)");
    }
    $wpdb->query("UPDATE {$tableoptionvalues} SET optionvalue_max = 23 , optionvalue_min = -23 WHERE option_id = 51");
    // fix upload users description
    $wpdb->query("UPDATE {$tableoptions} SET option_description = '_LANG_INST_BASE_VALUE37' WHERE option_id = 37");
    // and file types
    $wpdb->query("UPDATE {$tableoptions} SET option_description = '_LANG_INST_BASE_VALUE34' WHERE option_id = 34");
    // add link to php date format. this could be to a wordpress.org page in the future
    $wpdb->query("UPDATE {$tableoptions} SET option_description = '_LANG_INST_BASE_VALUE52' WHERE option_id = 52");
    $wpdb->query("UPDATE {$tableoptions} SET option_description = '_LANG_INST_BASE_VALUE53' WHERE option_id = 53");
    $wpdb->query("UPDATE {$tableoptions} SET option_value = REPLACE(option_value, 'wp-links/links-images/', 'wp-images/links/')\n                                                      WHERE option_name LIKE 'links_rating_image%'\n                                                      AND option_value LIKE 'wp-links/links-images/%'");
    $wpdb->query("DELETE FROM {$tableoptions} WHERE option_name = 'comment_allowed_tags'");
    $wpdb->query("DELETE FROM {$tableoptions} WHERE option_name = 'use_preview'");
    $wpdb->query("DELETE FROM {$tableoptions} WHERE option_name = 'search_engine_friendly_urls'");
    // Multiple categories
    maybe_create_table($tablepost2cat, "\n\t\tCREATE TABLE `{$tablepost2cat}` (\n\t\t`rel_id` INT NOT NULL AUTO_INCREMENT ,\n\t\t`post_id` INT NOT NULL ,\n\t\t`category_id` INT NOT NULL ,\n\t\tPRIMARY KEY ( `rel_id` ) ,\n\t\tINDEX ( `post_id` , `category_id` )\n\t\t)\n\t\t");
    $allposts = $wpdb->get_results("SELECT ID, post_category FROM {$tableposts}");
    foreach ($allposts as $post) {
        // Check to see if it's already been imported
        $cat = $wpdb->get_row("SELECT * FROM {$tablepost2cat} WHERE post_id = {$post->ID} AND category_id = {$post->post_category}");
        if (!$cat && 0 != $post->post_category) {
            // If there's no result
            $wpdb->query("\n\t\t\t\tINSERT INTO {$tablepost2cat}\n\t\t\t\t(post_id, category_id)\n\t\t\t\tVALUES\n\t\t\t\t('{$post->ID}', '{$post->post_category}')\n\t\t\t\t");
        }
    }
}
Example #21
0
function sticky_activate()
{
    global $wpdb;
    if (@is_file(ABSPATH . '/wp-admin/upgrade-functions.php')) {
        include_once ABSPATH . '/wp-admin/upgrade-functions.php';
    } elseif (@is_file(ABSPATH . '/wp-admin/includes/upgrade.php')) {
        include_once ABSPATH . '/wp-admin/includes/upgrade.php';
    } else {
        die('We have problem finding your \'/wp-admin/upgrade-functions.php\' and \'/wp-admin/includes/upgrade.php\'');
    }
    // Create Sticky Table
    $create_sticky_sql = "CREATE TABLE {$wpdb->sticky} (" . "sticky_post_id bigint(20) NOT NULL," . "sticky_status tinyint(1) NOT NULL default '0'," . "PRIMARY KEY (sticky_post_id))";
    maybe_create_table($wpdb->sticky, $create_sticky_sql);
    // Add Options
    $sticky_options = array();
    $sticky_options['category_only'] = 0;
    $sticky_options['display_date'] = 0;
    $sticky_options['announcement_banner'] = __('Announcement', 'wp-sticky');
    add_option('sticky_options', $sticky_options, 'Sticky Options');
}
Example #22
0
function downloadmanager_activate()
{
    global $wpdb, $blog_id;
    if (@is_file(ABSPATH . '/wp-admin/upgrade-functions.php')) {
        include_once ABSPATH . '/wp-admin/upgrade-functions.php';
    } elseif (@is_file(ABSPATH . '/wp-admin/includes/upgrade.php')) {
        include_once ABSPATH . '/wp-admin/includes/upgrade.php';
    } else {
        die('We have problem finding your \'/wp-admin/upgrade-functions.php\' and \'/wp-admin/includes/upgrade.php\'');
    }
    $charset_collate = '';
    if ($wpdb->supports_collation()) {
        if (!empty($wpdb->charset)) {
            $charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}";
        }
        if (!empty($wpdb->collate)) {
            $charset_collate .= " COLLATE {$wpdb->collate}";
        }
    }
    // Create WP-Downloads Table
    $create_table = "CREATE TABLE {$wpdb->downloads} (" . "file_id int(10) NOT NULL auto_increment," . "file tinytext NOT NULL," . "file_name text character set utf8 NOT NULL," . "file_des text character set utf8 NOT NULL," . "file_size varchar(20) NOT NULL default ''," . "file_category int(2) NOT NULL default '0'," . "file_date varchar(20) NOT NULL default ''," . "file_updated_date varchar(20) NOT NULL default ''," . "file_last_downloaded_date varchar(20) NOT NULL default ''," . "file_hits int(10) NOT NULL default '0'," . "file_permission TINYINT(2) NOT NULL default '0'," . "PRIMARY KEY (file_id)) {$charset_collate};";
    maybe_create_table($wpdb->downloads, $create_table);
    // WP-Downloads Options
    if (function_exists('is_site_admin')) {
        add_option('download_path', WP_CONTENT_DIR . '/blogs.dir/' . $blog_id . '/files', 'Download Path');
        add_option('download_path_url', WP_CONTENT_URL . '/blogs.dir/' . $blog_id . '/files', 'Download Path URL');
    } else {
        add_option('download_path', WP_CONTENT_DIR . '/files', 'Download Path');
        add_option('download_path_url', content_url('files'), 'Download Path URL');
    }
    add_option('download_page_url', site_url('downloads'), 'Download Page URL');
    add_option('download_method', 1, 'Download Type');
    add_option('download_categories', array('General'), 'Download Categories');
    add_option('download_sort', array('by' => 'file_name', 'order' => 'asc', 'perpage' => 20, 'group' => 1), 'Download Sorting Options');
    add_option('download_template_header', '<p>' . __('There are <strong>%TOTAL_FILES_COUNT% files</strong>, weighing <strong>%TOTAL_SIZE%</strong> with <strong>%TOTAL_HITS% hits</strong> in <strong>%FILE_CATEGORY_NAME%</strong>.</p><p>Displaying <strong>%RECORD_START%</strong> to <strong>%RECORD_END%</strong> of <strong>%TOTAL_FILES_COUNT%</strong> files.', 'wp-downloadmanager') . '</p>', 'Download Page Header Template');
    add_option('download_template_footer', '<form action="%DOWNLOAD_PAGE_URL%" method="get"><p><input type="hidden" name="dl_cat" value="%CATEGORY_ID%" /><input type="text" name="dl_search" value="%FILE_SEARCH_WORD%" />&nbsp;&nbsp;&nbsp;<input type="submit" value="' . __('Search', 'wp-downloadmanager') . '" /></p></form>', 'Download Page Footer Template');
    add_option('download_template_category_header', '<h2 id="downloadcat-%CATEGORY_ID%"><a href="%CATEGORY_URL%" title="' . __('View all downloads in %FILE_CATEGORY_NAME%', 'wp-downloadmanager') . '">%FILE_CATEGORY_NAME%</a></h2>', 'Download Category Header Template');
    add_option('download_template_category_footer', '', 'Download Category Footer Template');
    add_option('download_template_listing', array('<p><img src="' . plugins_url('wp-downloadmanager/images/ext') . '/%FILE_ICON%" alt="" title="" style="vertical-align: middle;" />&nbsp;&nbsp;<strong><a href="%FILE_DOWNLOAD_URL%">%FILE_NAME%</a></strong><br /><strong>&raquo; %FILE_SIZE% - %FILE_HITS% ' . __('hits', 'wp-downloadmanager') . ' - %FILE_DATE%</strong><br />%FILE_DESCRIPTION%</p>', '<p><img src="' . plugins_url('wp-downloadmanager/images/ext') . '/%FILE_ICON%" alt="" title="" style="vertical-align: middle;" />&nbsp;&nbsp;<strong>%FILE_NAME%</strong><br /><strong>&raquo; %FILE_SIZE% - %FILE_HITS% ' . __('hits', 'wp-downloadmanager') . ' - %FILE_DATE%</strong><br /><i>' . __('You do not have permission to download this file.', 'wp-downloadmanager') . '</i><br />%FILE_DESCRIPTION%</p>'), 'Download Listing Template');
    add_option('download_template_embedded', array('<p><img src="' . plugins_url('wp-downloadmanager/images/ext') . '/%FILE_ICON%" alt="" title="" style="vertical-align: middle;" />&nbsp;&nbsp;<strong><a href="%FILE_DOWNLOAD_URL%">%FILE_NAME%</a></strong> (%FILE_SIZE%' . __(',', 'wp-downloadmanager') . ' %FILE_HITS% ' . __('hits', 'wp-downloadmanager') . ')</p>', '<p><img src="' . plugins_url('wp-downloadmanager/images/ext') . '/%FILE_ICON%" alt="" title="" style="vertical-align: middle;" />&nbsp;&nbsp;<strong>%FILE_NAME%</strong> (%FILE_SIZE%' . __(',', 'wp-downloadmanager') . ' %FILE_HITS% ' . __('hits', 'wp-downloadmanager') . ')<br /><i>' . __('You do not have permission to download this file.', 'wp-downloadmanager') . '</i></p>'), 'Download Embedded Template');
    add_option('download_template_most', array('<li><a href="%FILE_DOWNLOAD_URL%">%FILE_NAME%</a> (%FILE_SIZE%' . __(',', 'wp-downloadmanager') . ' %FILE_HITS% ' . __('hits', 'wp-downloadmanager') . ')</li>', '<li>%FILE_NAME% (%FILE_SIZE%' . __(',', 'wp-downloadmanager') . ' %FILE_HITS% ' . __('hits', 'wp-downloadmanager') . ')<br /><i>' . __('You do not have permission to download this file.', 'wp-downloadmanager') . '</i></li>'), 'Most Download Template');
    // Database Upgrade For WP-DownloadManager 1.30
    $check_for_130 = $wpdb->get_var("SELECT option_value FROM {$wpdb->options} WHERE option_name = 'download_nice_permalink'");
    if (!$check_for_130) {
        maybe_add_column($wpdb->downloads, 'file_updated_date', "ALTER TABLE {$wpdb->downloads} ADD file_updated_date VARCHAR(20) NOT NULL AFTER file_date;");
        $wpdb->query("UPDATE {$wpdb->downloads} SET file_updated_date = file_date;");
        maybe_add_column($wpdb->downloads, 'file_last_downloaded_date', "ALTER TABLE {$wpdb->downloads} ADD file_last_downloaded_date VARCHAR(20) NOT NULL AFTER file_updated_date;");
        $wpdb->query("UPDATE {$wpdb->downloads} SET file_last_downloaded_date = file_date;");
    }
    add_option('download_template_pagingheader', '', 'Displayed Before Paging In The Downloads Page');
    add_option('download_template_pagingfooter', '', 'Displayed After Paging In The Downloads Page');
    add_option('download_nice_permalink', 1, 'Use Download Nice Permalink');
    add_option('download_template_download_page_link', '<p><a href="%DOWNLOAD_PAGE_URL%" title="' . __('Downloads Page', 'wp-downloadmanager') . '">' . __('Downloads Page', 'wp-downloadmanager') . '</a></p>', 'Template For Download Page Link');
    add_option('download_template_none', '<p style="text-align: center;">' . __('No Files Found.', 'wp-downloadmanager') . '</p>', 'Template For No Downloads Found');
    // Database Upgrade For WP-DownloadManager 1.50
    $check_for_150 = $wpdb->get_var("SELECT option_value FROM {$wpdb->options} WHERE option_name = 'download_options'");
    if (!$check_for_150) {
        $update_permission_1 = $wpdb->query("UPDATE {$wpdb->downloads} SET file_permission = -2 WHERE file_permission = -1;");
        if ($update_permission_1) {
            $update_permission_2 = $wpdb->query("UPDATE {$wpdb->downloads} SET file_permission = -1 WHERE file_permission = 0;");
            if ($update_permission_2) {
                $wpdb->query("UPDATE {$wpdb->downloads} SET file_permission = 0 WHERE file_permission = 1;");
            }
        }
    }
    add_option('download_options', array('use_filename' => 0, 'rss_sortby' => 'file_date', 'rss_limit' => 20), 'Download Options');
    // Create Files Folder
    if (function_exists('is_site_admin')) {
        if (!is_dir(WP_CONTENT_DIR . '/blogs.dir/' . $blog_id . '/files/') && is_writable(WP_CONTENT_DIR . '/blogs.dir/' . $blog_id . '/files/')) {
            mkdir(WP_CONTENT_DIR . '/blogs.dir/' . $blog_id . '/files/', 0777, true);
        }
    } else {
        if (!is_dir(WP_CONTENT_DIR . '/files/') && is_writable(WP_CONTENT_DIR . '/files/')) {
            mkdir(WP_CONTENT_DIR . '/files/', 0777, true);
        }
    }
    delete_option('widget_download_recent_downloads');
    delete_option('widget_download_most_downloaded');
    // Set 'manage_downloads' Capabilities To Administrator
    $role = get_role('administrator');
    if (!$role->has_cap('manage_downloads')) {
        $role->add_cap('manage_downloads');
    }
}
Example #23
0
function email_activate()
{
    global $wpdb;
    if (@is_file(ABSPATH . '/wp-admin/upgrade-functions.php')) {
        include_once ABSPATH . '/wp-admin/upgrade-functions.php';
    } elseif (@is_file(ABSPATH . '/wp-admin/includes/upgrade.php')) {
        include_once ABSPATH . '/wp-admin/includes/upgrade.php';
    } else {
        die('We have problem finding your \'/wp-admin/upgrade-functions.php\' and \'/wp-admin/includes/upgrade.php\'');
    }
    $charset_collate = '';
    if ($wpdb->supports_collation()) {
        if (!empty($wpdb->charset)) {
            $charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}";
        }
        if (!empty($wpdb->collate)) {
            $charset_collate .= " COLLATE {$wpdb->collate}";
        }
    }
    // Create E-Mail Table
    $create_table = "CREATE TABLE {$wpdb->email} (" . "email_id int(10) NOT NULL auto_increment," . "email_yourname varchar(200) NOT NULL default ''," . "email_youremail varchar(200) NOT NULL default ''," . "email_yourremarks text NOT NULL," . "email_friendname varchar(200) NOT NULL default ''," . "email_friendemail varchar(200) NOT NULL default ''," . "email_postid int(10) NOT NULL default '0'," . "email_posttitle text NOT NULL," . "email_timestamp varchar(20) NOT NULL default ''," . "email_ip varchar(100) NOT NULL default ''," . "email_host varchar(200) NOT NULL default ''," . "email_status varchar(20) NOT NULL default ''," . "PRIMARY KEY (email_id)) {$charset_collate};";
    maybe_create_table($wpdb->email, $create_table);
    // Add In Options
    add_option('email_smtp', array('username' => '', 'password' => '', 'server' => ''));
    add_option('email_contenttype', 'text/html');
    add_option('email_mailer', 'php');
    add_option('email_template_subject', __('Recommended Article By %EMAIL_YOUR_NAME%: %EMAIL_POST_TITLE%', 'wp-email'));
    add_option('email_template_body', __('<p>Hi <strong>%EMAIL_FRIEND_NAME%</strong>,<br />Your friend, <strong>%EMAIL_YOUR_NAME%</strong>, has recommended this article entitled \'<strong>%EMAIL_POST_TITLE%</strong>\' to you.</p><p><strong>Here is his/her remark:</strong><br />%EMAIL_YOUR_REMARKS%</p><p><strong>%EMAIL_POST_TITLE%</strong><br />Posted By %EMAIL_POST_AUTHOR% On %EMAIL_POST_DATE% In %EMAIL_POST_CATEGORY%</p>%EMAIL_POST_CONTENT%<p>Article taken from %EMAIL_BLOG_NAME% - <a href="%EMAIL_BLOG_URL%">%EMAIL_BLOG_URL%</a><br />URL to article: <a href="%EMAIL_PERMALINK%">%EMAIL_PERMALINK%</a></p>', 'wp-email'));
    add_option('email_template_bodyalt', __('Hi %EMAIL_FRIEND_NAME%,' . "\n" . 'Your friend, %EMAIL_YOUR_NAME%, has recommended this article entitled \'%EMAIL_POST_TITLE%\' to you.' . "\n\n" . 'Here is his/her remarks:' . "\n" . '%EMAIL_YOUR_REMARKS%' . "\n\n" . '%EMAIL_POST_TITLE%' . "\n" . 'Posted By %EMAIL_POST_AUTHOR% On %EMAIL_POST_DATE% In %EMAIL_POST_CATEGORY%' . "\n" . '%EMAIL_POST_CONTENT%' . "\n" . 'Article taken from %EMAIL_BLOG_NAME% - %EMAIL_BLOG_URL%' . "\n" . 'URL to article: %EMAIL_PERMALINK%', 'wp-email'));
    add_option('email_template_sentsuccess', '<p>' . __('Article: <strong>%EMAIL_POST_TITLE%</strong> has been sent to <strong>%EMAIL_FRIEND_NAME% (%EMAIL_FRIEND_EMAIL%)</strong></p><p>&laquo; <a href="%EMAIL_PERMALINK%">' . __('Back to %EMAIL_POST_TITLE%', 'wp-email') . '</a></p>', 'wp-email'));
    add_option('email_template_sentfailed', '<p>' . __('An error has occurred when trying to send this email: ', 'wp-email') . '<br /><strong>&raquo;</strong> %EMAIL_ERROR_MSG%</p>');
    add_option('email_template_error', '<p>' . __('An error has occurred: ', 'wp-email') . '<br /><strong>&raquo;</strong> %EMAIL_ERROR_MSG%</p>');
    add_option('email_interval', 10);
    add_option('email_snippet', 0);
    add_option('email_multiple', 5);
    // Version 2.05 Options
    add_option('email_imageverify', 1);
    // Version 2.10 Options
    $email_options = array('post_text' => __('Email This Post', 'wp-email'), 'page_text' => __('Email This Page', 'wp-email'), 'email_icon' => 'email_famfamfam.png', 'email_type' => 1, 'email_style' => 1, 'email_html' => '<a href="%EMAIL_URL%" rel="nofollow" title="%EMAIL_TEXT%">%EMAIL_TEXT%</a>');
    add_option('email_options', $email_options);
    $email_fields = array('yourname' => 1, 'youremail' => 1, 'yourremarks' => 1, 'friendname' => 1, 'friendemail' => 1);
    add_option('email_fields', $email_fields);
    // Version 2.11 Options
    add_option('email_template_title', __('E-Mail \'%EMAIL_POST_TITLE%\' To A Friend', 'wp-email'));
    add_option('email_template_subtitle', '<p style="text-align: center;">' . __('Email a copy of <strong>\'%EMAIL_POST_TITLE%\'</strong> to a friend', 'wp-email') . '</p>');
    // Mailchimp Integration
    add_option('mailchimp_api_key', 'empty');
    add_option('mailchimp_sender_listid', 'empty');
    add_option('mailchimp_receivers_listid', 'empty');
    // Set 'manage_email' Capabilities To Administrator
    $role = get_role('administrator');
    if (!$role->has_cap('manage_email')) {
        $role->add_cap('manage_email');
    }
    // Flush Rewrite Rules
    flush_rewrite_rules();
}
Example #24
0
function create_email_table()
{
    global $wpdb;
    email_textdomain();
    if (@is_file(ABSPATH . '/wp-admin/upgrade-functions.php')) {
        include_once ABSPATH . '/wp-admin/upgrade-functions.php';
    } elseif (@is_file(ABSPATH . '/wp-admin/includes/upgrade.php')) {
        include_once ABSPATH . '/wp-admin/includes/upgrade.php';
    } else {
        die('We have problem finding your \'/wp-admin/upgrade-functions.php\' and \'/wp-admin/includes/upgrade.php\'');
    }
    $charset_collate = '';
    if ($wpdb->supports_collation()) {
        if (!empty($wpdb->charset)) {
            $charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}";
        }
        if (!empty($wpdb->collate)) {
            $charset_collate .= " COLLATE {$wpdb->collate}";
        }
    }
    // Create E-Mail Table
    $create_table = "CREATE TABLE {$wpdb->email} (" . "email_id int(10) NOT NULL auto_increment," . "email_yourname varchar(200) NOT NULL default ''," . "email_youremail varchar(200) NOT NULL default ''," . "email_yourremarks text NOT NULL," . "email_friendname varchar(200) NOT NULL default ''," . "email_friendemail varchar(200) NOT NULL default ''," . "email_postid int(10) NOT NULL default '0'," . "email_posttitle text NOT NULL," . "email_timestamp varchar(20) NOT NULL default ''," . "email_ip varchar(100) NOT NULL default ''," . "email_host varchar(200) NOT NULL default ''," . "email_status varchar(20) NOT NULL default ''," . "PRIMARY KEY (email_id)) {$charset_collate};";
    maybe_create_table($wpdb->email, $create_table);
    // Add In Options (12 Records)
    add_option('email_smtp', array('username' => '', 'password' => '', 'server' => ''), 'Your SMTP Name, Password, Server');
    add_option('email_contenttype', 'text/html', 'Your E-Mail Type');
    add_option('email_mailer', 'php', 'Your Mailer Type');
    add_option('email_template_subject', __('Recommended Article By %EMAIL_YOUR_NAME%: %EMAIL_POST_TITLE%', 'wp-email'), 'Template For E-Mail Subject');
    add_option('email_template_body', __('<p>Hi <strong>%EMAIL_FRIEND_NAME%</strong>,<br />Your friend, <strong>%EMAIL_YOUR_NAME%</strong>, has recommended this article entitled \'<strong>%EMAIL_POST_TITLE%</strong>\' to you.</p><p><strong>Here is his/her remark:</strong><br />%EMAIL_YOUR_REMARKS%</p><p><strong>%EMAIL_POST_TITLE%</strong><br />Posted By %EMAIL_POST_AUTHOR% On %EMAIL_POST_DATE% In %EMAIL_POST_CATEGORY%</p>%EMAIL_POST_CONTENT%<p>Article taken from %EMAIL_BLOG_NAME% - <a href="%EMAIL_BLOG_URL%">%EMAIL_BLOG_URL%</a><br />URL to article: <a href="%EMAIL_PERMALINK%">%EMAIL_PERMALINK%</a></p>', 'wp-email'), 'Template For E-Mail Body');
    add_option('email_template_bodyalt', __('Hi %EMAIL_FRIEND_NAME%,' . "\n" . 'Your friend, %EMAIL_YOUR_NAME%, has recommended this article entitled \'%EMAIL_POST_TITLE%\' to you.' . "\n\n" . 'Here is his/her remarks:' . "\n" . '%EMAIL_YOUR_REMARKS%' . "\n\n" . '%EMAIL_POST_TITLE%' . "\n" . 'Posted By %EMAIL_POST_AUTHOR% On %EMAIL_POST_DATE% In %EMAIL_POST_CATEGORY%' . "\n" . '%EMAIL_POST_CONTENT%' . "\n" . 'Article taken from %EMAIL_BLOG_NAME% - %EMAIL_BLOG_URL%' . "\n" . 'URL to article: %EMAIL_PERMALINK%', 'wp-email'), 'Template For E-Mail Alternate Body');
    add_option('email_template_sentsuccess', '<p>' . __('Article: <strong>%EMAIL_POST_TITLE%</strong> has been sent to <strong>%EMAIL_FRIEND_NAME% (%EMAIL_FRIEND_EMAIL%)</strong></p><p>&laquo; <a href="%EMAIL_PERMALINK%">' . __('Back to %EMAIL_POST_TITLE%', 'wp-email') . '</a></p>', 'wp-email'), 'Template For E-Mail That Is Sent Successfully');
    add_option('email_template_sentfailed', '<p>' . __('An error has occurred when trying to send this email: ', 'wp-email') . '<br /><strong>&raquo;</strong> %EMAIL_ERROR_MSG%</p>', 'Template For E-Mail That Failed To Sent');
    add_option('email_template_error', '<p>' . __('An error has occurred: ', 'wp-email') . '<br /><strong>&raquo;</strong> %EMAIL_ERROR_MSG%</p>', 'Template For E-Mail That Has An Error');
    add_option('email_interval', 10, 'The Number Of Minutes Before The User Can E-Mail The Next Article');
    add_option('email_snippet', 0, 'Enable Snippet Feature For Your E-Mail?');
    add_option('email_multiple', 5, 'Maximum Number Of Multiple E-Mails');
    // Version 2.05 Options
    add_option('email_imageverify', 1, 'Enable Image Verification?');
    // Version 2.10 Options
    $email_options = array('post_text' => __('Email This Post', 'wp-email'), 'page_text' => __('Email This Page', 'wp-email'), 'email_icon' => 'email_famfamfam.png', 'email_type' => 1, 'email_style' => 1, 'email_html' => '<a href="%EMAIL_URL%" rel="nofollow" title="%EMAIL_TEXT%">%EMAIL_TEXT%</a>');
    $email_fields = array('yourname' => 1, 'youremail' => 1, 'yourremarks' => 1, 'friendname' => 1, 'friendemail' => 1);
    add_option('email_options', $email_options, 'Email Options');
    add_option('email_fields', $email_fields, 'Email Fields');
    // Version 2.11 Options
    add_option('email_template_title', __('E-Mail \'%EMAIL_POST_TITLE%\' To A Friend', 'wp-email'), 'Template For E-Mail Page Title');
    add_option('email_template_subtitle', '<p style="text-align: center;">' . __('Email a copy of <strong>\'%EMAIL_POST_TITLE%\'</strong> to a friend', 'wp-email') . '</p>', 'Template For E-Mail Page SubTitle');
    // Version 2.20 Upgrade
    $email_mailer = get_option('email_mailer');
    if ($email_mailer == 'php') {
        update_option('email_mailer', 'mail');
    }
    // Version 2.60 Upgrade
    delete_option('widget_email_most_emailed');
    // Set 'manage_email' Capabilities To Administrator
    $role = get_role('administrator');
    if (!$role->has_cap('manage_email')) {
        $role->add_cap('manage_email');
    }
}
Example #25
0
 /**
  * Create Downloads Table and add default options
  * @global type $wpdb
  * @global type $blog_id 
  */
 public function create_download_table()
 {
     global $wpdb, $blog_id;
     $this->load_textdomain();
     if (@is_file(ABSPATH . '/wp-admin/includes/upgrade.php')) {
         include_once ABSPATH . '/wp-admin/includes/upgrade.php';
     } elseif (@is_file(ABSPATH . '/wp-admin/upgrade-functions.php')) {
         include_once ABSPATH . '/wp-admin/upgrade-functions.php';
     } else {
         wp_die(__('We have problem finding your \'/wp-admin/upgrade-functions.php\' and \'/wp-admin/includes/upgrade.php\'', self::textdomain));
     }
     $charset_collate = '';
     if ($wpdb->supports_collation()) {
         if (!empty($wpdb->charset)) {
             $charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}";
         }
         if (!empty($wpdb->collate)) {
             $charset_collate .= " COLLATE {$wpdb->collate}";
         }
     }
     // Create WP-Downloads Table
     $create_table = "CREATE TABLE {$wpdb->downloads} (" . "file_id int(10) NOT NULL auto_increment," . "file tinytext NOT NULL," . "file_name text NOT NULL," . "file_des text NOT NULL," . "file_hash varchar(40) NOT NULL default ''," . "file_size varchar(20) NOT NULL default ''," . "file_date varchar(20) NOT NULL default ''," . "file_updated_date varchar(20) NOT NULL default ''," . "file_last_downloaded_date varchar(20) NOT NULL default ''," . "file_hits int(10) NOT NULL default '0'," . "file_permission TINYINT(2) NOT NULL default '0'," . "PRIMARY KEY (file_id)) {$charset_collate};";
     maybe_create_table($wpdb->downloads, $create_table);
     // WP-Downloads Options
     if (function_exists('is_site_admin')) {
         add_option('download_path', str_replace("\\", '/', WP_CONTENT_DIR) . '/blogs.dir/' . $blog_id . '/files');
         add_option('download_path_url', WP_CONTENT_URL . '/blogs.dir/' . $blog_id . '/files');
     } else {
         add_option('download_path', str_replace("\\", '/', WP_CONTENT_DIR) . '/files');
         add_option('download_path_url', content_url('files'));
     }
     add_option('download_method', 0);
     add_option('download_display_type', 0);
     add_option('download_template_embedded', self::get_default_value('download_template_embedded'));
     add_option('download_options', self::get_default_value('download_options'));
     add_option('download_template_custom_css', self::get_default_value('download_template_custom_css'));
     add_option('download_template_popup', self::get_default_value('download_template_popup'));
     //$wpdb->query("UPDATE $wpdb->downloads SET file_permission = -2 WHERE file_permission = -1;");
     //$wpdb->query("UPDATE $wpdb->downloads SET file_permission = -1 WHERE file_permission = 0;");
     //$wpdb->query("UPDATE $wpdb->downloads SET file_permission = 0 WHERE file_permission = 1;");
     // Create Files Folder
     if (function_exists('is_site_admin')) {
         if (!is_dir(str_replace("\\", '/', WP_CONTENT_DIR) . '/blogs.dir/' . $blog_id . '/files/')) {
             mkdir(str_replace("\\", '/', WP_CONTENT_DIR) . '/blogs.dir/' . $blog_id . '/files/', 0777, true);
         }
     } else {
         if (!is_dir(str_replace("\\", '/', WP_CONTENT_DIR) . '/files/')) {
             mkdir(str_replace("\\", '/', WP_CONTENT_DIR) . '/files/', 0777, true);
         }
     }
     // Set 'manage_downloads' Capabilities To Administrator
     $role = get_role('administrator');
     if (!$role->has_cap('manage_downloads')) {
         $role->add_cap('manage_downloads');
     }
 }
Example #26
0
function create_poll_table()
{
    global $wpdb;
    polls_textdomain();
    if (@is_file(ABSPATH . '/wp-admin/includes/upgrade.php')) {
        include_once ABSPATH . '/wp-admin/includes/upgrade.php';
    } elseif (@is_file(ABSPATH . '/wp-admin/upgrade-functions.php')) {
        include_once ABSPATH . '/wp-admin/upgrade-functions.php';
    } elseif (@is_file(ABSPATH . '/wp-admin/includes/upgrade.php')) {
        include_once ABSPATH . '/wp-admin/includes/upgrade.php';
    } else {
        die('We have problem finding your \'/wp-admin/upgrade-functions.php\' and \'/wp-admin/includes/upgrade.php\'');
    }
    // Create Poll Tables (3 Tables)
    $charset_collate = '';
    if ($wpdb->supports_collation()) {
        if (!empty($wpdb->charset)) {
            $charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}";
        }
        if (!empty($wpdb->collate)) {
            $charset_collate .= " COLLATE {$wpdb->collate}";
        }
    }
    $create_table = array();
    $create_table['pollsq'] = "CREATE TABLE {$wpdb->pollsq} (" . "pollq_id int(10) NOT NULL auto_increment," . "pollq_question varchar(200) character set utf8 NOT NULL default ''," . "pollq_timestamp varchar(20) NOT NULL default ''," . "pollq_totalvotes int(10) NOT NULL default '0'," . "pollq_active tinyint(1) NOT NULL default '1'," . "pollq_expiry varchar(20) NOT NULL default ''," . "pollq_multiple tinyint(3) NOT NULL default '0'," . "pollq_totalvoters int(10) NOT NULL default '0'," . "PRIMARY KEY (pollq_id)) {$charset_collate};";
    $create_table['pollsa'] = "CREATE TABLE {$wpdb->pollsa} (" . "polla_aid int(10) NOT NULL auto_increment," . "polla_qid int(10) NOT NULL default '0'," . "polla_answers varchar(200) character set utf8 NOT NULL default ''," . "polla_votes int(10) NOT NULL default '0'," . "PRIMARY KEY (polla_aid)) {$charset_collate};";
    $create_table['pollsip'] = "CREATE TABLE {$wpdb->pollsip} (" . "pollip_id int(10) NOT NULL auto_increment," . "pollip_qid varchar(10) NOT NULL default ''," . "pollip_aid varchar(10) NOT NULL default ''," . "pollip_ip varchar(100) NOT NULL default ''," . "pollip_host VARCHAR(200) NOT NULL default ''," . "pollip_timestamp varchar(20) NOT NULL default '0000-00-00 00:00:00'," . "pollip_user tinytext NOT NULL," . "pollip_userid int(10) NOT NULL default '0'," . "PRIMARY KEY (pollip_id)," . "KEY pollip_ip (pollip_id)," . "KEY pollip_qid (pollip_qid)" . ") {$charset_collate};";
    maybe_create_table($wpdb->pollsq, $create_table['pollsq']);
    maybe_create_table($wpdb->pollsa, $create_table['pollsa']);
    maybe_create_table($wpdb->pollsip, $create_table['pollsip']);
    // Check Whether It is Install Or Upgrade
    $first_poll = $wpdb->get_var("SELECT pollq_id FROM {$wpdb->pollsq} LIMIT 1");
    // If Install, Insert 1st Poll Question With 5 Poll Answers
    if (empty($first_poll)) {
        // Insert Poll Question (1 Record)
        $insert_pollq = $wpdb->query("INSERT INTO {$wpdb->pollsq} VALUES (1, '" . __('How Is My Site?', 'wp-polls') . "', '" . current_time('timestamp') . "', 0, 1, '', 0, 0);");
        if ($insert_pollq) {
            // Insert Poll Answers  (5 Records)
            $wpdb->query("INSERT INTO {$wpdb->pollsa} VALUES (1, 1, '" . __('Good', 'wp-polls') . "', 0);");
            $wpdb->query("INSERT INTO {$wpdb->pollsa} VALUES (2, 1, '" . __('Excellent', 'wp-polls') . "', 0);");
            $wpdb->query("INSERT INTO {$wpdb->pollsa} VALUES (3, 1, '" . __('Bad', 'wp-polls') . "', 0);");
            $wpdb->query("INSERT INTO {$wpdb->pollsa} VALUES (4, 1, '" . __('Can Be Improved', 'wp-polls') . "', 0);");
            $wpdb->query("INSERT INTO {$wpdb->pollsa} VALUES (5, 1, '" . __('No Comments', 'wp-polls') . "', 0);");
        }
    }
    // Add In Options (16 Records)
    add_option('poll_template_voteheader', '<p style="text-align: center;"><strong>%POLL_QUESTION%</strong></p>' . '<div id="polls-%POLL_ID%-ans" class="wp-polls-ans">' . '<ul class="wp-polls-ul">');
    add_option('poll_template_votebody', '<li><input type="%POLL_CHECKBOX_RADIO%" id="poll-answer-%POLL_ANSWER_ID%" name="poll_%POLL_ID%" value="%POLL_ANSWER_ID%" /> <label for="poll-answer-%POLL_ANSWER_ID%">%POLL_ANSWER%</label></li>');
    add_option('poll_template_votefooter', '</ul>' . '<p style="text-align: center;"><input type="button" name="vote" value="   ' . __('Vote', 'wp-polls') . '   " class="Buttons" onclick="poll_vote(%POLL_ID%);" /></p>' . '<p style="text-align: center;"><a href="#ViewPollResults" onclick="poll_result(%POLL_ID%); return false;" title="' . __('View Results Of This Poll', 'wp-polls') . '">' . __('View Results', 'wp-polls') . '</a></p>' . '</div>');
    add_option('poll_template_resultheader', '<p style="text-align: center;"><strong>%POLL_QUESTION%</strong></p>' . '<div id="polls-%POLL_ID%-ans" class="wp-polls-ans">' . '<ul class="wp-polls-ul">');
    add_option('poll_template_resultbody', '<li>%POLL_ANSWER% <small>(%POLL_ANSWER_PERCENTAGE%%' . __(',', 'wp-polls') . ' %POLL_ANSWER_VOTES% ' . __('Votes', 'wp-polls') . ')</small><div class="pollbar" style="width: %POLL_ANSWER_IMAGEWIDTH%%;" title="%POLL_ANSWER_TEXT% (%POLL_ANSWER_PERCENTAGE%% | %POLL_ANSWER_VOTES% ' . __('Votes', 'wp-polls') . ')"></div></li>');
    add_option('poll_template_resultbody2', '<li><strong><i>%POLL_ANSWER% <small>(%POLL_ANSWER_PERCENTAGE%%' . __(',', 'wp-polls') . ' %POLL_ANSWER_VOTES% ' . __('Votes', 'wp-polls') . ')</small></i></strong><div class="pollbar" style="width: %POLL_ANSWER_IMAGEWIDTH%%;" title="' . __('You Have Voted For This Choice', 'wp-polls') . ' - %POLL_ANSWER_TEXT% (%POLL_ANSWER_PERCENTAGE%% | %POLL_ANSWER_VOTES% ' . __('Votes', 'wp-polls') . ')"></div></li>');
    add_option('poll_template_resultfooter', '</ul>' . '<p style="text-align: center;">' . __('Total Voters', 'wp-polls') . ': <strong>%POLL_TOTALVOTERS%</strong></p>' . '</div>');
    add_option('poll_template_resultfooter2', '</ul>' . '<p style="text-align: center;">' . __('Total Voters', 'wp-polls') . ': <strong>%POLL_TOTALVOTERS%</strong></p>' . '<p style="text-align: center;"><a href="#VotePoll" onclick="poll_booth(%POLL_ID%); return false;" title="' . __('Vote For This Poll', 'wp-polls') . '">' . __('Vote', 'wp-polls') . '</a></p>' . '</div>');
    add_option('poll_template_disable', __('Sorry, there are no polls available at the moment.', 'wp-polls'));
    add_option('poll_template_error', __('An error has occurred when processing your poll.', 'wp-polls'));
    add_option('poll_currentpoll', 0);
    add_option('poll_latestpoll', 1);
    add_option('poll_archive_perpage', 5);
    add_option('poll_ans_sortby', 'polla_aid');
    add_option('poll_ans_sortorder', 'asc');
    add_option('poll_ans_result_sortby', 'polla_votes');
    add_option('poll_ans_result_sortorder', 'desc');
    // Database Upgrade For WP-Polls 2.1
    add_option('poll_logging_method', '3');
    add_option('poll_allowtovote', '2');
    maybe_add_column($wpdb->pollsq, 'pollq_active', "ALTER TABLE {$wpdb->pollsq} ADD pollq_active TINYINT( 1 ) NOT NULL DEFAULT '1';");
    // Database Upgrade For WP-Polls 2.12
    maybe_add_column($wpdb->pollsip, 'pollip_userid', "ALTER TABLE {$wpdb->pollsip} ADD pollip_userid INT( 10 ) NOT NULL DEFAULT '0';");
    add_option('poll_archive_url', site_url('pollsarchive'));
    // Database Upgrade For WP-Polls 2.13
    add_option('poll_bar', array('style' => 'default', 'background' => 'd8e1eb', 'border' => 'c8c8c8', 'height' => 8));
    // Database Upgrade For WP-Polls 2.14
    maybe_add_column($wpdb->pollsq, 'pollq_expiry', "ALTER TABLE {$wpdb->pollsq} ADD pollq_expiry varchar(20) NOT NULL default '';");
    add_option('poll_close', 1);
    // Database Upgrade For WP-Polls 2.20
    add_option('poll_ajax_style', array('loading' => 1, 'fading' => 1));
    add_option('poll_template_pollarchivelink', '<ul>' . '<li><a href="%POLL_ARCHIVE_URL%">' . __('Polls Archive', 'wp-polls') . '</a></li>' . '</ul>');
    add_option('poll_archive_displaypoll', 2);
    add_option('poll_template_pollarchiveheader', '');
    add_option('poll_template_pollarchivefooter', '<p>' . __('Start Date:', 'wp-polls') . ' %POLL_START_DATE%<br />' . __('End Date:', 'wp-polls') . ' %POLL_END_DATE%</p>');
    maybe_add_column($wpdb->pollsq, 'pollq_multiple', "ALTER TABLE {$wpdb->pollsq} ADD pollq_multiple TINYINT( 3 ) NOT NULL DEFAULT '0';");
    $pollq_totalvoters = maybe_add_column($wpdb->pollsq, 'pollq_totalvoters', "ALTER TABLE {$wpdb->pollsq} ADD pollq_totalvoters INT( 10 ) NOT NULL DEFAULT '0';");
    if ($pollq_totalvoters) {
        $pollq_totalvoters = intval($wpdb->get_var("SELECT SUM(pollq_totalvoters) FROM {$wpdb->pollsq}"));
        if ($pollq_totalvoters == 0) {
            $wpdb->query("UPDATE {$wpdb->pollsq} SET pollq_totalvoters = pollq_totalvotes");
        }
    }
    // Database Upgrade For WP-Polls 2.30
    add_option('poll_cookielog_expiry', 0);
    add_option('poll_template_pollarchivepagingheader', '');
    add_option('poll_template_pollarchivepagingfooter', '');
    // Database Upgrade For WP-Polls 2.50
    delete_option('poll_archive_show');
    // Database Upgrade For WP-Polls 2.61
    $wpdb->query("ALTER TABLE {$wpdb->pollsip} ADD INDEX pollip_ip (pollip_id);");
    $wpdb->query("ALTER TABLE {$wpdb->pollsip} ADD INDEX pollip_qid (pollip_qid);");
    // Set 'manage_polls' Capabilities To Administrator
    $role = get_role('administrator');
    if (!$role->has_cap('manage_polls')) {
        $role->add_cap('manage_polls');
    }
    cron_polls_place();
}
 /**
  * Create global database if it doesn't exist
  *
  **/
 function global_install()
 {
     global $wpdb;
     if (@is_file(ABSPATH . '/wp-admin/includes/upgrade.php')) {
         include_once ABSPATH . '/wp-admin/includes/upgrade.php';
     } else {
         die(__('We have problem finding your \'/wp-admin/upgrade-functions.php\' and \'/wp-admin/includes/upgrade.php\'', 'add_new_users'));
     }
     // choose correct table charset and collation
     $charset_collate = '';
     if ($wpdb->supports_collation()) {
         if (!empty($wpdb->charset)) {
             $charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}";
         }
         if (!empty($wpdb->collate)) {
             $charset_collate .= " COLLATE {$wpdb->collate}";
         }
     }
     $table = "CREATE TABLE IF NOT EXISTS `{$wpdb->base_prefix}add_new_users_queue` (\r\n\t\t\t`add_new_users_ID` bigint(20) unsigned NOT NULL auto_increment,\r\n\t\t\t`add_new_users_site_ID` bigint(20),\r\n\t\t\t`add_new_users_blog_ID` bigint(20),\r\n\t\t\t`add_new_users_batch_ID` varchar(255),\r\n\t\t\t`add_new_users_user_login` varchar(255),\r\n\t\t\t`add_new_users_user_email` varchar(255),\r\n\t\t\t`add_new_users_user_password` varchar(255),\r\n\t\t\t`add_new_users_user_role` varchar(255),\r\n\t\t\tPRIMARY KEY  (`add_new_users_ID`)\r\n\t\t) {$charset_collate};";
     maybe_create_table("{$wpdb->base_prefix}add_new_users_queue", $table);
 }