Changeset 1178131
- Timestamp:
- 06/10/2015 10:51:50 AM (11 years ago)
- Location:
- wpbase-cache/trunk/trunk
- Files:
-
- 2 edited
-
wpbase-cache-admin.php (modified) (7 diffs)
-
wpbase-cache.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wpbase-cache/trunk/trunk/wpbase-cache-admin.php
r989862 r1178131 1 1 <?php 2 2 3 class WPBase_Cache_Admin { 3 4 4 public function __construct() {5 public function __construct() { 5 6 add_action('admin_menu', array($this, 'add_wpbase_cache_page')); 6 7 add_action('admin_init', array($this, 'wpbase_cache_page_init')); … … 16 17 17 18 public function create_wpbase_cache_page() { 18 if ( ! current_user_can('manage_options')) {19 wp_die( __('You do not have sufficient permissions to access this page.'));19 if (!current_user_can('manage_options')) { 20 wp_die(__('You do not have sufficient permissions to access this page.')); 20 21 } 21 22 ?> 22 23 <div class="wrap"> 23 <?php screen_icon(); ?>24 <?php screen_icon(); ?> 24 25 <h2>WPBase Cache</h2> 25 26 <form method="post" action="options.php"> 26 27 <?php 27 settings_fields('wpbase_cache_options');28 do_settings_sections('wpbasecache');28 settings_fields('wpbase_cache_options'); 29 do_settings_sections('wpbasecache'); 29 30 ?> 30 <?php submit_button(); ?>31 <?php submit_button(); ?> 31 32 <a class="button" id="wpbase_cache_flush_all">Empty All Caches</a> 32 33 </form> … … 39 40 40 41 add_settings_section( 41 'wpbase_cache_section', 42 'WPBase Cache Settings', 43 array($this, 'wpbase_cache_section_desc'), 44 'wpbasecache' 42 'wpbase_cache_section', 'WPBase Cache Settings', array($this, 'wpbase_cache_section_desc'), 'wpbasecache' 45 43 ); 46 44 47 45 48 46 49 47 add_settings_field( 50 'wpbase_cache_options_varnish_cache', 51 'Enable Varnish Cache', 52 array($this, 'varnish_cache_input'), 53 'wpbasecache', 54 'wpbase_cache_section' 48 'wpbase_cache_options_varnish_cache', 'Enable Varnish Cache', array($this, 'varnish_cache_input'), 'wpbasecache', 'wpbase_cache_section' 55 49 ); 56 50 51 add_settings_field( 52 'wpbase_cache_options_send_as', 'Send Mail As', array($this, 'send_as_input'), 'wpbasecache', 'wpbase_cache_section' 53 ); 57 54 } 58 55 … … 61 58 } 62 59 63 64 60 public function varnish_cache_input() { 65 61 $options = get_option('wpbase_cache_options'); 66 62 67 63 $checked = checked(1, $options['varnish_cache'], FALSE); 68 if (!(defined('WPBASE_CACHE_SANDBOX') && WPBASE_CACHE_SANDBOX)) {64 if (!(defined('WPBASE_CACHE_SANDBOX') && WPBASE_CACHE_SANDBOX)) { 69 65 echo "<input id='wpbase_cache_varnish_cache' name='wpbase_cache_options[varnish_cache]' type='checkbox' value='1' $checked />"; 70 66 } else { 71 67 echo "<input id='wpbase_cache_varnish_cache' disabled='disabled' name='wpbase_cache_options[varnish_cache]' type='checkbox' value='1' $checked />"; 68 } 69 } 70 71 public function send_as_input() { 72 $options = get_option('wpbase_cache_options'); 73 74 if($options['send_as']!=''){ 75 $send_as= $options['send_as']; 76 } 77 if (!(defined('WPBASE_CACHE_SANDBOX') && WPBASE_CACHE_SANDBOX)) { 78 echo "<input id='wpbase_cache_send_as' name='wpbase_cache_options[send_as]' type='text' value='$send_as' />@yourdomain.com <br /><font color='gray'> Leave field empty to disable this feature.</font>"; 79 } else { 80 echo "<input id='wpbase_cache_send_as' disabled='disabled' name='wpbase_cache_options[send_as]' type='checkbox' value='1' />"; 72 81 } 73 82 } … … 77 86 ?> 78 87 <script type="text/javascript" > 79 jQuery(document).ready(function($) {88 jQuery(document).ready(function($) { 80 89 81 $('#wpbase_cache_flush_all').click(function(){82 var element = $(this);83 var data = {84 action: 'wpbase_cache_flush_all',85 _ajax_nonce: '<?php echo $nonce; ?>'86 };90 $('#wpbase_cache_flush_all').click(function() { 91 var element = $(this); 92 var data = { 93 action: 'wpbase_cache_flush_all', 94 _ajax_nonce: '<?php echo $nonce; ?>' 95 }; 87 96 88 $.post(ajaxurl, data, function(response) { 89 if(response == 1) { 90 message = 'Sucessfully flushed all caches'; 91 } else if(response == -1) { 92 message = 'Unauthorised request'; 93 } else { 94 message = response; 95 } 96 element.replaceWith(message); 97 $.post(ajaxurl, data, function(response) { 98 if (response == 1) { 99 message = 'Sucessfully flushed all caches'; 100 } else if (response == -1) { 101 message = 'Unauthorised request'; 102 } else { 103 message = response; 104 } 105 element.replaceWith(message); 106 }); 97 107 }); 98 108 }); 99 });100 109 </script> 101 110 <?php … … 105 114 check_ajax_referer('wpbase_cache_flush_all'); 106 115 107 if (!current_user_can('manage_options')) {108 wp_die( __('You do not have sufficient permissions to perform this action.'));116 if (!current_user_can('manage_options')) { 117 wp_die(__('You do not have sufficient permissions to perform this action.')); 109 118 } 110 119 … … 118 127 119 128 public function update_options($oldvalue, $newvalue) { 120 129 121 130 } 122 131 -
wpbase-cache/trunk/trunk/wpbase-cache.php
r1175754 r1178131 4 4 Plugin URI: https://github.com/baseapp/wpbase-cache 5 5 Description: A wordpress plugin for using all caches on varnish, nginx, php-fpm stack with php-apc. This plugin includes db-cache-reloaded-fix for dbcache. 6 Version: 1.0.76 Version: 2.0 7 7 Author: Vikrant Datta 8 8 Author URI: http://blog.wpoven.com … … 30 30 //$path = dirname(dirname(dirname(__FILE__))); 31 31 //if(is_file($path.'/db.php')){ 32 //rename($path.'/db.php',$path.'/db_old.php');32 // rename($path.'/db.php',$path.'/db_old.php'); 33 33 //} 34 34 function upon_activation(){ … … 62 62 'db_cache' => '0', 63 63 'varnish_cache' => '1', 64 'send_as' => 'noreply' 64 65 //'reject_url' => '', 65 66 //'reject_cookie' => '', … … 77 78 'db_cache' => '0', 78 79 'varnish_cache' => '0', 80 'send_as' =>'0' 79 81 //'reject_url' => '', 80 82 //'reject_cookie' => '', … … 183 185 } 184 186 } 187 188 add_filter('wp_mail_from', 'mail_from'); 189 add_filter('wp_mail_from_name', 'mail_from_name'); 190 function mail_from($email){ 191 192 $options = get_option('wpbase_cache_options'); 193 $send_as = $options['send_as']; 194 if($send_as != ''){ 195 $sitename = strtolower($_SERVER['SERVER_NAME']); 196 $sitename = str_replace('www.','',$sitename); 197 if($_SERVER['SERVER_PORT'] == '8080'){ 198 $dom = explode('/',$_SERVER['REQUEST_URI']); 199 return $send_as.'@'.$dom[1]; 200 } 201 else{ 202 return $send_as.'@'.$sitename; 203 } 204 205 //$sitename = substr($sitename,0,4)=='www.' ? substr($sitename, 4) : $sitename; 206 } 207 208 } 209 function mail_from_name($name){ 210 $options = get_option('wpbase_cache_options'); 211 $send_as = $options['send_as']; 212 if($send_as != ''){ 213 return $send_as; 214 } 215 216 }
Note: See TracChangeset
for help on using the changeset viewer.