include_files(); $this->init_hooks(); $this->register_post_types(); $this->register_taxonomies(); } private function include_files() { require_once PPP_PATH . 'includes/class-subscription-manager.php'; require_once PPP_PATH . 'includes/class-payment-handler.php'; require_once PPP_PATH . 'includes/class-odds-manager.php'; require_once PPP_PATH . 'includes/class-livescore-api.php'; require_once PPP_PATH . 'includes/class-elementor-widgets.php'; require_once PPP_PATH . 'includes/class-ajax-handlers.php'; require_once PPP_PATH . 'includes/class-shortcodes.php'; require_once PPP_PATH . 'includes/class-widgets.php'; require_once PPP_PATH . 'includes/class-admin.php'; require_once PPP_PATH . 'includes/class-install.php'; } private function init_hooks() { register_activation_hook(__FILE__, ['PPP_Install', 'activate']); register_deactivation_hook(__FILE__, ['PPP_Install', 'deactivate']); add_action('init', [$this, 'init']); add_action('plugins_loaded', [$this, 'load_textdomain']); add_action('wp_enqueue_scripts', [$this, 'enqueue_scripts']); add_action('admin_enqueue_scripts', [$this, 'admin_enqueue_scripts']); add_action('rest_api_init', [$this, 'register_rest_routes']); add_shortcode('ppp_daily_predictions', [$this, 'daily_predictions_shortcode']); add_shortcode('ppp_premium_predictions', [$this, 'premium_predictions_shortcode']); add_shortcode('ppp_subscription_plans', [$this, 'subscription_plans_shortcode']); add_shortcode('ppp_payment_form', [$this, 'payment_form_shortcode']); add_shortcode('ppp_live_scores', [$this, 'live_scores_shortcode']); } public function init() { new PPP_Subscription_Manager(); new PPP_Payment_Handler(); new PPP_Odds_Manager(); new PPP_LiveScore_API(); new PPP_Elementor_Widgets(); new PPP_Ajax_Handlers(); new PPP_Shortcodes(); new PPP_Widgets(); new PPP_Admin(); } public function register_post_types() { register_post_type('daily_prediction', [ 'labels' => [ 'name' => __('Daily Predictions', 'premium-predictions-pro'), 'singular_name' => __('Daily Prediction', 'premium-predictions-pro'), 'add_new' => __('Add New Prediction', 'premium-predictions-pro'), 'add_new_item' => __('Add New Daily Prediction', 'premium-predictions-pro'), 'edit_item' => __('Edit Daily Prediction', 'premium-predictions-pro'), 'new_item' => __('New Daily Prediction', 'premium-predictions-pro'), 'view_item' => __('View Daily Prediction', 'premium-predictions-pro'), 'search_items' => __('Search Daily Predictions', 'premium-predictions-pro'), 'not_found' => __('No daily predictions found', 'premium-predictions-pro'), 'not_found_in_trash' => __('No daily predictions found in Trash', 'premium-predictions-pro'), 'all_items' => __('All Daily Predictions', 'premium-predictions-pro'), 'menu_name' => __('Daily Predictions', 'premium-predictions-pro'), ], 'public' => true, 'has_archive' => true, 'supports' => ['title', 'editor', 'thumbnail', 'excerpt', 'custom-fields'], 'menu_icon' => 'dashicons-calendar-alt', 'menu_position' => 5, 'rewrite' => ['slug' => 'daily-predictions'], 'show_in_rest' => true, ]); register_post_type('premium_prediction', [ 'labels' => [ 'name' => __('Premium Predictions', 'premium-predictions-pro'), 'singular_name' => __('Premium Prediction', 'premium-predictions-pro'), 'add_new' => __('Add New Premium Prediction', 'premium-predictions-pro'), 'add_new_item' => __('Add New Premium Prediction', 'premium-predictions-pro'), 'edit_item' => __('Edit Premium Prediction', 'premium-predictions-pro'), 'new_item' => __('New Premium Prediction', 'premium-predictions-pro'), 'view_item' => __('View Premium Prediction', 'premium-predictions-pro'), 'search_items' => __('Search Premium Predictions', 'premium-predictions-pro'), 'not_found' => __('No premium predictions found', 'premium-predictions-pro'), 'not_found_in_trash' => __('No premium predictions found in Trash', 'premium-predictions-pro'), 'all_items' => __('All Premium Predictions', 'premium-predictions-pro'), 'menu_name' => __('Premium Predictions', 'premium-predictions-pro'), ], 'public' => true, 'has_archive' => true, 'supports' => ['title', 'editor', 'custom-fields'], 'menu_icon' => 'dashicons-star-filled', 'menu_position' => 6, 'rewrite' => ['slug' => 'premium-predictions'], 'show_in_rest' => true, ]); } public function register_taxonomies() { register_taxonomy('prediction_league', ['daily_prediction', 'premium_prediction'], [ 'labels' => [ 'name' => __('Leagues', 'premium-predictions-pro'), 'singular_name' => __('League', 'premium-predictions-pro'), 'search_items' => __('Search Leagues', 'premium-predictions-pro'), 'all_items' => __('All Leagues', 'premium-predictions-pro'), 'edit_item' => __('Edit League', 'premium-predictions-pro'), 'update_item' => __('Update League', 'premium-predictions-pro'), 'add_new_item' => __('Add New League', 'premium-predictions-pro'), 'new_item_name' => __('New League Name', 'premium-predictions-pro'), 'menu_name' => __('Leagues', 'premium-predictions-pro'), ], 'hierarchical' => true, 'public' => true, 'rewrite' => ['slug' => 'league'], 'show_in_rest' => true, ]); } public function enqueue_scripts() { wp_enqueue_style('ppp-main', PPP_URL . 'assets/css/style.css', [], PPP_VERSION); wp_enqueue_style('ppp-responsive', PPP_URL . 'assets/css/responsive.css', [], PPP_VERSION); wp_enqueue_style('font-awesome', 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css', [], '6.4.0'); wp_enqueue_style('google-fonts', 'https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700;800&display=swap', [], null); wp_enqueue_script('ppp-main', PPP_URL . 'assets/js/main.js', ['jquery'], PPP_VERSION, true); wp_enqueue_script('ppp-livescore', PPP_URL . 'assets/js/livescore.js', ['jquery'], PPP_VERSION, true); wp_enqueue_script('ppp-payment', PPP_URL . 'assets/js/payment.js', ['jquery'], PPP_VERSION, true); wp_localize_script('ppp-main', 'ppp_ajax', [ 'ajax_url' => admin_url('admin-ajax.php'), 'nonce' => wp_create_nonce('ppp_ajax_nonce'), 'rest_url' => rest_url('premium-predictions/v1/'), 'site_url' => home_url(), 'is_user_logged_in' => is_user_logged_in(), 'currency' => 'USD', 'currency_symbol' => '$', ]); } public function admin_enqueue_scripts($hook) { if (strpos($hook, 'premium-predictions') !== false) { wp_enqueue_style('ppp-admin', PPP_URL . 'assets/css/admin.css', [], PPP_VERSION); wp_enqueue_script('ppp-admin', PPP_URL . 'assets/js/admin.js', ['jquery'], PPP_VERSION, true); } } public function register_rest_routes() { register_rest_route('premium-predictions/v1', '/livescores', [ 'methods' => 'GET', 'callback' => [$this, 'get_live_scores'], 'permission_callback' => '__return_true', ]); register_rest_route('premium-predictions/v1', '/predictions/daily', [ 'methods' => 'GET', 'callback' => [$this, 'get_daily_predictions'], 'permission_callback' => '__return_true', ]); } public function get_live_scores() { $api = new PPP_LiveScore_API(); return rest_ensure_response($api->get_live_matches()); } public function get_daily_predictions($request) { $args = [ 'post_type' => 'daily_prediction', 'posts_per_page' => $request->get_param('per_page') ?: 10, 'paged' => $request->get_param('page') ?: 1, ]; $predictions = get_posts($args); $data = []; foreach ($predictions as $prediction) { $data[] = [ 'id' => $prediction->ID, 'title' => $prediction->post_title, 'content' => $prediction->post_content, 'excerpt' => $prediction->post_excerpt, 'link' => get_permalink($prediction), 'odds' => get_post_meta($prediction->ID, '_odds', true), ]; } return rest_ensure_response($data); } public function daily_predictions_shortcode($atts) { ob_start(); include PPP_PATH . 'templates/daily-predictions.php'; return ob_get_clean(); } public function premium_predictions_shortcode($atts) { ob_start(); include PPP_PATH . 'templates/premium-predictions.php'; return ob_get_clean(); } public function subscription_plans_shortcode($atts) { ob_start(); include PPP_PATH . 'templates/subscription-plans.php'; return ob_get_clean(); } public function payment_form_shortcode($atts) { ob_start(); include PPP_PATH . 'templates/payment-form.php'; return ob_get_clean(); } public function live_scores_shortcode($atts) { ob_start(); include PPP_PATH . 'templates/live-scores.php'; return ob_get_clean(); } public function load_textdomain() { load_plugin_textdomain('premium-predictions-pro', false, dirname(PPP_BASENAME) . '/languages'); } } function PremiumPredictionsPro() { return PremiumPredictionsPro::get_instance(); } PremiumPredictionsPro(); function ppp_create_directories() { $directories = [ PPP_PATH . 'templates', PPP_PATH . 'assets/css', PPP_PATH . 'assets/js', PPP_PATH . 'assets/images', PPP_PATH . 'includes', PPP_PATH . 'admin', PPP_PATH . 'languages', ]; foreach ($directories as $dir) { if (!file_exists($dir)) { wp_mkdir_p($dir); } } } add_action('plugins_loaded', 'ppp_create_directories'); PHP; file_put_contents($temp_dir . '/premium-football-predictions.php', $main_file); // Create all the include files $include_files = [ 'class-subscription-manager.php' => 'init_plans(); } private function init_plans() { $settings = get_option(\'ppp_settings\', []); $this->plans = [ \'daily\' => [ \'key\' => \'daily\', \'label\' => __(\'Daily\', \'premium-predictions-pro\'), \'price\' => isset($settings[\'daily_plan_price\']) ? floatval($settings[\'daily_plan_price\']) : 9.99, \'duration\' => 1, \'features\' => [__(\'Access to all daily predictions\', \'premium-predictions-pro\')], ], \'weekly\' => [ \'key\' => \'weekly\', \'label\' => __(\'Weekly\', \'premium-predictions-pro\'), \'price\' => isset($settings[\'weekly_plan_price\']) ? floatval($settings[\'weekly_plan_price\']) : 29.99, \'duration\' => 7, \'features\' => [__(\'Access to all daily predictions\', \'premium-predictions-pro\')], ], \'monthly\' => [ \'key\' => \'monthly\', \'label\' => __(\'Monthly\', \'premium-predictions-pro\'), \'price\' => isset($settings[\'monthly_plan_price\']) ? floatval($settings[\'monthly_plan_price\']) : 79.99, \'duration\' => 30, \'features\' => [__(\'Access to all predictions\', \'premium-predictions-pro\')], ], \'six_months\' => [ \'key\' => \'six_months\', \'label\' => __(\'6 Months\', \'premium-predictions-pro\'), \'price\' => isset($settings[\'six_months_plan_price\']) ? floatval($settings[\'six_months_plan_price\']) : 399.99, \'duration\' => 180, \'features\' => [__(\'Access to all predictions\', \'premium-predictions-pro\')], ], \'yearly\' => [ \'key\' => \'yearly\', \'label\' => __(\'Yearly\', \'premium-predictions-pro\'), \'price\' => isset($settings[\'yearly_plan_price\']) ? floatval($settings[\'yearly_plan_price\']) : 699.99, \'duration\' => 365, \'features\' => [__(\'Access to all predictions\', \'premium-predictions-pro\')], ], ]; } public function get_plans() { return $this->plans; } public function get_plan($key) { return isset($this->plans[$key]) ? $this->plans[$key] : null; } public function get_plan_price($key) { $plan = $this->get_plan($key); return $plan ? $plan[\'price\'] : 0; } public function activate_subscription($user_id, $plan_key, $payment_id = \'\', $payment_gateway = \'\') { global $wpdb; $plan = $this->get_plan($plan_key); if (!$plan) { return false; } $table_name = $wpdb->prefix . \'ppp_subscriptions\'; $wpdb->update($table_name, [\'status\' => \'expired\'], [\'user_id\' => $user_id, \'status\' => \'active\']); $start_date = current_time(\'mysql\'); $end_date = date(\'Y-m-d H:i:s\', strtotime("+{$plan[\'duration\']} days")); return $wpdb->insert($table_name, [ \'user_id\' => $user_id, \'plan\' => $plan_key, \'status\' => \'active\', \'amount\' => $plan[\'price\'], \'start_date\' => $start_date, \'end_date\' => $end_date, \'payment_id\' => $payment_id, \'payment_gateway\' => $payment_gateway, ]); } public function check_access($user_id = null) { if (!$user_id) $user_id = get_current_user_id(); if (!$user_id || user_can($user_id, \'manage_options\')) return true; global $wpdb; $table_name = $wpdb->prefix . \'ppp_subscriptions\'; $subscription = $wpdb->get_row($wpdb->prepare( "SELECT * FROM $table_name WHERE user_id = %d AND status = \'active\' AND end_date > NOW() ORDER BY id DESC LIMIT 1", $user_id )); return !empty($subscription); } }', 'class-payment-handler.php' => 'settings = get_option(\'ppp_settings\', []); add_action(\'wp_ajax_ppp_process_payment\', [$this, \'process_payment_ajax\']); add_action(\'wp_ajax_nopriv_ppp_process_payment\', [$this, \'process_payment_ajax\']); } public function process_payment_ajax() { check_ajax_referer(\'ppp_ajax_nonce\', \'nonce\'); $gateway = sanitize_text_field($_POST[\'gateway\']); $plan = sanitize_text_field($_POST[\'plan\']); $email = sanitize_email($_POST[\'email\']); if (empty($email) || !is_email($email)) { wp_send_json_error([\'message\' => __(\'Invalid email address\', \'premium-predictions-pro\')]); } $subscription_manager = new PPP_Subscription_Manager(); $plan_data = $subscription_manager->get_plan($plan); $user_id = is_user_logged_in() ? get_current_user_id() : $this->create_temporary_user($email); $response = $this->process_payment($gateway, $plan_data, $user_id, $email); if ($response[\'success\']) { wp_send_json_success($response[\'data\']); } else { wp_send_json_error([\'message\' => $response[\'message\']]); } } private function process_payment($gateway, $plan_data, $user_id, $email) { switch ($gateway) { case \'paystack\': return $this->process_paystack_payment($plan_data, $user_id, $email); case \'flutterwave\': return $this->process_flutterwave_payment($plan_data, $user_id, $email); case \'stripe\': return $this->process_stripe_payment($plan_data, $user_id, $email); default: return [\'success\' => false, \'message\' => __(\'Invalid payment gateway\', \'premium-predictions-pro\')]; } } private function process_paystack_payment($plan_data, $user_id, $email) { if (empty($this->settings[\'paystack_secret_key\'])) { return [\'success\' => false, \'message\' => __(\'Paystack is not configured\', \'premium-predictions-pro\')]; } $amount = $plan_data[\'price\'] * 100; $callback_url = home_url(\'/payment-return?gateway=paystack&plan=\' . $plan_data[\'key\']); $url = \'https://api.paystack.co/transaction/initialize\'; $response = wp_remote_post($url, [ \'headers\' => [ \'Authorization\' => \'Bearer \' . $this->settings[\'paystack_secret_key\'], \'Content-Type\' => \'application/json\', ], \'body\' => json_encode([ \'amount\' => $amount, \'email\' => $email, \'callback_url\' => $callback_url, \'metadata\' => [\'user_id\' => $user_id, \'plan\' => $plan_data[\'key\']], ]), \'timeout\' => 30, ]); if (is_wp_error($response)) { return [\'success\' => false, \'message\' => $response->get_error_message()]; } $body = json_decode(wp_remote_retrieve_body($response), true); if ($body[\'status\']) { return [\'success\' => true, \'data\' => [\'authorization_url\' => $body[\'data\'][\'authorization_url\']]]; } return [\'success\' => false, \'message\' => $body[\'message\'] ?? __(\'Payment failed\', \'premium-predictions-pro\')]; } private function process_flutterwave_payment($plan_data, $user_id, $email) { if (empty($this->settings[\'flutterwave_secret_key\'])) { return [\'success\' => false, \'message\' => __(\'Flutterwave is not configured\', \'premium-predictions-pro\')]; } $reference = \'tx_\' . uniqid() . \'_\' . time(); $url = \'https://api.flutterwave.com/v3/payments\'; $response = wp_remote_post($url, [ \'headers\' => [ \'Authorization\' => \'Bearer \' . $this->settings[\'flutterwave_secret_key\'], \'Content-Type\' => \'application/json\', ], \'body\' => json_encode([ \'tx_ref\' => $reference, \'amount\' => $plan_data[\'price\'], \'currency\' => \'USD\', \'redirect_url\' => home_url(\'/payment-return?gateway=flutterwave&plan=\' . $plan_data[\'key\']), \'customer\' => [\'email\' => $email], \'meta\' => [\'user_id\' => $user_id, \'plan\' => $plan_data[\'key\']], ]), \'timeout\' => 30, ]); if (is_wp_error($response)) { return [\'success\' => false, \'message\' => $response->get_error_message()]; } $body = json_decode(wp_remote_retrieve_body($response), true); if ($body[\'status\'] === \'success\') { return [\'success\' => true, \'data\' => [\'redirect_url\' => $body[\'data\'][\'link\']]]; } return [\'success\' => false, \'message\' => $body[\'message\'] ?? __(\'Payment failed\', \'premium-predictions-pro\')]; } private function process_stripe_payment($plan_data, $user_id, $email) { return [\'success\' => false, \'message\' => __(\'Stripe integration coming soon\', \'premium-predictions-pro\')]; } private function create_temporary_user($email) { $username = \'user_\' . uniqid(); $password = wp_generate_password(); $user_id = wp_create_user($username, $password, $email); if (!is_wp_error($user_id)) { wp_set_password($password, $user_id); } return $user_id; } }', 'class-odds-manager.php' => ' \'1.95\', \'draw\' => \'3.40\', \'away_win\' => \'3.80\']; } return $odds; } }', 'class-livescore-api.php' => 'api_key = isset($settings[\'livescore_api_key\']) ? $settings[\'livescore_api_key\'] : \'\'; } public function get_live_matches() { if (empty($this->api_key)) { return $this->get_mock_data(); } $response = wp_remote_get($this->api_url, [ \'headers\' => [\'X-Auth-Token\' => $this->api_key], ]); if (is_wp_error($response)) { return $this->get_mock_data(); } $data = json_decode(wp_remote_retrieve_body($response), true); return $this->format_response($data); } private function format_response($data) { $matches = []; if (isset($data[\'matches\'])) { foreach ($data[\'matches\'] as $match) { $matches[] = [ \'home_team\' => $match[\'homeTeam\'][\'name\'] ?? \'Team A\', \'away_team\' => $match[\'awayTeam\'][\'name\'] ?? \'Team B\', \'home_score\' => $match[\'score\'][\'fullTime\'][\'home\'] ?? 0, \'away_score\' => $match[\'score\'][\'fullTime\'][\'away\'] ?? 0, \'status\' => $match[\'status\'] ?? \'SCHEDULED\', \'league\' => $match[\'competition\'][\'name\'] ?? \'League\', ]; } } return $matches; } private function get_mock_data() { return [ [\'home_team\' => \'Manchester United\', \'away_team\' => \'Liverpool\', \'home_score\' => 2, \'away_score\' => 1, \'status\' => \'LIVE\', \'league\' => \'Premier League\'], [\'home_team\' => \'Real Madrid\', \'away_team\' => \'Barcelona\', \'home_score\' => 1, \'away_score\' => 1, \'status\' => \'LIVE\', \'league\' => \'La Liga\'], [\'home_team\' => \'Bayern Munich\', \'away_team\' => \'Borussia Dortmund\', \'home_score\' => 3, \'away_score\' => 0, \'status\' => \'HALF\', \'league\' => \'Bundesliga\'], ]; } }', 'class-elementor-widgets.php' => ' 'get_live_matches()); } public function update_odds() { check_ajax_referer(\'ppp_ajax_nonce\', \'nonce\'); $post_id = intval($_POST[\'post_id\']); $odds = array_map(\'sanitize_text_field\', $_POST[\'odds\']); update_post_meta($post_id, \'_odds\', $odds); wp_send_json_success([\'message\' => __(\'Odds updated successfully\', \'premium-predictions-pro\')]); } }', 'class-shortcodes.php' => ' \'daily_prediction\', \'posts_per_page\' => 10]); ?>

post_title); ?>

post_content, 20); ?>
View Details
check_access(get_current_user_id())) { return \'

\' . __(\'Premium Content\', \'premium-predictions-pro\') . \'

\' . __(\'Subscribe to access premium predictions\', \'premium-predictions-pro\') . \'

\' . __(\'Subscribe Now\', \'premium-predictions-pro\') . \'
\'; } ob_start(); $predictions = get_posts([\'post_type\' => \'premium_prediction\', \'posts_per_page\' => 5]); ?>

post_title); ?>

post_content, 30); ?>
Premium
get_plans(); ob_start(); ?>
$plan): ?>

Complete Your Payment

Live Scores

Loading scores...
' __(\'Display live football scores\', \'premium-predictions-pro\')]); } public function widget($args, $instance) { echo $args[\'before_widget\']; echo $args[\'before_title\'] . __(\'Live Scores\', \'premium-predictions-pro\') . $args[\'after_title\']; echo \'
Loading...
\'; echo $args[\'after_widget\']; } public function form($instance) { $refresh = isset($instance[\'refresh\']) ? $instance[\'refresh\'] : 60; ?>

__(\'Display recent predictions\', \'premium-predictions-pro\')]); } public function widget($args, $instance) { $count = isset($instance[\'count\']) ? $instance[\'count\'] : 5; $predictions = get_posts([\'post_type\' => [\'daily_prediction\', \'premium_prediction\'], \'posts_per_page\' => $count]); if (empty($predictions)) return; echo $args[\'before_widget\']; echo $args[\'before_title\'] . __(\'Recent Predictions\', \'premium-predictions-pro\') . $args[\'after_title\']; echo \'\'; echo $args[\'after_widget\']; } public function form($instance) { $count = isset($instance[\'count\']) ? $instance[\'count\'] : 5; ?>

'

Premium Football Predictions

Dashboard

Welcome to Premium Football Predictions Pro

Total Predictions

\'daily_prediction\', \'posts_per_page\' => -1])); ?>

Premium Members

Coming Soon

Payment Gateways

Paystack


Flutterwave


Stripe


Subscription Plans



Live Score API
Contact Information
$value) { if (strpos($key, \'_key\') !== false || strpos($key, \'secret\') !== false) { $sanitized[$key] = sanitize_text_field($value); } elseif (strpos($key, \'_price\') !== false) { $sanitized[$key] = floatval($value); } else { $sanitized[$key] = sanitize_text_field($value); } } return $sanitized; } }', 'class-install.php' => 'prefix . \'ppp_subscriptions\'; $charset_collate = $wpdb->get_charset_collate(); $sql = "CREATE TABLE IF NOT EXISTS $table_name ( id bigint(20) NOT NULL AUTO_INCREMENT, user_id bigint(20) NOT NULL, plan varchar(20) NOT NULL, status varchar(20) NOT NULL DEFAULT \'active\', amount decimal(10,2) NOT NULL, start_date datetime NOT NULL, end_date datetime NOT NULL, payment_id varchar(100) DEFAULT NULL, payment_gateway varchar(20) DEFAULT NULL, created_at datetime DEFAULT CURRENT_TIMESTAMP, updated_at datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (id), KEY user_id (user_id), KEY status (status) ) $charset_collate;"; $payments_table = $wpdb->prefix . \'ppp_payments\'; $sql .= "CREATE TABLE IF NOT EXISTS $payments_table ( id bigint(20) NOT NULL AUTO_INCREMENT, user_id bigint(20) NOT NULL, subscription_id bigint(20), amount decimal(10,2) NOT NULL, currency varchar(3) NOT NULL DEFAULT \'USD\', gateway varchar(20) NOT NULL, transaction_id varchar(100) NOT NULL, status varchar(20) NOT NULL DEFAULT \'pending\', payment_data longtext, created_at datetime DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (id), KEY user_id (user_id), KEY transaction_id (transaction_id) ) $charset_collate;"; require_once(ABSPATH . \'wp-admin/includes/upgrade.php\'); dbDelta($sql); self::create_default_pages(); self::set_default_options(); flush_rewrite_rules(); } private static function create_default_pages() { $pages = [ \'home\' => [\'title\' => \'Home\', \'slug\' => \'home\', \'content\' => \'[ppp_daily_predictions]\'], \'daily\' => [\'title\' => \'Daily Predictions\', \'slug\' => \'daily-predictions\', \'content\' => \'[ppp_daily_predictions]\'], \'premium\' => [\'title\' => \'Premium Predictions\', \'slug\' => \'premium-predictions\', \'content\' => \'[ppp_premium_predictions]\'], \'subscription\' => [\'title\' => \'Subscription Plans\', \'slug\' => \'subscription-plans\', \'content\' => \'[ppp_subscription_plans]\'], \'payment\' => [\'title\' => \'Payment\', \'slug\' => \'payment\', \'content\' => \'[ppp_payment_form]\'], \'contact\' => [\'title\' => \'Contact Us\', \'slug\' => \'contact-us\', \'content\' => \'\'], ]; foreach ($pages as $slug => $page) { $existing = get_page_by_path($slug); if (!$existing) { wp_insert_post([ \'post_title\' => $page[\'title\'], \'post_name\' => $slug, \'post_content\' => $page[\'content\'], \'post_status\' => \'publish\', \'post_type\' => \'page\', ]); } } } private static function set_default_options() { if (!get_option(\'ppp_settings\')) { update_option(\'ppp_settings\', [ \'daily_plan_price\' => 9.99, \'weekly_plan_price\' => 29.99, \'monthly_plan_price\' => 79.99, \'six_months_plan_price\' => 399.99, \'yearly_plan_price\' => 699.99, \'livescore_refresh\' => 60, \'currency\' => \'USD\', \'currency_symbol\' => \'$\', ]); } } public static function deactivate() { flush_rewrite_rules(); } }', ]; foreach ($include_files as $filename => $content) { file_put_contents($temp_dir . '/includes/' . $filename, $content); } // Create CSS files file_put_contents($temp_dir . '/assets/css/style.css', '/* Premium Football Predictions Styles */ .ppp-predictions-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 25px; margin: 20px 0; } .ppp-prediction-card { background: #fff; padding: 25px; border-radius: 12px; box-shadow: 0 4px 15px rgba(0,0,0,0.1); transition: transform 0.3s ease; } .ppp-prediction-card:hover { transform: translateY(-5px); } .ppp-prediction-card.premium { border-left: 4px solid #ff6f00; } .ppp-premium-badge { display: inline-block; background: #ff6f00; color: #fff; padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 600; } .ppp-btn { display: inline-block; padding: 12px 30px; background: #1a237e; color: #fff; border-radius: 30px; text-decoration: none; font-weight: 600; transition: background 0.3s ease; border: none; cursor: pointer; } .ppp-btn:hover { background: #0d47a1; color: #fff; } .ppp-plan-card { background: #fff; padding: 30px; border-radius: 12px; box-shadow: 0 4px 15px rgba(0,0,0,0.1); text-align: center; transition: transform 0.3s ease; } .ppp-plan-card.featured { border: 2px solid #ff6f00; transform: scale(1.05); } .ppp-plan-price { font-size: 32px; font-weight: 700; color: #1a237e; margin: 15px 0; } .ppp-plan-features { list-style: none; padding: 0; margin: 20px 0; } .ppp-plan-features li { padding: 8px 0; border-bottom: 1px solid #f0f0f0; } .ppp-plan-features li:last-child { border-bottom: none; } .ppp-live-scores { background: #fff; padding: 20px; border-radius: 12px; box-shadow: 0 4px 15px rgba(0,0,0,0.1); } .ppp-live-score-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid #f0f0f0; } .ppp-live-score-item:last-child { border-bottom: none; } .ppp-match-teams { display: flex; align-items: center; gap: 15px; } .ppp-match-score { font-weight: 700; color: #1a237e; font-size: 18px; } .ppp-match-status { font-size: 12px; padding: 4px 10px; border-radius: 20px; background: #e8f5e9; color: #2e7d32; } .ppp-payment-form { max-width: 500px; margin: 0 auto; padding: 30px; background: #fff; border-radius: 12px; box-shadow: 0 4px 15px rgba(0,0,0,0.1); } .ppp-form-group { margin-bottom: 20px; } .ppp-form-group label { display: block; margin-bottom: 5px; font-weight: 600; } .ppp-form-group input, .ppp-form-group select { width: 100%; padding: 12px; border: 2px solid #e0e0e0; border-radius: 8px; font-size: 16px; } .ppp-payment-gateways { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; } .ppp-gateway-btn { padding: 14px; border: none; border-radius: 8px; color: #fff; font-weight: 600; cursor: pointer; transition: opacity 0.3s ease; } .ppp-gateway-btn.paystack { background: linear-gradient(135deg, #00b3b3, #008080); } .ppp-gateway-btn.flutterwave { background: linear-gradient(135deg, #f5a623, #f57c00); } .ppp-gateway-btn.stripe { background: linear-gradient(135deg, #635bff, #5468ff); } .ppp-gateway-btn:hover { opacity: 0.9; } .ppp-premium-locked { text-align: center; padding: 40px; background: #fff3e0; border-radius: 12px; border: 2px dashed #ff6f00; } .ppp-loading { text-align: center; padding: 20px; color: #666; } @media (max-width: 768px) { .ppp-predictions-grid { grid-template-columns: 1fr; } .ppp-plan-card.featured { transform: none; } }'); file_put_contents($temp_dir . '/assets/css/responsive.css', '/* Responsive Styles */ @media (max-width: 768px) { .ppp-predictions-grid { grid-template-columns: 1fr; } .ppp-plan-card.featured { transform: none; order: -1; } .ppp-live-score-item { flex-direction: column; align-items: flex-start; gap: 5px; } .ppp-payment-form { padding: 20px; margin: 10px; } }'); file_put_contents($temp_dir . '/assets/css/admin.css', '/* Admin Styles */ .ppp-admin-card { background: #fff; padding: 20px; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); margin-bottom: 20px; } .ppp-admin-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-top: 20px; } .stat-box { background: #f5f5f5; padding: 15px; border-radius: 8px; text-align: center; } .stat-box h3 { margin: 0 0 10px 0; font-size: 14px; color: #666; } .stat-box p { margin: 0; font-size: 24px; font-weight: bold; color: #1a237e; }'); // Create JavaScript files file_put_contents($temp_dir . '/assets/js/main.js', 'jQuery(document).ready(function($) { // Initialize live scores if ($(".ppp-live-scores").length) { loadLiveScores(); var refreshInterval = $(".ppp-live-scores").data("refresh") || 60; setInterval(loadLiveScores, refreshInterval * 1000); } function loadLiveScores() { $.ajax({ url: ppp_ajax.ajax_url, type: "POST", data: { action: "ppp_get_live_scores", nonce: ppp_ajax.nonce }, success: function(response) { if (response.success && response.data) { updateLiveScores(response.data); } } }); } function updateLiveScores(scores) { var container = $(".ppp-live-scores-container"); if (!container.length) return; var html = ""; scores.forEach(function(match) { html += \'
\'; html += \'
\'; html += \'\' + match.home_team + \'\'; html += \'\' + match.home_score + \' - \' + match.away_score + \'\'; html += \'\' + match.away_team + \'\'; html += \'
\'; html += \'\' + match.status + \'\'; html += \'
\'; }); container.html(html); } // Payment processing $(".ppp-gateway-btn").on("click", function() { var gateway = $(this).data("gateway"); var plan = $("#ppp-plan").val(); var email = $("#ppp-email").val(); if (!email) { alert("Please enter your email address"); return; } $.ajax({ url: ppp_ajax.ajax_url, type: "POST", data: { action: "ppp_process_payment", gateway: gateway, plan: plan, email: email, nonce: ppp_ajax.nonce }, success: function(response) { if (response.success) { if (response.data.authorization_url) { window.location.href = response.data.authorization_url; } else if (response.data.redirect_url) { window.location.href = response.data.redirect_url; } } else { alert(response.data.message || "Payment failed"); } }, error: function() { alert("An error occurred. Please try again."); } }); }); });'); file_put_contents($temp_dir . '/assets/js/livescore.js', 'jQuery(document).ready(function($) { $(".ppp-widget-livescore").each(function() { var widget = $(this); var refresh = widget.data("refresh") || 60; function loadWidgetScores() { $.ajax({ url: ppp_ajax.ajax_url, type: "POST", data: { action: "ppp_get_live_scores", nonce: ppp_ajax.nonce }, success: function(response) { if (response.success && response.data) { var html = ""; response.data.slice(0, 5).forEach(function(match) { html += \'
\'; html += \'\' + match.home_team + \' \' + match.home_score + \'-\' + match.away_score + \' \' + match.away_team + \'\'; html += \'
\'; }); widget.html(html); } } }); } loadWidgetScores(); setInterval(loadWidgetScores, refresh * 1000); }); });'); file_put_contents($temp_dir . '/assets/js/payment.js', 'jQuery(document).ready(function($) { // Handle payment form submission $(".ppp-payment-form").on("submit", function(e) { e.preventDefault(); }); // Plan selection on payment page var urlParams = new URLSearchParams(window.location.search); var plan = urlParams.get("plan"); if (plan) { $("#ppp-plan").val(plan); } });'); file_put_contents($temp_dir . '/assets/js/admin.js', 'jQuery(document).ready(function($) { // Admin JS functionality console.log("Premium Predictions Admin Loaded"); });'); // Create template files file_put_contents($temp_dir . '/templates/daily-predictions.php', ' \'daily_prediction\', \'posts_per_page\' => 10]); ?>

Daily Predictions

post_title); ?>

post_content, 20); ?>
View Details
'); file_put_contents($temp_dir . '/templates/premium-predictions.php', 'check_access(get_current_user_id())) { echo \'

Premium Content

Subscribe to access premium predictions

Subscribe Now
\'; return; } $predictions = get_posts([\'post_type\' => \'premium_prediction\', \'posts_per_page\' => 5]); ?>

Premium Predictions

post_title); ?>

post_content, 30); ?>
Premium
'); file_put_contents($temp_dir . '/templates/subscription-plans.php', 'get_plans(); ?>

Subscription Plans

$plan): ?>
'); file_put_contents($temp_dir . '/templates/payment-form.php', '

Complete Your Payment

'); file_put_contents($temp_dir . '/templates/live-scores.php', 'get_live_matches(); ?>

Live Scores

'); // Create README file file_put_contents($temp_dir . '/readme.txt', "=== Premium Football Predictions Pro === Contributors: yourname Tags: football, soccer, predictions, betting, subscription, paystack, flutterwave Requires at least: 5.8 Tested up to: 6.2 Stable tag: 1.0.0 License: GPLv2 or later Professional football prediction system with Elementor integration, live scores, subscriptions, and payment gateways. == Description == Premium Football Predictions Pro is a complete solution for football prediction websites. It includes: * Daily and Premium Predictions * Live Score Integration * Subscription Management (Daily, Weekly, Monthly, 6-Month, Yearly) * Payment Gateways (Paystack, Flutterwave, Stripe) * Elementor Compatibility * SEO Optimized * Mobile Responsive * Custom Widgets * REST API Support == Installation == 1. Upload the plugin files to `/wp-content/plugins/premium-football-predictions` 2. Activate the plugin through the 'Plugins' screen in WordPress 3. Go to Premium Predictions > Settings to configure the plugin 4. Add your payment gateway API keys 5. Set your subscription prices 6. Start adding predictions! == Frequently Asked Questions == = How do I add predictions? = Go to Daily Predictions or Premium Predictions in the WordPress admin and click \"Add New\". = How do I set up payment gateways? = Go to Premium Predictions > Settings and enter your API keys for Paystack, Flutterwave, or Stripe. = Can I use this with Elementor? = Yes! The plugin includes Elementor widgets for all features. == Changelog == = 1.0.0 = * Initial release * Daily and Premium predictions * Subscription management * Paystack, Flutterwave, and Stripe integration * Live scores * Elementor widgets"); // Create the ZIP file $zip = new ZipArchive(); $zip_file = $plugin_name . '-' . $plugin_version . '.zip'; if ($zip->open($zip_file, ZipArchive::CREATE) === TRUE) { $files = new RecursiveIteratorIterator( new RecursiveDirectoryIterator($temp_dir), RecursiveIteratorIterator::LEAVES_ONLY ); foreach ($files as $name => $file) { if (!$file->isDir()) { $filePath = $file->getRealPath(); $relativePath = substr($filePath, strlen($temp_dir) + 1); $zip->addFile($filePath, $relativePath); } } $zip->close(); // Download the ZIP file header('Content-Type: application/zip'); header('Content-Disposition: attachment; filename="' . $zip_file . '"'); header('Content-Length: ' . filesize($zip_file)); readfile($zip_file); // Clean up $dir = new RecursiveDirectoryIterator($temp_dir, RecursiveDirectoryIterator::SKIP_DOTS); $files = new RecursiveIteratorIterator($dir, RecursiveIteratorIterator::CHILD_FIRST); foreach ($files as $file) { if ($file->isDir()) { rmdir($file->getRealPath()); } else { unlink($file->getRealPath()); } } rmdir($temp_dir); unlink($zip_file); exit; } else { echo "Could not create ZIP file."; } ?>