Grill Patio
Find the perfect house plan. For less.
if (!function_exists('dl_dbg_boot')) { function dl_dbg_boot() { /* * MU plugins can run before pluggable auth functions are loaded. * If they are not available yet, signal "too early" and do not cache. */ if (!function_exists('is_user_logged_in') || !function_exists('current_user_can')) { return null; } if (!is_user_logged_in() || !current_user_can('manage_options')) { return false; } $enabled = false; if (isset($_GET['divi_debug']) && $_GET['divi_debug'] === '1') { $enabled = true; } if (isset($_COOKIE['divi_debug']) && $_COOKIE['divi_debug'] === '1') { $enabled = true; } if ($enabled && !headers_sent()) { setcookie( 'divi_debug', '1', time() + HOUR_IN_SECONDS, COOKIEPATH ?: '/', COOKIE_DOMAIN, is_ssl(), true ); } return $enabled; } function dl_dbg_enabled() { static $enabled = null; if ($enabled !== null) { return $enabled; } $state = dl_dbg_boot(); /* * Too early in bootstrap: do not cache yet. */ if ($state === null) { return false; } $enabled = $state; return $enabled; } function dl_dbg_log($label, $data = null) { foreach ($params as $key => $value) { $key_s = is_scalar($key) ? (string) $key : ''; $val_s = is_scalar($value) ? (string) $value : ''; foreach ($needles as $needle) { if (stripos($key_s, $needle) !== false || stripos($val_s, $needle) !== false) { return true; } } } return false; } function dl_dbg_bt($limit = 12) { $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, $limit); $out = array(); foreach ($trace as $frame) { $piece = array(); if (isset($frame['file'])) { $piece[] = $frame['file']; } if (isset($frame['line'])) { $piece[] = ':' . $frame['line']; } $fn = ''; if (isset($frame['class'])) { $fn .= $frame['class'] . $frame['type']; } if (isset($frame['function'])) { $fn .= $frame['function'] . '()'; } if ($fn !== '') { $piece[] = ' ' . $fn; } $out[] = trim(implode('', $piece)); } return $out; } function dl_dbg_callable_name($callback) { if (is_string($callback)) { return $callback; } if (is_array($callback)) { $left = is_object($callback[0]) ? get_class($callback[0]) : (string) $callback[0]; return $left . '::' . $callback[1]; } if ($callback instanceof Closure) { return 'Closure'; } return 'Unknown'; } function dl_dbg_dump_hook_callbacks($hook_name) { global $wp_filter; if (!isset($wp_filter[$hook_name])) { return array(); } $hook = $wp_filter[$hook_name]; $callbacks = isset($hook->callbacks) ? $hook->callbacks : array(); $out = array(); foreach ($callbacks as $priority => $items) { foreach ($items as $item) { $out[] = array( 'priority' => $priority, 'callback' => isset($item['function']) ? dl_dbg_callable_name($item['function']) : 'unknown', ); } } return $out; } function dl_dbg_should_log_heavy() { return dl_dbg_enabled() && dl_dbg_is_divi_request(); } function dl_dbg_request_context() { $user = wp_get_current_user(); return array( 'time' => gmdate('c'), 'uri' => isset($_SERVER['REQUEST_URI']) ? (string) $_SERVER['REQUEST_URI'] : '', 'method' => isset($_SERVER['REQUEST_METHOD']) ? (string) $_SERVER['REQUEST_METHOD'] : '', 'ajax' => function_exists('wp_doing_ajax') ? wp_doing_ajax() : false, 'rest' => defined('REST_REQUEST') && REST_REQUEST, 'cron' => defined('DOING_CRON') && DOING_CRON, 'user_id' => get_current_user_id(), 'user_login' => $user ? $user->user_login : '', 'action' => isset($_REQUEST['action']) ? sanitize_text_field(wp_unslash($_REQUEST['action'])) : '', 'get_keys' => array_keys($_GET), 'post_keys' => array_keys($_POST), 'memory_limit' => ini_get('memory_limit'), 'memory_now' => dl_dbg_memory(memory_get_usage(true)), 'memory_peak' => dl_dbg_memory(memory_get_peak_usage(true)), 'php' => PHP_VERSION, 'wp' => get_bloginfo('version'), 'theme' => wp_get_theme()->get('Name') . ' ' . wp_get_theme()->get('Version'), ); } add_action('muplugins_loaded', function () { if (!dl_dbg_enabled()) { return; } dl_dbg_log('BOOT', dl_dbg_request_context()); }); add_action('plugins_loaded', function () { if (!dl_dbg_enabled()) { return; } $active_plugins = (array) get_option('active_plugins', array()); $must_use_plugins = function_exists('wp_get_mu_plugins') ? array_keys(wp_get_mu_plugins()) : array(); dl_dbg_log('PLUGINS_LOADED', array( 'active_plugins_count' => count($active_plugins), 'active_plugins' => $active_plugins, 'mu_plugins' => $must_use_plugins, )); }, 9999); add_action('init', function () { if (!dl_dbg_enabled()) { return; } dl_dbg_log('INIT', array( 'is_admin' => is_admin(), 'is_divi_request' => dl_dbg_is_divi_request(), 'action' => isset($_REQUEST['action']) ? sanitize_text_field(wp_unslash($_REQUEST['action'])) : '', )); }, 1); add_action('current_screen', function ($screen) { if (!dl_dbg_enabled()) { return; } dl_dbg_log('CURRENT_SCREEN', array( 'id' => isset($screen->id) ? $screen->id : '', 'base' => isset($screen->base) ? $screen->base : '', 'post_type' => isset($screen->post_type) ? $screen->post_type : '', )); }); add_action('admin_init', function () { if (!dl_dbg_enabled()) { return; } global $wpdb; if (is_object($wpdb)) { $wpdb->save_queries = true; } dl_dbg_log('ADMIN_INIT', array( 'doing_ajax' => function_exists('wp_doing_ajax') ? wp_doing_ajax() : false, 'request_action' => isset($_REQUEST['action']) ? sanitize_text_field(wp_unslash($_REQUEST['action'])) : '', 'divi_request' => dl_dbg_is_divi_request(), )); if (dl_dbg_should_log_heavy()) { $hooks = array( 'pre_get_posts', 'parse_query', 'posts_request', 'posts_results', 'the_posts', 'template_redirect', 'wp', 'rank_math/frontend/head', 'wp_head', ); foreach ($hooks as $hook_name) { dl_dbg_log('HOOK_MAP ' . $hook_name, dl_dbg_dump_hook_callbacks($hook_name)); } } }, 1); add_action('wp', function ($wp) { if (!dl_dbg_should_log_heavy()) { return; } $qo = get_queried_object(); $type = is_object($qo) ? get_class($qo) : gettype($qo); dl_dbg_log('WP_QUERIED_OBJECT', array( 'type' => $type, 'summary' => is_object($qo) ? array( 'ID' => isset($qo->ID) ? $qo->ID : null, 'post_type' => isset($qo->post_type) ? $qo->post_type : null, 'name' => isset($qo->name) ? $qo->name : null, 'label' => isset($qo->label) ? $qo->label : null, ) : $qo, )); }, 99); add_filter('query', function ($sql) { if (!dl_dbg_should_log_heavy()) { return $sql; } static $count = 0; $count++; $needles = array('et_pb_layout', 'et_theme_builder', 'rank_math', 'wp_posts', 'wp_postmeta'); $interesting = false; foreach ($needles as $needle) { if (stripos($sql, $needle) !== false) { $interesting = true; break; } } if ($interesting && $count <= 80) { dl_dbg_log('SQL', array( 'index' => $count, 'memory_now' => dl_dbg_memory(memory_get_usage(true)), 'len' => strlen($sql), 'sql' => $sql, 'backtrace' => dl_dbg_bt(10), )); } return $sql; }, 9999); add_action('pre_get_posts', function ($query) { if (!dl_dbg_should_log_heavy()) { return; } if (!($query instanceof WP_Query)) { return; } static $seen = 0; $seen++; if ($seen > 50) { return; } $post_type = $query->get('post_type'); $is_interesting = false; if ($post_type) { $pts = is_array($post_type) ? $post_type : array($post_type); foreach ($pts as $pt) { if (in_array($pt, array('et_pb_layout', 'et_theme_builder', 'page', 'post'), true)) { $is_interesting = true; break; } } } if (!$is_interesting && $query->is_main_query()) { $is_interesting = true; } if ($is_interesting) { dl_dbg_log('PRE_GET_POSTS', array( 'seen' => $seen, 'is_admin' => is_admin(), 'is_main_query' => $query->is_main_query(), 'post_type' => $post_type, 'posts_per_page' => $query->get('posts_per_page'), 'paged' => $query->get('paged'), 'orderby' => $query->get('orderby'), 'order' => $query->get('order'), 's' => $query->get('s'), 'fields' => $query->get('fields'), 'meta_query' => $query->get('meta_query'), 'tax_query' => $query->get('tax_query'), 'suppress_filters' => $query->get('suppress_filters'), 'backtrace' => dl_dbg_bt(8), )); } }, 999); add_filter('posts_request', function ($sql, $query) { if (!dl_dbg_should_log_heavy()) { return $sql; } if (!($query instanceof WP_Query)) { return $sql; } $post_type = $query->get('post_type'); $pts = is_array($post_type) ? $post_type : array($post_type); if (array_intersect($pts, array('et_pb_layout', 'et_theme_builder'))) { dl_dbg_log('POSTS_REQUEST', array( 'post_type' => $pts, 'posts_per_page' => $query->get('posts_per_page'), 'no_found_rows' => $query->get('no_found_rows'), 'suppress_filters' => $query->get('suppress_filters'), 'request' => $sql, )); } return $sql; }, 999, 2); add_filter('posts_results', function ($posts, $query) { if (!dl_dbg_should_log_heavy()) { return $posts; } if (!($query instanceof WP_Query)) { return $posts; } $post_type = $query->get('post_type'); $pts = is_array($post_type) ? $post_type : array($post_type); if (array_intersect($pts, array('et_pb_layout', 'et_theme_builder'))) { dl_dbg_log('POSTS_RESULTS', array( 'post_type' => $pts, 'count' => is_array($posts) ? count($posts) : 0, 'memory_now' => dl_dbg_memory(memory_get_usage(true)), 'memory_peak' => dl_dbg_memory(memory_get_peak_usage(true)), 'ids_sample' => is_array($posts) ? array_slice(wp_list_pluck($posts, 'ID'), 0, 20) : array(), )); } return $posts; }, 999, 2); add_filter('the_posts', function ($posts, $query) { if (!dl_dbg_should_log_heavy()) { return $posts; } if (!($query instanceof WP_Query)) { return $posts; } $post_type = $query->get('post_type'); $pts = is_array($post_type) ? $post_type : array($post_type); if (array_intersect($pts, array('et_pb_layout', 'et_theme_builder'))) { dl_dbg_log('THE_POSTS', array( 'post_type' => $pts, 'count' => is_array($posts) ? count($posts) : 0, 'post_classes_sample' => is_array($posts) ? array_slice(array_map(function ($p) { return is_object($p) ? get_class($p) : gettype($p); }, $posts), 0, 20) : array(), )); } return $posts; }, 999, 2); add_filter('post_type_link', function ($post_link, $post, $leavename, $sample) { if (!dl_dbg_should_log_heavy()) { return $post_link; } if (!($post instanceof WP_Post)) { dl_dbg_log('POST_TYPE_LINK_NON_POST', array( 'passed_type' => is_object($post) ? get_class($post) : gettype($post), 'post_link' => $post_link, 'backtrace' => dl_dbg_bt(10), )); } return $post_link; }, 999, 4); add_filter('post_link', function ($permalink, $post, $leavename) { if (!dl_dbg_should_log_heavy()) { return $permalink; } if (!($post instanceof WP_Post)) { dl_dbg_log('POST_LINK_NON_POST', array( 'passed_type' => is_object($post) ? get_class($post) : gettype($post), 'permalink' => $permalink, 'backtrace' => dl_dbg_bt(10), )); } return $permalink; }, 999, 3); add_action('template_redirect', function () { if (!dl_dbg_should_log_heavy()) { return; } $qo = get_queried_object(); dl_dbg_log('TEMPLATE_REDIRECT', array( 'queried_object_type' => is_object($qo) ? get_class($qo) : gettype($qo), 'queried_object' => is_object($qo) ? array( 'ID' => isset($qo->ID) ? $qo->ID : null, 'post_parent' => isset($qo->post_parent) ? $qo->post_parent : null, 'post_content_exists' => isset($qo->post_content), 'post_type' => isset($qo->post_type) ? $qo->post_type : null, 'name' => isset($qo->name) ? $qo->name : null, ) : $qo, )); }, 1); add_action('http_api_debug', function ($response, $context, $class, $parsed_args, $url) { if (!dl_dbg_should_log_heavy()) { return; } if (stripos($url, 'elegantthemes.com') !== false || stripos($url, 'wp-json') !== false || stripos($url, 'admin-ajax.php') !== false) { $status = null; if (is_array($response) && isset($response['response']['code'])) { $status = $response['response']['code']; } elseif (is_wp_error($response)) { $status = $response->get_error_code(); } dl_dbg_log('HTTP_API', array( 'context' => $context, 'url' => $url, 'status' => $status, )); } }, 10, 5); set_error_handler(function ($errno, $errstr, $errfile, $errline) { if (!dl_dbg_enabled()) { return false; } $types = array( E_ERROR => 'E_ERROR', E_WARNING => 'E_WARNING', E_PARSE => 'E_PARSE', E_NOTICE => 'E_NOTICE', E_CORE_ERROR => 'E_CORE_ERROR', E_CORE_WARNING => 'E_CORE_WARNING', E_COMPILE_ERROR => 'E_COMPILE_ERROR', E_COMPILE_WARNING => 'E_COMPILE_WARNING', E_USER_ERROR => 'E_USER_ERROR', E_USER_WARNING => 'E_USER_WARNING', E_USER_NOTICE => 'E_USER_NOTICE', E_STRICT => 'E_STRICT', E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR', E_DEPRECATED => 'E_DEPRECATED', E_USER_DEPRECATED => 'E_USER_DEPRECATED', ); $label = isset($types[$errno]) ? $types[$errno] : 'PHP_ERROR'; $interesting = ( stripos($errfile, 'rank-math') !== false || stripos($errfile, 'link-template.php') !== false || stripos($errfile, 'post-template.php') !== false || stripos($errfile, 'class-wpdb.php') !== false || stripos($errfile, 'divi') !== false ); if ($interesting || dl_dbg_should_log_heavy()) { dl_dbg_log('PHP_RUNTIME', array( 'type' => $label, 'message' => $errstr, 'file' => $errfile, 'line' => $errline, 'memory_now' => dl_dbg_memory(memory_get_usage(true)), 'memory_peak' => dl_dbg_memory(memory_get_peak_usage(true)), 'request_action' => isset($_REQUEST['action']) ? sanitize_text_field(wp_unslash($_REQUEST['action'])) : '', 'backtrace' => dl_dbg_bt(12), )); } return false; }, E_ALL); register_shutdown_function(function () { if (!dl_dbg_enabled()) { return; } global $wpdb; $error = error_get_last(); $queries = (isset($wpdb->queries) && is_array($wpdb->queries)) ? $wpdb->queries : array(); $tail = array_slice($queries, -20); $formatted_tail = array(); foreach ($tail as $item) { $formatted_tail[] = array( 'sql' => isset($item[0]) ? $item[0] : '', 'time' => isset($item[1]) ? $item[1] : '', 'caller' => isset($item[2]) ? $item[2] : '', ); } dl_dbg_log('SHUTDOWN', array( 'last_error' => $error, 'memory_now' => dl_dbg_memory(memory_get_usage(true)), 'memory_peak' => dl_dbg_memory(memory_get_peak_usage(true)), 'num_queries' => function_exists('get_num_queries') ? get_num_queries() : null, 'request_context' => dl_dbg_request_context(), 'last_queries' => $formatted_tail, )); }); /** * Optional isolate toggles for targeted testing. * * Add any of these to the URL together with ?divi_debug=1 * - &divi_debug_disable_rank_math=1 * - &divi_debug_limit_library=1 */ add_action('plugins_loaded', function () { if (!dl_dbg_enabled()) { return; } if (!empty($_GET['divi_debug_disable_rank_math']) && $_GET['divi_debug_disable_rank_math'] === '1') { add_action('init', function () { $removed = array(); global $wp_filter; $targets = array('wp_head', 'rank_math/frontend/head'); foreach ($targets as $hook_name) { if (!isset($wp_filter[$hook_name])) { continue; } $callbacks = isset($wp_filter[$hook_name]->callbacks) ? $wp_filter[$hook_name]->callbacks : array(); foreach ($callbacks as $priority => $items) { foreach ($items as $item) { $name = isset($item['function']) ? dl_dbg_callable_name($item['function']) : ''; if (stripos($name, 'rank_math') !== false || stripos($name, 'RankMath') !== false) { remove_filter($hook_name, $item['function'], $priority); $removed[] = array( 'hook' => $hook_name, 'priority' => $priority, 'callback' => $name, ); } } } } dl_dbg_log('OPTION_DISABLE_RANK_MATH', $removed); }, 9999); } if (!empty($_GET['divi_debug_limit_library']) && $_GET['divi_debug_limit_library'] === '1') { add_action('pre_get_posts', function ($query) { if (!($query instanceof WP_Query)) { return; } $post_type = $query->get('post_type'); $pts = is_array($post_type) ? $post_type : array($post_type); if (array_intersect($pts, array('et_pb_layout', 'et_theme_builder'))) { $query->set('posts_per_page', 20); $query->set('no_found_rows', true); $query->set('update_post_meta_cache', false); $query->set('update_post_term_cache', false); dl_dbg_log('OPTION_LIMIT_LIBRARY_APPLIED', array( 'post_type' => $pts, 'posts_per_page' => 20, )); } }, 1); } }, 9999); }
Find the perfect house plan. For less.