2023-06-05 11:23:16 +00:00
|
|
|
<?php
|
2023-12-08 23:23:32 +00:00
|
|
|
/**
|
|
|
|
* File: Cdnfsd_Plugin_Admin.php
|
|
|
|
*
|
|
|
|
* @package W3TC
|
|
|
|
*/
|
|
|
|
|
2023-06-05 11:23:16 +00:00
|
|
|
namespace W3TC;
|
|
|
|
|
2023-12-08 23:23:32 +00:00
|
|
|
/**
|
|
|
|
* Class: Cdnfsd_Plugin_Admin
|
|
|
|
*/
|
2023-06-05 11:23:16 +00:00
|
|
|
class Cdnfsd_Plugin_Admin {
|
2023-12-08 23:23:32 +00:00
|
|
|
/**
|
|
|
|
* Run.
|
|
|
|
*/
|
|
|
|
public function run() {
|
|
|
|
$c = Dispatcher::config();
|
2023-06-05 11:23:16 +00:00
|
|
|
$cdnfsd_engine = $c->get_string( 'cdnfsd.engine' );
|
|
|
|
|
2023-12-08 23:23:32 +00:00
|
|
|
// Attach to actions without firing class loading at all without need.
|
|
|
|
switch ( $cdnfsd_engine ) {
|
|
|
|
case 'cloudfront':
|
|
|
|
add_action( 'w3tc_ajax', array( '\W3TC\Cdnfsd_CloudFront_Popup', 'w3tc_ajax' ) );
|
|
|
|
add_action( 'w3tc_settings_box_cdnfsd', array( '\W3TC\Cdnfsd_CloudFront_Page', 'w3tc_settings_box_cdnfsd' ) );
|
|
|
|
break;
|
|
|
|
case 'limelight':
|
|
|
|
add_action( 'w3tc_ajax', array( '\W3TC\Cdnfsd_LimeLight_Popup', 'w3tc_ajax' ) );
|
|
|
|
add_action( 'w3tc_settings_box_cdnfsd', array( '\W3TC\Cdnfsd_LimeLight_Page', 'w3tc_settings_box_cdnfsd' ) );
|
|
|
|
break;
|
|
|
|
case 'stackpath':
|
|
|
|
add_action( 'w3tc_ajax', array( '\W3TC\Cdnfsd_StackPath_Popup', 'w3tc_ajax' ) );
|
|
|
|
add_action( 'w3tc_settings_box_cdnfsd', array( '\W3TC\Cdnfsd_StackPath_Page', 'w3tc_settings_box_cdnfsd' ) );
|
|
|
|
break;
|
|
|
|
case 'stackpath2':
|
|
|
|
add_action( 'w3tc_ajax', array( '\W3TC\Cdnfsd_StackPath2_Popup', 'w3tc_ajax' ) );
|
|
|
|
add_action( 'w3tc_settings_box_cdnfsd', array( '\W3TC\Cdnfsd_StackPath2_Page', 'w3tc_settings_box_cdnfsd' ) );
|
|
|
|
break;
|
|
|
|
case 'transparentcdn':
|
|
|
|
add_action( 'init', array( '\W3TC\Cdnfsd_TransparentCDN_Page', 'admin_test_api_parameters_transparentcdn' ) );
|
|
|
|
add_action( 'w3tc_settings_box_cdnfsd', array( '\W3TC\Cdnfsd_TransparentCDN_Page', 'w3tc_settings_box_cdnfsd' ) );
|
|
|
|
break;
|
|
|
|
case 'bunnycdn':
|
|
|
|
add_action( 'w3tc_ajax', array( '\W3TC\Cdnfsd_BunnyCdn_Popup', 'w3tc_ajax' ) );
|
|
|
|
add_action( 'w3tc_settings_box_cdnfsd', array( '\W3TC\Cdnfsd_BunnyCdn_Page', 'w3tc_settings_box_cdnfsd' ) );
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2023-06-05 11:23:16 +00:00
|
|
|
}
|
|
|
|
|
2023-12-08 23:23:32 +00:00
|
|
|
add_action( 'w3tc_settings_general_boxarea_cdn_footer', array( $this, 'w3tc_settings_general_boxarea_cdn_footer' ) );
|
2023-06-05 11:23:16 +00:00
|
|
|
}
|
|
|
|
|
2023-12-08 23:23:32 +00:00
|
|
|
/**
|
|
|
|
* Print the general settings page CDN footer.
|
|
|
|
*/
|
2023-06-05 11:23:16 +00:00
|
|
|
public function w3tc_settings_general_boxarea_cdn_footer() {
|
2023-12-08 23:23:32 +00:00
|
|
|
$config = Dispatcher::config();
|
|
|
|
$cdnfsd_enabled = $config->get_boolean( 'cdnfsd.enabled' );
|
|
|
|
$cdnfsd_engine = $config->get_string( 'cdnfsd.engine' );
|
|
|
|
$is_pro = Util_Environment::is_w3tc_pro( $config );
|
2023-06-05 11:23:16 +00:00
|
|
|
$cdnfsd_engine_values = array();
|
2023-12-08 23:23:32 +00:00
|
|
|
$tag = '';
|
|
|
|
|
2023-06-05 11:23:16 +00:00
|
|
|
$cdnfsd_engine_values[''] = array(
|
|
|
|
'label' => 'Select a provider',
|
|
|
|
);
|
2023-12-08 23:23:32 +00:00
|
|
|
|
|
|
|
$cdnfsd_engine_values['bunnycdn'] = array(
|
|
|
|
'label' => __( 'Bunny CDN (recommended)', 'w3-total-cache' ),
|
|
|
|
);
|
|
|
|
|
2023-06-05 11:23:16 +00:00
|
|
|
$cdnfsd_engine_values['cloudfront'] = array(
|
|
|
|
'label' => __( 'Amazon CloudFront', 'w3-total-cache' ),
|
|
|
|
);
|
2023-12-08 23:23:32 +00:00
|
|
|
|
2023-06-05 11:23:16 +00:00
|
|
|
$cdnfsd_engine_values['cloudflare'] = array(
|
|
|
|
'label' => __( 'CloudFlare (extension not activated)', 'w3-total-cache' ),
|
|
|
|
'disabled' => true,
|
|
|
|
);
|
2023-12-08 23:23:32 +00:00
|
|
|
|
2023-06-05 11:23:16 +00:00
|
|
|
$cdnfsd_engine_values['limelight'] = array(
|
|
|
|
'label' => __( 'Limelight', 'w3-total-cache' ),
|
|
|
|
);
|
2023-12-08 23:23:32 +00:00
|
|
|
|
2023-06-05 11:23:16 +00:00
|
|
|
$cdnfsd_engine_values['stackpath'] = array(
|
|
|
|
'label' => __( 'StackPath SecureCDN (Legacy)', 'w3-total-cache' ),
|
|
|
|
);
|
2023-12-08 23:23:32 +00:00
|
|
|
|
2023-06-05 11:23:16 +00:00
|
|
|
$cdnfsd_engine_values['stackpath2'] = array(
|
2023-12-08 23:23:32 +00:00
|
|
|
'label' => __( 'StackPath', 'w3-total-cache' ),
|
2023-06-05 11:23:16 +00:00
|
|
|
);
|
2023-12-08 23:23:32 +00:00
|
|
|
|
2023-06-05 11:23:16 +00:00
|
|
|
$cdnfsd_engine_values['transparentcdn'] = array(
|
|
|
|
'label' => __( 'TransparentCDN', 'w3-total-cache' ),
|
|
|
|
);
|
|
|
|
|
2023-12-08 23:23:32 +00:00
|
|
|
if ( 'cloudfront' === $cdnfsd_engine ) {
|
2023-06-05 11:23:16 +00:00
|
|
|
$tag = 'https://api.w3-edge.com/v1/redirects/faq/cdn-fsd/cloudfront';
|
2023-12-08 23:23:32 +00:00
|
|
|
} elseif ( 'stackpath' === $cdnfsd_engine || 'stackpath2' === $cdnfsd_engine ) {
|
2023-06-05 11:23:16 +00:00
|
|
|
$tag = 'https://api.w3-edge.com/v1/redirects/faq/cdn-fsd/stackpath';
|
|
|
|
}
|
|
|
|
|
2023-12-08 23:23:32 +00:00
|
|
|
$cdnfsd_engine_extra_description = empty( $tag ) ? '' : ' See <a href="' . $tag . '">setup instructions</a>';
|
2023-06-05 11:23:16 +00:00
|
|
|
|
2023-12-08 23:23:32 +00:00
|
|
|
include W3TC_DIR . '/Cdnfsd_GeneralPage_View.php';
|
2023-06-05 11:23:16 +00:00
|
|
|
}
|
|
|
|
}
|