). The assets must be * hooked to admin_enqueue_scripts instead. * * @return void */ public static function init() { // Priority 20: the main admin controller enqueues the plugin-wide // select2 at priority 10, so this handler must run afterwards to be // able to detect (and reuse) that handle instead of adding a second // copy of select2 on the same page. add_action( 'admin_enqueue_scripts', array( __CLASS__, 'enqueue_assets' ), 20 ); } /** * Render the module's admin page. * * @return void */ public function render_tab() { if ( ! current_user_can( 'manage_options' ) ) { return; } $settings = AILM_LlmsTxt_Settings::get_all(); $public_types = get_post_types( array( 'public' => true ), 'objects' ); // Attachment is technically public but never a content page. unset( $public_types['attachment'] ); $draft = AILM_LlmsTxt_Rebuilder::get_draft(); ?>
wp_create_nonce( AILM_LlmsTxt_Ajax::NONCE_ACTION ), 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'selected' => $selected, 'pinned' => $pinned, ) ); } /** * Map stored post IDs to select2 items ({id, text}). * * @param array $ids Post IDs in the stored order. * @return array List of picker items. */ private static function get_picker_items( array $ids ) { $items = array(); foreach ( $ids as $pid ) { $pid = absint( $pid ); $post = $pid ? get_post( $pid ) : null; if ( ! $post ) { continue; } // select2 renders the text as plain text, and the label is // stored as-is for display only (no HTML is emitted). $items[] = array( 'id' => (int) $pid, 'text' => $post->post_title . ' (' . $post->post_type . ')', ); } return $items; } }