| Server IP : 146.59.209.152 / Your IP : 216.73.216.46 Web Server : Apache System : Linux webm005.cluster131.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue Sep 17 08:14:20 UTC 2024 x86_64 User : infrafs ( 43850) PHP Version : 8.2.29 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/infrafs/INFRABIKEUS/wp-content/plugins/eltd-membership/dashboard/ |
Upload File : |
<?php
class ElatedMembershipPageTemplate {
/**
* A Unique Identifier
*/
protected $plugin_slug;
/**
* A reference to an instance of this class.
*/
private static $instance;
/**
* The array of templates that this plugin tracks.
*/
protected $templates;
/**
* Returns an instance of this class.
*/
public static function get_instance() {
if ( null == self::$instance ) {
self::$instance = new ElatedMembershipPageTemplate();
}
return self::$instance;
}
/**
* Initializes the plugin by setting filters and administration functions.
*/
private function __construct() {
$this->templates = array();
// Add your templates to this array.
$this->templates = array(
'user-dashboard.php' => 'User Dashboard',
);
// Add a filter to the theme page templates to assigned our custom template into the list
add_filter( 'theme_page_templates', array( $this, 'eltd_membership_add_user_dashboard_template' ) );
// Add a filter to the template include to determine if the page has our template assigned and return it's path
add_filter( 'template_include', array( $this, 'eltd_membership_view_directory_template' ) );
}
/**
* Assign our template into the list of templates
*/
public function eltd_membership_add_user_dashboard_template( $post_templates ) {
$templates = $post_templates;
if ( empty( $templates ) ) {
$templates = array();
}
$templates = array_merge( $templates, $this->templates );
return $templates;
}
/**
* Checks if the template is assigned to the page
*/
public function eltd_membership_view_directory_template( $template ) {
global $post;
if ( isset( $post ) ) {
if ( ! isset( $this->templates[ get_post_meta( $post->ID, '_wp_page_template', true ) ] ) ) {
return $template;
}
$file = plugin_dir_path( __FILE__ ) . 'page-templates/' . get_post_meta( $post->ID, '_wp_page_template', true );
// Just to be safe, we check if the file exist first
if ( file_exists( $file ) ) {
return $file;
} else {
echo trackstore_elated_get_module_part($file);
}
exit;
}
return $template;
}
}
add_action( 'plugins_loaded', array( 'ElatedMembershipPageTemplate', 'get_instance' ) );