I’d guess the problem is the end(), which accepts an array reference. Try saving the explode() result in a variable and passing that to end():
$path_components = @explode( get_template(), str_replace( '\\', "https://wordpress.stackexchange.com/", dirname( __FILE__ ) ) );
$path = ltrim( end( $path_components ), "https://wordpress.stackexchange.com/" );
define( 'OT_LANG_DIR', trailingslashit( trailingslashit( get_template_directory() ) . $path ) .
trailingslashit( 'languages' ) . 'theme-mode' );
Or there are plenty of other ways to get the last element of an array you could use instead of end().
Related Posts:
- Error Warning: Declaration of description_walker::start_el after PHP upgrade [duplicate]
- How to use nonce with front end submission form?
- WordPress Warning: preg_replace(): JIT compilation failed: no more memory
- Autoloading in Child Theme
- WSOD but WP_DEBUG not giving any errors
- How to loop through JSON data in wordpress WP REST API
- Rename image uploads replacing “width” and “height” in filename with “medium”, “large”, “small”
- Append code into wp-config.php
- How to remove “out of stock” variation options from size dropdown in woocommerce?
- WordPress Customizer: How can you have multiple active callbacks on one control?
- Looking for a better way to handle an ajax script that pulls in post data on click
- add_rewrite_rule with bottom priority doesn’t handle the WordPress pages
- Adding featured image via PHP
- wordpress custom endpoint multiple params
- Enable errors PHP WordPress 5.2
- wp_enqueue_style with style.php and WordPress functions
- How to set status codes such as 401 and 403?
- Minify HTML, CSS, JS with PHPWee?
- Show Custom Taxonomy Title
- How do themes render caption texts in extended markup (e.g. “wp-caption” paragraphs)
- WordPress widget/sidebar dividers?
- Add custom php database code above
- PHP code inside shortcodes
- Help with some php math in WordPress
- max_input_vars: how many am I using?
- Multiple WordPress Menus that will only display all pages
- Latest post in a specific menu
- WordPress not reflecting changed of the database
- Reload part of checkout on changed shipping method
- Woocommerce related product text
- how to combine wordpress htaccess on my root domain + php on subfolder
- WordPress, AJAX and pre_get_posts using conditional tags
- Input data from email form not going to JSON file
- Font Awesome changing default WordPress Font
- Help with a $wpdb MySQL Query
- Should `wp_login` be used since it’s deprecated?
- a:0:{} is replaced into database as s:6:”a:0:{}”;
- Echo a function inside a function
- Download full html page with CSV export plugin
- Hide HTML element (by class or ID) with PHP
- wp_force_remove_style’ not found
- Pagination on Custom Post
- Why can’t I return a value from $wpdb->get var?
- how to save checkbox data for custom setting?
- How to keep the capability of users and disable Gutenberg editor in WordPress?
- Is it possible to change content in my PHP file from WordPress dashboard
- change title page on search result
- Enqueing External JS on the remote server JS
- Trouble with a php code that adds a log in/log out button [closed]
- How to add aria role and schema markup to custom walker container
- jQuery accordion menu
- Restrict characters in comment section
- Required PHP version: 5.3.3 – Version found: 5.2.17… How or where do upgrade to 5.33 [closed]
- Adding custom url to readmore link using get_permalink()
- Remove submenu item from list
- is_user_logged_in returning nothing on custom page
- Customize field names in backend profile edit page through function.php [duplicate]
- WordPress: Export/Import Yoast meta title & description to custom taxonomy
- Page not visible in ‘All pages’ after being added through PHP
- How to exclude labels from certain categories in a shortcode?
- Hot to check if new posts have been published since page load and notify online users?
- How does add_option() function enable action hooks to fire right after actiavtion?
- Change permalink structure specific category
- How to pass username in affiliate link in wordpress website
- Wrong pagination results, page counter resets when navigating
- How can I update WordPress plugins or WordPress itself in all server?
- WooCommerce Query Product Titles
- Unable to display multiple parameters from url by javascript through shortcodes
- Run a sql (update) after 12 hours after the user login. Woocommerce users
- Wp_Schedule_Event every few minutes doesn’t work
- Check $post->ID against multiple values
- Get product price in a different currency using WooCommerce Currency Switcher
- Store user form submitted information in post type
- Block that renders html saved in a php file
- Cannot fetch posts with certain ‘product_cat’. WP_Query is empty
- WordPress files break if I edit them, but adding a closing PHP tag fixes it
- $_GET[‘title’] in WordPress
- Can’t update or install plugins in WordPress, php unidentified index
- Detect what link user clicks and Redirect to a specific page for logged in users only
- Offset with ajax load more posts duplicates
- Displaying logged in user name
- How to detect if a revision was made by woocommerce or wordpress?
- Create a hierarchical loop at predefined markup requirements
- Setting ‘post_format’
- WP Redirect with user nickname/username
- If else statement based on referral URL
- Custom Meta Boxes and Fields Multicheck Issue
- nested divs, classes for a grid in loop [duplicate]
- Hide sharing box and author box with a metabox on WordPress
- WordPress Website Featured Image Replacement Issue
- syntax error unexpected ‘}’ at 364 line
- 500 error when using wp_upload_dir() [closed]
- Shortcode to include PHP file, pass various parameters to include?
- Why can’t I include echo inside a variable? [closed]
- WP_Query not returning results
- Using Excel formula in PHP. Use ^ symbol [closed]
- How to increase excerpt length in wordpress? [duplicate]
- Are WordPress & PHP objectively and based on evidence going to die because the future is made of frontend rendering instead of server side rendering? [closed]
- Not able to see the error [closed]
- How do I link the side images?