Exemplo n.º 1
0
 */
function hw_module_counter_register_activation_hook()
{
    global $wpdb;
    if ($wpdb->get_var('SHOW TABLES LIKE "' . HW_BMW_TABLE_NAME . '"') != HW_BMW_TABLE_NAME) {
        $sql = "CREATE TABLE IF NOT EXISTS `" . HW_BMW_TABLE_NAME . "` (";
        $sql .= "`ip` varchar(20) NOT NULL default '',";
        $sql .= "`tanggal` date NOT NULL,";
        $sql .= "`hits` int(10) NOT NULL default '1',";
        $sql .= "`online` varchar(255) NOT NULL,";
        $sql .= "PRIMARY KEY  (`ip`,`tanggal`)";
        $sql .= ") ENGINE=MyISAM DEFAULT CHARSET=latin1;";
        $wpdb->query($sql);
    }
}
hw_register_activation_hook(__FILE__, 'hw_module_counter_register_activation_hook');
/**
 * register deactivation hook
 */
function hw_module_counter_register_deactivation_hook()
{
    global $wpdb;
    $sql = "DROP TABLE `" . HW_BMW_TABLE_NAME . "`;";
    $wpdb->query($sql);
}
hw_register_deactivation_hook(__FILE__, 'hw_module_counter_register_deactivation_hook');
#register_activation_hook(__FILE__, 'hw_module_counter_register_activation_hook');
#register_deactivation_hook(__FILE__, 'hw_module_counter_register_deactivation_hook');
/**
 * Class HW_Module_Counter
 */
Exemplo n.º 2
0
function hw_awc_require_plugins_activate()
{
    if (function_exists('hw_require_plugins_list_before_active')) {
        hw_require_plugins_list_before_active(array('hw-hoangweb/hoangweb.php' => 'hw-hoangweb', 'hw-skin/hw-skin.php' => 'hw-skin'));
    } else {
        wp_die('Xin lỗi, bạn cần kích hoạt plugin hw-hoangweb trước hoặc kích hoạt lại plugin này.');
    }
}
//for standalone wp plugin, since we migrate to module
#register_activation_hook( HW_AWC_PLUGIN_FILE, 'hw_awc_require_plugins_activate' );
function _hw_awc_require_plugins_activate()
{
    //create table if not exists
    $sql = "\r\n    CREATE TABLE IF EXISTS `hw_widgets_settings` (\r\n `id` int(11) NOT NULL AUTO_INCREMENT,\r\n `widget` varchar(100) COLLATE utf8_unicode_ci NOT NULL,\r\n `name` varchar(100) COLLATE utf8_unicode_ci NOT NULL,\r\n `_group` varchar(100) COLLATE utf8_unicode_ci NOT NULL,\r\n `setting` text COLLATE utf8_unicode_ci NOT NULL,\r\n `description` text COLLATE utf8_unicode_ci NOT NULL,\r\n PRIMARY KEY (`id`)\r\n) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci\r\n    ";
    global $wpdb;
    $wpdb->query($sql);
}
hw_register_activation_hook(HW_AWC_PLUGIN_FILE, '_hw_awc_require_plugins_activate');
/**
 * @hook init
 * register help for module
 */
function _hw_awc_init()
{
    if (class_exists('HW_HELP')) {
        HW_HELP::set_helps_path('awc', HW_AWC_PATH . 'helps');
        HW_HELP::register_help('awc');
        HW_HELP::load_module_help('awc');
    }
}
add_action('init', '_hw_awc_init');