parent = $redux; $this->template_path = Redux_Core::$dir . 'templates/panel/'; $this->original_path = Redux_Core::$dir . 'templates/panel/'; if ( ! empty( $this->parent->args['templates_path'] ) ) { $this->template_path = trailingslashit( $this->parent->args['templates_path'] ); } // phpcs:ignore WordPress.NamingConventions.ValidHookName $this->template_path = trailingslashit( apply_filters( "redux/{$this->parent->args['opt_name']}/panel/templates_path", $this->template_path ) ); } /** * Class init. */ public function init() { $this->panel_template(); } /** * Loads the panel templates where needed and provides the container for Redux */ private function panel_template() { if ( $this->parent->args['dev_mode'] ) { $this->template_file_check_notice(); } /** * Action 'redux/{opt_name}/panel/before' */ // phpcs:ignore WordPress.NamingConventions.ValidHookName do_action( "redux/{$this->parent->args['opt_name']}/panel/before" ); echo '

'; // Stupid hack for WordPress alerts and warnings. echo '
'; echo '
'; // Do we support JS? echo ''; // Security is vital! echo ''; /** * Action 'redux/page/{opt_name}/form/before' * * @param object $this ReduxFramework */ // phpcs:ignore WordPress.NamingConventions.ValidHookName do_action( "redux/page/{$this->parent->args['opt_name']}/form/before", $this ); if ( is_rtl() ) { $this->parent->args['class'] = ' redux-rtl'; } $this->get_template( 'container.tpl.php' ); /** * Action 'redux/page/{opt_name}/form/after' * * @param object $this ReduxFramework */ // phpcs:ignore WordPress.NamingConventions.ValidHookName do_action( "redux/page/{$this->parent->args['opt_name']}/form/after", $this ); echo '
'; echo '
'; if ( true === $this->parent->args['dev_mode'] ) { echo '
' . esc_html( get_num_queries() ) . ' queries in ' . esc_html( timer_stop() ) . ' seconds
Redux is currently set to developer mode.
'; } /** * Action 'redux/{opt_name}/panel/after' */ // phpcs:ignore WordPress.NamingConventions.ValidHookName do_action( "redux/{$this->parent->args['opt_name']}/panel/after" ); } /** * Calls the various notification bars and sets the appropriate templates. */ public function notification_bar() { if ( isset( $this->parent->transients['last_save_mode'] ) ) { if ( 'import' === $this->parent->transients['last_save_mode'] ) { /** * Action 'redux/options/{opt_name}/import' * * @param object $this ReduxFramework */ // phpcs:ignore WordPress.NamingConventions.ValidHookName do_action( "redux/options/{$this->parent->args['opt_name']}/import", $this, $this->parent->transients['changed_values'] ); echo '
'; /** * Filter 'redux-imported-text-{opt_name}' * * @param string $text Translated "settings imported" text. */ // phpcs:ignore WordPress.NamingConventions.ValidHookName echo '' . esc_html( apply_filters( "redux-imported-text-{$this->parent->args['opt_name']}", esc_html__( 'Settings Imported!', 'redux-framework' ) ) ) . ''; echo '
'; } elseif ( 'defaults' === $this->parent->transients['last_save_mode'] ) { /** * Action 'redux/options/{opt_name}/reset' * * @param object $this ReduxFramework */ // phpcs:ignore WordPress.NamingConventions.ValidHookName do_action( "redux/options/{$this->parent->args['opt_name']}/reset", $this ); echo '
'; /** * Filter 'redux-defaults-text-{opt_name}' * * @param string $text Translated "settings imported" text. */ // phpcs:ignore WordPress.NamingConventions.ValidHookName echo '' . esc_html( apply_filters( "redux-defaults-text-{$this->parent->args['opt_name']}", esc_html__( 'All Defaults Restored!', 'redux-framework' ) ) ) . ''; echo '
'; } elseif ( 'defaults_section' === $this->parent->transients['last_save_mode'] ) { /** * Action 'redux/options/{opt_name}/section/reset' * * @param object $this ReduxFramework */ // phpcs:ignore WordPress.NamingConventions.ValidHookName do_action( "redux/options/{$this->parent->args['opt_name']}/section/reset", $this ); echo '
'; /** * Filter 'redux-defaults-section-text-{opt_name}' * * @param string $text Translated "settings imported" text. */ // phpcs:ignore WordPress.NamingConventions.ValidHookName echo '' . esc_html( apply_filters( "redux-defaults-section-text-{$this->parent->args['opt_name']}", esc_html__( 'Section Defaults Restored!', 'redux-framework' ) ) ) . ''; echo '
'; } elseif ( 'normal' === $this->parent->transients['last_save_mode'] ) { /** * Action 'redux/options/{opt_name}/saved' * * @param mixed $value set/saved option value */ // phpcs:ignore WordPress.NamingConventions.ValidHookName do_action( "redux/options/{$this->parent->args['opt_name']}/saved", $this->parent->options, $this->parent->transients['changed_values'] ); echo '
'; /** * Filter 'redux-saved-text-{opt_name}' * * @param string $text Translated "settings saved" text. */ // phpcs:ignore WordPress.NamingConventions.ValidHookName echo '' . esc_html( apply_filters( "redux-saved-text-{$this->parent->args['opt_name']}", esc_html__( 'Settings Saved!', 'redux-framework' ) ) ) . ''; echo '
'; } unset( $this->parent->transients['last_save_mode'] ); $this->parent->transient_class->set(); } /** * Action 'redux/options/{opt_name}/settings/changes' * * @param mixed $value set/saved option value */ // phpcs:ignore WordPress.NamingConventions.ValidHookName do_action( "redux/options/{$this->parent->args['opt_name']}/settings/change", $this->parent->options, $this->parent->transients['changed_values'] ); echo '
'; /** * Filter 'redux-changed-text-{opt_name}' * * @param string $text Translated "settings have changed" text. */ // phpcs:ignore WordPress.NamingConventions.ValidHookName echo '' . esc_html( apply_filters( "redux-changed-text-{$this->parent->args['opt_name']}", esc_html__( 'Settings have changed, you should save them!', 'redux-framework' ) ) ) . ''; echo '
'; /** * Action 'redux/options/{opt_name}/errors' * * @param array $this ->errors error information */ // phpcs:ignore WordPress.NamingConventions.ValidHookName do_action( "redux/options/{$this->parent->args['opt_name']}/errors", $this->parent->errors ); echo '
'; echo ''; echo ' ' . esc_html__( 'error(s) were found!', 'redux-framework' ); echo ''; echo '
'; /** * Action 'redux/options/{opt_name}/warnings' * * @param array $this ->warnings warning information */ // phpcs:ignore WordPress.NamingConventions.ValidHookName do_action( "redux/options/{$this->parent->args['opt_name']}/warnings", $this->parent->warnings ); echo '
'; echo ''; echo ' ' . esc_html__( 'warning(s) were found!', 'redux-framework' ); echo ''; echo '
'; } /** * Used to initialize the settings fields for this panel. Required for saving and redirect. */ private function init_settings_fields() { // Must run or the page won't redirect properly. settings_fields( "{$this->parent->args['opt_name']}_group" ); } /** * Enable file deprecate warning from core. This is necessary because the function is considered private. * * @return bool */ public function tick_file_deprecate_warning(): bool { return true; } /** * Used to select the proper template. If it doesn't exist in the path, then the original template file is used. * * @param string $file Path to template file. */ public function get_template( string $file ) { if ( empty( $file ) ) { return; } if ( file_exists( $this->template_path . $file ) ) { $path = $this->template_path . $file; } else { $path = $this->original_path . $file; } // Shim for v3 templates. if ( ! file_exists( $path ) ) { $old_file = $file; add_filter( 'deprecated_file_trigger_error', array( $this, 'tick_file_deprecate_warning' ) ); $file = str_replace( '_', '-', $file ); _deprecated_file( esc_html( $old_file ), '4.0', esc_html( $file ), 'Please replace this outdated template with the current one from the Redux core.' ); if ( file_exists( $this->template_path . $file ) ) { $path = $this->template_path . $file; } else { $path = $this->original_path . $file; } } // phpcs:ignore WordPress.NamingConventions.ValidHookName do_action( "redux/{$this->parent->args['opt_name']}/panel/template/" . $file . '/before' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName $path = apply_filters( "redux/{$this->parent->args['opt_name']}/panel/template/" . $file, $path ); // phpcs:ignore WordPress.NamingConventions.ValidHookName do_action( "redux/{$this->parent->args['opt_name']}/panel/template/" . $file . '/after' ); if ( file_exists( $path ) ) { if ( is_readable( $path ) ) { require $path; } else { // translators: %1$s: template path. echo '

' . sprintf( esc_html__( 'Redux Panel Template %1$s cannot be read. Please check the permissions for this file.', 'redux-framework' ), '' . esc_html( $path ) . '' ) . '

'; } } elseif ( file_exists( Redux_Core::$dir . 'templates/panel/' . $file ) ) { require Redux_Core::$dir . 'templates/panel/' . $file; } else { // translators: %1$s: template path. echo '

' . sprintf( esc_html__( 'Redux Panel Template %1$s does not exist. Please reinstall Redux to replace this file.', 'redux-framework' ), '' . esc_html( $path ) . '' ) . '

'; } } /** * Scan the template files. * * @param string $template_path Path to template file. * * @return array */ public function scan_template_files( string $template_path ): array { $files = scandir( $template_path ); $result = array(); if ( $files ) { foreach ( $files as $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; } /** * Show a notice highlighting bad template files */ public function template_file_check_notice() { if ( $this->original_path === $this->template_path ) { return; } $core_templates = $this->scan_template_files( $this->original_path ); 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, '<' ) ) { ?>

  

parent->args['opt_name'] . $k . '_section_group' ); } } } if ( ! class_exists( 'reduxCorePanel' ) ) { class_alias( 'Redux_Panel', 'reduxCorePanel' ); }