Skip to content

Commit

Permalink
Merge pull request #69 from timse201/patch-2
Browse files Browse the repository at this point in the history
implementation of config hints; some restructure; donation link
  • Loading branch information
bueltge authored Feb 13, 2017
2 parents 20bed89 + ea6a462 commit e2f132c
Show file tree
Hide file tree
Showing 9 changed files with 506 additions and 113 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Smart, efficient cache solution for WordPress. Use DB, HDD, APC or Memcached for
* If you want to help us translate this plugin you can do so [on WordPress Translate](https://translate.wordpress.org/projects/wp-plugins/cachify).

### Donate
[Donate for us via Paypal](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LG5VC9KXMAYXJ)
[Donate for us via Paypal](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8CH5FPR88QYML)

### Credits ###
* Author: [Sergej Müller](https://sergejmueller.github.io/)
Expand Down
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=8CH5FPR88QYML" 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' => esc_html__('Settings', 'cachify'),
'setup' => esc_html__('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=8CH5FPR88QYML" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Donate', 'cachify' ); ?></a>
&bull; <a href="<?php echo esc_url( __( 'https://wordpress.org/plugins/cachify/faq/', 'cachify' ), 'https' ); ?>" 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=8CH5FPR88QYML" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Donate', 'cachify' ); ?></a>
&bull; <a href="<?php echo esc_url( __( 'https://wordpress.org/plugins/cachify/faq/', 'cachify' ), 'https' ); ?>" 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

0 comments on commit e2f132c

Please sign in to comment.