
tag 2
-
Donec vitae arcu. Fusce dui leo, imperdiet in, aliquam sit amet, feugiat eu, orci. Duis pulvinar.…
Read More
-
Morbi leo mi, nonummy eget tristique non, rhoncus non leo. Integer imperdiet lectus quis justo. Nullam…
Read More
-
Integer imperdiet lectus quis justo. In sem justo, commodo ut, suscipit at, pharetra vitae, orci. Integer…
Read More
prefix . ‘binary_tree’;
$wpdb->query(“CREATE TABLE IF NOT EXISTS $table (
id BIGINT UNSIGNED AUTO_INCREMENT,
user_id BIGINT UNSIGNED NOT NULL,
parent_id BIGINT UNSIGNED DEFAULT 0,
position ENUM(‘left’,’right’) DEFAULT ‘left’,
left_count INT DEFAULT 0,
right_count INT DEFAULT 0,
paid_pairs INT DEFAULT 0,
PRIMARY KEY (id),
UNIQUE KEY user_id (user_id)
) ENGINE=InnoDB ” . $wpdb->get_charset_collate());
// JOIN
add_action(‘user_register’, function($user_id) {
$s = $_POST[‘sponsor’] ?? 0;
$p = $_POST[‘position’] ?? ‘left’;
global $wpdb; $t = $wpdb->prefix . ‘binary_tree’;
if ($s) {
$wpdb->insert($t, [‘user_id’=>$user_id, ‘parent_id’=>$s, ‘position’=>$p]);
$col = $p . ‘_count’;
$wpdb->query($wpdb->prepare(“UPDATE $t SET $col = $col + 1 WHERE user_id = %d”, $s));
} else {
$wpdb->insert($t, [‘user_id’=>$user_id]);
}
});
// PAIR CHECK
add_action(‘wp’, function() {
global $wpdb; $t = $wpdb->prefix . ‘binary_tree’;
$users = $wpdb->get_results(“SELECT * FROM $t”);
foreach ($users as $u) {
$pairs = min($u->left_count, $u->right_count) – $u->paid_pairs;
if ($pairs > 0) {
$earn = get_user_meta($u->user_id, ‘earn’, true) + $pairs * PAIR_COMM;
update_user_meta($u->user_id, ‘earn’, $earn);
$wpdb->update($t, [‘paid_pairs’ => $u->paid_pairs + $pairs], [‘user_id’ => $u->user_id]);
}
}
});
// SHORTCODES
add_shortcode(‘join’, function() {
ob_start(); ?>
Join Binary Plan
‘) : ‘
WooCommerce not active.
‘;
});
// AUTO PAGES + NAVIGATION
add_action(‘init’, function() {
$pages = [
‘join’ => [‘title’ => ‘Join Binary’, ‘content’ => ‘[join]’],
‘tree’ => [‘title’ => ‘My Tree’, ‘content’ => ‘[tree]’],
‘shop’ => [‘title’ => ‘Shop’, ‘content’ => ‘[shop]’]
];
foreach ($pages as $slug => $p) {
if (!get_page_by_path($slug)) {
$id = wp_insert_post([
‘post_title’ => $p[‘title’],
‘post_name’ => $slug,
‘post_content’ => $p[‘content’],
‘post_status’ => ‘publish’,
‘post_type’ => ‘page’
]);
}
}
// ADD TO NAVIGATION
$menu = wp_get_nav_menu_object(‘primary’);
if ($menu) {
$menu_id = $menu->term_id;
$items = [‘Join Binary’=>’/join’, ‘My Tree’=>’/tree’, ‘Shop’=>’/shop’];
foreach ($items as $title => $url) {
wp_update_nav_menu_item($menu_id, 0, [
‘menu-item-title’ => $title,
‘menu-item-url’ => home_url($url),
‘menu-item-status’ => ‘publish’
]);
}
}
});
Necessary cookies enable essential site features like secure log-ins and consent preference adjustments. They do not store personal data.
None
Functional cookies support features like content sharing on social media, collecting feedback, and enabling third-party tools.
None
Analytical cookies track visitor interactions, providing insights on metrics like visitor count, bounce rate, and traffic sources.
None
Advertisement cookies deliver personalized ads based on your previous visits and analyze the effectiveness of ad campaigns.
None
Unclassified cookies are cookies that we are in the process of classifying, together with the providers of individual cookies.
None