is_abpw_page( $hook ) ) { return; } $page = $this->get_current_page(); // Welcome page styles. if ( 'abp-writer-welcome' === $page ) { wp_enqueue_style( 'abpw-welcome', ABPW_PLUGIN_URL . 'assets/css/welcome.css', array(), ABPW_BUILD_HASH ); return; } // Show welcome screen on protected pages when not authenticated. if ( ! $this->is_authenticated() && in_array( $page, array( 'abp-writer', 'abp-writer-config', 'abp-writer-topics', 'abp-writer-posts', 'abp-writer-automation', 'abp-writer-account', ), true ) ) { wp_enqueue_style( 'abpw-welcome', ABPW_PLUGIN_URL . 'assets/css/welcome.css', array(), ABPW_BUILD_HASH ); return; } // Onboarding page styles and scripts. if ( 'abp-writer-onboarding' === $page ) { if ( ! $this->is_authenticated() ) { wp_enqueue_style( 'abpw-welcome', ABPW_PLUGIN_URL . 'assets/css/welcome.css', array(), ABPW_BUILD_HASH ); return; } wp_enqueue_style( 'abpw-onboarding', ABPW_PLUGIN_URL . 'assets/css/onboarding.css', array(), ABPW_BUILD_HASH ); wp_enqueue_script( 'abpw-onboarding', ABPW_PLUGIN_URL . 'assets/js/onboarding.js', array( 'jquery' ), ABPW_BUILD_HASH, true ); wp_localize_script( 'abpw-onboarding', 'abpwOnboarding', array( 'ajaxUrl' => admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 'abpw_onboarding_nonce' ), 'topicsUrl' => admin_url( 'admin.php?page=abp-writer-topics' ), 'dashboardUrl' => admin_url( 'admin.php?page=abp-writer' ), 'i18n' => array( 'businessDescMin' => __( 'Business description must be at least 50 characters.', 'abp-writer-ai-blog-generator' ), 'businessDescMax' => __( 'Business description cannot exceed 1000 characters.', 'abp-writer-ai-blog-generator' ), 'selectLanguage' => __( 'Please select a language.', 'abp-writer-ai-blog-generator' ), 'keywordsMin' => __( 'Please enter at least 5 keywords, separated by commas.', 'abp-writer-ai-blog-generator' ), 'keywordsMax' => __( 'Please enter no more than 50 keywords.', 'abp-writer-ai-blog-generator' ), 'selectStyle' => __( 'Please select a communication style.', 'abp-writer-ai-blog-generator' ), 'saving' => __( 'Saving...', 'abp-writer-ai-blog-generator' ), 'finish' => __( 'Finish', 'abp-writer-ai-blog-generator' ), 'errorGeneric' => __( 'An error occurred. Please try again.', 'abp-writer-ai-blog-generator' ), 'networkError' => __( 'A network error occurred. Please try again.', 'abp-writer-ai-blog-generator' ), ), ) ); return; } // Auth page styles and scripts. if ( 'abp-writer-auth' === $page ) { wp_enqueue_style( 'abpw-auth', ABPW_PLUGIN_URL . 'assets/css/auth.css', array(), ABPW_BUILD_HASH ); wp_enqueue_script( 'abpw-auth', ABPW_PLUGIN_URL . 'assets/js/auth.js', array( 'jquery' ), ABPW_BUILD_HASH, true ); wp_localize_script( 'abpw-auth', 'abpw_auth', array( 'ajax_url' => admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 'abpw_auth_nonce' ), 'redirect_onboarding' => admin_url( 'admin.php?page=abp-writer-onboarding' ), 'redirect_dashboard' => admin_url( 'admin.php?page=abp-writer' ), 'i18n' => array( 'pleaseWait' => __( 'Please wait...', 'abp-writer-ai-blog-generator' ), 'invalidEmail' => __( 'Please enter a valid email address.', 'abp-writer-ai-blog-generator' ), 'passwordShort' => __( 'Password must be at least 8 characters.', 'abp-writer-ai-blog-generator' ), 'errorGeneric' => __( 'An error occurred. Please try again.', 'abp-writer-ai-blog-generator' ), 'loginInstead' => __( 'Log in instead', 'abp-writer-ai-blog-generator' ), 'networkError' => __( 'A network error occurred. Please try again.', 'abp-writer-ai-blog-generator' ), 'invalidLogin' => __( 'Invalid email or password.', 'abp-writer-ai-blog-generator' ), 'fullNameRequired' => __( 'Please enter your full name.', 'abp-writer-ai-blog-generator' ), 'passwordsMismatch' => __( 'Passwords do not match.', 'abp-writer-ai-blog-generator' ), 'checkEmail' => __( 'Check your email', 'abp-writer-ai-blog-generator' ), 'confirmationSent' => __( 'We sent a confirmation link to', 'abp-writer-ai-blog-generator' ), 'waitingConfirmation'=> __( 'Waiting for confirmation...', 'abp-writer-ai-blog-generator' ), 'emailConfirmed' => __( 'Email confirmed! Setting up your account...', 'abp-writer-ai-blog-generator' ), 'keyAlreadyIssued' => __( 'Account already set up. Please use login instead.', 'abp-writer-ai-blog-generator' ), 'checkSpam' => __( "Didn't receive the email? Check your spam folder.", 'abp-writer-ai-blog-generator' ), ), ) ); return; } // All other ABP pages: admin styles. wp_enqueue_style( 'abpw-admin', ABPW_PLUGIN_URL . 'assets/css/admin.css', array(), ABPW_BUILD_HASH ); // Dashboard page: separate JS with its own nonce. if ( 'abp-writer' === $page ) { wp_enqueue_script( 'abpw-dashboard', ABPW_PLUGIN_URL . 'assets/js/dashboard.js', array( 'jquery' ), ABPW_BUILD_HASH, true ); wp_localize_script( 'abpw-dashboard', 'abpwDashboard', array( 'ajaxUrl' => admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 'abpw_dashboard_nonce' ), 'topicsUrl' => admin_url( 'admin.php?page=abp-writer-topics' ), 'postsUrl' => admin_url( 'admin.php?page=abp-writer-posts' ), 'configUrl' => admin_url( 'admin.php?page=abp-writer-config' ), 'i18n' => array( 'loading' => __( 'Loading...', 'abp-writer-ai-blog-generator' ), 'failedLoad' => __( 'Failed to load dashboard data.', 'abp-writer-ai-blog-generator' ), 'networkError' => __( 'A network error occurred while loading the dashboard.', 'abp-writer-ai-blog-generator' ), 'upgradeError' => __( 'Unable to get upgrade link.', 'abp-writer-ai-blog-generator' ), 'networkErrorRetry'=> __( 'A network error occurred. Please try again.', 'abp-writer-ai-blog-generator' ), 'today' => __( 'today', 'abp-writer-ai-blog-generator' ), 'yesterday' => __( 'yesterday', 'abp-writer-ai-blog-generator' ), 'daysAgo' => __( '%d days ago', 'abp-writer-ai-blog-generator' ), ), ) ); return; } // Topics page: separate JS with its own nonce. if ( 'abp-writer-topics' === $page ) { wp_enqueue_script( 'abpw-topics', ABPW_PLUGIN_URL . 'assets/js/topics.js', array( 'jquery' ), ABPW_BUILD_HASH, true ); wp_localize_script( 'abpw-topics', 'abpwTopics', array( 'ajaxUrl' => admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 'abpw_topics_nonce' ), 'currentPage' => $page, 'authUrl' => admin_url( 'admin.php?page=abp-writer-auth' ), 'i18n' => array( 'loading' => __( 'Loading...', 'abp-writer-ai-blog-generator' ), 'generating' => __( 'Generating...', 'abp-writer-ai-blog-generator' ), 'generateTopics' => __( 'Generate New Topics', 'abp-writer-ai-blog-generator' ), 'generatingTopics' => __( 'Generating Topics...', 'abp-writer-ai-blog-generator' ), 'complete' => __( 'Complete!', 'abp-writer-ai-blog-generator' ), 'topicsGenerated' => __( 'Topics generated successfully.', 'abp-writer-ai-blog-generator' ), 'topicsSuccess' => __( 'Topics generated successfully! Refreshing list...', 'abp-writer-ai-blog-generator' ), 'failedGenerate' => __( 'Failed to generate topics.', 'abp-writer-ai-blog-generator' ), 'failedLoad' => __( 'Failed to load topics.', 'abp-writer-ai-blog-generator' ), 'failedUpdate' => __( 'Failed to update topic.', 'abp-writer-ai-blog-generator' ), 'failedDelete' => __( 'Failed to delete topic.', 'abp-writer-ai-blog-generator' ), 'bulkFailed' => __( 'Bulk action failed.', 'abp-writer-ai-blog-generator' ), 'topicDeleted' => __( 'Topic deleted.', 'abp-writer-ai-blog-generator' ), 'networkError' => __( 'A network error occurred. Please try again.', 'abp-writer-ai-blog-generator' ), 'sessionExpired' => __( 'Your session has expired. Redirecting to login...', 'abp-writer-ai-blog-generator' ), 'deleteConfirm' => __( 'Delete topic "%s"? This cannot be undone.', 'abp-writer-ai-blog-generator' ), 'selected' => __( '%d selected', 'abp-writer-ai-blog-generator' ), 'showing' => __( 'Showing %1$s-%2$s of %3$s', 'abp-writer-ai-blog-generator' ), 'doNotClose' => __( "Please don't close or refresh this page", 'abp-writer-ai-blog-generator' ), 'analyzingNiche' => __( 'Analyzing your niche', 'abp-writer-ai-blog-generator' ), 'finalizing' => __( 'Finalizing', 'abp-writer-ai-blog-generator' ), 'analyzingMsg' => __( 'Analyzing your niche and keywords...', 'abp-writer-ai-blog-generator' ), 'researchingMsg' => __( 'Researching high-potential topics...', 'abp-writer-ai-blog-generator' ), 'scoringMsg' => __( 'Scoring topics by SEO potential...', 'abp-writer-ai-blog-generator' ), 'finalizingMsg' => __( 'Almost there, finalizing...', 'abp-writer-ai-blog-generator' ), 'keywords' => __( 'keywords', 'abp-writer-ai-blog-generator' ), 'remaining' => __( '(%d remaining)', 'abp-writer-ai-blog-generator' ), 'pluginLimitTitle' => __( 'Plugin limit reached -- switch to your dashboard', 'abp-writer-ai-blog-generator' ), 'pluginLimitDesc' => __( 'The plugin supports up to 2 topic generations/month. Your plan includes more -- generate them in your AiBlogPress dashboard.', 'abp-writer-ai-blog-generator' ), 'openDashboard' => __( 'Open Dashboard', 'abp-writer-ai-blog-generator' ), 'usedAllFree' => __( "You've used all %1\$s free %2\$s this month", 'abp-writer-ai-blog-generator' ), 'upgradeDesc' => __( 'Your content is performing great! Upgrade to keep the momentum going -- get up to 60 posts/month with AI images and auto-publishing.', 'abp-writer-ai-blog-generator' ), 'free' => __( 'Free', 'abp-writer-ai-blog-generator' ), 'pro' => __( 'Pro', 'abp-writer-ai-blog-generator' ), 'max' => __( 'Max', 'abp-writer-ai-blog-generator' ), 'upgradeNow' => __( 'Upgrade Now', 'abp-writer-ai-blog-generator' ), 'cancelAnytime' => __( 'Cancel anytime', 'abp-writer-ai-blog-generator' ), 'postsYours' => __( 'Your posts are always yours', 'abp-writer-ai-blog-generator' ), 'postsLabel' => __( 'posts', 'abp-writer-ai-blog-generator' ), 'topicGensLabel' => __( 'topic generations', 'abp-writer-ai-blog-generator' ), 'monthLabel' => __( 'month', 'abp-writer-ai-blog-generator' ), ), ) ); return; } // Automation page: separate JS with its own nonce. if ( 'abp-writer-automation' === $page ) { wp_enqueue_script( 'abpw-admin', ABPW_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery' ), ABPW_BUILD_HASH, true ); wp_localize_script( 'abpw-admin', 'abpwAdmin', array( 'ajaxUrl' => admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 'abpw_automation_nonce' ), 'currentPage' => $page, 'i18n' => array( 'loading' => __( 'Loading...', 'abp-writer-ai-blog-generator' ), 'upgradeError' => __( 'Could not generate upgrade link.', 'abp-writer-ai-blog-generator' ), 'dashboardError' => __( 'Could not open dashboard.', 'abp-writer-ai-blog-generator' ), 'connectionError' => __( 'Connection error. Please try again.', 'abp-writer-ai-blog-generator' ), ), ) ); wp_enqueue_script( 'abpw-automation', ABPW_PLUGIN_URL . 'assets/js/automation.js', array( 'jquery', 'abpw-admin' ), ABPW_BUILD_HASH, true ); return; } // Account page: separate JS with its own nonce. if ( 'abp-writer-account' === $page ) { wp_enqueue_script( 'abpw-account', ABPW_PLUGIN_URL . 'assets/js/account.js', array( 'jquery' ), ABPW_BUILD_HASH, true ); wp_localize_script( 'abpw-account', 'abpwAccount', array( 'ajaxUrl' => admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 'abpw_account_nonce' ), 'authUrl' => admin_url( 'admin.php?page=abp-writer-auth' ), 'affiliateUrl' => 'https://aiblogpress.com/affiliate', 'i18n' => array( 'loading' => __( 'Loading...', 'abp-writer-ai-blog-generator' ), 'failedLoad' => __( 'Failed to load account data.', 'abp-writer-ai-blog-generator' ), 'connectionError' => __( 'Connection error. Please try again.', 'abp-writer-ai-blog-generator' ), 'upgradeError' => __( 'Could not generate upgrade link.', 'abp-writer-ai-blog-generator' ), 'disconnectConfirm'=> __( 'Are you sure you want to disconnect? This will remove your API key and all settings.', 'abp-writer-ai-blog-generator' ), 'disconnecting' => __( 'Disconnecting...', 'abp-writer-ai-blog-generator' ), 'disconnectBtn' => __( 'Disconnect Account', 'abp-writer-ai-blog-generator' ), 'failedDisconnect' => __( 'Failed to disconnect.', 'abp-writer-ai-blog-generator' ), 'upgradeImages' => __( 'Upgrade for images', 'abp-writer-ai-blog-generator' ), 'currentPlan' => __( 'Current Plan', 'abp-writer-ai-blog-generator' ), ), ) ); return; } // Posts page: separate JS with its own nonce. if ( 'abp-writer-posts' === $page ) { wp_enqueue_script( 'abpw-posts', ABPW_PLUGIN_URL . 'assets/js/posts.js', array( 'jquery' ), ABPW_BUILD_HASH, true ); wp_localize_script( 'abpw-posts', 'abpwPosts', array( 'ajaxUrl' => admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 'abpw_posts_nonce' ), 'currentPage' => $page, 'topicsUrl' => admin_url( 'admin.php?page=abp-writer-topics' ), 'i18n' => array( 'loading' => __( 'Loading...', 'abp-writer-ai-blog-generator' ), 'loadingPost' => __( 'Loading post...', 'abp-writer-ai-blog-generator' ), 'generatingPost' => __( 'Generating Post...', 'abp-writer-ai-blog-generator' ), 'generating' => __( 'Generating...', 'abp-writer-ai-blog-generator' ), 'complete' => __( 'Complete!', 'abp-writer-ai-blog-generator' ), 'postGenerated' => __( 'Post generated successfully.', 'abp-writer-ai-blog-generator' ), 'postSuccess' => __( 'Post generated successfully! Review and publish when ready.', 'abp-writer-ai-blog-generator' ), 'postPublished' => __( 'Post published successfully!', 'abp-writer-ai-blog-generator' ), 'publishing' => __( 'Publishing...', 'abp-writer-ai-blog-generator' ), 'publish' => __( 'Publish', 'abp-writer-ai-blog-generator' ), 'preview' => __( 'Preview', 'abp-writer-ai-blog-generator' ), 'viewInWP' => __( 'View in WP', 'abp-writer-ai-blog-generator' ), 'editInWP' => __( 'Edit in WP', 'abp-writer-ai-blog-generator' ), 'publishConfirm' => __( 'Publish this post to your WordPress site?', 'abp-writer-ai-blog-generator' ), 'failedLoad' => __( 'Failed to load posts.', 'abp-writer-ai-blog-generator' ), 'failedLoadTopics' => __( 'Failed to load topics.', 'abp-writer-ai-blog-generator' ), 'failedGenerate' => __( 'Failed to start post generation.', 'abp-writer-ai-blog-generator' ), 'failedPublish' => __( 'Failed to publish post.', 'abp-writer-ai-blog-generator' ), 'failedLoadContent' => __( 'Failed to load post content.', 'abp-writer-ai-blog-generator' ), 'generationFailed' => __( 'Generation failed', 'abp-writer-ai-blog-generator' ), 'postGenFailed' => __( 'Post generation failed.', 'abp-writer-ai-blog-generator' ), 'timedOut' => __( 'Post generation timed out. Please try again.', 'abp-writer-ai-blog-generator' ), 'mayStillProgress' => __( 'Generation may still be in progress. Refreshing...', 'abp-writer-ai-blog-generator' ), 'networkError' => __( 'A network error occurred. Please try again.', 'abp-writer-ai-blog-generator' ), 'networkErrorLoad' => __( 'A network error occurred while loading posts.', 'abp-writer-ai-blog-generator' ), 'networkErrorTopics' => __( 'A network error occurred while loading topics.', 'abp-writer-ai-blog-generator' ), 'networkErrorGeneric'=> __( 'A network error occurred.', 'abp-writer-ai-blog-generator' ), 'untitledPost' => __( 'Untitled Post', 'abp-writer-ai-blog-generator' ), 'noContent' => __( 'No content available.', 'abp-writer-ai-blog-generator' ), 'error' => __( 'Error', 'abp-writer-ai-blog-generator' ), 'metaDescription' => __( 'Meta Description:', 'abp-writer-ai-blog-generator' ), 'usageText' => __( '%1$s of %2$s posts generated this month', 'abp-writer-ai-blog-generator' ), 'doNotClose' => __( "Please don't close or refresh this page", 'abp-writer-ai-blog-generator' ), 'writingContent' => __( 'Writing content', 'abp-writer-ai-blog-generator' ), 'generatingImage' => __( 'Generating featured image', 'abp-writer-ai-blog-generator' ), 'finalizing' => __( 'Finalizing', 'abp-writer-ai-blog-generator' ), 'craftingContent' => __( 'Crafting your SEO-optimized content...', 'abp-writer-ai-blog-generator' ), 'structuringMsg' => __( 'Structuring headings and paragraphs...', 'abp-writer-ai-blog-generator' ), 'weavingMsg' => __( 'Weaving in your target keywords...', 'abp-writer-ai-blog-generator' ), 'polishingMsg' => __( 'Polishing the final details...', 'abp-writer-ai-blog-generator' ), 'creatingImageMsg' => __( 'Creating a unique featured image...', 'abp-writer-ai-blog-generator' ), 'almostThereMsg' => __( 'Almost there, just a moment...', 'abp-writer-ai-blog-generator' ), 'limitReachedDashboard' => __( 'Plugin limit reached -- switch to your dashboard', 'abp-writer-ai-blog-generator' ), 'postsLimitProDesc' => __( 'The plugin supports up to 5 posts/month. Your plan includes more -- generate them in your AiBlogPress dashboard.', 'abp-writer-ai-blog-generator' ), 'openDashboard' => __( 'Open Dashboard', 'abp-writer-ai-blog-generator' ), 'usedAllFreePosts' => __( "You've used all 5 free posts this month", 'abp-writer-ai-blog-generator' ), 'upgradeDesc' => __( 'Your content is performing great! Upgrade to keep the momentum going -- get up to 60 posts/month with AI images and auto-publishing.', 'abp-writer-ai-blog-generator' ), 'planFree' => __( 'Free', 'abp-writer-ai-blog-generator' ), 'planPro' => __( 'Pro', 'abp-writer-ai-blog-generator' ), 'planMax' => __( 'Max', 'abp-writer-ai-blog-generator' ), 'upgradeNow' => __( 'Upgrade Now', 'abp-writer-ai-blog-generator' ), 'guarantee' => __( 'Cancel anytime', 'abp-writer-ai-blog-generator' ), 'postsYours' => __( 'Your posts are always yours', 'abp-writer-ai-blog-generator' ), 'postsPerMonth' => __( 'posts / month', 'abp-writer-ai-blog-generator' ), 'published' => __( 'Published', 'abp-writer-ai-blog-generator' ), ), ) ); return; } // All other ABP pages: admin scripts. wp_enqueue_script( 'abpw-admin', ABPW_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery' ), ABPW_BUILD_HASH, true ); wp_localize_script( 'abpw-admin', 'abpwAdmin', array( 'ajaxUrl' => admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 'abpw_config_nonce' ), 'currentPage' => $page, 'i18n' => array( 'loading' => __( 'Loading...', 'abp-writer-ai-blog-generator' ), 'saving' => __( 'Saving...', 'abp-writer-ai-blog-generator' ), 'saveConfig' => __( 'Save Configuration', 'abp-writer-ai-blog-generator' ), 'descError' => __( 'Business description must be between 50 and 1000 characters.', 'abp-writer-ai-blog-generator' ), 'keywordsError' => __( 'Please enter between 5 and 50 keywords separated by commas.', 'abp-writer-ai-blog-generator' ), 'styleError' => __( 'Please select a communication style.', 'abp-writer-ai-blog-generator' ), 'savedSuccess' => __( 'Configuration saved successfully.', 'abp-writer-ai-blog-generator' ), 'failedSave' => __( 'Failed to save configuration.', 'abp-writer-ai-blog-generator' ), 'failedLoad' => __( 'Failed to load configuration. You can still fill in the form.', 'abp-writer-ai-blog-generator' ), 'networkError' => __( 'A network error occurred. Please try again.', 'abp-writer-ai-blog-generator' ), 'lastSaved' => __( 'Last saved: %s', 'abp-writer-ai-blog-generator' ), 'keywords' => __( 'keywords', 'abp-writer-ai-blog-generator' ), ), ) ); } /** * Render the welcome page. */ public function render_welcome() { include ABPW_PLUGIN_DIR . 'admin/views/welcome.php'; } /** * Render the auth page. */ public function render_auth() { include ABPW_PLUGIN_DIR . 'admin/views/auth.php'; } /** * Render the onboarding page. */ public function render_onboarding() { if ( ! $this->is_authenticated() ) { include ABPW_PLUGIN_DIR . 'admin/views/welcome.php'; return; } include ABPW_PLUGIN_DIR . 'admin/views/onboarding.php'; } /** * Render the dashboard page. */ public function render_dashboard() { if ( ! $this->is_authenticated() ) { include ABPW_PLUGIN_DIR . 'admin/views/welcome.php'; return; } include ABPW_PLUGIN_DIR . 'admin/views/dashboard.php'; } /** * Render the config page. */ public function render_config() { if ( ! $this->is_authenticated() ) { include ABPW_PLUGIN_DIR . 'admin/views/welcome.php'; return; } include ABPW_PLUGIN_DIR . 'admin/views/config.php'; } /** * Render the topics page. */ public function render_topics() { if ( ! $this->is_authenticated() ) { include ABPW_PLUGIN_DIR . 'admin/views/welcome.php'; return; } include ABPW_PLUGIN_DIR . 'admin/views/topics.php'; } /** * Render the posts page. */ public function render_posts() { if ( ! $this->is_authenticated() ) { include ABPW_PLUGIN_DIR . 'admin/views/welcome.php'; return; } include ABPW_PLUGIN_DIR . 'admin/views/posts.php'; } /** * Render the automation page. */ public function render_automation() { if ( ! $this->is_authenticated() ) { include ABPW_PLUGIN_DIR . 'admin/views/welcome.php'; return; } include ABPW_PLUGIN_DIR . 'admin/views/automation.php'; } /** * Render the account page. */ public function render_account() { if ( ! $this->is_authenticated() ) { include ABPW_PLUGIN_DIR . 'admin/views/welcome.php'; return; } include ABPW_PLUGIN_DIR . 'admin/views/account.php'; } }