Posted: August 11, 2017 at 7:00 am
I am seeing multiple errors on various EE pages related to various different plugins I have installed and their metaboxes. Here are a couple of examples: Trying to get property of non-object in /home/torontot/public_html/beta/wp-content/plugins/envira-albums/includes/admin/metaboxes.php on line 324 Notice: Trying to get property of non-object in /home/torontot/public_html/beta/wp-content/plugins/revslider/includes/framework/base-admin.class.php on line 132 When I look at those lines giving an error they are trying to get the $post->ID. Of course, this page is not a post or a page. How do I fix these and remove these errors? Thanks! |
|
Hi there, Without seeing the code we don’t know what is happening.
Can you send me a copy of one of the plugins so I can see what is happening? |
|
`<?php if( !defined( ‘ABSPATH’) ) exit(); class RevSliderBaseAdmin extends RevSliderBase { protected static $master_view; private static $arrSettings = array(); private static $allowed_views = array(‘master-view’, ‘system/validation’, ‘system/dialog-video’, ‘system/dialog-update’, ‘system/dialog-global-settings’, ‘sliders’, ‘slider’, ‘slider_template’, ‘slides’, ‘slide’, ‘navigation-editor’, ‘slide-editor’, ‘slide-overview’, ‘slide-editor’, ‘slider-overview’, ‘themepunch-google-fonts’); /** parent::__construct($t); //set view //add internal hook for adding a menu in arrMenus //if not inside plugin don’t continue //a must event for any admin. call onActivate function. self::addActionAjax(‘show_image’, ‘onShowImage’); /** $box = array(); self::$arrMetaBoxes[] = $box; /** foreach(self::$arrMetaBoxes as $index=>$box){ $title = $box[‘title’]; $boxID = ‘mymetabox_revslider_’.$index; if(is_array($location)){ /** //protection against autosave $postID = RevSliderFunctions::getPostVariable(“ID”); foreach(self::$arrMetaBoxes as $box){ $arrSettingNames = array(‘slide_template’); } //end foreach meta } /** $postID = $post->ID; $boxID = RevSliderFunctions::getVal($boxData, “id”); $arrMetabox = self::$arrMetaBoxes[$index]; //draw element } /** /** /** /** if($page == ‘revslider’ || $page == ‘themepunch-google-fonts’ || $page == ‘revslider_navigation’) /** /** if(function_exists(“wp_enqueue_media”)) wp_enqueue_script(array(‘jquery’, ‘jquery-ui-core’, ‘jquery-ui-mouse’, ‘jquery-ui-accordion’, ‘jquery-ui-datepicker’, ‘jquery-ui-dialog’, ‘jquery-ui-slider’, ‘jquery-ui-autocomplete’, ‘jquery-ui-sortable’, ‘jquery-ui-droppable’, ‘jquery-ui-tabs’, ‘jquery-ui-widget’, ‘wp-color-picker’)); wp_enqueue_style(array(‘wp-jquery-ui’, ‘wp-jquery-ui-core’, ‘wp-jquery-ui-dialog’, ‘wp-color-picker’)); wp_enqueue_script(‘unite_settings’, RS_PLUGIN_URL .’admin/assets/js/settings.js’, array(), RevSliderGlobals::SLIDER_REVISION ); wp_enqueue_style(‘unite_admin’, RS_PLUGIN_URL .’admin/assets/css/admin.css’, array(), RevSliderGlobals::SLIDER_REVISION); //add tipsy //include codemirror } /** /** if( is_admin() && current_user_can(“manage_options”) ) return(false); /** /** /** self::$tempVars[“is_masterView”] = true; switch($view){ //switch URLs to corresponding php files $viewFilepath = self::$path_views.$view.”.php”; RevSliderFunctions::validateFilepath($viewFilepath,”View”); }catch (Exception $e){ /** return($pathTemplate); /** wp_enqueue_script(‘thickbox’); } /** $role = “manage_options”; switch(self::$menuRole){ foreach(self::$arrMenuPages as $menu){ foreach(self::$arrSubMenuPages as $menu){ } /** self::$arrMenuPages[] = array(“title”=>$title,”pageFunction”=>$pageFunctionName); } /** self::$arrSubMenuPages[] = array(“title”=>$title,”pageFunction”=>$pageFunctionName,”pageSlug”=>$pageSlug); } /** $link = admin_url( ‘admin.php?page=revslider’.$params); /** protected function addAction_onActivate(){ public static function onActivateHook(){ $options = array(); $options = apply_filters(‘revslider_mod_activation_option’, $options); $operations = new RevSliderOperations(); } /** /** /** /** $response = array(); if(!empty($arrData)){ if(gettype($arrData) == “string”) $response = array_merge($response,$arrData); $json = json_encode($response); echo $json; /** self::ajaxResponse(true,””,$arrData); /** self::ajaxResponse(false,$message,$arrData,true); /** self::ajaxResponse(true,$message,$arrData,true); } /** self::ajaxResponse(true,$message,$arrData,true); } /** |
|
Problem is on line 132, where it tries to create the metabox. |
|
But EE seems to have a problem with metabox creation with multiple plugins. That is why I think it has something to do with EE, and not the plugins itself. |
|
The forums really aren’t great for posting large sections of code, we recommend creating a pastebin or gist when posting code. Having said that, the above doesn’t really help as I can see what the code is trying to do, but not what is actually happening. I have an older version of revslider that is working on EE pages without any problems. Can you send me a copy of the plugin so I can take a look? |
|
It’s also possible that one of the plugins you’re using is actually causing the problem and then any other plugin that loads after that is throwing a notice. You can rule that out by disabling all non EE plugins and activating either one of the above plugins referenced, do they work with just EE and that specific plugin activated? |
|
ok – how do I provide you the plugin? Through github? How would I make it private for only you? |
|
I’m not sure why it’d be necessary to make the download private since it’s a GPL licensed plugin. Do you use a file sharing service like Dropbox? If so, you can post a download URL here. The first thing to check though is if the notices go away with all other plugins deactivated (so only Event Espresso activated and then one of the plugins that add metaboxes activated one at at time). |
|
I tried de-activating all plugins but EE4 and revslider and the error was still there. I uploaded a zip of the version of revslider that I am using here : https://github.com/RoacheDezigne/revslider5.2.6 |
|
I’ve installed that plugin on a test site, edited an EE event and didn’t get any errors/notices. It looks like something is altering the global If you didn’t disable all other plugins you’ll need to make sure your testing with only EE and Rev slider activated, everything else should be disabled. If it’s not a plugin it could be the theme, so try temporarily switching to a default theme such as twenty seventeen and confirm if the errors are removed then? |
|
You are correct, and plugins like Revslider do not check to see whether there’s a valid $post->ID included in the request. To fix this, the plugins need to add a check for a $post object and if no $post object, bail. For example, you can add this to line before 132 on /revslider/includes/framework/base-admin.class.php
|
|
I spent some time looking into this and Josh mentioned he was getting errors/notices on various sections outside of EE on his site when using the plugin. The problem is that rev slider is assuming that meta-boxes will only ever be used on post pages and tries to use the global post object without actually checking a WP_Post object is available. Rev slider depends on a post object so it should check that it actually has one before attempting to use it. So for example if we go to Event Espresso -> Maintenance you’ll see the error there – http://take.ms/PomLb The first question to ask is why would we want the Rev Slider options on that page? (It’s exactly the same issue on that page with any other it is throwing the error on) It’s not a post page, there is no post object to assign the slider to and you will never need to select a slider to display as it will never be displayed. In short if Rev Slider (or any other plugin) is dependent on a WP_Post object is should be checking if that object is available before trying to use it. The If your getting the same error from other plugins it will very likely be the same issue, you’ll need to contact the author of that plugin and have them add a check to confirm they have a WP_Post object before they attempt to add metaboxes and/or try to use it. Note – I assumed from the above that you were getting the above error on the EE event editor (as it would be expected for it to work there) which is why mentioned the steps above. |
|
The support post ‘Trying to get property of non-object error: metabox issue with multiple plugins’ is closed to new replies.
Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.