Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implementation of config hints; some restructure; donation link #69

Merged
merged 52 commits into from
Feb 13, 2017
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
894c80f
paypal to donate; nav_tab; excluded settings
timse201 Jan 26, 2017
3e49749
ui page created; deleted valign; paypal to donate
timse201 Jan 26, 2017
94ed0f6
file to include specific conf hints; + links
timse201 Jan 26, 2017
7b2a520
Create cachify.apc.htaccess.php
timse201 Jan 26, 2017
8204e78
Create cachify.apc.nginx.php
timse201 Jan 26, 2017
cddee55
Create cachify.hdd.htaccess.php
timse201 Jan 26, 2017
5eca744
Create cachify.hdd.nginx.php
timse201 Jan 26, 2017
a27bd39
Create cachify.memcached.nginx.php
timse201 Jan 26, 2017
38c87df
Notes added; relative path to wp_content
timse201 Jan 26, 2017
a57bf41
navbar h3 to h2 for better styling
timse201 Jan 27, 2017
f8a8442
Update cachify.settings.php
timse201 Jan 27, 2017
141a8ec
Update cachify.setup.php
timse201 Jan 27, 2017
107b166
take advantage of elseif
timse201 Jan 27, 2017
1fb9b2d
Include correct memcached file
timse201 Jan 27, 2017
b31662a
ACC in htaccess; get_home_path as an example
timse201 Jan 27, 2017
d183996
Notes
timse201 Jan 27, 2017
8760a56
Notes
timse201 Jan 27, 2017
037d5e1
path to plugin dir
timse201 Jan 28, 2017
99b5440
replaced Document_root
timse201 Jan 28, 2017
7bff937
Delete cachify.setup.php
timse201 Jan 28, 2017
cb5946b
enhanced error message; unnessesary code deleted
timse201 Jan 28, 2017
bfc7ec1
Update cachify.apc.htaccess.php
timse201 Jan 28, 2017
a5b4faa
full path
timse201 Jan 28, 2017
b01366a
Update cachify.hdd.htaccess.php
timse201 Jan 28, 2017
93273b6
Update cachify.hdd.nginx.php
timse201 Jan 28, 2017
779ddf3
Update cachify.memcached.nginx.php
timse201 Jan 28, 2017
d0de997
Update cachify.settings.php
timse201 Jan 29, 2017
02a6060
remove unnecessary check
timse201 Jan 29, 2017
7adfe2d
Make usage of an WordPress styled info symbol
timse201 Jan 29, 2017
72a7f15
typo fixed
timse201 Jan 29, 2017
0b55bd1
typo fixed
timse201 Jan 29, 2017
98dff1f
typo fixed
timse201 Jan 29, 2017
70adcc0
https and http
timse201 Jan 30, 2017
2ba89e4
switch to esc_html__
timse201 Jan 30, 2017
4181ce5
update donation link
timse201 Jan 30, 2017
57bdb6c
update donation link
timse201 Jan 30, 2017
d6604ad
update donation link
timse201 Jan 30, 2017
74a55a4
update donation link
timse201 Jan 30, 2017
82da6ef
update donation link
timse201 Jan 30, 2017
ac102e0
update donation link
timse201 Jan 30, 2017
38f0c46
update donation link
timse201 Jan 30, 2017
e2428cd
update donation link
timse201 Jan 30, 2017
d9aff83
update donation link
timse201 Jan 30, 2017
68d352a
note for ipv6 errors
timse201 Jan 31, 2017
95a97f5
acc optional
timse201 Jan 31, 2017
022389f
sanitize URL
timse201 Feb 2, 2017
bcad916
sanitize URL
timse201 Feb 2, 2017
4c7541d
sanitize URL
timse201 Feb 2, 2017
673b0c5
sanitize URL
timse201 Feb 2, 2017
3f1dcd9
sanitize URL
timse201 Feb 2, 2017
d1cf389
sanitize URL
timse201 Feb 2, 2017
ea6a462
make it relative and not an URL
timse201 Feb 2, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
156 changes: 45 additions & 111 deletions inc/cachify.class.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?php


/* Quit */
defined('ABSPATH') OR exit;

Expand Down Expand Up @@ -605,7 +603,8 @@ public static function row_meta($input, $page)
return array_merge(
$input,
array(
'<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LG5VC9KXMAYXJ" target="_blank" rel="noopener noreferrer">PayPal</a>'
'<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LG5VC9KXMAYXJ" target="_blank" rel="noopener noreferrer">' . esc_html__( 'Donate', 'cachify' ) . '</a>',
'<a href="https://wordpress.org/support/plugin/cachify" target="_blank" rel="noopener noreferrer">' . esc_html__( 'Support', 'cachify' ) . '</a>',
)
);
}
Expand Down Expand Up @@ -1679,8 +1678,8 @@ public static function validate_options($data)
'cachify_method_tip',
'cachify_method_tip',
sprintf(
'%s [<a href="https://github.com/pluginkollektiv/cachify/wiki" target="_blank" rel="noopener noreferrer">?</a>]',
esc_html__( 'The server configuration file (e.g. .htaccess) needs to be adjusted', 'cachify' )
'&#8505; %s',
esc_html__( 'The server configuration file (e.g. .htaccess) needs to be adjusted. Please have a look at the Setup-Tab.', 'cachify' )
),
'updated'
);
Expand Down Expand Up @@ -1708,121 +1707,56 @@ public static function validate_options($data)

public static function options_page()
{ ?>
<style>
#cachify_settings input[type="text"],
#cachify_settings input[type="number"] {
height: 30px;
}
</style>

<div class="wrap" id="cachify_settings">
<h2>
<h1>
Cachify
</h2>
</h1>

<form method="post" action="options.php">
<?php settings_fields('cachify') ?>

<?php $options = self::_get_options() ?>

<table class="form-table">
<tr valign="top">
<th scope="row">
<?php esc_html_e( 'Cache method', 'cachify' ); ?>
</th>
<td>
<label for="cachify_cache_method">
<select name="cachify[use_apc]" id="cachify_cache_method">
<?php foreach( self::_method_select() as $k => $v ) { ?>
<option value="<?php echo esc_attr($k) ?>" <?php selected($options['use_apc'], $k); ?>><?php echo esc_html($v) ?></option>
<?php } ?>
</select>
</label>
</td>
</tr>

<tr valign="top">
<th scope="row">
<?php esc_html_e('Cache expiration', 'cachify') ?>
</th>
<td>
<label for="cachify_cache_expires">
<?php if ( $options [ 'use_apc' ] === self::METHOD_HDD): ?>&#8734;
<?php else: ?><input type="number" min="0" step="1" name="cachify[cache_expires]" id="cachify_cache_expires" value="<?php echo esc_attr($options [ 'cache_expires' ] ) ?>" class="small-text" />
<?php endif; ?>
<?php esc_html_e( 'Hours', 'cachify' ); ?>
</label>
</td>
</tr>

<tr valign="top">
<th scope="row">
<?php esc_html_e( 'Cache generation', 'cachify' ); ?>
</th>
<td>
<fieldset>
<label for="cachify_only_guests">
<input type="checkbox" name="cachify[only_guests]" id="cachify_only_guests" value="1" <?php checked('1', $options['only_guests']); ?> />
<?php esc_html_e( 'No cache generation by logged in users', 'cachify' ); ?>
</label>

<br />

<label for="cachify_reset_on_comment">
<input type="checkbox" name="cachify[reset_on_comment]" id="cachify_reset_on_comment" value="1" <?php checked('1', $options['reset_on_comment']); ?> />
<?php esc_html_e( 'Flush the cache at new comments', 'cachify' ); ?>
</label>
</fieldset>
</td>
</tr>

<tr valign="top">
<th scope="row">
<?php esc_html_e( 'Cache exceptions', 'cachify' ); ?>
</th>
<td>
<fieldset>
<label for="cachify_without_ids">
<textarea name="cachify[without_ids]" id="cachify_without_ids" rows="1" placeholder="<?php esc_attr_e( 'e.g. 1,2,3', 'cachify' ); ?>"><?php echo esc_attr($options['without_ids']) ?></textarea>
<?php esc_html_e( 'Post/Pages-IDs (separated by commas)', 'cachify' ); ?>
</label>

<br />

<label for="cachify_without_agents">
<textarea name="cachify[without_agents]" id="cachify_without_agents" rows="1" placeholder="<?php esc_attr_e( 'e.g. MSIE 6, Opera', 'cachify' ); ?>"><?php echo esc_attr($options['without_agents']) ?></textarea>
<?php esc_html_e( 'Browser User-Agents (separated by commas)', 'cachify' ); ?>
</label>
</fieldset>
</td>
</tr>

<tr valign="top">
<th scope="row">
<?php esc_html_e( 'Cache minify', 'cachify' ); ?>
</th>
<td>
<label for="cachify_compress_html">
<select name="cachify[compress_html]" id="cachify_compress_html">
<?php foreach( self::_minify_select() as $k => $v ) { ?>
<option value="<?php echo esc_attr($k) ?>" <?php selected($options['compress_html'], $k); ?>>
<?php echo esc_html($v) ?>
</option>
<?php } ?>
</select>
</label>
</td>
</tr>

<tr valign="top">
<th scope="row">
<?php submit_button() ?>
</th>
<td>
<a href="<?php esc_html_e( 'https://wordpress.org/plugins/cachify/faq/', 'cachify' ); ?>" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'FAQ', 'cachify' ); ?></a> &bull; <a href="https://github.com/pluginkollektiv/cachify/wiki" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Manual', 'cachify' ); ?></a> &bull; <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LG5VC9KXMAYXJ" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'PayPal', 'cachify' ); ?></a> &bull; <a href="https://wordpress.org/support/plugin/cachify" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Support', 'cachify' ); ?></a>
</td>
</tr>
</table>
<?php /* Adds a navbar and includes the specific page */
if ( $options [ 'use_apc' ] !== self::METHOD_DB) {
$cachify_tabs = array('settings' => __('Settings', 'cachify'),
'setup' => __('Setup', 'cachify'),
);

$current_tab = isset($_GET['cachify_tab']) ? $_GET['cachify_tab'] : 'settings';

echo '<h2 class="nav-tab-wrapper">';
foreach($cachify_tabs as $tab => $name){
$class = ($tab == $current_tab) ? ' nav-tab-active' : '';
$link = "?page=cachify&cachify_tab=$tab";
echo "<a class='nav-tab$class' href='$link'>$name</a>";
}
echo '</h2>';

switch ($current_tab){
case 'settings' :
include 'cachify.settings.php';
break;
case 'setup' :
if ( $options [ 'use_apc' ] === self::METHOD_HDD) {
if ($is_nginx) { include 'setup/cachify.hdd.nginx.php'; }
else { include 'setup/cachify.hdd.htaccess.php'; }
}

elseif ( $options [ 'use_apc' ] === self::METHOD_APC) {
if ($is_nginx) { include 'setup/cachify.apc.nginx.php'; }
else { include 'setup/cachify.apc.htaccess.php'; }
}

elseif ( ( $options [ 'use_apc' ] === self::METHOD_MMC) && ($is_nginx) )
{include 'setup/cachify.memcached.nginx.php';
}
break;
}
}
else { include 'cachify.settings.php'; }
?>
</form>
</div><?php
}
Expand Down
106 changes: 106 additions & 0 deletions inc/cachify.settings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<?php
/* Quit */
defined('ABSPATH') OR exit;
?>

<table class="form-table">
<tr>
<th scope="row">
<?php esc_html_e( 'Cache method', 'cachify' ); ?>
</th>
<td>
<label for="cachify_cache_method">
<select name="cachify[use_apc]" id="cachify_cache_method">
<?php foreach( self::_method_select() as $k => $v ) { ?>
<option value="<?php echo esc_attr($k) ?>" <?php selected($options['use_apc'], $k); ?>><?php echo esc_html($v) ?></option>
<?php } ?>
</select>
</label>
</td>
</tr>

<tr>
<th scope="row">
<?php esc_html_e('Cache expiration', 'cachify') ?>
</th>
<td>
<label for="cachify_cache_expires">
<?php if ( $options [ 'use_apc' ] === self::METHOD_HDD): ?>&#8734;
<?php else: ?><input type="number" min="0" step="1" name="cachify[cache_expires]" id="cachify_cache_expires" value="<?php echo esc_attr($options [ 'cache_expires' ] ) ?>" class="small-text" />
<?php endif; ?>
<?php esc_html_e( 'Hours', 'cachify' ); ?>
</label>
</td>
</tr>

<tr>
<th scope="row">
<?php esc_html_e( 'Cache generation', 'cachify' ); ?>
</th>
<td>
<fieldset>
<label for="cachify_only_guests">
<input type="checkbox" name="cachify[only_guests]" id="cachify_only_guests" value="1" <?php checked('1', $options['only_guests']); ?> />
<?php esc_html_e( 'No cache generation by logged in users', 'cachify' ); ?>
</label>

<br />

<label for="cachify_reset_on_comment">
<input type="checkbox" name="cachify[reset_on_comment]" id="cachify_reset_on_comment" value="1" <?php checked('1', $options['reset_on_comment']); ?> />
<?php esc_html_e( 'Flush the cache at new comments', 'cachify' ); ?>
</label>
</fieldset>
</td>
</tr>

<tr>
<th scope="row">
<?php esc_html_e( 'Cache exceptions', 'cachify' ); ?>
</th>
<td>
<fieldset>
<label for="cachify_without_ids">
<textarea name="cachify[without_ids]" id="cachify_without_ids" rows="1" placeholder="<?php esc_attr_e( 'e.g. 1,2,3', 'cachify' ); ?>"><?php echo esc_attr($options['without_ids']) ?></textarea>
<?php esc_html_e( 'Post/Pages-IDs', 'cachify' ); ?>
</label>

<br />

<label for="cachify_without_agents">
<textarea name="cachify[without_agents]" id="cachify_without_agents" rows="1" placeholder="<?php esc_attr_e( 'e.g. MSIE 6, Opera', 'cachify' ); ?>"><?php echo esc_attr($options['without_agents']) ?></textarea>
<?php esc_html_e( 'Browser User-Agents', 'cachify' ); ?>
</label>
</fieldset>
</td>
</tr>

<tr>
<th scope="row">
<?php esc_html_e( 'Cache minify', 'cachify' ); ?>
</th>
<td>
<label for="cachify_compress_html">
<select name="cachify[compress_html]" id="cachify_compress_html">
<?php foreach( self::_minify_select() as $k => $v ) { ?>
<option value="<?php echo esc_attr($k) ?>" <?php selected($options['compress_html'], $k); ?>>
<?php echo esc_html($v) ?>
</option>
<?php } ?>
</select>
</label>
</td>
</tr>

<tr>
<th scope="row">
<?php submit_button() ?>
</th>
<td>
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LG5VC9KXMAYXJ" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Donate', 'cachify' ); ?></a>
&bull; <a href="<?php esc_html_e( 'https://wordpress.org/plugins/cachify/faq/', 'cachify' ); ?>" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'FAQ', 'cachify' ); ?></a>
&bull; <a href="https://github.com/pluginkollektiv/cachify/wiki" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Manual', 'cachify' ); ?></a>
&bull; <a href="https://wordpress.org/support/plugin/cachify" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Support', 'cachify' ); ?></a>
</td>
</tr>
</table>
42 changes: 42 additions & 0 deletions inc/setup/cachify.apc.htaccess.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php
/* Quit */
defined('ABSPATH') OR exit;

$beginning = '&lt;Files index.php&gt;
php_value auto_prepend_file ';

$ending = '/cachify/apc/proxy.php
&lt;/Files&gt;';

?>

<table class="form-table">
<tr>
<th>
<?php esc_html_e( '.htaccess APC setup', 'cachify' ); ?>
</th>
<td>
<label for="cachify_setup">
<?php esc_html_e( 'Please add the following lines to your .htaccess file', 'cachify' ); ?>
</label>
</td>
</tr>
</table>

<div style="background:#fff;border:1px solid #ccc;padding:10px 20px">
<pre><?php echo sprintf ( '%s%s%s',
$beginning,
WP_PLUGIN_DIR,
$ending ); ?></pre>
</div>

<table class="form-table">
<tr>
<td>
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LG5VC9KXMAYXJ" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Donate', 'cachify' ); ?></a>
&bull; <a href="<?php esc_html_e( 'https://wordpress.org/plugins/cachify/faq/', 'cachify' ); ?>" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'FAQ', 'cachify' ); ?></a>
&bull; <a href="https://github.com/pluginkollektiv/cachify/wiki" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Manual', 'cachify' ); ?></a>
&bull; <a href="https://wordpress.org/support/plugin/cachify" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Support', 'cachify' ); ?></a>
</td>
</tr>
</table>
50 changes: 50 additions & 0 deletions inc/setup/cachify.apc.nginx.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php
/* Quit */
defined('ABSPATH') OR exit;

$beginning = 'location ~ .php {
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param PHP_VALUE auto_prepend_file=';

$ending = '/cachify/apc/proxy.php;

location ~ /wp-admin/ {
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param PHP_VALUE auto_prepend_file=;
}
}';

?>

<table class="form-table">
<tr>
<th>
<?php esc_html_e( 'php.ini APC setup', 'cachify' ); ?>
</th>
<td>
<label for="cachify_setup">
<?php esc_html_e( 'Please add the following lines to your php.ini file', 'cachify' ); ?>
</label>
</td>
</tr>
</table>

<div style="background:#fff;border:1px solid #ccc;padding:10px 20px">
<pre><?php echo sprintf ( '%s%s%s',
$beginning,
WP_PLUGIN_DIR,
$ending ); ?></pre>
</div>

<table class="form-table">
<tr>
<td>
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LG5VC9KXMAYXJ" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Donate', 'cachify' ); ?></a>
&bull; <a href="<?php esc_html_e( 'https://wordpress.org/plugins/cachify/faq/', 'cachify' ); ?>" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'FAQ', 'cachify' ); ?></a>
&bull; <a href="https://github.com/pluginkollektiv/cachify/wiki" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Manual', 'cachify' ); ?></a>
&bull; <a href="https://wordpress.org/support/plugin/cachify" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Support', 'cachify' ); ?></a>
</td>
</tr>
</table>
Loading