Tag Info

Hot answers tagged

6

You are calling the function too early. The functions.php is included before current_user_can() is defined. Never do anything before the hook 'after_setup_theme': Example for the functions.php add_action( 'after_setup_theme', array( 'WPSE_14041_Base', 'setup' ) ); class WPSE_14041_Base { public static function setup() { ! isset ( ...


5

The only way that function returns an instance of WP_Error is if $cat (in your example) has an empty value. You need to check the return before doing anything with it. Replacing that line with this should fix the problem: echo is_wp_error( $cat_parents = get_category_parents($cat, TRUE, '' . $delimiter . '') ) ? '' : $cat_parents;


4

In almost all cases you can simply delete the plugin and it will be switched off automatically, and in fact that is advice I've given many times to help reel in broken sites. The same is true for themes. Some plugins are actually more complicated than that and require additional steps. Notably, the caching plugins tend to fall into that category as some add ...


3

"the errors (…) don't show a stack trace" - they would if you were using xdebug. It means $wpdb is not loaded yet, not loaded properly, or gone: If you added code that calls it to your wp-config file or something to that order, remove it. If you've a db.php file in wp-content, it's probably broken so rename it. If you're messing around with things on a ...


3

Your issue is in the callable object you add: array( __CLASS__, "build_shortcode") This translates to: array( "WC_Product_Categories", "build_shortcode") Which is equivalent to: WC_Product_Categories::build_shortcode(); But build_shortcode is not a static function/method, and static functions/methods do not have a $this object, because there is no ...


3

There is no reference to 'classes.php' anywhere in the WP codebase, either in the 3.1 branch or in trunk. You probably have a modified version. Do a 'svn stat' and then a 'svn diff'.


3

The Health Check plugin is triggering the first error. Is this when you're running 2.7? get_transient() was only introduced in 2.8, which would explain it's absence. The second failure is merely a failed HTTP request. This can happen every now and then (mainly due to timeouts). It shouldn't interrupt the normal functioning of WordPress (the HTTP request was ...


3

Why exactly are you trying to redeclare that function? You can either edit the original function, or, better yet, use remove_action to remove add_action( 'widgets_init', 'twentyeleven_widgets_init' ); and then reattach your own function add_action('widgets_init', 'your_widgets_init_function' );


3

wp_mail() is defined in wp-includes/pluggable.php. This file is loaded after the plugins are loaded, but before the hook plugins_loaded has been fired. So the answer is: wait. add_action( 'plugins_loaded', 'renderHTML' ); On a side note: prefix your function names and your global variables.


3

You're getting the error because the Facebook and All In One Event Calendar plugins are both declaring the fb_admin_dialog() function, but PHP only allows a function to be declared once. To fix the immediate problem, log in to your server with S/FTP and rename the wp-content/plugins/all-in-one-event-calendar directory to something like ...


3

Don't mess around with changing those files directly. It will break when that file gets changed in an update. Do this instead. add_filter( 'wp_mail_from', 'override_mail_from_address' ); add_filter( 'wp_mail_from_name', 'override_mail_from_name' ); function override_mail_from_address($email_address) { $from_array = explode('@', $email_address); ...


2

You have found a bug in Genesis. Your Xdebug stack trace fingers the culprit as the genesis_save_custom_fields() function which calls current_user_can() with a singular capability (edit_post and edit_page) which also requires an additional argument, in this case the post ID which is missing. current_user_can() calls has_cap() which calls map_meta_cap() ...


2

This issue usually stems from PHP configuration issues, APC caching, and/or a call to an incompatible XML library. From what I've seen, it is usually a combination of php 5.2.X and caching. If you're using caching on your site, try switching from APC/memcached cache to disk caching and see if it clears up. 9/10 times, disabling APC at the server level ...


2

You failed to update the files in the root of WordPress. I don't know why, but a lot of people make this simple mistake. It is not enough to upgrade only the wp-admin and wp-includes directories. The files in the root directory, such as wp-settings.php and all the other wp-* files there, also must be upgraded. WordPress 3.1 no longer contains a ...


2

Ok, solved my own issue... This might be very specific, but in case anyone ever finds a similar issue: to catch unexpected output errors I had another function: add_action('activated_plugin','save_error'); function save_error(){ $file = "unexpected-output.txt"; $fh = fopen($file, 'w') or die("can't open file"); $error = ob_get_contents(); ...


2

I'm gonna add this as an answer, though it's probably not the answer you want. The answer is "No, it is not possible". Out of memory errors in PHP are fatal errors. There is no recovering from a fatality, and so no way to return a useful error message.


2

wp() is quite essential function. It resides in functions.php file (don't confuse with functions.php in theme, different thing) and I don't think you can load WP without passing require directive for that file at some point. So your install seems very broken - either functions.php file in core is damaged or something else is broken and makes it skip loading ...


2

Fatal errors point to bad syntax, or bad naming conventions. WordPress does a good job of not activating plugins that throw fatal errors. However, once a plugin is activated, all bets are off. If you've created a function or a class, it's best to follow good naming conventions and namespace properly. For example, a function called post_extras() would not be ...


2

You need to escape your quotes, or use doubles, or use heredoc: // Escaped return '<div id="xxxx-xxxxxx"></div> <script type="text/javascript"> window._taboola = window._taboola || []; _taboola.push({ mode: \'xxxxxxx-xxxxx\', container: \'xxxxxx-xxxxxxx\', placement: \'one word word\', target_type: ...


2

the_title() calls your function again. If you want to avoid that, remove the callback inside of your function: function filter_title_after() { remove_filter( current_filter(), __FUNCTION__ ); // the rest of your code. But you shouldn’t call the_title() in your function at all: it prints the title – this is not what you want – and you get the ...


2

get_current_screen() is a backend function and it returns data about the current backend administration page. It makes no sense to use this in theme code. The only way it would work (I think but haven't tested) in functions.php would be if it were hooked into a backend hook later than admin_init. You don't explain what you are trying to do with ...


1

Do a complete update of WordPress, including all the files. The function named "reset_mbstring_encoding" is in the wp-includes/functions.php file and has been since 3.7, so if you're missing it or some other file, then you need to make sure all the WordPress files are up-to-date.


1

Hey I found the answer in this forum https://wordpress.org/support/topic/fatal-error-cannot-call-overloaded-function-for-non-object-1/page/2?replies=35#post-6035835. "Just wanted to share how I fix the issue. In the cpanel control panel, choose "Select PHP version". Then I select "PHP Version 5.5". Then click save." Worked for me. It seems like it's a ...


1

From the error you posted, I suspect that there was some kind of file corruption. The original file /wp-includes/post.php shouldn't end at line 235. The file should have 5841 lines (in WP version 4.0 and 4.0.1). If it was a file corruption and the error doesn't appear anymore, the update probably "healed" the damage by overwriting the file. Nevertheless I ...


1

Instantiate your object inside a function hooked to the template_redirect action: function wpse_177056_init_shortcode() { new callShortCode(); } add_action( 'template_redirect', 'wpse_177056_init_shortcode' );


1

I had the same problem but it occured while importing the theme-unit-test-data.xml along with its attachments. I am using WP 3.8.1. It's a WordPress issue so editing the php.ini has no effect. WP uses a hardcoded value (60 secs) for http_request_timeout of WP_Http in class-http.php. To solve it, place this code in functions.php of your currently active ...


1

You can try to use functions.php to handle the form submission and send the data via AJAX. Add a hidden field in your form with the action to be taken (on functions.php): <input type="hidden" name="action" value="save_contact"/> In you footer.php add the jQuery code to handle the AJAX request: jQuery('#your-form').submit(ajaxSubmit); function ...


1

The CSS for my parent theme (core) was incorrectly formatted. The code at the top read: Theme Name: Core Theme URI: http://www.domain.co.uk Description: The core theme. Author: Squideyes Author URI: http://www.domain.co.uk Template: Core Version: 1.0.0 Tags: clean, simple, easy The Template: tag should only appear in the child theme css. This is what ...


1

Found the problem. It was a problem with my host, in the path the ID3 folder name was uppercase, while on the server for some reason it was lowercase, this is why it didn't find it.


1

To diagnose a load-intensive (either CPU cycles or memory) Plugin, start by deactivating all Plugins. Ensure that, with no Plugins active, you do not observe the same issues. If you observe the same issues with all Plugins deactivated, then the problem is somewhere else, either with your Theme, your database, or your server configuration. If you don't ...



Only top voted, non community-wiki answers of a minimum length are eligible