Skip to content

Commit b8b679b

Browse files
committed
get_theme_path uses JSON.
Dependent function changed.
1 parent e8049b3 commit b8b679b

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

‎docs/info.php‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
<script type="text/javascript">
3939
/**
4040
* Perform an AJAX query to get the current theme style sheet.
41+
*
42+
* @since 2.9.0 Function is modified to use JSON with the REST API.
4143
*/
4244
function ajaxGetTheme () {
4345
$.ajax(
@@ -51,10 +53,18 @@ function ajaxGetTheme () {
5153
path: '../css/styles.css'
5254
},
5355
success: function (data) {
54-
if (data.match(/styles.css$/g))
55-
$('style').text( "@import url(../" + data.trim() + ");" );
56+
if ("error" in data)
57+
return;
58+
const path = data["theme_path"].trim();
59+
if (path.endsWith("styles.css")) {
60+
$('style').html(
61+
"@import url(../" + path + ");"
62+
);
63+
}
64+
},
65+
dataType: "json"
5666
}
57-
});
67+
);
5868
}
5969

6070
/**

‎inc/ajax.php‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,9 @@ function get_phonetic_reading($get_req)
139139
function get_theme_path($get_req)
140140
{
141141
chdir('..');
142-
return get_file_path($get_req['path']);
142+
return json_encode(
143+
array("theme_path" => get_file_path($get_req['path']))
144+
);
143145
}
144146

145147
/**

0 commit comments

Comments
 (0)