Title: WordPress override CM Tooltip plugin function
Last modified: August 30, 2016

---

# WordPress override CM Tooltip plugin function

 *  [giliopoulos](https://wordpress.org/support/users/giliopoulos/)
 * (@giliopoulos)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/wordpress-override-cm-tooltip-plugin-function/)
 * I want to customize the behavior of `CM tooltip` plugin.
    From what I see in 
   the code the plugin is a class that has the following filters, which are kind
   of self descriptive.
 *     ```
       class CMTooltipGlossaryFrontend {
   
                   /*
                    * FILTERS
                    */
                       add_filter('get_the_excerpt',array(self::$calledClassName,'cmtt_disable_parsing'), 1);
                       add_filter('wpseo_opengraph_desc', array(self::$calledClassName, 'cmtt_reenable_parsing'), 1);
   
                   /*
                    * Make sure parser runs before the post or page content is outputted
                    */
                       add_filter('the_content', array(self::$calledClassName, 'cmtt_glossary_parse'), 9999);
                       add_filter('the_content', array(self::$calledClassName, 'cmtt_glossary_createList'), 9998);
                       add_filter('the_content', array(self::$calledClassName, 'cmtt_glossary_addBacklink'), 10000);
           }
       ```
   
 * I want to enable/disable the parsing functionality according to my needs ( post
   type etc).
 * The plugin code has `get_the_excerpt` filter, that checks some conditions and
   disables the parsing. When the `wpseo_opengraph_desc` gets activated it reanables
   parsing. The actual parsing happens in `cmtt_glossary_parse` function.
 * I wrote a new plugin and tried the following:
 * 1. I wrote my cmtt_disable_parsing function with higher precedence
    `add_filter('
   get_the_excerpt', array($this, 'cmtt_disable_parsing'), 100);`
 * 2. I wrote my cmtt_glossary_parse function which checks the conditions and then
   calls the CMTooltipClossaryFrontent::cmtt_glossary_parse function
 *  `add_filter('the_content', array($this, 'cmtt_glossary_parse'), 10008);`
 * but none of them works. Also, when i instantiate the original plugin inside my
   plugin, the original plugin is not working properly ( it does not parse the content)
 * Any help would be appreciated on how to customize properly the plugin functionality.
   
   Should i create a new plugin or is it better to put the code in functions.php?
   Is it a bad practice to instantiate a plugin class and call its methods somehwere
   else, lets say inside another plugin?

Viewing 1 replies (of 1 total)

 *  Thread Starter [giliopoulos](https://wordpress.org/support/users/giliopoulos/)
 * (@giliopoulos)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/wordpress-override-cm-tooltip-plugin-function/#post-6821138)
 * Finally i found a working solution for me. So i drop a line here in case someone
   else finds it useful.
 * I read this [https://iandunn.name/the-right-way-to-customize-a-wordpress-plugin/](https://iandunn.name/the-right-way-to-customize-a-wordpress-plugin/)
   guide, which describes the alternatives someone has, if he wants to override 
   a plugin functionality.
 * In my case the solution was similar as the one described in the “Override their
   callbacks” section. I downloaded his example that overrides google-authenticator
   plugin and followed pretty much the same tactic.
 * Especially for the cm tooltp plugin that i wanted to customize removing the original
   hooks and re-adding them if my requirements are met worked for me.
 *     ```
       remove_filter('the_content',array(CMTooltipGlossaryFrontend::$calledClassName, 'cmtt_glossary_parse'), 9999);
           remove_filter('the_content', array(CMTooltipGlossaryFrontend::$calledClassName, 'cmtt_glossary_createList'), 9998);
           remove_filter('the_content', array(CMTooltipGlossaryFrontend::$calledClassName, 'cmtt_glossary_addBacklink'), 10000);
       ```
   
 * and register my callback that enables again the original plugin functions if 
   my requirements are met using the following code
 *     ```
       //if (my_condition)
           add_filter('the_content', array(CMTooltipGlossaryFrontend::$calledClassName, 'cmtt_glossary_parse'), 9999);
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘WordPress override CM Tooltip plugin function’ is closed to new replies.

 * 1 reply
 * 1 participant
 * Last reply from: [giliopoulos](https://wordpress.org/support/users/giliopoulos/)
 * Last activity: [10 years, 6 months ago](https://wordpress.org/support/topic/wordpress-override-cm-tooltip-plugin-function/#post-6821138)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
