PluginExtension.php 966 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. if ( !class_exists('Puc_v4p11_DebugBar_PluginExtension', false) ):
  3. class Puc_v4p11_DebugBar_PluginExtension extends Puc_v4p11_DebugBar_Extension {
  4. /** @var Puc_v4p11_Plugin_UpdateChecker */
  5. protected $updateChecker;
  6. public function __construct($updateChecker) {
  7. parent::__construct($updateChecker, 'Puc_v4p11_DebugBar_PluginPanel');
  8. add_action('wp_ajax_puc_v4_debug_request_info', array($this, 'ajaxRequestInfo'));
  9. }
  10. /**
  11. * Request plugin info and output it.
  12. */
  13. public function ajaxRequestInfo() {
  14. if ( $_POST['uid'] !== $this->updateChecker->getUniqueName('uid') ) {
  15. return;
  16. }
  17. $this->preAjaxRequest();
  18. $info = $this->updateChecker->requestInfo();
  19. if ( $info !== null ) {
  20. echo 'Successfully retrieved plugin info from the metadata URL:';
  21. echo '<pre>', htmlentities(print_r($info, true)), '</pre>';
  22. } else {
  23. echo 'Failed to retrieve plugin info from the metadata URL.';
  24. }
  25. exit;
  26. }
  27. }
  28. endif;