';
}
/**
* Used to intitialize the settings fields for this panel. Required for saving and redirect.
*/
function init_settings_fields() {
// Must run or the page won't redirect properly
settings_fields( "{$this->parent->args['opt_name']}_group" );
}
/**
* Used to select the proper template. If it doesn't exist in the path, then the original template file is used.
*
* @param $file
*/
function get_template( $file ) {
if ( empty( $file ) ) {
return;
}
if ( file_exists( $this->template_path . $file ) ) {
$path = $this->template_path . $file;
} else {
$path = $this->original_path . $file;
}
do_action( "redux/{$this->parent->args['opt_name']}/panel/template/" . $file . '/before' );
$path = apply_filters( "redux/{$this->parent->args['opt_name']}/panel/template/" . $file, $path );
do_action( "redux/{$this->parent->args['opt_name']}/panel/template/" . $file . '/after' );
require $path;
}
/**
* Scan the template files
*
* @param string $template_path
*
* @return array
*/
public function scan_template_files( $template_path ) {
$files = scandir( $template_path );
$result = array();
if ( $files ) {
foreach ( $files as $key => $value ) {
if ( ! in_array( $value, array( ".", ".." ) ) ) {
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;
}
/**
* Show a notice highlighting bad template files
*/
public function template_file_check_notice() {
if ( $this->template_path == $this->original_path ) {
return;
}
$core_templates = $this->scan_template_files( $this->original_path );
$outdated = false;
foreach ( $core_templates as $file ) {
$developer_theme_file = false;
if ( file_exists( $this->template_path . $file ) ) {
$developer_theme_file = $this->template_path . $file;
}
if ( $developer_theme_file ) {
$core_version = Redux_Helpers::get_template_version( $this->original_path . $file );
$developer_version = Redux_Helpers::get_template_version( $developer_theme_file );
if ( $core_version && $developer_version && version_compare( $developer_version, $core_version, '<' ) ) {
?>
Your panel has bundled outdated copies of Redux Framework template files – if you encounter functionality issues this could be the reason. Ensure you update or remove them.', 'virtue' ); ?>