| @@ -53,8 +53,10 @@ | ||
| 53 | 53 | $assets->register( 'betterdocs-category-archive-header', 'public/css/archive-header.css' ); |
| 54 | 54 | $assets->register( 'betterdocs-category-archive-doc-list', 'public/css/archive-doc-list.css' ); |
| 55 | 55 | $assets->register( 'betterdocs-article-summary', 'public/css/article-summary.css' ); |
| 56 | 56 | $assets->register( 'betterdocs-author', 'public/css/author.css' ); |
| 57 | + $assets->register( 'betterdocs-ai-actions', 'public/css/ai-actions.css' ); | |
| 58 | + $assets->register( 'betterdocs-listen', 'public/css/listen.css' ); | |
| 57 | 59 | |
| 58 | 60 | $assets->register( 'betterdocs-category-grid', 'public/css/category-grid.css', [ 'simplebar' ] ); |
| 59 | 61 | $assets->register( 'betterdocs-category-box', 'public/css/category-box.css' ); |
| 60 | 62 | $assets->register( 'betterdocs-category-grid-list', 'public/css/category-grid-list.css' ); |
| @@ -103,8 +105,30 @@ | ||
| 103 | 105 | 'copy_text' => __( 'Copied', 'betterdocs' ), |
| 104 | 106 | 'sticky_toc_offset' => $this->settings->get( 'sticky_toc_offset' ), |
| 105 | 107 | 'summary_nonce' => wp_create_nonce( 'betterdocs_article_summary_nonce' ), |
| 106 | 108 | 'summary_error' => __( 'Failed to generate doc summary. Please try again.', 'betterdocs' ), |
| 109 | + // Namespaced so the AI Actions strings do not collide as the feature | |
| 110 | + // grows. Nothing URL-shaped belongs here: init() runs with no $post, | |
| 111 | + // so every per-doc URL lives on the rendered data-bd-* attributes. | |
| 112 | + 'ai_actions' => [ | |
| 113 | + 'i18n' => [ | |
| 114 | + 'copy' => __( 'Copy page', 'betterdocs' ), | |
| 115 | + 'copying' => __( 'Copying…', 'betterdocs' ), | |
| 116 | + 'copied' => __( 'Copied', 'betterdocs' ), | |
| 117 | + 'copy_failed' => __( 'Copy failed', 'betterdocs' ), | |
| 118 | + 'copy_error' => __( 'Could not copy this page. Please try again.', 'betterdocs' ) | |
| 119 | + ] | |
| 120 | + ], | |
| 121 | + // Same shape and the same reasoning: namespaced, and with nothing | |
| 122 | + // per-doc in it. Core\Listen owns the contents, because the rates and | |
| 123 | + // the two content selectors are filterable and the filters have to | |
| 124 | + // reach the script. | |
| 125 | + // | |
| 126 | + // Guarded: this runs on `init` at 1 and Plugin::initialize() — which | |
| 127 | + // builds the property — is the `init` callback at 0, so the ordering | |
| 128 | + // holds today. It is one priority of slack, and a fatal if it ever | |
| 129 | + // changes. | |
| 130 | + 'listen' => isset( betterdocs()->listen ) ? betterdocs()->listen->localize() : [], | |
| 107 | 131 | 'print' => [ |
| 108 | 132 | 'logo' => $print_logo ? esc_url( $print_logo ) : '', |
| 109 | 133 | 'footer' => $print_footer ? wp_kses_post( $print_footer ) : '' |
| 110 | 134 | ] |
| @@ -114,9 +138,12 @@ | ||
| 114 | 138 | $assets->localize( |
| 115 | 139 | 'betterdocs-search', |
| 116 | 140 | 'betterdocsSearchConfig', |
| 117 | 141 | [ |
| 118 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), | |
| 142 | + // Root-relative so live search stays same-origin when the KB is | |
| 143 | + // served on a different host than the Site Address (subdomain / | |
| 144 | + // domain alias / reverse proxy). See Helper::frontend_ajax_url(). | |
| 145 | + 'ajax_url' => Helper::frontend_ajax_url(), | |
| 119 | 146 | 'search_letter_limit' => $this->settings->get( 'search_letter_limit' ) |
| 120 | 147 | ] |
| 121 | 148 | ); |
| 122 | 149 | |
| @@ -123,9 +150,10 @@ | ||
| 123 | 150 | $assets->localize( |
| 124 | 151 | 'betterdocs-search-modal', |
| 125 | 152 | 'betterdocsSearchModalConfig', |
| 126 | 153 | [ |
| 127 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), | |
| 154 | + // Same-origin (see betterdocsSearchConfig above). | |
| 155 | + 'ajax_url' => Helper::frontend_ajax_url(), | |
| 128 | 156 | 'rest_url' => esc_url_raw(rest_url()), |
| 129 | 157 | 'advance_search' => $this->settings->get( 'advance_search' ), |
| 130 | 158 | 'child_category_exclude' => $this->settings->get( 'child_category_exclude' ), |
| 131 | 159 | 'popular_keyword_limit' => $this->settings->get( 'popular_keyword_limit' ), |