Plugin Directory

Changeset 3801921


Ignore:
Timestamp:
11/14/2026 12:56:58 PM (4 days ago)
Author:
mnprweb
Message:

Release 1.2.0 with AI Abilities.

Location:
mnpr-client-portal
Files:
100 added
8 edited

Legend:

Unmodified
Added
Removed
  • mnpr-client-portal/trunk/includes/admin/class-mnprcp-admin-settings.php

    r3801836 r3801921  
    9797                check_admin_referer( 'mnprcp_save_appearance' );
    9898
    99                 $current = MNPRCP_Settings::all();
    10099                // phpcs:disable WordPress.Security.ValidatedSanitizedInput.MissingUnslash -- each value is unslashed and sanitised.
    101                 $new = array(
    102                         'portal_name' => isset( $_POST['portal_name'] ) ? sanitize_text_field( wp_unslash( $_POST['portal_name'] ) ) : '',
    103                         'login_text'  => isset( $_POST['login_text'] ) ? sanitize_text_field( wp_unslash( $_POST['login_text'] ) ) : '',
    104                         'accent'      => isset( $_POST['accent'] ) ? sanitize_hex_color( wp_unslash( $_POST['accent'] ) ) : '',
    105                         'logo'        => isset( $_POST['logo'] ) ? absint( $_POST['logo'] ) : 0,
    106                         'slug'        => isset( $_POST['slug'] ) ? sanitize_title( wp_unslash( $_POST['slug'] ) ) : '',
     100                $result = MNPRCP_Settings::update(
     101                        array(
     102                                'portal_name' => isset( $_POST['portal_name'] ) ? sanitize_text_field( wp_unslash( $_POST['portal_name'] ) ) : '',
     103                                'login_text'  => isset( $_POST['login_text'] ) ? sanitize_text_field( wp_unslash( $_POST['login_text'] ) ) : '',
     104                                'accent'      => isset( $_POST['accent'] ) ? sanitize_hex_color( wp_unslash( $_POST['accent'] ) ) : '',
     105                                'logo'        => isset( $_POST['logo'] ) ? absint( $_POST['logo'] ) : 0,
     106                                'slug'        => isset( $_POST['slug'] ) ? sanitize_title( wp_unslash( $_POST['slug'] ) ) : '',
     107                        )
    107108                );
    108109                // phpcs:enable
    109 
    110                 $errors = array();
    111                 if ( ! $new['accent'] ) {
    112                         $new['accent'] = $current['accent'];
    113                         $errors[]      = __( 'The accent colour wasn\'t a valid colour, so it wasn\'t changed.', 'mnpr-client-portal' );
    114                 }
    115                 if ( $new['logo'] && ! wp_attachment_is_image( $new['logo'] ) ) {
    116                         $new['logo'] = 0;
    117                         $errors[]    = __( 'The logo must be an image.', 'mnpr-client-portal' );
    118                 }
    119                 if ( '' === $new['slug'] ) {
    120                         $new['slug'] = 'portal';
    121                 }
    122                 $taken = get_page_by_path( $new['slug'] ) || post_type_exists( $new['slug'] ) || in_array( $new['slug'], array( 'wp-admin', 'wp-content', 'wp-includes', 'wp-json', 'feed' ), true );
    123                 if ( $new['slug'] !== $current['slug'] && $taken ) {
    124                         /* translators: %s: address slug. */
    125                         $errors[]    = sprintf( __( '"%s" is already used on this site, so the portal address wasn\'t changed.', 'mnpr-client-portal' ), $new['slug'] );
    126                         $new['slug'] = $current['slug'];
    127                 }
    128 
    129                 update_option( MNPRCP_Settings::OPTION, array_merge( $current, $new ) );
    130                 if ( $new['slug'] !== $current['slug'] ) {
    131                         update_option( 'mnprcp_flush_rewrites', 1, false );
    132                 }
     110                $errors = $result['errors'];
    133111
    134112                if ( $errors ) {
  • mnpr-client-portal/trunk/includes/class-mnprcp-config.php

    r3801836 r3801921  
    6363                }
    6464                return self::$cache;
     65        }
     66
     67        /**
     68         * The saved setup, validated but without add-ons' changes from the
     69         * mnprcp_config filter. Used when editing the setup, so sections an add-on
     70         * adds on the fly are never saved into it.
     71         *
     72         * @since 1.2.0
     73         *
     74         * @return array
     75         */
     76        public static function stored() {
     77                $stored = get_option( self::OPTION, array() );
     78                $result = MNPRCP_Validator::validate( is_array( $stored ) ? $stored : array() );
     79                return $result['config'];
     80        }
     81
     82        /**
     83         * Find a section by its key in a given setup.
     84         *
     85         * @since 1.2.0
     86         *
     87         * @param array  $config Setup.
     88         * @param string $key    Section key.
     89         * @return array|null
     90         */
     91        public static function section_from( array $config, $key ) {
     92                foreach ( $config['sections'] as $section ) {
     93                        if ( $section['key'] === $key ) {
     94                                return $section;
     95                        }
     96                }
     97                return null;
     98        }
     99
     100        /**
     101         * Find the section that manages a post type in a given setup.
     102         *
     103         * @since 1.2.0
     104         *
     105         * @param array  $config    Setup.
     106         * @param string $post_type Post type name.
     107         * @return array|null
     108         */
     109        public static function section_for_post_type_from( array $config, $post_type ) {
     110                foreach ( $config['sections'] as $section ) {
     111                        if ( $section['post_type'] === $post_type ) {
     112                                return $section;
     113                        }
     114                }
     115                return null;
    65116        }
    66117
  • mnpr-client-portal/trunk/includes/class-mnprcp-plugin.php

    r3801836 r3801921  
    4545                MNPRCP_Site_Tools::init();
    4646                MNPRCP_Coming_Soon::init();
     47                MNPRCP_Abilities::init();
    4748                add_action( 'init', array( __CLASS__, 'maybe_upgrade' ), 1 );
    4849
  • mnpr-client-portal/trunk/includes/class-mnprcp-settings.php

    r3801836 r3801921  
    7070
    7171        /**
     72         * Change some settings, checking each one. Settings that fail a check keep
     73         * their current value and are described in the errors.
     74         *
     75         * @since 1.2.0
     76         *
     77         * @param array $changes Any of portal_name, login_text, accent, logo, slug (unslashed).
     78         * @return array{settings:array,errors:string[]}
     79         */
     80        public static function update( array $changes ) {
     81                $current = self::all();
     82                $new     = array();
     83                $errors  = array();
     84
     85                if ( array_key_exists( 'portal_name', $changes ) ) {
     86                        $new['portal_name'] = sanitize_text_field( (string) $changes['portal_name'] );
     87                }
     88                if ( array_key_exists( 'login_text', $changes ) ) {
     89                        $new['login_text'] = sanitize_text_field( (string) $changes['login_text'] );
     90                }
     91                if ( array_key_exists( 'accent', $changes ) ) {
     92                        $accent = sanitize_hex_color( (string) $changes['accent'] );
     93                        if ( $accent ) {
     94                                $new['accent'] = $accent;
     95                        } else {
     96                                $errors[] = __( 'The accent colour wasn\'t a valid colour, so it wasn\'t changed.', 'mnpr-client-portal' );
     97                        }
     98                }
     99                if ( array_key_exists( 'logo', $changes ) ) {
     100                        $logo = absint( $changes['logo'] );
     101                        if ( $logo && ! wp_attachment_is_image( $logo ) ) {
     102                                $logo     = 0;
     103                                $errors[] = __( 'The logo must be an image.', 'mnpr-client-portal' );
     104                        }
     105                        $new['logo'] = $logo;
     106                }
     107                if ( array_key_exists( 'slug', $changes ) ) {
     108                        $slug = sanitize_title( (string) $changes['slug'] );
     109                        if ( '' === $slug ) {
     110                                $slug = 'portal';
     111                        }
     112                        $taken = get_page_by_path( $slug ) || post_type_exists( $slug ) || in_array( $slug, array( 'wp-admin', 'wp-content', 'wp-includes', 'wp-json', 'feed' ), true );
     113                        if ( $slug !== $current['slug'] && $taken ) {
     114                                /* translators: %s: address slug. */
     115                                $errors[] = sprintf( __( '"%s" is already used on this site, so the portal address wasn\'t changed.', 'mnpr-client-portal' ), $slug );
     116                                $slug     = $current['slug'];
     117                        }
     118                        $new['slug'] = $slug;
     119                }
     120
     121                $stored = get_option( self::OPTION, array() );
     122                update_option( self::OPTION, array_merge( is_array( $stored ) ? $stored : array(), $current, $new ) );
     123                if ( isset( $new['slug'] ) && $new['slug'] !== $current['slug'] ) {
     124                        update_option( 'mnprcp_flush_rewrites', 1, false );
     125                }
     126
     127                return array(
     128                        'settings' => array_intersect_key( self::all(), self::defaults() ),
     129                        'errors'   => $errors,
     130                );
     131        }
     132
     133        /**
    72134         * The name shown at the top of the portal.
    73135         *
  • mnpr-client-portal/trunk/includes/portal/class-mnprcp-portal-content.php

    r3801836 r3801921  
    386386         * Make a title for sections without a title field, e.g. "The Fleece – 5 Dec 2026".
    387387         *
     388         * Public since 1.2.0 (used by the abilities).
     389         *
    388390         * @param array $section Section definition.
    389391         * @param array $values  Clean values.
    390392         * @return string
    391393         */
    392         private static function auto_title( array $section, array $values ) {
     394        public static function auto_title( array $section, array $values ) {
    393395                $parts = array();
    394396                foreach ( $section['fields'] as $field ) {
  • mnpr-client-portal/trunk/languages/mnpr-client-portal.pot

    r3801836 r3801921  
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: MNPR Client Portal 1.1.1\n"
     5"Project-Id-Version: MNPR Client Portal 1.2.0\n"
    66"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/mnpr-client-portal\n"
    77"MIME-Version: 1.0\n"
    88"Content-Type: text/plain; charset=UTF-8\n"
    99"Content-Transfer-Encoding: 8bit\n"
    10 "POT-Creation-Date: 2026-11-13T11:52:16+00:00\n"
     10"POT-Creation-Date: 2026-11-14T12:22:48+00:00\n"
    1111"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
    1212"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
    … …  
    24192419msgid "Choose a field in the block settings."
    24202420msgstr ""
     2421
     2422#: includes/class-mnprcp-abilities.php:49
     2423msgid "Set up MNPR Client Portal and manage the content clients edit in the portal."
     2424msgstr ""
     2425
     2426#: includes/class-mnprcp-abilities.php:137
     2427msgid "Get the portal setup"
     2428msgstr ""
     2429
     2430#: includes/class-mnprcp-abilities.php:143
     2431msgid "List field types"
     2432msgstr ""
     2433
     2434#: includes/class-mnprcp-abilities.php:149
     2435msgid "List presets"
     2436msgstr ""
     2437
     2438#: includes/class-mnprcp-abilities.php:155
     2439msgid "Apply a preset"
     2440msgstr ""
     2441
     2442#: includes/class-mnprcp-abilities.php:173
     2443msgid "Export the setup"
     2444msgstr ""
     2445
     2446#: includes/class-mnprcp-abilities.php:179
     2447msgid "Import a setup"
     2448msgstr ""
     2449
     2450#: includes/class-mnprcp-abilities.php:202
     2451msgid "Add or change a section"
     2452msgstr ""
     2453
     2454#: includes/class-mnprcp-abilities.php:224
     2455msgid "Remove a section"
     2456msgstr ""
     2457
     2458#: includes/class-mnprcp-abilities.php:240
     2459msgid "Add or change a field"
     2460msgstr ""
     2461
     2462#: includes/class-mnprcp-abilities.php:269
     2463msgid "Remove a field"
     2464msgstr ""
     2465
     2466#: includes/class-mnprcp-abilities.php:292
     2467msgid "Get Site details"
     2468msgstr ""
     2469
     2470#: includes/class-mnprcp-abilities.php:298
     2471msgid "Update Site details"
     2472msgstr ""
     2473
     2474#: includes/class-mnprcp-abilities.php:315
     2475msgid "List entries in a section"
     2476msgstr ""
     2477
     2478#: includes/class-mnprcp-abilities.php:343
     2479msgid "Get an entry"
     2480msgstr ""
     2481
     2482#: includes/class-mnprcp-abilities.php:360
     2483msgid "Add or change an entry"
     2484msgstr ""
     2485
     2486#: includes/class-mnprcp-abilities.php:393
     2487msgid "Move an entry to the bin"
     2488msgstr ""
     2489
     2490#: includes/class-mnprcp-abilities.php:412
     2491msgid "Add media from a web address"
     2492msgstr ""
     2493
     2494#: includes/class-mnprcp-abilities.php:433
     2495msgid "Update the portal appearance"
     2496msgstr ""
     2497
     2498#: includes/class-mnprcp-abilities.php:453
     2499msgid "Get Coming soon mode"
     2500msgstr ""
     2501
     2502#: includes/class-mnprcp-abilities.php:459
     2503msgid "Update Coming soon mode"
     2504msgstr ""
     2505
  • mnpr-client-portal/trunk/mnpr-client-portal.php

    r3801836 r3801921  
    33 * Plugin Name:       MNPR Client Portal
    44 * Description:       Give clients a branded portal to manage their own site content, without wp-admin.
    5  * Version:           1.1.1
     5 * Version:           1.2.0
    66 * Requires at least: 6.5
    77 * Requires PHP:      7.4
    … …  
    2020}
    2121
    22 define( 'MNPRCP_VERSION', '1.1.1' );
     22define( 'MNPRCP_VERSION', '1.2.0' );
    2323define( 'MNPRCP_FILE', __FILE__ );
    2424define( 'MNPRCP_DIR', plugin_dir_path( __FILE__ ) );
    … …  
    4747require_once MNPRCP_DIR . 'includes/frontend/class-mnprcp-site-tools.php';
    4848require_once MNPRCP_DIR . 'includes/frontend/class-mnprcp-coming-soon.php';
     49require_once MNPRCP_DIR . 'includes/class-mnprcp-abilities.php';
    4950require_once MNPRCP_DIR . 'includes/functions.php';
    5051require_once MNPRCP_DIR . 'includes/class-mnprcp-plugin.php';
  • mnpr-client-portal/trunk/readme.txt

    r3801836 r3801921  
    55Tested up to: 7.1
    66Requires PHP: 7.4
    7 Stable tag: 1.1.1
     7Stable tag: 1.2.0
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    5050* **Cache clearing.** Common caching plugins are cleared when clients save, so changes show straight away.
    5151* **Contact email routing.** Send form plugin emails to an address your client manages in Site details.
     52* **AI agent ready.** Set up in minutes, or ask your AI agent to do it for you. On WordPress 6.9 and later, agents connected through the MCP Adapter can set up sections and fields, fill in Site details and add content. Only administrators can use this, and every change gets the same checks as the admin screens.
    5253* **Export and import** setups between sites, plus WP-CLI commands.
    5354* **Translation-ready** and accessible, with suggested privacy policy text.
    … …  
    9192
    9293* `[mnprcp_list section="events" show="upcoming"]` lists a section's items. Options: show (all, upcoming, past), layout (list, cards), limit, fields, image, link, empty.
    93 * `[mnprcp_field name="venue"]` shows one field of the current item. Add post_id="123" to show it from another item.
     94* `[mnprcp_field name="venue"]` shows one field of the current item. Add `post_id="123"` to show it from another item.
    9495* `[mnprcp_site name="phone"]` shows a Site detail anywhere.
    9596
    … …  
    110111Your posts and their values are always kept. The plugin's settings are only removed if you first tick "Also delete the portal setup, appearance settings and Site details" under Client Portal → Tools.
    111112
     113= Can an AI agent set it up for me? =
     114
     115Yes, on WordPress 6.9 and later. The plugin registers its own abilities with the WordPress Abilities API, so an AI agent connected to your site through the MCP Adapter plugin can see the setup, apply a starter, add, change and remove sections and fields, fill in Site details, add and edit entries, change the portal's appearance and switch Coming soon mode. Only administrators can use them. Every change goes through the same checks as the admin screens, anything that removes something needs a confirmation, and content is never deleted: removed sections and fields keep their stored values, and entries go to the bin.
     116
    112117= Is it translation-ready? =
    113118
    … …  
    125130
    126131== Changelog ==
     132
     133= 1.2.0 =
     134* New: AI agent support. On WordPress 6.9 and later, AI agents (for example through the MCP Adapter) can set up the portal and add content using the plugin's abilities. Administrators only; every change is checked like the admin screens, and removals need a confirmation.
     135* New: developer methods `MNPRCP_Config::stored()` and `MNPRCP_Settings::update()`, and the `mnprcp_abilities` filter for add-ons.
     136* Fixed: the `post_id` shortcode example in the readme showed curly quotes on WordPress.org.
    127137
    128138= 1.1.1 =
    … …  
    142152== Upgrade Notice ==
    143153
     154= 1.2.0 =
     155Adds AI agent support: on WordPress 6.9 and later, agents can set up the portal and add content.
     156
    144157= 1.0.0 =
    145158First public release.
Note: See TracChangeset for help on using the changeset viewer.