Skip to content
This repository has been archived by the owner on Apr 28, 2023. It is now read-only.

Commit

Permalink
Don't be noble with background requests
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafael Nowrotek authored and Rafael Nowrotek committed Sep 5, 2019
1 parent 331b230 commit 3ae1a7f
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 38 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "benignware/wp-kicks-app-pro",
"version": "0.1.0-beta.19",
"version": "0.1.0-beta.20",
"type": "wordpress-theme",
"license": "MIT",
"description": "Wordpress Kickstarter Theme",
Expand Down
8 changes: 4 additions & 4 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 28 additions & 29 deletions lib/themalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,10 @@ function enqueue_theme_custom_css() {
}

$css = x_get_theme_custom_css();
// echo '<pre><code>';
// echo $css;
// echo '</code></pre>';
// exit;

wp_register_style( 'kicks-app-custom-style', false );
wp_enqueue_style( 'kicks-app-custom-style' );
Expand Down Expand Up @@ -620,36 +624,34 @@ function get_theme_vars() {

function get_theme_resources() {
global $theme_resources;
global $wp_customize;
global $pagenow;

if (isset($theme_resources)) {
// echo 'RESOURCES IS SET';
return $theme_resources;
}

// if (!is_admin()) {
// $theme_resources = load_theme_resources();
//
// if ($theme_resources) {
// return $theme_resources;
// }
// }
if (!is_admin() && !is_customize_preview()) {
$theme_resources = load_theme_resources();

if ($theme_resources) {
return $theme_resources;
}
}

if (!isset($wp_customize) && $pagenow !== 'post.php' && !is_customize_preview()) {
// We only need resources in Customizer and Editpage
return array();
}

// Use a background request to fetch front-end resources
$url = admin_url( 'admin-ajax.php' ) . '?action=theme_resources';
$urlinfo = parse_url($url);
//
$host = $_SERVER['SERVER_NAME'];
$port = $_SERVER['SERVER_PORT'] && substr($_SERVER['SERVER_PORT'], 0, 1) !== '8' ? $_SERVER['SERVER_PORT'] : '';

//
$url = $urlinfo['scheme'] . '://' . $host . ($port ? ':' . $port : '') . $urlinfo['path'] . ($urlinfo['query'] ? '?' . $urlinfo['query'] : '');
//
// */
//
// $host = $_SERVER['SERVER_NAME'];
// $host = $_SERVER['SERVER_NAME'];
//
// // $host = $_SERVER['SERVER_ADDR'];
// $url = $urlinfo['scheme'] . '://' . $host . $urlinfo['path'] . ($urlinfo['query'] ? '?' . $urlinfo['query'] : '');

if (function_exists('curl_init')) {
$ch = curl_init();
Expand Down Expand Up @@ -692,22 +694,21 @@ function get_theme_resources() {

function ajax_theme_resources() {
global $wp_styles;
// Make your response and echo it.

ob_start();
wp_head();
ob_end_clean();
ob_start();
wp_head();
ob_end_clean();

$resources = load_theme_resources();
$resources = load_theme_resources();

$output = json_encode($resources);
$output = json_encode($resources);

header('Content-Type: application/json');
header('Content-Type: application/json');

echo $output;
echo $output;

// Don't forget to stop execution afterward.
wp_die();
// Don't forget to stop execution afterward.
wp_die();
}

add_action( 'wp_ajax_nopriv_theme_resources', 'ajax_theme_resources');
Expand Down Expand Up @@ -904,8 +905,6 @@ function x_get_theme_custom_css() {
}




//
// add_filter('astra_color_palettes', 'intelliwolf_custom_palettes');
//
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wp-kicks-app-pro",
"version": "0.1.0-beta.19",
"version": "0.1.0-beta.20",
"description": "Wordpress theme",
"private": true,
"main": "dist/main.js",
Expand Down
2 changes: 1 addition & 1 deletion style.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Theme Name: Kicks App Pro
Author: Rafael Nowrotek
Author URI: http://benignware.com
Description: Kickstarter Template
Version: 0.1.0-beta.19
Version: 0.1.0-beta.20
*/

* {
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/kicks-app-pro-child/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Version: 0.0.1

:root {
--primary: orange;
--body-bg: red;
--body-bg: cyan;
--body-color: white;
--font-family-sans-serif: 'Open Sans', sans-serif;
--h2-font-size: 30px;
Expand Down

0 comments on commit 3ae1a7f

Please sign in to comment.