W3TCGeneric_AdminNotes

The W3 Total Cache W3TC Generic AdminNotes class.

Defined (1)

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

/Generic_AdminNotes.php  
  1. class Generic_AdminNotes { 
  2. /** 
  3. * @param Config $config 
  4. * @return string 
  5. */ 
  6. function w3tc_notes( $notes ) { 
  7. $c = Dispatcher::config(); 
  8. $state = Dispatcher::config_state(); 
  9. $state_master = Dispatcher::config_state_master(); 
  10. $state_note = Dispatcher::config_state_note(); 
  11.  
  12. /** 
  13. * Check wp-content permissions 
  14. */ 
  15. if ( !W3TC_WIN && !$state_master->get_boolean( 'common.hide_note_wp_content_permissions' ) ) { 
  16. $wp_content_mode = Util_File::get_file_permissions( WP_CONTENT_DIR ); 
  17.  
  18. if ( $wp_content_mode > 0755 ) { 
  19. $notes['generic_wp_content_writeable'] = sprintf( 
  20. __( '<strong>%s</strong> is write-able. When finished installing the plugin, change the permissions back to the default: <strong>chmod 755 %s</strong>. Permissions are currently %s. %s',  
  21. 'w3-total-cache' ),  
  22. WP_CONTENT_DIR,  
  23. WP_CONTENT_DIR,  
  24. base_convert( Util_File::get_file_permissions( WP_CONTENT_DIR ), 10, 8 ),  
  25. Util_Ui::button_hide_note2( array( 
  26. 'w3tc_default_config_state_master' => 'y',  
  27. 'key' => 'common.hide_note_wp_content_permissions',  
  28. 'value' => 'true' ) ) ); 
  29.  
  30. /** 
  31. * Check Zlib extension 
  32. */ 
  33. if ( !$state_master->get_boolean( 'common.hide_note_no_zlib' ) && 
  34. !function_exists( 'gzencode' ) ) { 
  35. $notes['no_zlib'] = sprintf( 
  36. __( 'Unfortunately the PHP installation is incomplete, the <strong>zlib module is missing</strong>. This is a core PHP module. Notify the server administrator. %s',  
  37. 'w3-total-cache' ),  
  38. Util_Ui::button_hide_note2( array( 
  39. 'w3tc_default_config_state_master' => 'y',  
  40. 'key' => 'common.hide_note_no_zlib',  
  41. 'value' => 'true' ) ) ); 
  42.  
  43. /** 
  44. * Check if Zlib output compression is enabled 
  45. */ 
  46. if ( !$state_master->get_boolean( 'common.hide_note_zlib_output_compression' ) && 
  47. Util_Environment::is_zlib_enabled() ) { 
  48. $notes['zlib_output_compression'] = sprintf( 
  49. __( 'Either the PHP configuration, web server configuration or a script in the WordPress installation has <strong>zlib.output_compression</strong> enabled.<br />Please locate and disable this setting to ensure proper HTTP compression behavior. %s',  
  50. 'w3-total-cache' ),  
  51. Util_Ui::button_hide_note2( array( 
  52. 'w3tc_default_config_state_master' => 'y',  
  53. 'key' => 'common.hide_note_zlib_output_compression',  
  54. 'value' => 'true' ) ) ); 
  55.  
  56. if ( $state_master->get_boolean( 'common.show_note.nginx_restart_required' ) ) { 
  57. $cf = Dispatcher::component( 'CacheFlush' ); 
  58. $notes['nginx_restart_required'] = sprintf( 
  59. __( 'nginx.conf rules have been updated. Please restart nginx server to provide a consistent user experience. %s',  
  60. 'w3-total-cache' ),  
  61. Util_Ui::button_hide_note2( array( 
  62. 'w3tc_default_config_state_master' => 'y',  
  63. 'key' => 'common.show_note.nginx_restart_required',  
  64. 'value' => 'false' ) ) ); 
  65.  
  66. /** 
  67. * Preview mode 
  68. */ 
  69. if ( $c->is_preview() ) { 
  70. $notes['preview_mode'] = sprintf( 
  71. __( 'Preview mode is active: Changed settings will not take effect until preview mode is %s or %s.', 'w3-total-cache' ),  
  72. Util_Ui::button_link( __( 'deploy', 'w3-total-cache' ),  
  73. Util_Ui::url( array( 
  74. 'w3tc_config_preview_deploy' => 'y' ) ) ),  
  75. Util_Ui::button_link( __( 'disable', 'w3-total-cache' ),  
  76. Util_Ui::url( array( 
  77. 'w3tc_config_preview_disable' => 'y' ) ) ) ) . 
  78. '<br /><span class="description">'. 
  79. sprintf( 
  80. __( 'To preview any changed settings (without deploying): %s',  
  81. 'w3-total-cache' ),  
  82. Util_Ui::preview_link() ). 
  83. '</span>'; 
  84.  
  85. /** 
  86. * Show notification after plugin activate/deactivate 
  87. */ 
  88. if ( $state_note->get( 'common.show_note.plugins_updated' ) && 
  89. !is_network_admin() /** flushing under network admin do nothing */ ) { 
  90. $texts = array(); 
  91.  
  92. if ( $c->get_boolean( 'pgcache.enabled' ) ) { 
  93. $texts[] = Util_Ui::button_link( 
  94. __( 'empty the page cache', 'w3-total-cache' ),  
  95. Util_Ui::url( array( 'w3tc_flush_posts' => 'y' ) ) ); 
  96.  
  97. if ( $c->get_boolean( 'minify.enabled' ) ) { 
  98. $texts[] = sprintf( 
  99. __( 'check the %s to maintain the desired user experience',  
  100. 'w3-total-cache' ),  
  101. Util_Ui::button_link( 
  102. __( 'minify settings', 'w3-total-cache' ),  
  103. Util_Ui::url( array( 
  104. 'w3tc_default_config_state_note' => 'y',  
  105. 'key' => 'common.show_note.plugins_updated',  
  106. 'value' => 'false' ) ) ) ); 
  107.  
  108. if ( count( $texts ) ) { 
  109. $notes['some_plugins_activated'] = sprintf( 
  110. __( 'One or more plugins have been activated or deactivated, please %s. %s',  
  111. 'w3-total-cache' ),  
  112. implode( __( ' and ', 'w3-total-cache' ), $texts ),  
  113. Util_Ui::button_hide_note2( array( 
  114. 'w3tc_default_config_state_note' => 'y',  
  115. 'key' => 'common.show_note.plugins_updated',  
  116. 'value' => 'false' ) ) ); 
  117.  
  118.  
  119. /** 
  120. * Show notification when flush_statics needed 
  121. */ 
  122. if ( $c->get_boolean( 'browsercache.enabled' ) && 
  123. $state_note->get( 'common.show_note.flush_statics_needed' ) && 
  124. !is_network_admin() /** flushing under network admin do nothing */ && 
  125. !$c->is_preview() ) { 
  126. $notes['flush_statics_needed'] = sprintf( 
  127. __( 'The setting change(s) made either invalidate the cached data or modify the behavior of the site. %s now to provide a consistent user experience. %s', 'w3-total-cache' ),  
  128. Util_Ui::button_link( 'Empty the static files cache',  
  129. Util_Ui::url( array( 'w3tc_flush_statics' => 'y' ) ) ),  
  130. Util_Ui::button_hide_note2( array( 
  131. 'w3tc_default_config_state_note' => 'y',  
  132. 'key' => 'common.show_note.flush_statics_needed',  
  133. 'value' => 'false' ) ) ); 
  134.  
  135. /** 
  136. * Show notification when flush_posts needed 
  137. */ 
  138. if ( $state_note->get( 'common.show_note.flush_posts_needed' ) && 
  139. !is_network_admin() /** flushing under network admin do nothing */ && 
  140. !$c->is_preview() && 
  141. !isset( $notes['flush_statics_needed'] ) ) { 
  142. $cf = Dispatcher::component( 'CacheFlush' ); 
  143. if ( $cf->flushable_posts() ) { 
  144. $notes['flush_posts_needed'] = sprintf( 
  145. __( 'The setting change(s) made either invalidate the cached data or modify the behavior of the site. %s now to provide a consistent user experience. %s', 'w3-total-cache' ),  
  146. Util_Ui::button_link( 'Empty the page cache',  
  147. Util_Ui::url( array( 'w3tc_flush_posts' => 'y' ) ) ),  
  148. Util_Ui::button_hide_note2( array( 
  149. 'w3tc_default_config_state_note' => 'y',  
  150. 'key' => 'common.show_note.flush_posts_needed',  
  151. 'value' => 'false' ) ) ); 
  152.  
  153. return $notes; 
  154.  
  155.  
  156.  
  157. public function w3tc_errors( $errors ) { 
  158. $state = Dispatcher::config_state(); 
  159. $c = Dispatcher::config(); 
  160.  
  161. /** 
  162. * Check permalinks 
  163. */ 
  164. if ( !$state->get_boolean( 'common.hide_note_no_permalink_rules' ) && 
  165. ( ( $c->get_boolean( 'pgcache.enabled' ) && 
  166. $c->get_string( 'pgcache.engine' ) == 'file_generic' ) || 
  167. ( $c->get_boolean( 'browsercache.enabled' ) && 
  168. $c->get_boolean( 'browsercache.no404wp' ) ) ) && 
  169. !Util_Rule::is_permalink_rules() ) { 
  170. $errors['generic_no_permalinks'] = sprintf( 
  171. __( 'The required directives for fancy permalinks could not be detected, please confirm they are available: <a href="http://codex.wordpress.org/Using_Permalinks#Creating_and_editing_.28.htaccess.29">Creating and editing</a> %s',  
  172. 'w3-total-cache' ),  
  173. Util_Ui::button_hide_note2( array( 
  174. 'w3tc_default_config_state_master' => 'y',  
  175. 'key' => 'common.hide_note_no_permalink_rules',  
  176. 'value' => 'true' ) ) ); 
  177.  
  178. /** 
  179. * Check memcached 
  180. */ 
  181. if ( isset( $errors['memcache_not_responding.details'] ) ) { 
  182. $memcache_error = 
  183. __( 'The following memcached servers are not responding or not running:</p><ul>',  
  184. 'w3-total-cache' ); 
  185.  
  186. foreach ( $errors['memcache_not_responding.details'] as $memcaches_error ) { 
  187. $memcache_error .= '<li>' . $memcaches_error . '</li>'; 
  188.  
  189. $memcache_error .= __( '</ul><p>This message will automatically disappear once the issue is resolved.', 'w3-total-cache' ); 
  190.  
  191. $errors['memcache_not_responding'] = $memcache_error; 
  192. unset( $errors['memcache_not_responding.details'] ); 
  193.  
  194. return $errors;