Skip to content

Commit

Permalink
Rename 'permalink structure' to 'enforce canonical urls' for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
raamdev committed Jun 25, 2016
1 parent 4f0671a commit 8d7e787
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
10 changes: 5 additions & 5 deletions src/includes/classes/MenuPageOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1079,17 +1079,17 @@ public function __construct()
echo ' <hr />'."\n";
echo ' <h3 class="'.(!IS_PRO ? 'pro-preview-feature' : '').'">'.__('Enforce Canonical URLs', SLUG_TD).'</h3>'."\n";
echo ' <p>'.__('Permalinks (URLs) leading to Posts/Pages on your site (based on your WordPress Permalink Settings) '.($GLOBALS['wp_rewrite']->use_trailing_slashes ? 'require a <code>.../trailing-slash/</code>' : 'do not require a <code>.../trailing-slash</code>').'. Ordinarily, WordPress enforces this by redirecting a request for '.($GLOBALS['wp_rewrite']->use_trailing_slashes ? '<code>.../something</code>' : '<code>.../something/</code>').', to '.($GLOBALS['wp_rewrite']->use_trailing_slashes ? '<code>.../something/</code>' : '<code>.../something</code>').', thereby forcing the final location to match your Permalink configuration. However, whenever you install a plugin like Comet Cache, much of WordPress (including this automatic redirection) is out of the picture when the cached copy of a page is being served. So enabling this option will add rules to your `.htaccess` file that make Apache aware of your WordPess Permalink configuration. Apache can do what WordPress normally would, only much more efficiently.', SLUG_TD).'</p>'."\n";
echo ' <p><select name="'.esc_attr(GLOBAL_NS).'[saveOptions][htaccess_permalink_structure_enable]" data-target=".-htaccess-permalink-structure-options">'."\n";
echo ' <option value="0"'.(!IS_PRO ? '' : selected($this->plugin->options['htaccess_permalink_structure_enable'], '0', false)).'>'.__('No, do NOT enforce canonical URLs (or I\'ll update my configuration manually; see below)', SLUG_TD).'</option>'."\n";
echo ' <option value="1"'.(!IS_PRO ? 'selected' : selected($this->plugin->options['htaccess_permalink_structure_enable'], '1', false)).'>'.__('Yes, enforce canonical URLs (recommended)', SLUG_TD).'</option>'."\n";
echo ' <p><select name="'.esc_attr(GLOBAL_NS).'[saveOptions][htaccess_enforce_canonical_urls]" data-target=".-htaccess-enforce-canonical-urls-options">'."\n";
echo ' <option value="0"'.(!IS_PRO ? '' : selected($this->plugin->options['htaccess_enforce_canonical_urls'], '0', false)).'>'.__('No, do NOT enforce canonical URLs (or I\'ll update my configuration manually; see below)', SLUG_TD).'</option>'."\n";
echo ' <option value="1"'.(!IS_PRO ? 'selected' : selected($this->plugin->options['htaccess_enforce_canonical_urls'], '1', false)).'>'.__('Yes, enforce canonical URLs (recommended)', SLUG_TD).'</option>'."\n";
echo ' </select></p>'."\n";
echo ' <p>Or, you can update your configuration manually: [<a href="#" data-toggle-target=".'.esc_attr(GLOBAL_NS.'-apache-optimizations--enforce-cononical-urls').'"><i class="si si-eye"></i> .htaccess configuration <i class="si si-eye"></i></a>]</p>'."\n";
echo ' <div class="'.esc_attr(GLOBAL_NS.'-apache-optimizations--enforce-cononical-urls').'" style="display:none; margin-top:1em;">'."\n";
echo ' <p>'.__('<strong>To enforce Canonical URLs:</strong> Create or edit the <code>.htaccess</code> file in your WordPress installation directory and add the following lines to the top:', SLUG_TD).'</p>'."\n";
if ($GLOBALS['wp_rewrite']->use_trailing_slashes) {
echo ' <pre class="code"><code>'.esc_html(file_get_contents(dirname(__DIR__).'/templates/htaccess/permalink-structure-ts-enable.txt')).'</code></pre>'."\n";
echo ' <pre class="code"><code>'.esc_html(file_get_contents(dirname(__DIR__).'/templates/htaccess/canonical-urls-ts-enable.txt')).'</code></pre>'."\n";
} else {
echo ' <pre class="code"><code>'.esc_html(file_get_contents(dirname(__DIR__).'/templates/htaccess/permalink-structure-no-ts-enable.txt')).'</code></pre>'."\n";
echo ' <pre class="code"><code>'.esc_html(file_get_contents(dirname(__DIR__).'/templates/htaccess/canonical-urls-no-ts-enable.txt')).'</code></pre>'."\n";
}
echo ' </div>'."\n";
echo ' </div>'."\n";
Expand Down
4 changes: 2 additions & 2 deletions src/includes/classes/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ public function setup()

'htaccess_client_side_cache_enable',
'htaccess_gzip_enable',
'htaccess_permalink_structure_enable',
'htaccess_enforce_canonical_urls',

'cdn_enable',
'cdn_host',
Expand Down Expand Up @@ -413,7 +413,7 @@ public function setup()

'htaccess_client_side_cache_enable' => '0', // `0|1`; enable client-side caching via .htaccess?
'htaccess_gzip_enable' => '0', // `0|1`; enable GZIP via .htaccess?
'htaccess_permalink_structure_enable' => '0', // `0|1`; enable permalink structure via .htaccess?
'htaccess_enforce_canonical_urls' => '0', // `0|1`; enforce canonical URLs?
/* Related to CDN functionality. */

Expand Down
14 changes: 7 additions & 7 deletions src/includes/traits/Plugin/HtaccessUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ trait HtaccessUtils
*
* @note We keep track of this to avoid the issue described here: http://git.io/vEFIH
*/
public $options_with_htaccess_rules = ['cdn_enable', 'htaccess_client_side_cache_enable', 'htaccess_gzip_enable', 'htaccess_permalink_structure_enable',];
public $options_with_htaccess_rules = ['cdn_enable', 'htaccess_client_side_cache_enable', 'htaccess_gzip_enable', 'htaccess_enforce_canonical_urls',];

/**
* Add template blocks to `/.htaccess` file.
Expand Down Expand Up @@ -80,16 +80,16 @@ public function addWpHtaccess()
} // Only if GZIP is enabled via .htaccess at this time.
break;

case 'permalink-structure-ts-enable.txt':
if ($this->options['htaccess_permalink_structure_enable'] && $GLOBALS['wp_rewrite']->use_trailing_slashes) {
case 'canonical-urls-ts-enable.txt':
if ($this->options['htaccess_enforce_canonical_urls'] && $GLOBALS['wp_rewrite']->use_trailing_slashes) {
$template_blocks .= trim(file_get_contents($templates_dir.'/'.$_template_file))."\n";
} // Only if permalink structure is enabled via .htaccess at this time.
} // Only if enforce canonical URLs enabled at this time.
break;

case 'permalink-structure-no-ts-enable.txt':
if ($this->options['htaccess_permalink_structure_enable'] && !$GLOBALS['wp_rewrite']->use_trailing_slashes) {
case 'canonical-urls-no-ts-enable.txt':
if ($this->options['htaccess_enforce_canonical_urls'] && !$GLOBALS['wp_rewrite']->use_trailing_slashes) {
$template_blocks .= trim(file_get_contents($templates_dir.'/'.$_template_file))."\n";
} // Only if permalink structure is enabled via .htaccess at this time.
} // Only if enforce canonical URLs enabled at this time.
break;
/*[/pro]*/
}
Expand Down

0 comments on commit 8d7e787

Please # to comment.