diff --git a/wp-content/plugins/w3-total-cache/Base_Page_Settings.php b/wp-content/plugins/w3-total-cache/Base_Page_Settings.php new file mode 100644 index 00000000..5c0023ef --- /dev/null +++ b/wp-content/plugins/w3-total-cache/Base_Page_Settings.php @@ -0,0 +1,281 @@ +_config = Dispatcher::config(); + $this->_config_master = Dispatcher::config_master(); + $this->_page = Util_Admin::get_current_page(); + } + + /** + * Render header. + */ + public function options() { + $this->view(); + } + + /** + * Render footer. + */ + public function render_footer() { + include W3TC_INC_OPTIONS_DIR . '/common/footer.php'; + } + + /** + * Returns true if config section is sealed. + * + * @param string $section Config section. + * + * @return boolean + */ + protected function is_sealed( $section ) { + return true; + } + + /** + * Returns true if we edit master config. + * + * @return boolean + */ + protected function is_master() { + return $this->_config->is_master(); + } + + /** + * Prints checkbox with config option value. + * + * @param string $option_id Option ID. + * @param bool $disabled Disabled flag. + * @param string $class_prefix Class prefix. + * @param bool $label Label. + * @param bool $force_value Override value. + */ + protected function checkbox( $option_id, $disabled = false, $class_prefix = '', $label = true, $force_value = null ) { + $disabled = $disabled || $this->_config->is_sealed( $option_id ); + $name = Util_Ui::config_key_to_http_name( $option_id ); + + if ( ! $disabled ) { + echo ''; + } + + if ( $label ) { + echo '
\n"; + + Util_Ui::error_box( $message ); + } + } + + + + function w3tc_notes( $notes ) { + $newrelic_notes = Dispatcher::component( 'Extension_NewRelic_AdminNotes' ); + $notes = array_merge( $notes, + $newrelic_notes->notifications( $this->_config ) ); + + return $notes; + } + + + + /** + * Returns a list of the verification status of the the new relic + * requirements. To be used on the compatibility page + * + * @param unknown $verified_list + * @return array + */ + function verify_compatibility( $verified_list ) { + $nerser = Dispatcher::component( 'Extension_NewRelic_Service' ); + $nr_verified = $nerser->verify_compatibility(); + $verified_list[] = 'New Relic'; + foreach ( $nr_verified as $criteria => $result ) + $verified_list[] = sprintf( "$criteria: %s", $result ); + return $verified_list; + } + + + + public function w3tc_config_save( $config ) { + // frontend activity + $api_key = $config->get_string( array( 'newrelic', 'api_key' ) ); + $is_filled = !empty( $api_key ); + + if ( $is_filled ) { + $monitoring_type = $config->get_string( array( + 'newrelic', 'monitoring_type' ) ); + + if ( $monitoring_type == 'browser' ) { + $v = $config->get_string( array( 'newrelic', + 'browser.application_id' ) ); + $is_filled = !empty( $v ); + } else { + $v = $config->get_string( array( 'newrelic', + 'apm.application_name' ) ); + $is_filled = !empty( $v ); + } + } + + $config->set_extension_active_frontend( 'newrelic', $is_filled ); + } +} diff --git a/wp-content/plugins/w3-total-cache/Extension_NewRelic_Popup.php b/wp-content/plugins/w3-total-cache/Extension_NewRelic_Popup.php new file mode 100644 index 00000000..6ce9d1d1 --- /dev/null +++ b/wp-content/plugins/w3-total-cache/Extension_NewRelic_Popup.php @@ -0,0 +1,93 @@ +render_intro( + array( + 'api_key' => $c->get_string( array( 'newrelic', 'api_key' ) ), + ) + ); + } + + private function render_intro( $details ) { + include W3TC_DIR . '/Extension_NewRelic_Popup_View_Intro.php'; + } + + public function w3tc_ajax_newrelic_list_applications() { + $api_key = Util_Request::get_string( 'api_key' ); + $c = Dispatcher::config(); + $details = array( + 'api_key' => $api_key, + 'monitoring_type' => $c->get_string( array( 'newrelic', 'monitoring_type' ) ), + 'apm.application_name' => $c->get_string( array( 'newrelic', 'apm.application_name' ) ), + 'browser.application_id' => $c->get_string( array( 'newrelic', 'browser.application_id' ) ), + ); + + if ( 'browser' !== $details['monitoring_type'] ) { + $details['monitoring_type'] = 'apm'; + } + + $service = new Extension_NewRelic_Service( $api_key ); + + try { + $api = new Extension_NewRelic_Api( $api_key ); + $details['apm_applications'] = $service->get_applications(); + $details['browser_applications'] = $api->get_browser_applications(); + } catch ( \Exception $ex ) { + $details = array( + 'api_key' => $api_key, + 'error_message' => 'API key verification failed: ' . $ex->getMessage(), + ); + $this->render_intro( $details ); + return; + } + + $details['browser_disabled'] = ! Util_Environment::is_w3tc_pro( $c ); + + include W3TC_DIR . '/Extension_NewRelic_Popup_View_ListApplications.php'; + } + + public function w3tc_ajax_newrelic_apply_configuration() { + $api_key = Util_Request::get_string( 'api_key' ); + $monitoring_type = Util_Request::get_string( 'monitoring_type', 'apm' ); + $apm_application_name = Util_Request::get_string( 'apm_application_name' ); + $browser_application_id = Util_Request::get_string( 'browser_application_id' ); + $c = Dispatcher::config(); + + $c->set( array( 'newrelic', 'api_key' ), $api_key ); + + if ( 'apm' === $monitoring_type ) { + $c->set( array( 'newrelic', 'monitoring_type' ), 'apm' ); + $c->set( array( 'newrelic', 'apm.application_name' ), $apm_application_name ); + } else { + $c->set( array( 'newrelic', 'monitoring_type' ), 'browser' ); + $c->set( array( 'newrelic', 'browser.application_id' ), $browser_application_id ); + } + + $c->save(); + + // flush cached values on api key change to allow to reset it from ui if something goes wrong. + update_option( 'w3tc_nr_account_id', '' ); + update_option( 'w3tc_nr_application_id', '' ); + + $postfix = Util_Admin::custom_message_id( + array(), + array( + 'newrelic_configuration_saved' => 'NewRelic configuration is saved successfully', + ) + ); + + echo esc_url( 'Location admin.php?page=w3tc_general&' . $postfix ); + } +} diff --git a/wp-content/plugins/w3-total-cache/Extension_NewRelic_Popup_View.js b/wp-content/plugins/w3-total-cache/Extension_NewRelic_Popup_View.js new file mode 100644 index 00000000..158aa73d --- /dev/null +++ b/wp-content/plugins/w3-total-cache/Extension_NewRelic_Popup_View.js @@ -0,0 +1,48 @@ +jQuery(function($) { + $('body') + .on('click', '.w3tcnr_configure', function() { + W3tc_Lightbox.open({ + id:'w3tc-overlay', + close: '', + width: 800, + height: 400, + url: ajaxurl + '?action=w3tc_ajax&_wpnonce=' + w3tc_nonce + + '&w3tc_action=newrelic_popup', + }); + }) + + + + .on('click', '.w3tcnr_list_applications', function() { + var url = ajaxurl + '?action=w3tc_ajax&_wpnonce=' + w3tc_nonce + + '&w3tc_action=newrelic_list_applications&api_key=' + + encodeURIComponent($('.w3tcnr_api_key').val()); + W3tc_Lightbox.load(url); + }) + + + + .on('click', '.w3tcnr_apply_configuration', function() { + var url = ajaxurl + '?action=w3tc_ajax&_wpnonce=' + w3tc_nonce + + '&w3tc_action=newrelic_apply_configuration'; + $('.w3tcnr_form').find('input').each(function(i) { + var name = $(this).attr('name'); + var type = $(this).attr('type'); + if (type == 'radio') { + if (!$(this).prop('checked')) + return; + } + + if (name) + url += '&' + encodeURIComponent(name) + '=' + + encodeURIComponent($(this).val()); + }); + $('.w3tcnr_form').find('select').each(function(i) { + var name = $(this).attr('name'); + url += '&' + encodeURIComponent(name) + '=' + + encodeURIComponent($(this).val()); + }); + + W3tc_Lightbox.load(url); + }); +}); diff --git a/wp-content/plugins/w3-total-cache/Extension_NewRelic_Popup_View_Intro.php b/wp-content/plugins/w3-total-cache/Extension_NewRelic_Popup_View_Intro.php new file mode 100644 index 00000000..9a5ed8eb --- /dev/null +++ b/wp-content/plugins/w3-total-cache/Extension_NewRelic_Popup_View_Intro.php @@ -0,0 +1,55 @@ + +' . $transaction . + ' | ' . Util_Ui::secs_to_time( $time ) . + ' |
' . $transaction . + ' | ' . Util_Ui::secs_to_time( $time ) . + ' |
' . $transaction . + ' | ' . Util_Ui::secs_to_time( $time ) . + ' |
+
+ N/A
+
+
+
+ N/A
+
+ + + +
diff --git a/wp-content/plugins/w3-total-cache/Extension_NewRelic_Widget_View_NotConfigured.php b/wp-content/plugins/w3-total-cache/Extension_NewRelic_Widget_View_NotConfigured.php new file mode 100644 index 00000000..b2aee851 --- /dev/null +++ b/wp-content/plugins/w3-total-cache/Extension_NewRelic_Widget_View_NotConfigured.php @@ -0,0 +1,8 @@ +set( array( 'swarmify', 'api_key' ), $swarmcdnkey_val ); + $config->save(); + } + + Util_Environment::redirect( Util_Ui::admin_url( + 'admin.php?page=w3tc_extensions&extension=swarmify&action=view' ) ); + exit(); + } +} diff --git a/wp-content/plugins/w3-total-cache/Extension_Swarmify_Core.php b/wp-content/plugins/w3-total-cache/Extension_Swarmify_Core.php new file mode 100644 index 00000000..a43cc02b --- /dev/null +++ b/wp-content/plugins/w3-total-cache/Extension_Swarmify_Core.php @@ -0,0 +1,21 @@ +first_name . + ( empty( $u->first_name ) ? '' : ' ' ) . + $u->last_name; + + return 'https://www.swarmify.com/landing/w3tc?' . + 'email=' . urlencode( $email ) . + '&name=' . urlencode( $name ) . + '&return=' . + urlencode( wp_nonce_url( Util_Ui::admin_url( 'admin.php' ), 'w3tc' ) . + '&page=w3tc_extensions&w3tc_swarmify_set_key=set' ); + } +} diff --git a/wp-content/plugins/w3-total-cache/Extension_Swarmify_Page.php b/wp-content/plugins/w3-total-cache/Extension_Swarmify_Page.php new file mode 100644 index 00000000..385bb8bc --- /dev/null +++ b/wp-content/plugins/w3-total-cache/Extension_Swarmify_Page.php @@ -0,0 +1,23 @@ +get_string( array( 'swarmify', 'api_key' ) ); + $authorized = !empty( $api_key ); + + $email = get_bloginfo( 'admin_email' ); + $u = wp_get_current_user(); + $name = $u->first_name . + ( empty( $u->first_name ) ? '' : ' ' ) . + $u->last_name; + + $swarmify_signup_url = Extension_Swarmify_Core::signup_url(); + + include W3TC_DIR . '/Extension_Swarmify_Page_View.php'; + } +} diff --git a/wp-content/plugins/w3-total-cache/Extension_Swarmify_Page_View.php b/wp-content/plugins/w3-total-cache/Extension_Swarmify_Page_View.php new file mode 100644 index 00000000..3d4c229a --- /dev/null +++ b/wp-content/plugins/w3-total-cache/Extension_Swarmify_Page_View.php @@ -0,0 +1,81 @@ + + ++ + is_extension_active_frontend( 'swarmify' ) ) { + echo '' . esc_html__( 'enabled', 'w3-total-cache' ) . ''; + } else { + echo '' . esc_html__( 'disabled', 'w3-total-cache' ) . ''; + } + ?> + . +
+ +