After several long hours of research, I’ve come to the conclusion that there are but two options:
1) Get the developers to create do the job (unfeasable);
2) Edit the plugin and change the name and source URL to prevent any updates from happening.
Against all my convictions, I went with option #2. I will be closing this question but leaving this note as a reference for anyone who wishes to do something similar.
I need to extend the “Bookly” plugin and customize it with a few custom functionalities and edit some of the existing functionalities. I’ve never worked with OO PHP, not namespaces, but I have been reading a lot about it since starting this project.
As of right now, I (somehow) managed to edit some of the code to create new columns in the database and add data, however I cannot retrieve them.
- I’ve logged every hook related to the plugin in order to trace where the loading occurs, all the way back to the
add_action
hook; - I’ve double-, triple-, and quadruple-checked every place through the original plugin and pinpointed which function I needed to edit;
- I’ve created a new file calling the namespace and everything just like the original plugin (making sure I avoided duplicate class names and extended the original), but it’s not being called. This is where I’m getting annoyed since I can get data to be added but not fetched using the same techniques.
When I worked on adding columns, it took a while, but it’s now working no trouble. However, AJAX hooks are added dynamically, like so:
protected function registerWpAjaxActions( $with_nopriv = false ) { if ( defined( 'DOING_AJAX' ) ) { $plugin_class = Lib\Base\Plugin::getPluginFor( $this ); // Prefixes for auto generated add_action() $tag parameter. $prefix = sprintf( 'wp_ajax_%s', $plugin_class::getPrefix() ); if ( $with_nopriv ) { $nopriv_prefix = sprintf( 'wp_ajax_nopriv_%s', $plugin_class::getPrefix() ); } $_this = $this; foreach ( $this->reflection->getMethods( \ReflectionMethod::IS_PUBLIC ) as $method ) { if ( preg_match( '/^execute(.*)/', $method->name, $match ) ) { $action = strtolower( preg_replace( '/([a-z])([A-Z])/', '$1_$2', $match[1] ) ); $function = function () use ( $_this, $match ) { $_this->forward( $match[0], true, true ); add_action( $prefix . $action, $function ); if ( $with_nopriv ) { add_action( $nopriv_prefix . $action, $function ); } } } } }
Before the add_action( $prefix . $action, $function );
line, I’ve added a wp_die( $prefix . $action );
if this was equal to wp_ajax_bookly_get_customers
, which is the hook called when loading the data from the database. However, I cannot load the additional columns and their data despite because I cannot seem to extend the plugin before I can load the data from the database.