In my wp-config.php file, I have the line: define('DISALLOW_FILE_EDIT', true); I always include this on all sites as standard, and it's always worked exactly as expected. However, I've only just noticed that on one client's site, it has stopped working. They have the User Role Editor plugin that was set up to define a handful of custom roles. Once the roles were set up, the plugin was deactivated (it doesn't need to be active for the roles to exist) and …
I'm using WPML, which has several ways to access the current language. ICL_LANGUAGE_CODE if( ICL_LANGUAGE_CODE === 'en' ){ // Do stuff } apply_filter( 'wpml_current_language', null )' docs $lang = apply_filter( 'wpml_current_language', null ); if( $lang === 'en' ){ // Do stuff } I can't find any documentation on the ICL_LANGUAGE_CODE. The apply_filter has a documentation page, but in my opinion, the readability drops with this. Are there any obvious drawbacks using one or the other? Update I know that I …
I have a program that can run standalone (outside WP) or inside WP. If the program is running 'inside' WP (via a custom template using appropriate enqueue scripts and add_actions), then there is a constant that the program needs to be defined - an email address that the standalone program will use. If the program is running on a WP site (inside WP), then the program needs to use the WP admin email address (via the get_option( 'admin_email' ) function. …
What I am trying to achieve I am looking at using Wordpress decoupled, and most tutorials and guides go into detail on using the Rest API. Recently, I discovered the SHORTINIT option to load a very minimal Wordpress instance. There is next to no documentation, and very few questions about its use, however I am interested in making use of it. What have I tried So far, I have setup a simple test php file in the root directory: define('WP_DEBUG', …
Last week I got an error in my logs on a standard WP install - Use of undefined constant ABSPATH - assumed 'ABSPATH' (this will throw an Error in a future version of PHP) in /wp-settings.php on line 33 I have ABSPATH defined in wp-config as standard: /** Absolute path to the WordPress directory. */ if ( ! defined( 'ABSPATH' ) ) { define( 'ABSPATH', __DIR__ . '/' ); And it seems the site only accessed wp-settings because of the …
My site's working, but there's a "cannot complete a loopback request" error in the (dashboard) Tools/Site_Health window I'm tracking down. My installation is in a subdirectory on my server: /home/public_html/my-site/wordpress I have, in my (dashboard) Settings/General window: WordPress Address (URL) https://my-site/wordpress and Site Address (URL) https://my-site BUT: this doesn't agree with the WordPress Constants listed in the (dashboard) Tools/Site_Health (info) window: ABSPATH /home/public_html/my-site/wordpress/ and WP_HOME Undefined and WP_SITEURL Undefined Any clues as to how to make WordPress "globally aware" of …
I recently posted a comment on a general tech group about this line of code: define('WP_POST_REVISIONS', true); Someone replied, "If the original coders don't know that you can't redefine a constant than why would you even trust any of their other code?" That made me wonder, what mechanism in WordPress keeps themes/plugins/etc from redefining constants? I'm guessing that it has to do with the order in which code loads.
In wp-config.php I have this code: var_dump(defined('WP_ALLOW_MULTISITE')); // false var_dump(defined('MULTISITE')); // true var_dump(defined('SUBDOMAIN_INSTALL')); // false define('WP_ALLOW_MULTISITE', true ); var_dump(WP_ALLOW_MULTISITE); // true define('MULTISITE', true); var_dump(MULTISITE); // false define('SUBDOMAIN_INSTALL', true); var_dump(SUBDOMAIN_INSTALL); // true MULTISITE constant is already defined with false before wp-confing.php. I searched with grep and it's defined only in ./wp-admin/includes/network.php as define('MULTISITE', true);. How to make it true? I tried on local Laradock instance and shared hosting. In both cases result is the same. EDIT (new info) Results of running …
I ran into an issue today with files uploaded through the Wordpress Backend not getting the correct permissions. The permission on the new 2018 folder in the uploads directory as well as the files within it were too tight, the webserver user couldn't even access them. I found the constants FS_CHMOD_DIR and FS_CHMOD_FILE that can be used to overwrite the default permissions for uploaded files. The Wordpress Codex suggests using the the following settings in the wp-config.php: define( 'FS_CHMOD_DIR', ( …
I use 'constants' a lot. I set them in functions.php like define('mytheme_town', 'Orlando'); and then call them into the theme <?php echo mytheme_town ; ?>. It's simple and easy. But I need them to be site-specific (for multisite) so I thought it might be possible to append the current blog_id to the theme call and declare constants for each MultiSite in functions.php? I don't know how to code that, but what I'm trying to achieve in the theme file this …
Running Wordpress 4.1 on a CentOS 6.5 instance through VirtualBox as a dev server. When logged in as admin on both ssl and non-ssl sites Wordpress curl requests are taking a long time to run (45+ seconds overall before page loads). This renders my dev site unusable, as you can imagine. While browsing around I found many people complaining of this extremely slow curl issue and I've discovered that setting the WP_INSTALLING constant to true speeds the site up 100%. …
I'm working on a plugin and trying to build in an option to disable post revisions. I have the setting registered, and confirmed that the checkbox is linking to the database. The option value is either null or 1. What I want to do is define this constant: define('WP_POST_REVISIONS', false); in the plugin file only if the option is set to 1. If I put the constant directly into the plugin functions file it works, but if I try and …
I'm studying wordpress development and i was bumped to this codes. i'm trying my best to look from google but i can't seem to find it. Just wondering if what these codes means. what does the /admin stands for in the theme_css_uri? define( 'name_THEME_URI', get_stylesheet_directory_uri()); define( 'name_THEME_TEMPLATE_URI', name_THEME_URI . '/templates' ); define( 'name_THEME_LANGUAGES_URI', name_THEME_URI . '/languages' ); define( 'name_THEME_ASSETS_URI', name_THEME_URI . '/assets' ); define( 'name_THEME_JS_URI', name_THEME_ASSETS_URI . '/js' ); define( 'name_THEME_CSS_URI', name_THEME_ASSETS_URI . '/css' ); define( 'name_THEME_IMAGES_URI', name_THEME_ASSETS_URI . '/images' …
I have a client who wants to use the trash feature, but keep items in there indefinitely (I have no idea why, but they insist on it). From reading this codex article on the trash status, I see that you can set the EMPTY_TRASH_DAYS constant to zero. But it says that this will disable trash functionality altogether. I don't want to do this. I just want to disable the auto-trash emptying. Is there any way to do this? Or am …
I am trying to use SMOF Options Framework in a plugin and i have this problem. SMOOF use this constants to get theme directory url: if( !defined('ADMIN_PATH') ) define( 'ADMIN_PATH', get_template_directory() . '/admin/' ); if( !defined('ADMIN_DIR') ) define( 'ADMIN_DIR', get_template_directory_uri() . '/admin/' ); But i want to use SMOF in a plugin, not in theme, how can i get the plugin directory url? What to put in order to get_template_directory() and get_template_directory_uri() to use it in a plugin?
I have the plugin which have constant defined, i will call this plugin PLUGIN A: if ( ! defined('BLA')){ define('BLA', 'http://google.com); } I want to make another plugin PLUGIN B which will define constant BLA before PLUGIN A. Is that possible? I guess Wordpress needs to read PLUGIN B before PLUGIN A, but in which order Wordpress is reading plugins?
I want to translate constant strings in my plugin defined as: define( 'CONSTANT', __( 'string-A', 'textdomain' ) ); And later using it somewhere like: $x= '<h4>'.CONSTANT_NAME.'<h4>'; echo $x; But I am still getting English text even after adding that locale's .mo file & the text-domain. This is happening only for strings defined by PHP constants, rest all strings are working fine. So, does strings defined using PHP constants not work for translation as even in popular translated plugins I can't …
Here is my code. defined( 'ABSPATH' ) || exit; namespace JSR; class myClass{ ... } This is giving below error Global code should be enclosed in global namespace declaration Any idea how to fix it?
I've got a problem with translations, that sounds pretty simple, but I can't find a way around this. The Situation I got a software running on WordPress, and I need to send Emails to my users after certain actions. The contents of these Mails has been localized using __() and all the other built in translation functions, as well as translated in the corresponging .mo/.po files. My users can choose the language for the frontend of the software, and this …