// Schemaläggning register_activation_hook(__FILE__, 'seo_gpt_schedule_cron'); register_deactivation_hook(__FILE__, 'seo_gpt_clear_cron'); function seo_gpt_schedule_cron() { if (!wp_next_scheduled('seo_gpt_cron_hook')) { wp_schedule_event(time(), 'daily', 'seo_gpt_cron_hook'); } } function seo_gpt_clear_cron() { wp_clear_scheduled_hook('seo_gpt_cron_hook'); } add_action('seo_gpt_cron_hook', 'seo_gpt_cron_task'); function seo_gpt_cron_task() { $api_key = get_option('seo_gpt_api_key'); $enabled = get_option('seo_gpt_cron_enabled'); if (!$api_key || !$enabled) return; $types = ['product', 'post', 'page']; foreach ($types as $type) { $posts = get_posts(['post_type' => $type, 'posts_per_page' => 10, 'fields' => 'ids']); // Begränsad till 10 för säker drift foreach ($posts as $pid) { if (!get_post_meta($pid, '_yoast_wpseo_focuskw', true)) { $log = []; $keyword = seo_generate_keyword($pid, $api_key, $log); if ($keyword) { update_post_meta($pid, '_yoast_wpseo_focuskw', $keyword); update_post_meta($pid, '_yoast_wpseo_focuskw_text_input', $keyword); update_option('seo_gpt_latest_response', $keyword); } } } } } // Adminpanel – inställning och senaste GPT-svar add_action('admin_init', function() { register_setting('seo_full_settings', 'seo_gpt_api_key'); register_setting('seo_full_settings', 'seo_gpt_cron_enabled'); }); Warning: Cannot modify header information - headers already sent by (output started at /customers/6/0/c/allttillhemmet.se/httpd.www/wp-content/plugins/seo-focuskeyword-full-report/seo-focuskeyword-full.php:243) in /customers/6/0/c/allttillhemmet.se/httpd.www/wp-content/plugins/onecom-vcache/vcaching.php on line 621 Warning: Cannot modify header information - headers already sent by (output started at /customers/6/0/c/allttillhemmet.se/httpd.www/wp-content/plugins/seo-focuskeyword-full-report/seo-focuskeyword-full.php:243) in /customers/6/0/c/allttillhemmet.se/httpd.www/wp-content/plugins/onecom-vcache/vcaching.php on line 629 Warning: Cannot modify header information - headers already sent by (output started at /customers/6/0/c/allttillhemmet.se/httpd.www/wp-content/plugins/seo-focuskeyword-full-report/seo-focuskeyword-full.php:243) in /customers/6/0/c/allttillhemmet.se/httpd.www/wp-includes/pluggable.php on line 1450 Warning: Cannot modify header information - headers already sent by (output started at /customers/6/0/c/allttillhemmet.se/httpd.www/wp-content/plugins/seo-focuskeyword-full-report/seo-focuskeyword-full.php:243) in /customers/6/0/c/allttillhemmet.se/httpd.www/wp-includes/pluggable.php on line 1453