最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Plugin function in child theme

programmeradmin1浏览0评论

I need to customize a message returned from a plugin function using my child theme.
In the plugin:

if ( ! class_exists( 'my_class' ) ) {
    class my_class {
        if ( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
            add_filter( 'wcm_additional_notification', array( $this, 'wcm_cart_additional_notification' ), 10 );
        }
    }
}

public function wcm_cart_additional_notification( $message ) {
  if ( $this->checked_products ) {
    $message = 'my message';
  }
  return $message;
}

If I add in my functions.php

add_filter( 'wcm_additional_notification', array( $this, 'wcm_cart_additional_notification' ), 10 );
function wcm_cart_additional_notification( $message ) {
if ( $this->checked_products ) {
    $message = 'my new message';
}

or

add_filter( 'wcm_additional_notification',  'wcm_cart_additional_notification' );
function wcm_cart_additional_notification( $message ) {
if ( $this->checked_products ) {
    $message = 'my new message';
}

I get this: "Fatal error: Uncaught Error: Using $this when not in object context"

Hoping someone can point out what I'm doing wrong. Many thanks.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论