$files ) { foreach ( $files as $file ) { $file = wp_normalize_path( $file ); // for not a Linux hosting. if ( false === strpos( $file, 'email/' ) ) { /** * Filters an array of the template files for scanning versions based on $key. * * Note: $key - means um or extension key. * * @since 2.6.1 * @hook um_override_templates_get_template_path__{$key} * * @param {array} $located Template file paths for scanning versions. * @param {string} $file Template file name. * * @return {array} Template file paths for scanning versions. */ $located = apply_filters( "um_override_templates_get_template_path__{$key}", array(), $file ); $exceptions = array( 'members-grid.php', 'members-header.php', 'members-list.php', 'members-pagination.php', 'searchform.php', 'login-to-view.php', 'profile/comments.php', 'profile/comments-single.php', 'profile/posts.php', 'profile/posts-single.php', 'modal/upload-single.php', 'modal/view-photo.php', ); $theme_file = false; if ( ! empty( $located ) ) { $theme_file = $located['theme']; } elseif ( in_array( $file, $exceptions, true ) && file_exists( get_stylesheet_directory() . '/ultimate-member/' . $file ) ) { $theme_file = get_stylesheet_directory() . '/ultimate-member/' . $file; } elseif ( file_exists( get_stylesheet_directory() . '/ultimate-member/templates/' . $file ) ) { $theme_file = get_stylesheet_directory() . '/ultimate-member/templates/' . $file; } if ( ! empty( $theme_file ) ) { if ( ! empty( $located ) ) { $core_path = $located['core']; } else { $core_path = UM_PATH . 'templates/' . $file; } $files_in_theme[] = array( 'core' => $core_path, 'theme' => $theme_file, ); } } } } return $files_in_theme; } public function is_outdated_template_exist() { $outdated_exists = false; $templates = $this->get_custom_templates_list(); foreach ( $templates as $files ) { if ( ! array_key_exists( 'core', $files ) || ! array_key_exists( 'theme', $files ) ) { continue; } $core_path = $files['core']; $theme_file = $files['theme']; $core_version = self::get_file_version( $core_path ); $theme_version = self::get_file_version( $theme_file ); if ( '' === $theme_version || version_compare( $theme_version, $core_version, '<' ) ) { $outdated_exists = true; break; } } return $outdated_exists; } public function build_templates_data() { $templates_data = array(); // Get from cache if isn't empty and request isn't force. $transient = get_transient( 'um_custom_templates_list' ); if ( false !== $transient && array_key_exists( 'data', $transient ) ) { return $transient['data']; } $templates = $this->get_custom_templates_list(); foreach ( $templates as $files ) { if ( ! array_key_exists( 'core', $files ) || ! array_key_exists( 'theme', $files ) ) { continue; } $core_path = $files['core']; $theme_file = $files['theme']; $core_version = self::get_file_version( $core_path ); $theme_version = self::get_file_version( $theme_file ); $status = esc_html__( 'Theme version up to date', 'ultimate-member' ); $status_code = 1; if ( '' === $theme_version ) { $status = esc_html__( 'Theme version is empty', 'ultimate-member' ); $status_code = 0; } elseif ( version_compare( $theme_version, $core_version, '<' ) ) { $status = esc_html__( 'Theme version is out of date', 'ultimate-member' ); $status_code = 0; } $templates_data[] = array( 'core_version' => $core_version, 'theme_version' => $theme_version, 'core_file' => stristr( $core_path, 'wp-content' ), 'theme_file' => stristr( $theme_file, 'wp-content' ), 'status' => $status, 'status_code' => $status_code, ); } // Cache results via transient setting. $transient = array( 'data' => $templates_data, 'time' => time(), ); set_transient( 'um_custom_templates_list', $transient, 5 * MINUTE_IN_SECONDS ); return $templates_data; } }