first commit

This commit is contained in:
CHIEFSOFT\ameye
2023-11-30 13:20:54 -05:00
commit e9e5c0546c
5833 changed files with 1801865 additions and 0 deletions
@@ -0,0 +1,220 @@
<?php
/**
* The admin-specific functionality of the module.
*
* @link https://codesupply.co
* @since 1.0.0
*
* @package Powerkit
* @subpackage Modules/Admin
*/
/**
* The admin-specific functionality of the module.
*/
class Powerkit_Coming_Soon_Admin extends Powerkit_Module_Admin {
/**
* Initialize
*/
public function initialize() {
add_action( 'init', array( $this, 'activation' ) );
add_action( 'admin_menu', array( $this, 'register_options_page' ) );
add_action( 'admin_notices', array( $this, 'notices' ) );
add_action( 'display_post_states', array( $this, 'post_state' ), 10, 2 );
}
/**
* Activation.
*/
public function activation() {
$activate = get_option( 'powerkit_coming_soon_init', false );
if ( ! $activate ) {
$page_id = wp_insert_post( wp_slash( array(
'post_title' => esc_html__( 'Coming Soon', 'powerkit' ),
'post_content' => powerkit_coming_soon_default_content(),
'post_type' => 'page',
'post_status' => 'publish',
'post_author' => 1,
) ) );
update_option( 'powerkit_coming_soon_init', true );
update_option( 'powerkit_coming_soon_page', $page_id );
}
}
/**
* Prints admin screen notices.
*/
public function notices() {
$screen = get_current_screen();
if ( false !== strpos( $screen->base, $this->slug ) ) {
return;
}
// Check Status.
if ( ! powerkit_coming_soon_status() ) {
return;
}
// Check Notice.
if ( 'yes' === get_option( 'powerkit_coming_soon_notice', 'yes' ) ) {
?>
<div class="notice notice-error is-dismissible">
<p>
<?php
// translators: Link deactivate.
echo wp_kses( sprintf( __( 'The Coming Soon is active. Please don\'t forget to <a href="%1$s">deactivate</a> as soon as you are done.', 'powerkit' ), powerkit_get_page_url( $this->slug ) ), 'post' );
?>
</p>
</div>
<?php
}
}
/**
* Set display state for page of Coming Soon.
*
* @param string $states An array of post display states.
* @param object $post The current post object.
*/
public function post_state( $states, $post ) {
$page_id = get_option( 'powerkit_coming_soon_page' );
if ( (int) $post->ID === (int) $page_id ) {
$states[] = esc_html__( 'Coming Soon Page', 'powerkit' );
}
return $states;
}
/**
* Register admin page
*
* @since 1.0.0
*/
public function register_options_page() {
add_options_page( esc_html__( 'Coming Soon', 'powerkit' ), esc_html__( 'Coming Soon', 'powerkit' ), 'manage_options', powerkit_get_page_slug( $this->slug ), array( $this, 'build_options_page' ) );
}
/**
* Build admin page
*
* @since 1.0.0
*/
public function build_options_page() {
if ( ! current_user_can( 'manage_options' ) ) {
wp_die( esc_html__( 'You do not have sufficient rights to view this page.', 'powerkit' ) );
}
$this->save_options_page();
?>
<div class="wrap pk-wrap">
<h1><?php esc_html_e( 'Coming Soon', 'powerkit' ); ?></h1>
<div class="pk-settings">
<form method="post">
<table class="form-table">
<tbody>
<!-- Status -->
<tr>
<th scope="row"><label for="powerkit_coming_soon_status"><?php esc_html_e( 'Status', 'powerkit' ); ?></label></th>
<td>
<label><input class="regular-text" id="powerkit_coming_soon_status" name="powerkit_coming_soon_status" type="radio" value="yes" <?php checked( true, (bool) get_option( 'powerkit_coming_soon_status', false ) ); ?>> <?php esc_html_e( 'Activated', 'powerkit' ); ?></label>
<br>
<label><input value="no" class="regular-text" id="powerkit_coming_soon_status" name="powerkit_coming_soon_status" type="radio" <?php checked( false, (bool) get_option( 'powerkit_coming_soon_status', false ) ); ?>> <?php esc_html_e( 'Deactivated', 'powerkit' ); ?></label>
</td>
</tr>
<!-- Content from Page -->
<tr>
<?php
$pages = new WP_Query();
$pages = $pages->query( array(
'posts_per_page' => -1,
'post_type' => 'page',
) );
if ( $pages ) {
?>
<th scope="row"><label for="powerkit_coming_soon_page"><?php esc_html_e( 'Content from Page', 'powerkit' ); ?></label></th>
<td>
<select class="regular-text" name="powerkit_coming_soon_page" id="powerkit_coming_soon_page">
<option value=""><?php esc_html_e( '- not selected -', 'powerkit' ); ?></option>
<?php foreach ( $pages as $page ) : ?>
<option <?php selected( $page->ID, get_option( 'powerkit_coming_soon_page' ) ); ?> value="<?php echo esc_attr( $page->ID ); ?>"><?php echo esc_html( $page->post_title ); ?></option>
<?php endforeach; ?>
</select>
</td>
<?php } else { ?>
<td colspan="2">
<code><?php esc_html_e( 'Pages no found.', 'powerkit' ); ?></code>
</td>
<?php } ?>
<!-- Notice -->
<tr>
<th scope="row"><label for="powerkit_coming_soon_notice"><?php esc_html_e( 'Notice', 'powerkit' ); ?></label></th>
<td>
<select class="regular-text" id="powerkit_coming_soon_notice" name="powerkit_coming_soon_notice">
<option value="yes" <?php selected( 'yes', get_option( 'powerkit_coming_soon_notice', 'yes' ) ); ?>><?php esc_html_e( 'Yes', 'powerkit' ); ?></option>
<option value="no" <?php selected( 'no', get_option( 'powerkit_coming_soon_notice', 'yes' ) ); ?>><?php esc_html_e( 'No', 'powerkit' ); ?></option>
</select>
<p class="description"><?php esc_html_e( 'Do you want to see notices when maintenance mode is activated?', 'powerkit' ); ?></p>
</td>
</tr>
<!-- HTTP status code -->
<tr>
<th scope="row"><label for="powerkit_coming_soon_httpcode"><?php esc_html_e( 'HTTP status code', 'powerkit' ); ?></label></th>
<td><input class="regular-text" id="powerkit_coming_soon_httpcode" name="powerkit_coming_soon_httpcode" type="text" value="<?php echo esc_attr( get_option( 'powerkit_coming_soon_httpcode', 404 ) ); ?>"></td>
</tr>
</tr>
</tbody>
</table>
<?php wp_nonce_field(); ?>
<p class="submit"><input class="button button-primary" name="save_settings" type="submit" value="<?php esc_html_e( 'Save changes', 'powerkit' ); ?>" /></p>
</form>
</div>
</div>
<?php
}
/**
* Settings save
*
* @since 1.0.0
*/
protected function save_options_page() {
if ( ! isset( $_POST['_wpnonce'] ) || ! wp_verify_nonce( $_POST['_wpnonce'] ) ) { // Input var ok; sanitization ok.
return;
}
if ( isset( $_POST['save_settings'] ) ) { // Input var ok.
if ( isset( $_POST['powerkit_coming_soon_status'] ) && 'yes' === $_POST['powerkit_coming_soon_status'] ) { // Input var ok; sanitization ok.
update_option( 'powerkit_coming_soon_status', true );
} else {
update_option( 'powerkit_coming_soon_status', false );
}
if ( isset( $_POST['powerkit_coming_soon_page'] ) ) { // Input var ok.
update_option( 'powerkit_coming_soon_page', sanitize_text_field( wp_unslash( $_POST['powerkit_coming_soon_page'] ) ) ); // Input var ok.
}
if ( isset( $_POST['powerkit_coming_soon_notice'] ) ) { // Input var ok.
update_option( 'powerkit_coming_soon_notice', sanitize_text_field( wp_unslash( $_POST['powerkit_coming_soon_notice'] ) ) ); // Input var ok.
}
if ( isset( $_POST['powerkit_coming_soon_httpcode'] ) ) { // Input var ok.
update_option( 'powerkit_coming_soon_httpcode', sanitize_text_field( wp_unslash( $_POST['powerkit_coming_soon_httpcode'] ) ) ); // Input var ok.
}
printf( '<div id="message" class="updated fade"><p><strong>%s</strong></p></div>', esc_html__( 'Settings saved.', 'powerkit' ) );
}
}
}
@@ -0,0 +1,64 @@
<?php
/**
* Coming Soon
*
* @package Powerkit
* @subpackage Modules
*/
if ( class_exists( 'Powerkit_Module' ) ) {
/**
* Init module
*/
class Powerkit_Coming_Soon extends Powerkit_Module {
/**
* Register module
*/
public function register() {
$this->name = esc_html__( 'Coming Soon', 'powerkit' );
$this->desc = esc_html__( 'Coming soon module to perfectly manage your coming soon, under construction website, under maintenance mode website and offline website.', 'powerkit' );
$this->slug = 'coming_soon';
$this->type = 'default';
$this->category = 'tools';
$this->priority = 140;
$this->public = true;
$this->enabled = true;
$this->links = array(
array(
'name' => esc_html__( 'Go to settings', 'powerkit' ),
'url' => powerkit_get_page_url( $this->slug ),
),
array(
'name' => esc_html__( 'View documentation', 'powerkit' ),
'url' => powerkit_get_setting( 'documentation' ) . '/coming-soon/',
'target' => '_blank',
),
);
}
/**
* Initialize module
*/
public function initialize() {
define( 'POWERKIT_CS_TEMPLATES', dirname( __FILE__ ) . '/templates' );
// Set plugin dir url.
define( 'POWERKIT_CS_URL', plugin_dir_url( __FILE__ ) );
/* Load the required dependencies for this module */
// Helpers Functions for the module.
require_once dirname( __FILE__ ) . '/helpers/helper-powerkit-coming-soon.php';
// Admin and public area.
require_once dirname( __FILE__ ) . '/admin/class-powerkit-coming-soon-admin.php';
require_once dirname( __FILE__ ) . '/public/class-powerkit-coming-soon-public.php';
new Powerkit_Coming_Soon_Admin( $this->slug );
new Powerkit_Coming_Soon_Public( $this->slug );
}
}
new Powerkit_Coming_Soon();
}
@@ -0,0 +1,55 @@
<?php
/**
* Helpers Coming Soon
*
* @package Powerkit
* @subpackage Modules/Helper
*/
/**
* The function returns the status
*/
function powerkit_coming_soon_status() {
return get_option( 'powerkit_coming_soon_status', false );
}
/**
* The function returns the status page
*/
function powerkit_coming_soon_page_visible() {
$option_coming_soon_page = get_option( 'powerkit_coming_soon_page' );
if ( ! empty( $option_coming_soon_page ) && is_page( $option_coming_soon_page ) ) {
return __return_true();
}
}
/**
* The function returns the status site
*/
function powerkit_coming_soon_site_visible() {
// Check Status.
if ( ! powerkit_coming_soon_status() ) {
return;
}
// Check Administrator.
if ( current_user_can( 'editor' ) || current_user_can( 'administrator' ) ) {
return;
}
return __return_true();
}
/**
* The function returns the default content
*/
function powerkit_coming_soon_default_content() {
ob_start();
?>
<!-- wp:heading {"align":"center","level":1,"canvasClassName":"cnvs-block-core-heading-1"} -->
<h1 class="has-text-align-center">I'm working on something amazing!<br>But don't worry, I'll back soon. </h1>
<!-- /wp:heading -->
<?php
return ob_get_clean();
}
@@ -0,0 +1,112 @@
<?php
/**
* The public-facing functionality of the module.
*
* @link https://codesupply.co
* @since 1.0.0
*
* @package Powerkit
* @subpackage Modules/public
*/
/**
* The public-facing functionality of the module.
*/
class Powerkit_Coming_Soon_Public extends Powerkit_Module_Public {
/**
* Initialize
*/
public function initialize() {
add_filter( 'wp', array( $this, 'init_page' ) );
add_action( 'wp', array( $this, 'change_httpcode' ) );
}
/**
* Set HTTP status header.
*/
public function change_httpcode() {
// Check location.
if ( is_admin() ) {
return;
}
if ( powerkit_coming_soon_page_visible() || powerkit_coming_soon_site_visible() ) {
$httpcode = get_option( 'powerkit_coming_soon_httpcode', 404 );
status_header( $httpcode );
}
}
/**
* Init Page
*/
public function init_page() {
// Check location.
if ( is_admin() ) {
return;
}
if ( powerkit_coming_soon_page_visible() || powerkit_coming_soon_site_visible() ) {
add_filter( 'pre_get_document_title', array( $this, 'title' ) );
add_action( 'template_redirect', array( $this, 'template' ) );
}
}
/**
* Title
*/
public function title() {
$page_id = get_option( 'powerkit_coming_soon_page' );
if ( $page_id ) {
$page = get_post( $page_id );
// Set title.
$title = $page ? $page->post_title : esc_html__( 'Coming Soon', 'powerkit' );
return $title;
}
}
/**
* Template
*/
public function template() {
$page_id = get_option( 'powerkit_coming_soon_page' );
if ( $page_id ) {
// Get page object.
$object = get_post( $page_id );
// Get title.
$title = $object ? $object->post_title : esc_html__( 'Coming Soon', 'powerkit' );
// Get content.
$content = $object ? $object->post_content : esc_html__( 'Get Ready... Something Really Cool Is Coming Soon', 'powerkit' );
// Set template path.
$template_path = apply_filters( 'powerkit_coming_soon_template', POWERKIT_CS_TEMPLATES . '/default.php' );
if ( ! file_exists( $template_path ) ) {
wp_die( 'Template file does not exist!' );
}
include_once $template_path;
}
die();
}
/**
* Register the stylesheets for the public-facing side of the site.
*/
public function wp_enqueue_scripts() {
// Styles.
wp_enqueue_style( 'powerkit-coming-soon', powerkit_style( plugin_dir_url( __FILE__ ) . 'css/public-powerkit-coming-soon.css' ), array(), powerkit_get_setting( 'version' ), 'all' );
// Add RTL support.
wp_style_add_data( 'powerkit-coming-soon', 'rtl', 'replace' );
}
}
@@ -0,0 +1,78 @@
/**
* All of the CSS for your public-facing functionality should be
* included in this file.
*/
/**
* Environment for all styles (variables, additions, etc).
*/
/*--------------------------------------------------------------*/
/*--------------------------------------------------------------*/
.pk-coming-soon-container {
display: flex;
flex-direction: column;
flex-wrap: wrap;
height: 100%;
}
.pk-coming-soon-image {
position: relative;
width: 100%;
}
.pk-coming-soon-image img {
width: 100%;
height: auto;
}
.pk-coming-soon-content {
display: flex;
align-items: center;
padding: 40px;
width: 100%;
}
@media (min-width: 992px) {
.pk-coming-soon-page {
min-height: 100vh;
}
.pk-coming-soon-container {
flex-direction: row;
flex-wrap: nowrap;
min-height: 100vh;
}
.pk-coming-soon-image {
flex: 0 0 50%;
max-width: 50%;
min-height: 100vh;
height: 100%;
}
.pk-coming-soon-image img {
position: absolute;
top: 0;
right: 0;
left: 0;
bottom: 0;
width: 100%;
height: 100%;
-o-object-fit: cover;
object-fit: cover;
}
.pk-coming-soon-content {
flex: 0 0 50%;
max-width: 50%;
}
.pk-coming-soon-content:first-child:last-child {
flex: 0 0 100%;
max-width: 100%;
}
}
.pk-coming-soon-content .entry-content {
margin: 0 auto;
max-width: 640px;
width: 100%;
}
.pk-coming-soon-content .pk-social-links-items {
justify-content: center;
}
@@ -0,0 +1,78 @@
/**
* All of the CSS for your public-facing functionality should be
* included in this file.
*/
/**
* Environment for all styles (variables, additions, etc).
*/
/*--------------------------------------------------------------*/
/*--------------------------------------------------------------*/
.pk-coming-soon-container {
display: flex;
flex-direction: column;
flex-wrap: wrap;
height: 100%;
}
.pk-coming-soon-image {
position: relative;
width: 100%;
}
.pk-coming-soon-image img {
width: 100%;
height: auto;
}
.pk-coming-soon-content {
display: flex;
align-items: center;
padding: 40px;
width: 100%;
}
@media (min-width: 992px) {
.pk-coming-soon-page {
min-height: 100vh;
}
.pk-coming-soon-container {
flex-direction: row;
flex-wrap: nowrap;
min-height: 100vh;
}
.pk-coming-soon-image {
flex: 0 0 50%;
max-width: 50%;
min-height: 100vh;
height: 100%;
}
.pk-coming-soon-image img {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
width: 100%;
height: 100%;
-o-object-fit: cover;
object-fit: cover;
}
.pk-coming-soon-content {
flex: 0 0 50%;
max-width: 50%;
}
.pk-coming-soon-content:first-child:last-child {
flex: 0 0 100%;
max-width: 100%;
}
}
.pk-coming-soon-content .entry-content {
margin: 0 auto;
max-width: 640px;
width: 100%;
}
.pk-coming-soon-content .pk-social-links-items {
justify-content: center;
}
@@ -0,0 +1,55 @@
<?php
/**
* Coming Soon default template
*
* @var $object - Page object.
* @var $title - The title.
* @var $content - The content.
*
* @package Powerkit
*/
?><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<?php wp_head(); ?>
<?php
if ( function_exists( 'cnvs_gutenberg' ) ) {
$blocks = parse_blocks( $content );
$blocks_css = cnvs_gutenberg()->parse_blocks_css( $blocks );
if ( $blocks_css ) {
call_user_func( 'printf', '<style>%s</style>', $blocks_css );
}
}
?>
</head>
<body>
<div class="pk-coming-soon-page pk-coming-soon-default">
<div class="pk-coming-soon-container">
<?php if ( $object && has_post_thumbnail( $object ) ) { ?>
<div class="pk-coming-soon-image">
<?php echo get_the_post_thumbnail( $object, 'large', array( 'class' => 'pk-lazyload-disabled' ) ); ?>
</div>
<?php } ?>
<div class="pk-coming-soon-content">
<div class="entry-content">
<?php
$content = do_blocks( $content );
call_user_func( 'printf', '%s', do_shortcode( $content ) );
?>
</div>
</div>
</div>
</div>
<?php wp_footer(); ?>
</body>
</html>