Hello I need to fetch the ticket iframe from Eventbrite to a wordpress page. I purchased the ticket plugin and is
getting PHP Fatal error: Using $this when not in object context for the following Function
for the following function for inlcude line
public function displayEventBriteTicketForm() {
include( TribeEventsTemplates::getTemplateHierarchy( 'ticket-form', 'hooks', 'eventbrite', $this->pluginPath ) );
include( TribeEventsTemplates::getTemplateHierarchy( 'ticket-form', 'modules', 'eventbrite', $this->pluginPath ) );
}
Help
Solved the Problem
replaced $this->pluginPath with $pluginPath resolved the error message
Related
I create a class that managed my api call using curl.
I create a method that get me the version of my plugin but when i instance the class in the main file file of plugin get me an error.
ERROR:
PHP Fatal error: Uncaught Error: Call to undefined function
get_plugin_data().
the method :
$plugin_data = get_plugin_data( __FILE__ );
return $plugin_data['Version']."; wp:".wp_version_check()."; php:".phpversion();
the instance in the plugin class:
if(class_exists('API')){
$this->api=new API();
}
i think that is because the path is not good for the main file
The get_plugin_data function is not available at run time. You'll have to include the file containing the function declaration.
Try the following:
if ( is_admin() ) {
if( ! function_exists('get_plugin_data') ){
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
}
$plugin_data = get_plugin_data( __FILE__ );
}
I'm using awesome support plugin for creating a ticket system in my project.
The problem I have is that support plugin will add some fields into Users Admin page which I don't want them.
I searched inside plugin code and I've found the action that is used to put the fields in users page and I want to remove that action.
I tried removing its action by using this code:
remove_action('wpas_all_user_profile_fields', array( WPAS_User::get_instance() , 'profile_phone_fields'), 10)
and it is working and the fields doesn't show on users page but I'm getting a fatal error inside my debug.log which says:
PHP Fatal error: Uncaught Error: Class 'WPAS_User' not found in ...
the plugin class that is something like this
class WPAS_User {
public function __construct() {
add_action( 'wpas_all_user_profile_fields', array( $this, 'profile_phone_fields' ), 10, 1 );
}
public static function get_instance() {
// If the single instance hasn't been set, set it now.
if ( null == self::$instance ) {
self::$instance = new self;
}
return self::$instance;
}
.
.
.
}
Do you include in your php the name of the file ?
<?php include('yourfile.php') ?>
I have taken the following code from a tutorial. It is meant to create a shortcode I can use to add a button to my Wordpress posts, which directly sends a message to the user who created the post.
I am getting the php error -
Fatal error: Class 'wpchats' not found in /homepages/22/d688271077/htdocs/clickandbuilds/VillaShare/wp-content/themes/listable/functions.php on line 755
Please see the functions.php code and shortcode below:
add_shortcode('wpc-link-to-chat', function($atts) {
$a = shortcode_atts( array(
'user_id' => wp_get_current_user()->ID
), $atts );
$user_id = (int) "{$a['user_id']}";
$wpchats = new wpchats;
return $wpchats->get_settings( 'messages_page' ) . "?recipient=$user_id";
});
Shortcode:
[wpc-link-to-chat user_id="3"]
Try to use:
...
$wpchats = new wpChats;
return $wpchats->get_settings( 'messages_page' ) . "?recipient=$user_id";
});
Maybe it sounds stupid, but if wpChats is a class you should declare it with ()
$wpchats = new wpchats();
Just upgraded Mediawiki 1.19.6 to the most current, 1.22.2.
Used update.php, which worked just fine. The front page loads, as do SOME of the articles if you enter their exact URL. However, following any of the links produces:
Catchable fatal error: Argument 1 passed to
ContentHandler::getContentText() must implement interface Content,
boolean given, called in <wiki path>/includes/Article.php on line 389
and defined in <wiki path>/includes/content/ContentHandler.php on line
95.
I've looked up the call to getContentText() in Article.php, and it's in a function called fetchContent(), with a comment about it being crufty and a note that the ContentHandler method within is deprecated.
I can't figure out how to fix what's gone wrong, and web searches are only turning up bug reports that are marked fixed... any ideas? Thanks very much.
getContentText() is depreciated.
Use WikiPage::getContent()
https://doc.wikimedia.org/mediawiki-core/master/php/html/classArticle.html#affd3b52d2544cc334d7805ae9e5aba98
We had the same problem. Our ICT guy handled it by adapting the Article.php file placed in the includes directory of your mediawiki. Only 1 function was adapted (line 377 function function fetchContent()). I do not know the exact working principle but the MediaWiki returned to normal.
Also I believe you need to run the mediawiki update routine by visiting:
'HostAdress'/MediaWiki/mw-config/
Original function in Article.php:
function fetchContent() { #BC cruft!
ContentHandler::deprecated( __METHOD__, '1.21' );
if ( $this->mContentLoaded && $this->mContent ) {
return $this->mContent;
}
wfProfileIn( __METHOD__ );
$content = $this->fetchContentObject();
// #todo Get rid of mContent everywhere!
$this->mContent = ContentHandler::getContentText( $content );
ContentHandler::runLegacyHooks( 'ArticleAfterFetchContent', array( &$this, &$this->mContent ) );
wfProfileOut( __METHOD__ );
return $this->mContent;
}
New function in Article.php:
function fetchContent() { #BC cruft!
ContentHandler::deprecated( __METHOD__, '1.21' );
if ( $this->mContentLoaded && $this->mContent ) {
return $this->mContent;
}
wfProfileIn( __METHOD__ );
$content = $this->fetchContentObject();
if ( !$content ) {
wfProfileOut( __METHOD__ );
return false;
}
// #todo Get rid of mContent everywhere!
$this->mContent = ContentHandler::getContentText( $content );
ContentHandler::runLegacyHooks( 'ArticleAfterFetchContent', array( &$this, &$this->mContent ) );
wfProfileOut( __METHOD__ );
return $this->mContent;
}
So, I followed:
How to create a custom admin page in opencart?
This tut to try and add a page to my OpenCart v1.5.6 shop.
<?
class ControllerCommonHelloworld extends Controller {
public function index(){
// VARS
$template="common/hello.tpl"; // .tpl location and file
$this->load->model('common/hello');
$this->template = ''.$template.'';
$this->children = array(
'common/header',
'common/footer'
);
$this->response->setOutput($this->render());
}
}
?>
but upon opening the new page am fed with this:
load->model('common/hello'); $this->template = ''.$template.''; $this->children = array('common/header', 'common/footer' ); $this->response->setOutput($this->render()); } }?>
( ! ) Fatal error: Class 'Controllercommonhelloworld' not found in ------\store\system\engine\front.php on line 39
Call Stack
# Time Memory Function Location
1 0.0015 303736 {main}( ) ..\index.php:0
2 0.0634 2285056 Front->dispatch( ) ..\index.php:166
3 0.0663 2439760 Front->execute( ) ..\front.php:29`
now as far as I am aware this error is telling me I have no Class named "ControllerCommonHelloworld" even though I have a file called helloworld.php
I have both of these things, and have tried all types of case combinations, and moving the files around...
does anyone know of any other reason this error might be appearing? or can see anything else I might have missed?
Your server doesn't seem to be able to use php short tags. Change <? to <?php - Since PHP doesn't load that file as a PHP file, the class doesn't exist. Changing it to <?php will get it working