The filter itself probably works, but the file_exists()
returns false
.
So not sure if this answers the question, but one issue I see in your code is:
When you put the code in your-plugin/admin/partials/ggowl_template/ggowl_template_func.php
, plugin_dir_path( __FILE__ )
from within the ggowl_template_post_function()
would be your-plugin/admin/partials/ggowl_template/
— and not the main plugin file path, so I suggest you to define the main plugin file (its absolute path) in the main plugin file, like so:
<?php
/**
* Plugin Name: My Plugin
* Version: 1.0
*/
defined( 'ABSPATH' ) || exit;
define( 'MY_PLUGIN_PLUGIN_FILE', __FILE__ );
And from other PHP files than the main plugin file, you’d use MY_PLUGIN_PLUGIN_FILE
and not __FILE__
when referencing to the main plugin file.