yoast-sitemap on/off command

New option to enable or disabled the Yoast Sitemap default support.
This commit is contained in:
Cristhian Martínez Ochoa 2018-08-20 20:43:26 -06:00
parent 0b5e1637fc
commit e87cbad39c
2 changed files with 38 additions and 2 deletions

View file

@ -2,13 +2,13 @@
# Webinoly Server Manager Plugin # Webinoly Server Manager Plugin
# Syntax: webinoly <option> # Syntax: webinoly <option>
# Options: -update, -server-update or -server-reset, -verify, -dbpass, -tools-port, -login-www-data, -nologin-www-data, -config-cache, -uninstall, -info, -external-list-update, -clear-cache, -version, -blockip, -unblockip, -conf-value_ # Options: -update, -server-update or -server-reset, -verify, -dbpass, -tools-port, -login-www-data, -nologin-www-data, -config-cache, -uninstall, -info, -external-list-update, -clear-cache, -version, -blockip, -unblockip, -conf-value_, -yoast-sitemap
opt="$1" opt="$1"
source /opt/webinoly/lib/webin source /opt/webinoly/lib/webin
# Extract value if exist # Extract value if exist
if [[ $opt == "-tools-port="* || $opt == "-config-cache="* || $opt == "-clear-cache="* || $opt == "-server-update="* || $opt == "-server-reset="* || $opt == "-timezone="* || $opt == "-update="* || $opt == "-blockip="* || $opt == "-unblockip="* || $opt == "-conf-value_"* ]]; then if [[ $opt == "-tools-port="* || $opt == "-config-cache="* || $opt == "-clear-cache="* || $opt == "-server-update="* || $opt == "-server-reset="* || $opt == "-timezone="* || $opt == "-update="* || $opt == "-blockip="* || $opt == "-unblockip="* || $opt == "-conf-value_"* || $opt == "-yoast-sitemap="* ]]; then
value=$(echo "${opt}" | cut -d'=' -f 2 -s) value=$(echo "${opt}" | cut -d'=' -f 2 -s)
opt=$(echo "${opt}" | cut -d'=' -f 1 -s) opt=$(echo "${opt}" | cut -d'=' -f 1 -s)
# Prevent cases like -conf-value where is valid enter a value without = causing empty opt. # Prevent cases like -conf-value where is valid enter a value without = causing empty opt.
@ -402,6 +402,27 @@ elif [[ $opt == "-conf-value_"* ]]; then
fi fi
elif [[ $opt == "-yoast-sitemap"* ]]; then
ystmap=$( grep -F "# YoastSitemapStart - Yoast SEO Plugin" /etc/nginx/common/wpcommon.conf )
if [[ $value == "on" ]]; then
if [[ -z $ystmap ]]; then
sudo cat /opt/webinoly/templates/template-yoast-sitemap >> /etc/nginx/common/wpcommon.conf
echo "${gre}Yoast Sitemap Support was successfully enabled!${end}"
else
echo "${red}Yoast Sitemap Support is already enabled!${end}"
fi
elif [[ $value == "off" ]]; then
if [[ -n $ystmap ]]; then
sudo sed -i '/YoastSitemapStart/,/YoastSitemapEnd/{/.*/d}' /etc/nginx/common/wpcommon.conf
echo "${gre}Yoast Sitemap Support was successfully disabled!${end}"
else
echo "${red}Yoast Sitemap Support is already disabled!${end}"
fi
else
echo "${red}Please, enter a valid option to enable/disable Yoast Sitemap Support!${end}"
fi
else else
echo "${red}Please enter a valid option!${end}" echo "${red}Please enter a valid option!${end}"
fi fi

View file

@ -0,0 +1,15 @@
# YoastSitemapStart - Yoast SEO Plugin
location ~ ([^/]*)sitemap(.*)\.x(m|s)l$ {
rewrite ^(.*)/sitemap\.xml$ $1/sitemap_index.xml permanent;
rewrite ^.*/([a-z]+)?-?sitemap\.xsl$ /index.php?xsl=$1 last;
# Rules for yoast sitemap with wp|wpsubdir|wpsubdomain
rewrite ^.*/sitemap_index\.xml$ /index.php?sitemap=1 last;
rewrite ^.*/([^/]+?)-sitemap([0-9]+)?\.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;
# Following lines are optional. Needed for Yoast Premium.
rewrite ^.*/news_sitemap\.xml$ /index.php?sitemap=wpseo_news last;
rewrite ^.*/locations\.kml$ /index.php?sitemap=wpseo_local_kml last;
rewrite ^.*/geo_sitemap\.xml$ /index.php?sitemap=wpseo_local last;
rewrite ^.*/video-sitemap\.xsl$ /index.php?xsl=video last;
access_log off;
}
# YoastSitemapEnd