Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d1492c4c1a | ||
| 080e0a43c4 | |||
|
|
fe368569a7 | ||
| 276fac6409 | |||
| 20751b5052 | |||
|
|
16e8ecf708 | ||
| 7014a64e31 |
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"version": "1.4.1",
|
||||
"version": "2.0.2",
|
||||
"author": "Ivan Carlos"
|
||||
}
|
||||
|
||||
122
plugin.php
122
plugin.php
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
/*
|
||||
Plugin Name: ICC Webmaster Settings
|
||||
Plugin URI: https://github.com/ivancarlosti/yourlsiccwebmastersettings
|
||||
Description: Customize Logo, Title, Footer, CSS & Favicons. Add reCAPTCHA v3, Meta Redirects (delayed), and Force 302 Redirects.
|
||||
Version: 2.0
|
||||
Plugin URI: https://git.icc.gg/ivancarlos/yourlsiccwebmastersettings
|
||||
Description: Customize Logo, Title, Footer, CSS & Favicons. Add reCAPTCHA v3, HTTP Redirect, 301/302 Redirects, Dash/Underscore, Force Lowercase & Share features.
|
||||
Version: 2.3
|
||||
Author: Ivan Carlos
|
||||
Author URI: https://ivancarlos.com.br/
|
||||
*/
|
||||
@@ -78,10 +78,24 @@ function icc_config_do_page()
|
||||
}
|
||||
$escaped_delay = (int) $icc_mrdr_delay;
|
||||
|
||||
// 302 Redirect options
|
||||
$icc_302_redirect_enabled = yourls_get_option('icc_302_redirect_enabled');
|
||||
// 302 Redirect options
|
||||
$icc_302_redirect_enabled = yourls_get_option('icc_302_redirect_enabled');
|
||||
$redirect_302_checked = $icc_302_redirect_enabled ? 'checked' : '';
|
||||
|
||||
// Remove Share options
|
||||
$icc_remove_share_enabled = yourls_get_option('icc_remove_share_enabled');
|
||||
$remove_share_checked = $icc_remove_share_enabled ? 'checked' : '';
|
||||
|
||||
// Allow Dash/Underscore options
|
||||
$icc_allow_dash_underscore_enabled = yourls_get_option('icc_allow_dash_underscore_enabled');
|
||||
$allow_dash_underscore_checked = $icc_allow_dash_underscore_enabled ? 'checked' : '';
|
||||
|
||||
// Force Lowercase options
|
||||
$icc_force_lowercase_enabled = yourls_get_option('icc_force_lowercase_enabled');
|
||||
$force_lowercase_checked = $icc_force_lowercase_enabled ? 'checked' : '';
|
||||
|
||||
echo <<<HTML
|
||||
<h2>Webmaster Settings</h2>
|
||||
<form method="post">
|
||||
@@ -143,12 +157,29 @@ function icc_config_do_page()
|
||||
<br><span style="padding-left: 205px;"><small>Use 302 (Temporary) instead of 301 (Permanent) for standard redirects.</small></span>
|
||||
</p>
|
||||
|
||||
<h3>Interface Settings</h3>
|
||||
<p>
|
||||
<label for="icc_remove_share_enabled" style="display: inline-block; width: 200px;">Remove Share Button</label>
|
||||
<input type="checkbox" id="icc_remove_share_enabled" name="icc_remove_share_enabled" value="1" {$remove_share_checked} />
|
||||
<br><span style="padding-left: 205px;"><small>Remove the Share button and box from the Admin Dashboard.</small></span>
|
||||
</p>
|
||||
<p>
|
||||
<label for="icc_allow_dash_underscore_enabled" style="display: inline-block; width: 200px;">Allow Dash & Underscore</label>
|
||||
<input type="checkbox" id="icc_allow_dash_underscore_enabled" name="icc_allow_dash_underscore_enabled" value="1" {$allow_dash_underscore_checked} />
|
||||
<br><span style="padding-left: 205px;"><small>Allow dashes (-) and underscores (_) in custom short URLs.</small></span>
|
||||
</p>
|
||||
<p>
|
||||
<label for="icc_force_lowercase_enabled" style="display: inline-block; width: 200px;">Force Lowercase</label>
|
||||
<input type="checkbox" id="icc_force_lowercase_enabled" name="icc_force_lowercase_enabled" value="1" {$force_lowercase_checked} />
|
||||
<br><span style="padding-left: 205px;"><small>Force uppercase keywords to be converted to lowercase (e.g., ABC -> abc).</small></span>
|
||||
</p>
|
||||
|
||||
<p><input type="submit" name="icc_submit" value="Update values" /></p>
|
||||
</form>
|
||||
<hr style="margin-top: 40px" />
|
||||
<p><strong><a href="https://ivancarlos.me/" target="_blank">Ivan Carlos</a></strong> »
|
||||
<a href="http://github.com/ivancarlosti/" target="_blank">GitHub</a> »
|
||||
<a href="https://buymeacoffee.com/ivancarlos" target="_blank">Buy Me a Coffee</a></p>
|
||||
<a href="https://buymeacoffee.com/ivancarlos" target="_blank">Buy Me a Coffee</a> »
|
||||
<a href="https://patreon.com/ivancarlos" target="_blank">Patreon</a></p>
|
||||
HTML;
|
||||
}
|
||||
|
||||
@@ -205,6 +236,20 @@ function icc_config_update_option()
|
||||
// 302 Redirect update
|
||||
$redirect_302_enabled = isset($_POST['icc_302_redirect_enabled']);
|
||||
yourls_update_option('icc_302_redirect_enabled', $redirect_302_enabled);
|
||||
$redirect_302_enabled = isset($_POST['icc_302_redirect_enabled']);
|
||||
yourls_update_option('icc_302_redirect_enabled', $redirect_302_enabled);
|
||||
|
||||
// Remove Share update
|
||||
$remove_share_enabled = isset($_POST['icc_remove_share_enabled']);
|
||||
yourls_update_option('icc_remove_share_enabled', $remove_share_enabled);
|
||||
|
||||
// Allow Dash/Underscore update
|
||||
$allow_dash_underscore_enabled = isset($_POST['icc_allow_dash_underscore_enabled']);
|
||||
yourls_update_option('icc_allow_dash_underscore_enabled', $allow_dash_underscore_enabled);
|
||||
|
||||
// Force Lowercase update
|
||||
$force_lowercase_enabled = isset($_POST['icc_force_lowercase_enabled']);
|
||||
yourls_update_option('icc_force_lowercase_enabled', $force_lowercase_enabled);
|
||||
}
|
||||
|
||||
// Show custom logo
|
||||
@@ -276,10 +321,12 @@ function icc_print_custom_css()
|
||||
|
||||
// reCAPTCHA v3 Integration
|
||||
yourls_add_action('html_head', 'icc_recaptcha_v3_html_head');
|
||||
|
||||
function icc_recaptcha_v3_html_head()
|
||||
{
|
||||
if (!yourls_get_option('icc_recaptcha_enabled'))
|
||||
return;
|
||||
|
||||
$site_key = yourls_get_option('icc_recaptcha_site_key');
|
||||
if ($site_key) {
|
||||
echo '<script src="https://www.google.com/recaptcha/api.js?render=' . htmlspecialchars($site_key, ENT_QUOTES) . '"></script>';
|
||||
@@ -403,3 +450,68 @@ function icc_force_302_redirect($args)
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
// Allow dash and underscore in custom short URLs
|
||||
if (yourls_get_option('icc_allow_dash_underscore_enabled')) {
|
||||
yourls_add_filter('get_shorturl_charset', 'icc_custom_shorturl_charset');
|
||||
yourls_add_filter('get_shorturl_charset_regex', 'icc_custom_shorturl_charset_regex');
|
||||
}
|
||||
|
||||
function icc_custom_shorturl_charset($charset)
|
||||
{
|
||||
return $charset . '-_';
|
||||
}
|
||||
|
||||
function icc_custom_shorturl_charset_regex($pattern)
|
||||
{
|
||||
return $pattern . '|[-_]';
|
||||
}
|
||||
|
||||
// Force Lowercase Logic
|
||||
if (yourls_get_option('icc_force_lowercase_enabled')) {
|
||||
// Redirection: http://sho.rt/ABC first converted to http://sho.rt/abc
|
||||
yourls_add_filter('get_request', 'icc_break_the_web_lowercase');
|
||||
|
||||
// Short URL creation: custom keyword 'ABC' converted to 'abc'
|
||||
yourls_add_action('add_new_link_custom_keyword', 'icc_break_the_web_add_filter');
|
||||
|
||||
// Force random keywords to be lowercase
|
||||
yourls_add_filter('random_keyword', 'icc_break_the_web_lowercase');
|
||||
}
|
||||
|
||||
function icc_break_the_web_lowercase($keyword)
|
||||
{
|
||||
return strtolower($keyword);
|
||||
}
|
||||
|
||||
function icc_break_the_web_add_filter()
|
||||
{
|
||||
yourls_add_filter('get_shorturl_charset', 'icc_break_the_web_add_uppercase');
|
||||
yourls_add_filter('custom_keyword', 'icc_break_the_web_lowercase');
|
||||
}
|
||||
|
||||
function icc_break_the_web_add_uppercase($charset)
|
||||
{
|
||||
return $charset . strtoupper($charset);
|
||||
}
|
||||
|
||||
// Remove Share Functionality
|
||||
if (yourls_get_option('icc_remove_share_enabled')) {
|
||||
// Dump the Share button
|
||||
yourls_add_filter('table_add_row_action_array', 'icc_rmv_row_action_share');
|
||||
// No Share Box either
|
||||
yourls_add_filter('shunt_share_box', 'icc_shunt_share_box');
|
||||
}
|
||||
|
||||
function icc_rmv_row_action_share($links)
|
||||
{
|
||||
if (array_key_exists('share', $links))
|
||||
unset($links['share']);
|
||||
|
||||
return $links;
|
||||
}
|
||||
|
||||
function icc_shunt_share_box($shunt)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user