%PDF- %PDF-
| Direktori : /dom405686/wp-content/plugins/pws-core/ |
| Current File : /dom405686/wp-content/plugins/pws-core/cORe.php |
<?php
/**
* Plugin Name: GD cORe
* Description: Brings in a whole set of tools and settings for GoDaddy Websites
* Version: 4.1.16
* Author: GoDaddy
* Author URI: https://www.godaddy.com/websites/web-design
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Text Domain: GD cORe
* Domain Path: /languages.
*/
if ( !defined( 'ABSPATH' ) ) {
exit;
}
/*
* Currently plugin version.
*/
define( 'GD_cORe_VERSION', '4.1.16' );
define( 'GD_cORe_USAGE', 'production' );
define( 'GD_cORe_ROOT_PATH_FILE', __FILE__ );
define( 'GD_cORe_ROOT_PATH', plugin_dir_path( __FILE__ ) );
require_once GD_cORe_ROOT_PATH.'includes/class-GD-cORe-site-auth.php';
define( 'GD_CORE_API_BASE', 'https://gdcore.api.godaddy.com/v1/' );
// Legacy unsigned accountId; the fallback is for local installations only.
// Signed requests use GD_cORe_Site_Auth::account_id() (GD_ACCOUNT_UID).
define( 'GD_ACCOUNT_ID_IN_CORE', defined('GD_ACCOUNT_ID') ? GD_ACCOUNT_ID : 'c9b1d6e2-1234-4a7d-b890-abcdef123456' );
/**
* Activation Function.
*/
function activate_GD_cORe() {
require_once plugin_dir_path( __FILE__ ).'includes/class-GD-cORe-activator.php';
GD_cORe_Activator::activate();
}
/**
* Deactivation Function.
*/
function deactivate_GD_cORe() {
require_once plugin_dir_path( __FILE__ ).'includes/class-GD-cORe-deactivator.php';
GD_cORe_Deactivator::deactivate();
}
register_activation_hook( __FILE__, 'activate_GD_cORe' );
register_deactivation_hook( __FILE__, 'deactivate_GD_cORe' );
function gd_core_init() {
/**
* The core plugin class.
*/
require GD_cORe_ROOT_PATH.'includes/class-GD-cORe.php';
$plugin = new GD_cORe();
$plugin->run();
}
add_action( 'init', 'gd_core_init' );
//Loads our Beaver builder templates
function gd_core_fl_templates_core_load() {
/*
* Return if the builder isn't installed or if the current
* version doesn't support registering templates.
*/
if ( !class_exists( 'FLBuilder' ) || !method_exists( 'FLBuilder', 'register_templates' ) ) {
return;
}
/*
* Register the path to the templates.dat file.
*/
FLBuilder::register_templates( GD_cORe_ROOT_PATH.'admin/assets/data/templates.dat', array(
'group' => 'WDS',
));
}
add_action( 'plugins_loaded', 'gd_core_fl_templates_core_load' );
function remove_default_bb_templates($templates) {
$custom_templates = array();
foreach ($templates as $template) {
// Check if the template belongs to the custom group
if (isset($template->group) && $template->group === 'WDS') {
$custom_templates[] = $template;
}
}
return $custom_templates;
}
add_filter('fl_builder_get_templates', 'remove_default_bb_templates');
/**
* registers our custom field connectors to the DCT data
*/
function register_dct_field_connectors() {
require_once plugin_dir_path( __FILE__ ).'includes/class-GD-cORe-fieldConnectors.php';
$gd_core_field_connectors = new GD_cORe_FieldConnectors();
$gd_core_field_connectors->dct_add_properties();
}
add_action('fl_page_data_add_properties', 'register_dct_field_connectors');
function gd_core_define_revision_limits( $num ) {
return $num > 0 ? $num : 5;
}
add_filter( 'wp_revisions_to_keep', 'gd_core_define_revision_limits', 10 );
/**
* Add custom header to wp-rocket requests - account UID has been registered as token
*/
add_filter('http_request_args', function($args, $url) {
if(!str_contains($url, 'wp-rocket.me')) {
return $args;
}
$args['headers']['X-ACCOUNT-UID'] = GD_ACCOUNT_UID;
return $args;
}, 10, 2);
/**
* Module specific inclusions.
*/
require_once GD_cORe_ROOT_PATH.'modules/page-performance/page-performance.php';
// Add the Lighthouse report view action
add_action('admin_post_view_lighthouse_report', function () {
if (!current_user_can('manage_options') || !isset($_GET['report_id'])) {
wp_die('Unauthorized', 403);
}
// Validated IDs contain only path-safe characters, so they are used as-is.
$report_id = wp_unslash($_GET['report_id']);
if (!GD_cORe_Site_Auth::is_report_id($report_id)) {
wp_die('Invalid report ID.', 400);
}
$audit_class = new \GD_cORe\handlers\Audits();
$response = $audit_class->gdcore_http_response(
'lighthouse/reports/' . $report_id . '?format=reportHtml&accountId=' . GD_cORe_Site_Auth::account_id(),
'GET'
);
// Never echo GDCore error bodies or transport errors into the page.
if (is_wp_error($response)) {
wp_die('Failed to load report.', 502);
}
$status = (int) wp_remote_retrieve_response_code($response);
if ($status === 401 || $status === 403) {
wp_die('This site could not be authorized to load the report.', 502);
}
if ($status === 404) {
wp_die('Report not found.', 404);
}
// Print only an HTML report, never a JSON body or envelope.
$html = wp_remote_retrieve_body($response);
$content_type = wp_remote_retrieve_header($response, 'content-type');
$is_html = is_string($content_type) && stripos($content_type, 'text/html') === 0;
if ($status < 200 || $status >= 300 || $html === '' || !$is_html) {
wp_die('Failed to load report.', 502);
}
header('Cache-Control: no-store');
header('X-Content-Type-Options: nosniff');
header('Content-Type: text/html; charset=utf-8');
echo $html;
exit;
});