can_use_premium_code(); // Build summary text. if ( 'manual' === $mode ) { $summary = esc_html__( 'Manual mode: posts are generated only when you click the button below.', 'ai-publisher' ); } else { $interval_label = ( 'day' === $mode ? esc_html__( 'day', 'ai-publisher' ) : esc_html__( 'week', 'ai-publisher' ) ); /* translators: 1: number of posts, 2: interval label (day/week) */ $summary = sprintf( esc_html__( '%1$d post(s) per %2$s', 'ai-publisher' ), $count, $interval_label ); // Next scheduled run. $next = wp_next_scheduled( 'aipub_generate_post_event' ); if ( $next ) { $time = date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $next ); /* translators: %s: date/time of next run */ $summary .= ' ' . sprintf( esc_html__( 'Next run: %s', 'ai-publisher' ), esc_html( $time ) ); } } $general_incomplete = !Settings::is_complete(); $brand_incomplete = !Brand_Strategy::is_complete(); $keywords_incomplete = !Keywords::is_complete(); // Disable if prerequisites aren’t ready OR if automatic scheduling is active (non-manual mode). $manual_disabled = 'manual' !== $mode; $disable_prereqs = $general_incomplete || $brand_incomplete || $keywords_incomplete; $disable_buttons = $disable_prereqs || $manual_disabled; if ( $disable_buttons ) { if ( $manual_disabled ) { $disable_msg = esc_html__( 'Manual post generation is disabled while automatic scheduling is active. Switch to Manual mode in the General Settings to enable this button.', 'ai-publisher' ); } else { $prereqs = []; if ( $general_incomplete ) { $prereqs[] = __( 'General Settings', 'ai-publisher' ); } if ( $brand_incomplete ) { $prereqs[] = __( 'Brand Strategy', 'ai-publisher' ); } if ( $keywords_incomplete ) { $prereqs[] = __( 'SEO Keywords', 'ai-publisher' ); } $last = array_pop( $prereqs ); if ( $prereqs ) { $disable_msg = sprintf( /* translators: 1: comma-separated list, 2: last item */ esc_html__( 'Complete %1$s and %2$s before proceeding.', 'ai-publisher' ), implode( ', ', $prereqs ), $last ); } else { $disable_msg = sprintf( /* translators: %s: section name */ esc_html__( 'Complete %s before proceeding.', 'ai-publisher' ), $last ); } } } list( $limit_allowed, $limit_msg ) = Limits::can_generate(); if ( !$limit_allowed ) { $limit_notice = $limit_msg; $disable_buttons = true; } ?>


admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 'aipub_nonce' ), 'keywords' => $keywords_list, 'manual_disabled' => $manual_disabled, 'prereqs_incomplete' => $disable_prereqs, 'limit_reached' => !$limit_allowed, 'status_msgs' => $status_msgs, 'error_generate_post' => __( 'Error generating post:', 'ai-publisher' ), 'success_prefix' => __( 'Post generated successfully:', 'ai-publisher' ), 'edit_post' => __( 'Edit post', 'ai-publisher' ), 'view_post' => __( 'View post', 'ai-publisher' ), ]; wp_add_inline_script( 'ai_publisher_admin', 'var aipubConfig = ' . wp_json_encode( $data ) . ';' ); wp_enqueue_script( 'ai_publisher_admin_settings_general', plugins_url( '../../assets/js/generate-posts-inline.js', __FILE__ ), ['ai_publisher_admin'], filemtime( AIPUB_DIR . 'assets/js/generate-posts-inline.js' ), true );