W3TCExampleExtension_Example_Admin

Backend functionality of an extension.

Defined (1)

The class is defined in the following location(s).

/extension-example/Extension_Example_Admin.php  
  1. class Extension_Example_Admin { 
  2. /** 
  3. * w3tc_extensions filter handler 
  4. * @param array $extensions array of extension descriptors to fill 
  5. * @param Config $config w3-total-cache configuration 
  6. * @return array 
  7. */ 
  8. static public function w3tc_extensions( $extensions, $config ) { 
  9. $extensions['example'] = array ( 
  10. 'name' => 'Example Extension',  
  11. 'author' => 'W3 EDGE',  
  12. 'description' => __( 'Example extension' ),  
  13. 'author_uri' => 'https://www.w3-edge.com/',  
  14. 'extension_uri' => 'https://www.w3-edge.com/',  
  15. 'extension_id' => 'example',  
  16. 'settings_exists' => true,  
  17. 'version' => '1.0',  
  18. 'enabled' => true,  
  19. 'requirements' => '',  
  20. 'path' => 'w3-total-cache-example/Extension_Example.php' 
  21. ); 
  22.  
  23. return $extensions; 
  24.  
  25.  
  26.  
  27. /** 
  28. * Entry point of extension for wp-admin/ requests 
  29. * Called from Extension_Example.php 
  30. */ 
  31. public function run() { 
  32. // handle settings page of this extension 
  33. add_action( 'w3tc_extension_page_example', array( 
  34. $this,  
  35. 'w3tc_extension_page' 
  36. ) ); 
  37.  
  38. // get control when configuration is changed by user 
  39. add_action( 'w3tc_config_ui_save', array( 
  40. $this,  
  41. 'w3tc_config_ui_save' 
  42. ), 10, 2 ); 
  43.  
  44. // Register widget on W3 Total Cache Dashboard page 
  45. add_action( 'w3tc_widget_setup', array( 
  46. $this,  
  47. 'w3tc_widget_setup' 
  48. ) ); 
  49.  
  50. // get control when extension is deactivated 
  51. add_action( 'w3tc_deactivate_extension_example', array( 
  52. $this, 'w3tc_deactivate_extension' ) ); 
  53.  
  54.  
  55.  
  56.  
  57. /** 
  58. * Show settings page 
  59. */ 
  60. public function w3tc_extension_page() { 
  61. include dirname( __FILE__ ) . '/Extension_Example_Page_View.php'; 
  62.  
  63.  
  64.  
  65. /** 
  66. * Get control when configuration is changed by user 
  67. */ 
  68. public function w3tc_config_ui_save( $config, $old_config ) { 
  69. if ( $config->get( array( 'example', 'is_title_postfix' ) ) != 
  70. $old_config->get( array( 'example', 'is_title_postfix' ) ) || 
  71. $config->get( array( 'example', 'title_postfix' ) ) != 
  72. $old_config->get( array( 'example', 'title_postfix' ) ) ) { 
  73. // flush all content caches, since our extension will now alter 
  74. // content 
  75. w3tc_flush_posts(); 
  76.  
  77.  
  78.  
  79. /** 
  80. * Registers widget on W3 Total Cache Dashboard page 
  81. */ 
  82. public function w3tc_widget_setup() { 
  83. $screen = get_current_screen(); 
  84. add_meta_box( 'example', 'example', array( $this, 'widget_content' ),  
  85. $screen, 'normal', 'core' ); 
  86.  
  87.  
  88.  
  89. /** 
  90. * Renders content of widget 
  91. */ 
  92. public function widget_content() { 
  93. echo "Example extension's widget"; 
  94.  
  95.  
  96.  
  97. /** 
  98. * Called when extension is deactivated. 
  99. * Perform a cleanup here 
  100. */ 
  101. public function w3tc_deactivate_extension() {