Plugin Directory

Changeset 3413565


Ignore:
Timestamp:
12/07/2025 03:45:30 PM (3 months ago)
Author:
jruns
Message:

WP 6.9 compat and settings config from wp-config

Location:
disable-ai/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • disable-ai/trunk/README.txt

    r3388453 r3413565  
    44Requires at least: 6.0
    55Tested up to: 6.8
    6 Stable tag: 0.4.0
     6Stable tag: 0.4.1
    77License: GPL-2.0+
    88License URI: http://www.gnu.org/licenses/gpl-2.0.txt
     
    4242Because AI can have negative impacts on people and the planet. And because AI should not be forced on anyone.
    4343
     44= How can I configure plugin settings from my wp-config.php file? =
     45
     46There is a Settings page for the plugin in your wp-admin. But you can also disable AI in specific plugins by setting their related constants to true in your wp-config.php file. Ex: DISAI_PLUGIN_AIOSEO, DISAI_PLUGIN_ELEMENTOR, DISAI_PLUGIN_RANKMATH
     47
     48If you also want to make a few less database queries and only configure plugin settings from wp-config.php, you can set the DISAI_ENABLE_WPCONFIG_MODE constant to true in your wp-config.php file.
     49
    4450== Changelog ==
    4551
     52= 0.4.1 =
     53* New: Support wp-config.php constant DISAI_ENABLE_WPCONFIG_MODE for enabling/disabling plugin settings from wp-config.php.
     54* Updated: Convert wp-config.php string constants to booleans so 'false' evaluates to false.
     55* Updated: Compatibility with WordPress 6.9.
     56
    4657= 0.4.0 =
    47 * Add support for Rank Math SEO - Disable Content AI module and features, and hide the module from the Rank Math admin Dashboard.
    48 * Change: Add AIOSEO editor styles to fewer admin pages, and disable the AI features on custom post type edit screens.
    49 * Change: Load utilities earlier in the WP sequence so Rank Math SEO's options can be overridden.
    50 * Fix: Correctly update Yoast SEO settings when disabling AI.
     58* New: Add support for Rank Math SEO - Disable Content AI module and features, and hide the module from the Rank Math admin Dashboard.
     59* Updated: Add AIOSEO editor styles to fewer admin pages, and disable the AI features on custom post type edit screens.
     60* Updated: Load utilities earlier in the WP sequence so Rank Math SEO's options can be overridden.
     61* Fixed: Correctly update Yoast SEO settings when disabling AI.
    5162
    5263= 0.3.0 =
    53 * Rename plugin option and add sanitization.
    54 * Update PHP file structure and comments.
    55 * Move css to enqueued files.
    56 * Hide AIOSEO AI tab in AIOSEO's General Settings, and load style in Elementor editor too.
     64* Updated: Rename plugin option and add sanitization.
     65* Updated: Update PHP file structure and comments.
     66* Updated: Move css to enqueued files.
     67* Updated: Hide AIOSEO AI tab in AIOSEO's General Settings, and load style in Elementor editor too.
    5768
    5869= 0.2.0 =
    59 * Add support for All in One SEO. Hide AI menu items and tabs, hide AI buttons, and remove the Writing Assistant metabox in the post editor.
    60 * Remove WP from more instances of the plugin's name to comply with WordPress plugin repository rules.
     70* New: Add support for All in One SEO. Hide AI menu items and tabs, hide AI buttons, and remove the Writing Assistant metabox in the post editor.
     71* Updated: Remove WP from more instances of the plugin's name to comply with WordPress plugin repository rules.
    6172
    6273= 0.1.0 =
  • disable-ai/trunk/admin/partials/admin-options-display.php

    r3385999 r3413565  
    1616if ( ! defined( 'ABSPATH' ) ) exit;
    1717
     18
     19$disai_wpconfig_mode = false;
     20if( defined( 'DISAI_ENABLE_WPCONFIG_MODE' ) ) {
     21    if ( rest_sanitize_boolean( constant( 'DISAI_ENABLE_WPCONFIG_MODE' ) ) ) {
     22        $disai_wpconfig_mode = true;
     23    }
     24}
    1825$disai_settings = (array) get_option( 'disai_settings', array() );
    1926?>
     
    3845    'description'       => 'Disable All in One SEO\'s AI features. Removes the Writing Assistant and AI-related buttons, menu items and tabs from the WordPress Editor.'
    3946);
    40 disai_output_admin_option( $args, $disai_settings );
     47disai_output_admin_option( $args, $disai_settings, $disai_wpconfig_mode );
    4148
    4249$args = array(
     
    4653    'description'       => 'Disable Elementor\'s AI features.'
    4754);
    48 disai_output_admin_option( $args, $disai_settings );
     55disai_output_admin_option( $args, $disai_settings, $disai_wpconfig_mode );
    4956
    5057$args = array(
     
    5461    'description'       => 'Disable Rank Math SEO\'s AI features.'
    5562);
    56 disai_output_admin_option( $args, $disai_settings );
     63disai_output_admin_option( $args, $disai_settings, $disai_wpconfig_mode );
    5764
    5865$args = array(
     
    6269    'description'       => 'Disable WPForms\' AI features.'
    6370);
    64 disai_output_admin_option( $args, $disai_settings );
     71disai_output_admin_option( $args, $disai_settings, $disai_wpconfig_mode );
    6572
    6673$args = array(
     
    7077    'description'       => 'Disable Yoast SEO\'s AI features.'
    7178);
    72 disai_output_admin_option( $args, $disai_settings );
     79disai_output_admin_option( $args, $disai_settings, $disai_wpconfig_mode );
    7380?>
    7481</table>
     
    8693<?php
    8794
    88 function disai_output_admin_option( $args , $settings ) {
     95function disai_output_admin_option( $args , $settings, $wpconfig_mode = false ) {
    8996    $type = $args['type'] ?? '';
    9097    $name = $args['name'] ?? '';
     
    96103    $placeholder = '';
    97104    $after_label_msg = '';
     105
    98106    if( defined( $utility_constant ) ) {
    99         $utility_value = constant( $utility_constant );
    100         $after_label_msg = "<span class='tooltip'><span class='dashicons dashicons-warning'></span><span class='tooltip-text'>This setting is currently configured in your wp-config.php file and can only be enabled or disabled there.<br/><br/>Remove $utility_constant from wp-config.php in order to configure this setting here.</span></span>";
    101     } else if ( array_key_exists( $type, $settings ) && array_key_exists( $name, $settings[$type] ) ) {
     107        $utility_value = rest_sanitize_boolean( constant( $utility_constant ) );
     108        $after_label_msg = "<span class='tooltip'><span class='dashicons dashicons-warning'></span><span class='tooltip-text'>This setting is currently configured in your wp-config.php file and can only be enabled or disabled there.<br/><br/>" . ( $wpconfig_mode ? "WP-Config Mode is enabled as well. Remove DISAI_ENABLE_WPCONFIG_MODE and $utility_constant from wp-config.php in order to enable/disable this setting here." : "Remove $utility_constant from wp-config.php in order to enable/disable this setting here." ) . "</span></span>";
     109    } else if ( ! $wpconfig_mode && array_key_exists( $type, $settings ) && array_key_exists( $name, $settings[$type] ) ) {
    102110        $utility_value = absint( $settings[$type][$name] );
    103111    }
    104112
    105     $input_output = "<input type='checkbox' name='disai_settings[$type][$name]' value='1' " . ( $utility_value ? "checked='checked'" : '' ) . ( defined( $utility_constant ) ? " disabled='' title='Remove $utility_constant from wp-config.php in order to configure this setting here.'" : "" ) . "/>" . $description . "$after_label_msg";
     113    $disabled_title = "Remove $utility_constant from wp-config.php in order to configure this setting here.";
     114    if ( $wpconfig_mode ) {
     115        $disabled_title = "This setting is managed by the $utility_constant constant in wp-config.php because WP-Config Mode is enabled. Remove DISAI_ENABLE_WPCONFIG_MODE " . ( defined( $utility_constant ) ? "and $utility_constant " : "" ) . "from wp-config.php in order to configure this setting here.";
     116    }
     117
     118    $input_output = "<input type='checkbox' name='disai_settings[$type][$name]' value='1' " . ( $utility_value ? "checked='checked'" : '' ) . ( $wpconfig_mode || defined( $utility_constant ) ? " disabled='' title='$disabled_title'" : "" ) . "/>" . $description . "$after_label_msg";
    106119
    107120    $allowed_html = array(
  • disable-ai/trunk/disable-ai.php

    r3385999 r3413565  
    22
    33/**
    4  *
    5  * @link              https://github.com/jruns
    6  * @since             0.1.0
    74 * @package           DisableAI
    85 *
     
    118 * Plugin URI:        https://github.com/jruns/wp-disable-ai
    129 * Description:       Turn off unwanted AI features and notifications in plugins, themes, and WordPress Core.
    13  * Version:           0.4.0
     10 * Version:           0.4.1
    1411 * Author:            jruns
    1512 * Author URI:        https://github.com/jruns
     
    2421if ( ! defined( 'ABSPATH' ) ) exit;
    2522
    26 define( 'DISAI_VERSION', '0.4.0' );
     23define( 'DISAI_VERSION', '0.4.1' );
    2724define( 'DISAI_BASE_NAME', plugin_basename( __FILE__ ) );
    2825
  • disable-ai/trunk/includes/class-disableai.php

    r3385999 r3413565  
    5858     */
    5959    protected $settings;
     60
     61    /**
     62     * If we should only check wp-config.php constants for active plugins.
     63     *
     64     * @since    0.4.1
     65     * @access   protected
     66     * @var      array    $wpconfig_mode    The wp-config mode setting.
     67     */
     68    protected $wpconfig_mode;
    6069
    6170    /**
     
    7281            $this->version = DISAI_VERSION;
    7382        } else {
    74             $this->version = '0.4.0';
     83            $this->version = '0.4.1';
    7584        }
    7685        $this->plugin_name = 'disable-ai';
     
    135144        );
    136145        $this->settings = wp_parse_args( get_option( 'disai_settings' ), $defaults );
     146
     147        $this->wpconfig_mode = false;
     148        if( defined( 'DISAI_ENABLE_WPCONFIG_MODE' ) && rest_sanitize_boolean( constant( 'DISAI_ENABLE_WPCONFIG_MODE' ) ) ) {
     149            $this->wpconfig_mode = true;
     150        }
    137151    }
    138152
     
    147161
    148162        if( defined( $constant_name ) ) {
    149             if ( constant( $constant_name ) ) {
     163            if ( rest_sanitize_boolean( constant( $constant_name ) ) ) {
    150164                return true;
    151165            }
    152         } else if ( array_key_exists( $utility_name, $this->settings[$utility_type] ) && $this->settings[$utility_type][$utility_name] ) {
    153             return true;
     166        } else if ( ! $this->wpconfig_mode ) {
     167            if ( array_key_exists( $utility_name, $this->settings[$utility_type] ) && $this->settings[$utility_type][$utility_name] ) {
     168                return true;
     169            }
    154170        }
    155171
Note: See TracChangeset for help on using the changeset viewer.