mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-11 18:56:10 +09:00
- basic list of override templates
This commit is contained in:
@@ -3020,6 +3020,46 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
|
||||
|
||||
|
||||
public function settings_override_templates_tab( $html, $section_fields ) {
|
||||
$outdated_files = array();
|
||||
$scan_files = $this->scan_template_files( um_path . '/templates/' );
|
||||
foreach ( $scan_files as $key => $file ) {
|
||||
if ( ! str_contains( $file, 'email/' ) ) {
|
||||
$located = apply_filters( 'um_located_template', $file, get_stylesheet_directory() . '/ultimate-member/' );
|
||||
if ( file_exists( $located ) ) {
|
||||
$theme_file = $located;
|
||||
} elseif ( file_exists( get_stylesheet_directory() . '/ultimate-member/templates/' . $file ) ) {
|
||||
$theme_file = get_stylesheet_directory() . '/ultimate-member/templates/' . $file;
|
||||
} else {
|
||||
$theme_file = false;
|
||||
}
|
||||
if ( ! empty( $theme_file ) ) {
|
||||
$core_file = $file;
|
||||
|
||||
$core_version = $this->get_file_version( um_path . '/templates/' . $core_file );
|
||||
$theme_version = $this->get_file_version( $theme_file );
|
||||
|
||||
$status = esc_html__( 'Theme version up to date', 'ultimate-member' );
|
||||
$status_code = 1;
|
||||
if ( version_compare( $theme_version, $core_version, '<' ) ) {
|
||||
$status = esc_html__( 'Theme version is out of date', 'ultimate-member' );
|
||||
$status_code = 0;
|
||||
}
|
||||
if ( '' === $theme_version ) {
|
||||
$status = esc_html__( 'Theme version is empty', 'ultimate-member' );
|
||||
$status_code = 0;
|
||||
}
|
||||
$outdated_files[] = array(
|
||||
'core_version' => $core_version,
|
||||
'theme_version' => $theme_version,
|
||||
'core_file' => stristr( um_path . 'templates/' . $core_file, 'wp-content' ),
|
||||
'theme_file' => stristr( $theme_file, 'wp-content' ),
|
||||
'status' => $status,
|
||||
'status_code' => $status_code,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ob_start();
|
||||
?>
|
||||
<p>
|
||||
@@ -3034,6 +3074,65 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Scan the template files.
|
||||
*
|
||||
* @param string $template_path Path to the template directory.
|
||||
* @return array
|
||||
*/
|
||||
public static function scan_template_files( $template_path ) {
|
||||
$files = @scandir( $template_path ); // @codingStandardsIgnoreLine.
|
||||
$result = array();
|
||||
|
||||
if ( ! empty( $files ) ) {
|
||||
|
||||
foreach ( $files as $key => $value ) {
|
||||
|
||||
if ( ! in_array( $value, array( '.', '..' ), true ) ) {
|
||||
|
||||
if ( is_dir( $template_path . DIRECTORY_SEPARATOR . $value ) ) {
|
||||
$sub_files = self::scan_template_files( $template_path . DIRECTORY_SEPARATOR . $value );
|
||||
foreach ( $sub_files as $sub_file ) {
|
||||
$result[] = $value . DIRECTORY_SEPARATOR . $sub_file;
|
||||
}
|
||||
} else {
|
||||
$result[] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
public static function get_file_version( $file ) {
|
||||
|
||||
// Avoid notices if file does not exist.
|
||||
if ( ! file_exists( $file ) ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// We don't need to write to the file, so just open for reading.
|
||||
$fp = fopen( $file, 'r' ); // @codingStandardsIgnoreLine.
|
||||
|
||||
// Pull only the first 8kiB of the file in.
|
||||
$file_data = fread( $fp, 8192 ); // @codingStandardsIgnoreLine.
|
||||
|
||||
// PHP will close file handle, but we are good citizens.
|
||||
fclose( $fp ); // @codingStandardsIgnoreLine.
|
||||
|
||||
// Make sure we catch CR-only line endings.
|
||||
$file_data = str_replace( "\r", "\n", $file_data );
|
||||
$version = '';
|
||||
|
||||
if ( preg_match( '/^[ \t\/*#@]*' . preg_quote( '@version', '/' ) . '(.*)$/mi', $file_data, $match ) && $match[1] ) {
|
||||
$version = _cleanup_header_comment( $match[1] );
|
||||
}
|
||||
|
||||
return $version;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $html
|
||||
* @param $section_fields
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
|
||||
<?php
|
||||
/**
|
||||
* @version 2.6.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; ?>
|
||||
|
||||
<div class="um <?php echo esc_attr( $this->get_class( $mode ) ); ?> um-<?php echo esc_attr( $form_id ); ?>">
|
||||
|
||||
@@ -8,4 +13,4 @@
|
||||
printf( __( '%s', 'ultimate-member' ), $this->custom_message ); ?>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
|
||||
<?php
|
||||
/**
|
||||
* @version 2.6.0
|
||||
*/
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; ?>
|
||||
|
||||
<div class="um <?php echo esc_attr( $this->get_class( $mode ) ); ?> um-<?php echo esc_attr( $form_id ); ?> um-role-<?php echo esc_attr( um_user( 'role' ) ); ?> ">
|
||||
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
|
||||
<?php
|
||||
/**
|
||||
* @version 2.6.0
|
||||
*/
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; ?>
|
||||
|
||||
<div class="search-form um-search-form" data-members_page="<?php echo esc_url( $members_page ); ?>">
|
||||
<?php foreach ( array_keys( $query ) as $key ) { ?>
|
||||
@@ -9,4 +13,4 @@
|
||||
<input type="search" class="um-search-field search-field" placeholder="<?php echo esc_attr_x( 'Search …', 'placeholder' ); ?>" value="<?php echo esc_attr( $search_value ); ?>" name="search" title="<?php echo esc_attr_x( 'Search for:', 'label' ); ?>" />
|
||||
<a href="javascript:void(0);" id="um-search-button" class="um-search-icon um-faicon um-faicon-search"></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user