admin管理员组文章数量:1316980
Or must a site be launched manually?
I want my site, in honour of my late Uncle's WWII experiences, to launch at 11am on Nov 11th.
Or must a site be launched manually?
I want my site, in honour of my late Uncle's WWII experiences, to launch at 11am on Nov 11th.
Share Improve this question asked Nov 6, 2020 at 4:54 Jaq SladeJaq Slade 1 2- Yes, there's a large variety of ways to do that though. Is there a specific timezone that it should launch at 11am at? A good solution might be to soft-launch the site but use a countdown timer plugin to control when the site becomes publicly accessible – admcfajn Commented Nov 6, 2020 at 6:27
- Thank you for this. I thought about using a relevant plugin, but I thought plugins are only an option if you have a paid for service? My site is just a hobby, and is a wordpress not site - thanks – Jaq Slade Commented Nov 6, 2020 at 14:01
1 Answer
Reset to default 1You should create a small plugin that checks the time stamp and run on an alternate page or similar. Bigger than the time stamp, the default WordPress run should work. An Example, write my answer to this question that's not working code.
The method timestamp
is your key to control the logic for loading an alternate splash page. The current example loads the alternate page only if the date is the current date. So in this method, you should enhance the logic, like now is smaller than the loading starter's defined date.
Load in the WP environment
add_action(
'plugins_loaded',
static function (): bool {
try {
(new Alternate())
->set(__FILE__, '2020-11-06')
->run();
} catch (Throwable $error) {
if (defined('WP_DEBUG') && WP_DEBUG) {
throw $error;
}
return false;
}
return true;
}
);
Class to control the alternate page
use DateTime;
class Alternate
{
private $pluginurl;
private $date;
/**
* @param string $root
* @param string $date
*
* @return Alternate
*/
public function set(string $root, string $date): self
{
$this->pluginroot = plugin_dir_path($root);
$this->pluginurl = plugin_dir_url($root);
$this->date = $date;
return $this;
}
public function run()
{
// Load alternate page or WordPress loop.
if ($this->timestamp()) {
wp_cache_flush();
header('Location: '.$this->placeholderFile(), true, 302);
exit();
}
}
/**
* @return string
*/
private function placeholderFile(): string
{
if (file_exists($this->pluginroot.'assets/placeholder.html')) {
return $this->pluginurl.'assets/placeholder.html';
}
return $this->pluginurl.'assets/placeholder_en.html';
}
private function timestamp(): bool
{
return $this->date === (new DateTime())->format('Y-m-d');
}
}
Similar working plugin
You will find a similar idea in this solution, that splash a page on a defied date.
Note
I mean, it also gives free plugins for this goal. Maybe you will search for them. I haven't a plugin in mind for this, but maybe the plugin "Maintenance Mode" should have this option.
本文标签: pagesCan I schedule my site to launch at a set time and date
版权声明:本文标题:pages - Can I schedule my site to launch at a set time and date? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742013069a2413255.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论