• HI i was just wondering certain things about developing a plugin for myself the right wordpress way. In terms of wordpress constants and renaming the wp-admin. how would be the best way to create a plugin that defines certain wordpress constants such as wp-debug, wp_cache, SITECOOKIEPATH, ADMIN_COOKIE_PATH. Ive seen plugins such as W# total cache that write onto the wp-config in order to define WP_CACHE constant. Ive also seen some security plugins that in turn change the template of the login page in order to change the wp-admin. Is it ok and secure for me to recreate the functionality of w3 total cache in order to add and change wp constants on the wp-config?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    It’s OK, and it can be secure to have a plugin activation script alter wp-config.php (IMHO at least), provided the code doing the alteration is robust enough to not cause any errors regardless of how the page is coded. It must account for any legal PHP syntax. In order to alter existing constants there really isn’t any alternative.

    Also consider that certain server configurations could prevent your script from altering the file. To be safe, your script should make the usual security checks, even though it was probably done prior to triggering the activation hook. You must be sure a bad actor cannot call your script directly and use it to arbitrarily alter code.

    It’d be a good idea to store the original values somewhere and restore them when your plugin is deactivated.

    I’ve no idea if altering wp-config.php would run afoul with the plugin review team, but if you’re not trying to place your plugin in the repository it’s less of an issue.

    Thread Starter Xavier Serrano

    (@xavierserranoa)

    yea thats what i was thinking about the server. I just wasn’t sure if handling and writing to the wp-config was good practice. it should essentially only be seen by wordpress and handle by wordpress.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Plugin wp-admin rename and constants’ is closed to new replies.