esc_url( admin_url() ), 'settings' => esc_attr( get_option( 'kadence_theme_config' ) ), 'changelog' => $this->get_changelog(), 'proChangelog' => ( class_exists( 'Kadence_Theme_Pro' ) ? $this->get_pro_changelog() : '' ), 'starterTemplates' => ( defined( 'KADENCE_STARTER_TEMPLATES_VERSION' ) ? true : false ), 'ajax_url' => admin_url( 'admin-ajax.php' ), 'ajax_nonce' => wp_create_nonce( 'kadence-ajax-verification' ), 'proURL' => esc_url( \Kadence\kadence()->get_pro_url( 'https://www.kadencewp.com/kadence-theme/premium/', 'https://www.kadencewp.com/kadence-theme/premium/', 'in-app', 'theme-dash' ) ), 'status' => $data_action, 'starterLabel' => $button_label, 'starterImage' => esc_attr( get_template_directory_uri() . '/assets/images/starter-templates-banner.jpeg' ), 'starterURL' => esc_url( class_exists( '\\KadenceWP\\KadenceBlocks\\StellarWP\\Uplink\\Register' ) ? admin_url( 'admin.php?page=kadence-starter-templates' ) : admin_url( 'themes.php?page=kadence-starter-templates' ) ), 'videoImage' => esc_attr( get_template_directory_uri() . '/assets/images/getting-started-video.jpg' ), ) ); if ( function_exists( 'wp_set_script_translations' ) ) { wp_set_script_translations( 'kadence-dashboard', 'kadence' ); } } /** * Get Changelog ( Largely Borrowed From Neve Theme ) */ public function get_changelog() { $changelog = array(); $changelog_path = get_template_directory() . '/changelog.txt'; if ( ! is_file( $changelog_path ) ) { return $changelog; } global $wp_filesystem; if ( ! is_object( $wp_filesystem ) ) { require_once ABSPATH . '/wp-admin/includes/file.php'; WP_Filesystem(); } $changelog_string = $wp_filesystem->get_contents( $changelog_path ); if ( is_wp_error( $changelog_string ) ) { return $changelog; } $changelog = explode( PHP_EOL, $changelog_string ); $releases = []; foreach ( $changelog as $changelog_line ) { if ( empty( $changelog_line ) ) { continue; } if ( substr( ltrim( $changelog_line ), 0, 2 ) === '==' ) { if ( isset( $release ) ) { $releases[] = $release; } $changelog_line = trim( str_replace( '=', '', $changelog_line ) ); $release = array( 'head' => $changelog_line, ); } else { if ( preg_match( '/[*|-]?\s?(\[fix]|\[Fix]|fix|Fix)[:]?\s?\b/', $changelog_line ) ) { //$changelog_line = preg_replace( '/[*|-]?\s?(\[fix]|\[Fix]|fix|Fix)[:]?\s?\b/', '', $changelog_line ); $changelog_line = trim( str_replace( [ '*', '-' ], '', $changelog_line ) ); $release['fix'][] = $changelog_line; continue; } if ( preg_match( '/[*|-]?\s?(\[add]|\[Add]|add|Add)[:]?\s?\b/', $changelog_line ) ) { //$changelog_line = preg_replace( '/[*|-]?\s?(\[add]|\[Add]|add|Add)[:]?\s?\b/', '', $changelog_line ); $changelog_line = trim( str_replace( [ '*', '-' ], '', $changelog_line ) ); $release['add'][] = $changelog_line; continue; } $changelog_line = trim( str_replace( [ '*', '-' ], '', $changelog_line ) ); $release['update'][] = $changelog_line; } } return $releases; } /** * Get Changelog ( Largely Borrowed From Neve Theme ) */ public function get_pro_changelog() { $changelog = array(); if ( ! defined( 'KTP_PATH' ) ) { return $changelog; } $changelog_path = KTP_PATH . '/changelog.txt'; if ( ! is_file( $changelog_path ) ) { return $changelog; } global $wp_filesystem; if ( ! is_object( $wp_filesystem ) ) { require_once ABSPATH . '/wp-admin/includes/file.php'; WP_Filesystem(); } $changelog_string = $wp_filesystem->get_contents( $changelog_path ); if ( is_wp_error( $changelog_string ) ) { return $changelog; } $changelog = explode( PHP_EOL, $changelog_string ); $releases = []; foreach ( $changelog as $changelog_line ) { if ( empty( $changelog_line ) ) { continue; } if ( substr( ltrim( $changelog_line ), 0, 2 ) === '==' ) { if ( isset( $release ) ) { $releases[] = $release; } $changelog_line = trim( str_replace( '=', '', $changelog_line ) ); $release = array( 'head' => $changelog_line, ); } else { if ( preg_match( '/[*|-]?\s?(\[fix]|\[Fix]|fix|Fix)[:]?\s?\b/', $changelog_line ) ) { //$changelog_line = preg_replace( '/[*|-]?\s?(\[fix]|\[Fix]|fix|Fix)[:]?\s?\b/', '', $changelog_line ); $changelog_line = trim( str_replace( [ '*', '-' ], '', $changelog_line ) ); $release['fix'][] = $changelog_line; continue; } if ( preg_match( '/[*|-]?\s?(\[add]|\[Add]|add|Add)[:]?\s?\b/', $changelog_line ) ) { //$changelog_line = preg_replace( '/[*|-]?\s?(\[add]|\[Add]|add|Add)[:]?\s?\b/', '', $changelog_line ); $changelog_line = trim( str_replace( [ '*', '-' ], '', $changelog_line ) ); $release['add'][] = $changelog_line; continue; } $changelog_line = trim( str_replace( [ '*', '-' ], '', $changelog_line ) ); $release['update'][] = $changelog_line; } } return $releases; } /** * Register settings */ public function load_api_settings() { register_setting( 'kadence_theme_config', 'kadence_theme_config', array( 'type' => 'string', 'description' => __( 'Config Kadence Modules', 'kadence' ), 'sanitize_callback' => 'sanitize_text_field', 'show_in_rest' => true, 'default' => '', ) ); } /** * Loads config page */ public function config_page() { ?>