Plugin Directory

Changeset 3846863


Ignore:
Timestamp:
12/05/2026 09:52:33 PM (less than one hour ago)
Author:
dauphinia
Message:

Version 1.0.2: choose llms.txt content types, noindex content left out

Location:
dauphinia
Files:
12 edited
1 copied

Legend:

Unmodified
Added
Removed
  • dauphinia/tags/1.0.2/dauphinia.php

    r3846414 r3846863  
    33 * Plugin Name:       Dauphinia – AI Visibility Check
    44 * Description:       Can ChatGPT, Claude, Perplexity and Gemini read your site? Finds which robots.txt rule blocks each AI crawler, and where it comes from (SEO plugin, host, Cloudflare). Also tests post-quantum HTTPS (TLS 1.3, ML-KEM), search engine visibility and sitemap, and can serve an llms.txt file.
    5  * Version:           1.0.1
     5 * Version:           1.0.2
    66 * Requires at least: 6.0
    77 * Requires PHP:      7.4
    … …  
    1919}
    2020
    21 define( 'DAUPHINIA_VERSION', '1.0.1' );
     21define( 'DAUPHINIA_VERSION', '1.0.2' );
    2222define( 'DAUPHINIA_FILE', __FILE__ );
    2323define( 'DAUPHINIA_DIR', plugin_dir_path( __FILE__ ) );
  • dauphinia/tags/1.0.2/includes/class-dauphinia-admin.php

    r3846414 r3846863  
    5454                                'sanitize_callback' => 'rest_sanitize_boolean',
    5555                                'default'           => false,
     56                        )
     57                );
     58                register_setting(
     59                        'dauphinia',
     60                        Dauphinia_Llms::OPTION_TYPES,
     61                        array(
     62                                'type'              => 'array',
     63                                'sanitize_callback' => array( 'Dauphinia_Llms', 'sanitize_types' ),
     64                                'default'           => Dauphinia_Llms::DEFAULT_TYPES,
    5665                        )
    5766                );
    … …  
    292301                                                                                <?php
    293302                                                                                /* translators: %s: llms.txt address. */
    294                                                                                 echo esc_html( sprintf( __( 'Publish %s, built from your pages, products and latest articles', 'dauphinia' ), Dauphinia_Llms::url() ) );
     303                                                                                echo esc_html( sprintf( __( 'Publish %s, built from the content ticked below', 'dauphinia' ), Dauphinia_Llms::url() ) );
    295304                                                                                ?>
    296305                                                                        </label>
     306                                                                </td>
     307                                                        </tr>
     308                                                        <tr>
     309                                                                <th scope="row"><?php esc_html_e( 'Content listed', 'dauphinia' ); ?></th>
     310                                                                <td>
     311                                                                        <fieldset>
     312                                                                                <input type="hidden" name="<?php echo esc_attr( Dauphinia_Llms::OPTION_TYPES ); ?>[]" value="">
     313                                                                                <?php foreach ( Dauphinia_Llms::available_types() as $type_name => $type_object ) : ?>
     314                                                                                        <?php $noindex_by = Dauphinia_Llms::type_noindex_by( $type_name ); ?>
     315                                                                                        <label>
     316                                                                                                <input type="checkbox" name="<?php echo esc_attr( Dauphinia_Llms::OPTION_TYPES ); ?>[]" value="<?php echo esc_attr( $type_name ); ?>" <?php checked( '' === $noindex_by && in_array( $type_name, Dauphinia_Llms::selected_types(), true ) ); ?> <?php disabled( '' !== $noindex_by ); ?>>
     317                                                                                                <?php echo esc_html( $type_object->labels->name ); ?>
     318                                                                                                <?php if ( '' !== $noindex_by ) : ?>
     319                                                                                                        <span class="description">
     320                                                                                                                <?php
     321                                                                                                                /* translators: %s: SEO plugin name, e.g. Yoast SEO. */
     322                                                                                                                echo esc_html( sprintf( __( '(set to "noindex" in %s, left out)', 'dauphinia' ), $noindex_by ) );
     323                                                                                                                ?>
     324                                                                                                        </span>
     325                                                                                                <?php endif; ?>
     326                                                                                        </label><br>
     327                                                                                <?php endforeach; ?>
     328                                                                                <p class="description"><?php esc_html_e( 'Pages marked "noindex" in Yoast SEO, Rank Math or SEOPress are always left out, as are drafts, private and password-protected content.', 'dauphinia' ); ?></p>
     329                                                                        </fieldset>
    297330                                                                </td>
    298331                                                        </tr>
  • dauphinia/tags/1.0.2/includes/class-dauphinia-checks.php

    r3846062 r3846863  
    206206                                'status' => 'good',
    207207                                'title'  => __( 'llms.txt is served by this plugin', 'dauphinia' ),
    208                                 'detail' => __( 'It lists your pages, products and latest articles, and updates itself when you publish.', 'dauphinia' ),
     208                                'detail' => __( 'It lists the content you chose (pages, products, articles…) and updates itself when you publish.', 'dauphinia' ),
    209209                                'action' => array( 'label' => __( 'View llms.txt', 'dauphinia' ), 'url' => Dauphinia_Llms::url() ),
    210210                        );
  • dauphinia/tags/1.0.2/includes/class-dauphinia-llms.php

    r3846062 r3846863  
    1717        const OPTION_ENABLED = 'dauphinia_llms_enabled';
    1818        const OPTION_INTRO   = 'dauphinia_llms_intro';
     19        const OPTION_TYPES   = 'dauphinia_llms_post_types';
    1920        const CACHE          = 'dauphinia_llms_txt';
     21
     22        /**
     23         * Content types listed until the administrator chooses: pages, WooCommerce products and articles.
     24         */
     25        const DEFAULT_TYPES = array( 'page', 'product', 'post' );
    2026
    2127        /**
    … …  
    3036                add_action( 'add_option_' . self::OPTION_INTRO, array( __CLASS__, 'flush' ) );
    3137                add_action( 'update_option_' . self::OPTION_INTRO, array( __CLASS__, 'flush' ) );
     38                add_action( 'add_option_' . self::OPTION_TYPES, array( __CLASS__, 'flush' ) );
     39                add_action( 'update_option_' . self::OPTION_TYPES, array( __CLASS__, 'flush' ) );
     40                add_action( 'updated_post_meta', array( __CLASS__, 'flush_on_robots_meta' ), 10, 3 );
     41                add_action( 'added_post_meta', array( __CLASS__, 'flush_on_robots_meta' ), 10, 3 );
     42                add_action( 'deleted_post_meta', array( __CLASS__, 'flush_on_robots_meta' ), 10, 3 );
     43        }
     44
     45        /**
     46         * SEO plugin fields that mark one page as "noindex".
     47         *
     48         * @return array<string, string> Meta key => plugin.
     49         */
     50        private static function noindex_meta_keys() {
     51                return array(
     52                        '_yoast_wpseo_meta-robots-noindex' => 'yoast',
     53                        'rank_math_robots'                 => 'rank-math',
     54                        '_seopress_robots_index'           => 'seopress',
     55                );
     56        }
     57
     58        /**
     59         * Rebuilds the file when an SEO plugin changes the "noindex" setting of a page.
     60         *
     61         * @param int|array $meta_id  Meta ID(s).
     62         * @param int       $post_id  Post ID.
     63         * @param string    $meta_key Meta key.
     64         */
     65        public static function flush_on_robots_meta( $meta_id, $post_id, $meta_key ) {
     66                if ( isset( self::noindex_meta_keys()[ $meta_key ] ) ) {
     67                        self::flush();
     68                }
     69        }
     70
     71        /**
     72         * Public content types an administrator can list in llms.txt (media excluded).
     73         *
     74         * @return array<string, WP_Post_Type>
     75         */
     76        public static function available_types() {
     77                $types = get_post_types( array( 'public' => true ), 'objects' );
     78                unset( $types['attachment'] );
     79
     80                return $types;
     81        }
     82
     83        /**
     84         * Content types listed in llms.txt.
     85         *
     86         * @return string[]
     87         */
     88        public static function selected_types() {
     89                $saved = get_option( self::OPTION_TYPES, null );
     90                $types = is_array( $saved ) ? $saved : self::DEFAULT_TYPES;
     91                $types = array_values( array_intersect( $types, array_keys( self::available_types() ) ) );
     92
     93                /**
     94                 * Filters the content types listed in llms.txt.
     95                 *
     96                 * @param string[] $types Post type names.
     97                 */
     98                return (array) apply_filters( 'dauphinia_llms_post_types', $types );
     99        }
     100
     101        /**
     102         * Keeps only public content types from the settings form.
     103         *
     104         * @param mixed $value Submitted value.
     105         * @return string[]
     106         */
     107        public static function sanitize_types( $value ) {
     108                $value = is_array( $value ) ? array_map( 'sanitize_key', $value ) : array();
     109
     110                return array_values( array_intersect( $value, array_keys( self::available_types() ) ) );
     111        }
     112
     113        /**
     114         * SEO plugin that marks a whole content type as "noindex", if any.
     115         *
     116         * @param string $type Post type name.
     117         * @return string Plugin name, or '' when the type may be indexed.
     118         */
     119        public static function type_noindex_by( $type ) {
     120                $yoast = get_option( 'wpseo_titles' );
     121                if ( defined( 'WPSEO_VERSION' ) && is_array( $yoast ) && ! empty( $yoast[ 'noindex-' . $type ] ) ) {
     122                        return 'Yoast SEO';
     123                }
     124
     125                $rank_math = get_option( 'rank-math-options-titles' );
     126                if ( class_exists( 'RankMath' ) && is_array( $rank_math ) && ! empty( $rank_math[ 'pt_' . $type . '_custom_robots' ] )
     127                        && isset( $rank_math[ 'pt_' . $type . '_robots' ] ) && in_array( 'noindex', (array) $rank_math[ 'pt_' . $type . '_robots' ], true ) ) {
     128                        return 'Rank Math';
     129                }
     130
     131                $seopress = get_option( 'seopress_titles_option_name' );
     132                if ( defined( 'SEOPRESS_VERSION' ) && is_array( $seopress ) && ! empty( $seopress['seopress_titles_single_titles'][ $type ]['noindex'] ) ) {
     133                        return 'SEOPress';
     134                }
     135
     136                return '';
     137        }
     138
     139        /**
     140         * Whether a page is marked "noindex" by Yoast SEO, Rank Math or SEOPress.
     141         *
     142         * @param WP_Post $post Post.
     143         * @return bool
     144         */
     145        private static function post_noindex( $post ) {
     146                foreach ( self::noindex_meta_keys() as $key => $plugin ) {
     147                        $value = get_post_meta( $post->ID, $key, true );
     148                        if ( 'yoast' === $plugin && '1' === (string) $value ) {
     149                                return true;
     150                        }
     151                        if ( 'rank-math' === $plugin && is_array( $value ) && in_array( 'noindex', $value, true ) ) {
     152                                return true;
     153                        }
     154                        if ( 'seopress' === $plugin && 'yes' === $value ) {
     155                                return true;
     156                        }
     157                }
     158
     159                return false;
    32160        }
    33161
    … …  
    156284                }
    157285
    158                 $sections = array(
     286                $known = array(
    159287                        'page'    => array( __( 'Pages', 'dauphinia' ), 100 ),
    160288                        'product' => array( __( 'Products', 'dauphinia' ), 100 ),
    161289                        'post'    => array( __( 'Latest articles', 'dauphinia' ), 30 ),
    162290                );
    163 
    164                 foreach ( $sections as $type => $section ) {
    165                         if ( ! post_type_exists( $type ) ) {
     291                $types = self::available_types();
     292
     293                foreach ( self::selected_types() as $type ) {
     294                        if ( ! isset( $types[ $type ] ) || '' !== self::type_noindex_by( $type ) ) {
    166295                                continue;
    167296                        }
     297                        $section = isset( $known[ $type ] ) ? $known[ $type ] : array( $types[ $type ]->labels->name, 50 );
    168298
    169299                        $posts = get_posts(
    … …  
    186316                        foreach ( $posts as $post ) {
    187317                                $title = self::clean( get_the_title( $post ) );
    188                                 if ( '' === $title ) {
     318
     319                                /**
     320                                 * Filters whether a published page is listed in llms.txt. Pages marked "noindex" in Yoast SEO,
     321                                 * Rank Math or SEOPress are left out by default.
     322                                 *
     323                                 * @param bool    $include Whether to list it.
     324                                 * @param WP_Post $post    The page, article, product…
     325                                 */
     326                                if ( '' === $title || ! apply_filters( 'dauphinia_llms_include_post', ! self::post_noindex( $post ), $post ) ) {
    189327                                        continue;
    190328                                }
  • dauphinia/tags/1.0.2/readme.txt

    r3846414 r3846863  
    55Tested up to: 7.1
    66Requires PHP: 7.4
    7 Stable tag: 1.0.1
     7Stable tag: 1.0.2
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    6666* your site name and tagline,
    6767* an introduction you write yourself (two or three sentences: what you do, where, for whom),
    68 * your pages, your WooCommerce products and your latest articles, each with a link and a one-line summary.
     68* your pages, your WooCommerce products and your latest articles, each with a link and a one-line summary,
     69* any other public content type you choose (portfolio, events, courses…), one checkbox each.
     70
     71Content marked "noindex" in Yoast SEO, Rank Math or SEOPress is left out automatically, page by page or for a whole content type, so llms.txt never lists what you keep out of search engines.
    6972
    7073The file is cached for 12 hours, rebuilt as soon as you publish or edit content, and written in your site's language. An llms.txt file already on your server is never replaced. Developers can change its content with the `dauphinia_llms_txt` filter.
    … …  
    99102= Privacy =
    100103
    101 The plugin does not track you, sets no cookie on your visitors, contacts no external service, and stores only two settings (llms.txt on/off and its introduction) plus three temporary caches. Uninstalling removes them.
     104The plugin does not track you, sets no cookie on your visitors, contacts no external service, and stores only three settings (llms.txt on/off, its introduction and the content types it lists) plus three temporary caches. Uninstalling removes them.
    102105
    103106== External services ==
    … …  
    179182= Does llms.txt include private or draft content? =
    180183
    181 No. Only published pages, products and articles without a password are listed.
     184No. Only published content without a password is listed.
     185
     186= Can I choose which content types appear in llms.txt, or exclude some? =
     187
     188Yes. Under "llms.txt", tick the content types to list: pages, products and articles by default, plus any public custom post type. Content marked "noindex" in Yoast SEO, Rank Math or SEOPress is always left out, and a content type set to "noindex" as a whole cannot be ticked. Developers can also use the `dauphinia_llms_post_types` and `dauphinia_llms_include_post` filters.
    182189
    183190= I already have an llms.txt file. Will the plugin overwrite it? =
    … …  
    209216
    210217== Changelog ==
     218
     219= 1.0.2 =
     220* llms.txt: choose which content types are listed, including custom post types.
     221* llms.txt: content marked "noindex" in Yoast SEO, Rank Math or SEOPress is left out, page by page or for a whole content type.
     222* New filters for developers: `dauphinia_llms_post_types` and `dauphinia_llms_include_post`.
    211223
    212224= 1.0.1 =
    … …  
    224236== Upgrade Notice ==
    225237
     238= 1.0.2 =
     239Choose the content types listed in llms.txt; "noindex" content is now left out.
     240
    226241= 1.0.1 =
    227242Checks Amazon's crawlers (Amzn-SearchBot, Amazonbot) and ByteDance's Bytespider.
  • dauphinia/tags/1.0.2/uninstall.php

    r3846062 r3846863  
    1212delete_option( 'dauphinia_llms_enabled' );
    1313delete_option( 'dauphinia_llms_intro' );
     14delete_option( 'dauphinia_llms_post_types' );
    1415delete_transient( 'dauphinia_llms_txt' );
    1516delete_transient( 'dauphinia_checks' );
  • dauphinia/trunk/dauphinia.php

    r3846414 r3846863  
    33 * Plugin Name:       Dauphinia – AI Visibility Check
    44 * Description:       Can ChatGPT, Claude, Perplexity and Gemini read your site? Finds which robots.txt rule blocks each AI crawler, and where it comes from (SEO plugin, host, Cloudflare). Also tests post-quantum HTTPS (TLS 1.3, ML-KEM), search engine visibility and sitemap, and can serve an llms.txt file.
    5  * Version:           1.0.1
     5 * Version:           1.0.2
    66 * Requires at least: 6.0
    77 * Requires PHP:      7.4
    … …  
    1919}
    2020
    21 define( 'DAUPHINIA_VERSION', '1.0.1' );
     21define( 'DAUPHINIA_VERSION', '1.0.2' );
    2222define( 'DAUPHINIA_FILE', __FILE__ );
    2323define( 'DAUPHINIA_DIR', plugin_dir_path( __FILE__ ) );
  • dauphinia/trunk/includes/class-dauphinia-admin.php

    r3846414 r3846863  
    5454                                'sanitize_callback' => 'rest_sanitize_boolean',
    5555                                'default'           => false,
     56                        )
     57                );
     58                register_setting(
     59                        'dauphinia',
     60                        Dauphinia_Llms::OPTION_TYPES,
     61                        array(
     62                                'type'              => 'array',
     63                                'sanitize_callback' => array( 'Dauphinia_Llms', 'sanitize_types' ),
     64                                'default'           => Dauphinia_Llms::DEFAULT_TYPES,
    5665                        )
    5766                );
    … …  
    292301                                                                                <?php
    293302                                                                                /* translators: %s: llms.txt address. */
    294                                                                                 echo esc_html( sprintf( __( 'Publish %s, built from your pages, products and latest articles', 'dauphinia' ), Dauphinia_Llms::url() ) );
     303                                                                                echo esc_html( sprintf( __( 'Publish %s, built from the content ticked below', 'dauphinia' ), Dauphinia_Llms::url() ) );
    295304                                                                                ?>
    296305                                                                        </label>
     306                                                                </td>
     307                                                        </tr>
     308                                                        <tr>
     309                                                                <th scope="row"><?php esc_html_e( 'Content listed', 'dauphinia' ); ?></th>
     310                                                                <td>
     311                                                                        <fieldset>
     312                                                                                <input type="hidden" name="<?php echo esc_attr( Dauphinia_Llms::OPTION_TYPES ); ?>[]" value="">
     313                                                                                <?php foreach ( Dauphinia_Llms::available_types() as $type_name => $type_object ) : ?>
     314                                                                                        <?php $noindex_by = Dauphinia_Llms::type_noindex_by( $type_name ); ?>
     315                                                                                        <label>
     316                                                                                                <input type="checkbox" name="<?php echo esc_attr( Dauphinia_Llms::OPTION_TYPES ); ?>[]" value="<?php echo esc_attr( $type_name ); ?>" <?php checked( '' === $noindex_by && in_array( $type_name, Dauphinia_Llms::selected_types(), true ) ); ?> <?php disabled( '' !== $noindex_by ); ?>>
     317                                                                                                <?php echo esc_html( $type_object->labels->name ); ?>
     318                                                                                                <?php if ( '' !== $noindex_by ) : ?>
     319                                                                                                        <span class="description">
     320                                                                                                                <?php
     321                                                                                                                /* translators: %s: SEO plugin name, e.g. Yoast SEO. */
     322                                                                                                                echo esc_html( sprintf( __( '(set to "noindex" in %s, left out)', 'dauphinia' ), $noindex_by ) );
     323                                                                                                                ?>
     324                                                                                                        </span>
     325                                                                                                <?php endif; ?>
     326                                                                                        </label><br>
     327                                                                                <?php endforeach; ?>
     328                                                                                <p class="description"><?php esc_html_e( 'Pages marked "noindex" in Yoast SEO, Rank Math or SEOPress are always left out, as are drafts, private and password-protected content.', 'dauphinia' ); ?></p>
     329                                                                        </fieldset>
    297330                                                                </td>
    298331                                                        </tr>
  • dauphinia/trunk/includes/class-dauphinia-checks.php

    r3846062 r3846863  
    206206                                'status' => 'good',
    207207                                'title'  => __( 'llms.txt is served by this plugin', 'dauphinia' ),
    208                                 'detail' => __( 'It lists your pages, products and latest articles, and updates itself when you publish.', 'dauphinia' ),
     208                                'detail' => __( 'It lists the content you chose (pages, products, articles…) and updates itself when you publish.', 'dauphinia' ),
    209209                                'action' => array( 'label' => __( 'View llms.txt', 'dauphinia' ), 'url' => Dauphinia_Llms::url() ),
    210210                        );
  • dauphinia/trunk/includes/class-dauphinia-llms.php

    r3846062 r3846863  
    1717        const OPTION_ENABLED = 'dauphinia_llms_enabled';
    1818        const OPTION_INTRO   = 'dauphinia_llms_intro';
     19        const OPTION_TYPES   = 'dauphinia_llms_post_types';
    1920        const CACHE          = 'dauphinia_llms_txt';
     21
     22        /**
     23         * Content types listed until the administrator chooses: pages, WooCommerce products and articles.
     24         */
     25        const DEFAULT_TYPES = array( 'page', 'product', 'post' );
    2026
    2127        /**
    … …  
    3036                add_action( 'add_option_' . self::OPTION_INTRO, array( __CLASS__, 'flush' ) );
    3137                add_action( 'update_option_' . self::OPTION_INTRO, array( __CLASS__, 'flush' ) );
     38                add_action( 'add_option_' . self::OPTION_TYPES, array( __CLASS__, 'flush' ) );
     39                add_action( 'update_option_' . self::OPTION_TYPES, array( __CLASS__, 'flush' ) );
     40                add_action( 'updated_post_meta', array( __CLASS__, 'flush_on_robots_meta' ), 10, 3 );
     41                add_action( 'added_post_meta', array( __CLASS__, 'flush_on_robots_meta' ), 10, 3 );
     42                add_action( 'deleted_post_meta', array( __CLASS__, 'flush_on_robots_meta' ), 10, 3 );
     43        }
     44
     45        /**
     46         * SEO plugin fields that mark one page as "noindex".
     47         *
     48         * @return array<string, string> Meta key => plugin.
     49         */
     50        private static function noindex_meta_keys() {
     51                return array(
     52                        '_yoast_wpseo_meta-robots-noindex' => 'yoast',
     53                        'rank_math_robots'                 => 'rank-math',
     54                        '_seopress_robots_index'           => 'seopress',
     55                );
     56        }
     57
     58        /**
     59         * Rebuilds the file when an SEO plugin changes the "noindex" setting of a page.
     60         *
     61         * @param int|array $meta_id  Meta ID(s).
     62         * @param int       $post_id  Post ID.
     63         * @param string    $meta_key Meta key.
     64         */
     65        public static function flush_on_robots_meta( $meta_id, $post_id, $meta_key ) {
     66                if ( isset( self::noindex_meta_keys()[ $meta_key ] ) ) {
     67                        self::flush();
     68                }
     69        }
     70
     71        /**
     72         * Public content types an administrator can list in llms.txt (media excluded).
     73         *
     74         * @return array<string, WP_Post_Type>
     75         */
     76        public static function available_types() {
     77                $types = get_post_types( array( 'public' => true ), 'objects' );
     78                unset( $types['attachment'] );
     79
     80                return $types;
     81        }
     82
     83        /**
     84         * Content types listed in llms.txt.
     85         *
     86         * @return string[]
     87         */
     88        public static function selected_types() {
     89                $saved = get_option( self::OPTION_TYPES, null );
     90                $types = is_array( $saved ) ? $saved : self::DEFAULT_TYPES;
     91                $types = array_values( array_intersect( $types, array_keys( self::available_types() ) ) );
     92
     93                /**
     94                 * Filters the content types listed in llms.txt.
     95                 *
     96                 * @param string[] $types Post type names.
     97                 */
     98                return (array) apply_filters( 'dauphinia_llms_post_types', $types );
     99        }
     100
     101        /**
     102         * Keeps only public content types from the settings form.
     103         *
     104         * @param mixed $value Submitted value.
     105         * @return string[]
     106         */
     107        public static function sanitize_types( $value ) {
     108                $value = is_array( $value ) ? array_map( 'sanitize_key', $value ) : array();
     109
     110                return array_values( array_intersect( $value, array_keys( self::available_types() ) ) );
     111        }
     112
     113        /**
     114         * SEO plugin that marks a whole content type as "noindex", if any.
     115         *
     116         * @param string $type Post type name.
     117         * @return string Plugin name, or '' when the type may be indexed.
     118         */
     119        public static function type_noindex_by( $type ) {
     120                $yoast = get_option( 'wpseo_titles' );
     121                if ( defined( 'WPSEO_VERSION' ) && is_array( $yoast ) && ! empty( $yoast[ 'noindex-' . $type ] ) ) {
     122                        return 'Yoast SEO';
     123                }
     124
     125                $rank_math = get_option( 'rank-math-options-titles' );
     126                if ( class_exists( 'RankMath' ) && is_array( $rank_math ) && ! empty( $rank_math[ 'pt_' . $type . '_custom_robots' ] )
     127                        && isset( $rank_math[ 'pt_' . $type . '_robots' ] ) && in_array( 'noindex', (array) $rank_math[ 'pt_' . $type . '_robots' ], true ) ) {
     128                        return 'Rank Math';
     129                }
     130
     131                $seopress = get_option( 'seopress_titles_option_name' );
     132                if ( defined( 'SEOPRESS_VERSION' ) && is_array( $seopress ) && ! empty( $seopress['seopress_titles_single_titles'][ $type ]['noindex'] ) ) {
     133                        return 'SEOPress';
     134                }
     135
     136                return '';
     137        }
     138
     139        /**
     140         * Whether a page is marked "noindex" by Yoast SEO, Rank Math or SEOPress.
     141         *
     142         * @param WP_Post $post Post.
     143         * @return bool
     144         */
     145        private static function post_noindex( $post ) {
     146                foreach ( self::noindex_meta_keys() as $key => $plugin ) {
     147                        $value = get_post_meta( $post->ID, $key, true );
     148                        if ( 'yoast' === $plugin && '1' === (string) $value ) {
     149                                return true;
     150                        }
     151                        if ( 'rank-math' === $plugin && is_array( $value ) && in_array( 'noindex', $value, true ) ) {
     152                                return true;
     153                        }
     154                        if ( 'seopress' === $plugin && 'yes' === $value ) {
     155                                return true;
     156                        }
     157                }
     158
     159                return false;
    32160        }
    33161
    … …  
    156284                }
    157285
    158                 $sections = array(
     286                $known = array(
    159287                        'page'    => array( __( 'Pages', 'dauphinia' ), 100 ),
    160288                        'product' => array( __( 'Products', 'dauphinia' ), 100 ),
    161289                        'post'    => array( __( 'Latest articles', 'dauphinia' ), 30 ),
    162290                );
    163 
    164                 foreach ( $sections as $type => $section ) {
    165                         if ( ! post_type_exists( $type ) ) {
     291                $types = self::available_types();
     292
     293                foreach ( self::selected_types() as $type ) {
     294                        if ( ! isset( $types[ $type ] ) || '' !== self::type_noindex_by( $type ) ) {
    166295                                continue;
    167296                        }
     297                        $section = isset( $known[ $type ] ) ? $known[ $type ] : array( $types[ $type ]->labels->name, 50 );
    168298
    169299                        $posts = get_posts(
    … …  
    186316                        foreach ( $posts as $post ) {
    187317                                $title = self::clean( get_the_title( $post ) );
    188                                 if ( '' === $title ) {
     318
     319                                /**
     320                                 * Filters whether a published page is listed in llms.txt. Pages marked "noindex" in Yoast SEO,
     321                                 * Rank Math or SEOPress are left out by default.
     322                                 *
     323                                 * @param bool    $include Whether to list it.
     324                                 * @param WP_Post $post    The page, article, product…
     325                                 */
     326                                if ( '' === $title || ! apply_filters( 'dauphinia_llms_include_post', ! self::post_noindex( $post ), $post ) ) {
    189327                                        continue;
    190328                                }
  • dauphinia/trunk/readme.txt

    r3846414 r3846863  
    55Tested up to: 7.1
    66Requires PHP: 7.4
    7 Stable tag: 1.0.1
     7Stable tag: 1.0.2
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    6666* your site name and tagline,
    6767* an introduction you write yourself (two or three sentences: what you do, where, for whom),
    68 * your pages, your WooCommerce products and your latest articles, each with a link and a one-line summary.
     68* your pages, your WooCommerce products and your latest articles, each with a link and a one-line summary,
     69* any other public content type you choose (portfolio, events, courses…), one checkbox each.
     70
     71Content marked "noindex" in Yoast SEO, Rank Math or SEOPress is left out automatically, page by page or for a whole content type, so llms.txt never lists what you keep out of search engines.
    6972
    7073The file is cached for 12 hours, rebuilt as soon as you publish or edit content, and written in your site's language. An llms.txt file already on your server is never replaced. Developers can change its content with the `dauphinia_llms_txt` filter.
    … …  
    99102= Privacy =
    100103
    101 The plugin does not track you, sets no cookie on your visitors, contacts no external service, and stores only two settings (llms.txt on/off and its introduction) plus three temporary caches. Uninstalling removes them.
     104The plugin does not track you, sets no cookie on your visitors, contacts no external service, and stores only three settings (llms.txt on/off, its introduction and the content types it lists) plus three temporary caches. Uninstalling removes them.
    102105
    103106== External services ==
    … …  
    179182= Does llms.txt include private or draft content? =
    180183
    181 No. Only published pages, products and articles without a password are listed.
     184No. Only published content without a password is listed.
     185
     186= Can I choose which content types appear in llms.txt, or exclude some? =
     187
     188Yes. Under "llms.txt", tick the content types to list: pages, products and articles by default, plus any public custom post type. Content marked "noindex" in Yoast SEO, Rank Math or SEOPress is always left out, and a content type set to "noindex" as a whole cannot be ticked. Developers can also use the `dauphinia_llms_post_types` and `dauphinia_llms_include_post` filters.
    182189
    183190= I already have an llms.txt file. Will the plugin overwrite it? =
    … …  
    209216
    210217== Changelog ==
     218
     219= 1.0.2 =
     220* llms.txt: choose which content types are listed, including custom post types.
     221* llms.txt: content marked "noindex" in Yoast SEO, Rank Math or SEOPress is left out, page by page or for a whole content type.
     222* New filters for developers: `dauphinia_llms_post_types` and `dauphinia_llms_include_post`.
    211223
    212224= 1.0.1 =
    … …  
    224236== Upgrade Notice ==
    225237
     238= 1.0.2 =
     239Choose the content types listed in llms.txt; "noindex" content is now left out.
     240
    226241= 1.0.1 =
    227242Checks Amazon's crawlers (Amzn-SearchBot, Amazonbot) and ByteDance's Bytespider.
  • dauphinia/trunk/uninstall.php

    r3846062 r3846863  
    1212delete_option( 'dauphinia_llms_enabled' );
    1313delete_option( 'dauphinia_llms_intro' );
     14delete_option( 'dauphinia_llms_post_types' );
    1415delete_transient( 'dauphinia_llms_txt' );
    1516delete_transient( 'dauphinia_checks' );
Note: See TracChangeset for help on using the changeset viewer.