*/ if ( ! function_exists( 'acme_coming_soon_default_options' ) ) : /** * Get the Plugin Default Options. * * @since 1.0.0 * @return array Default Options * @author codersantosh */ function acme_coming_soon_default_options() { $default_options = array( 'on' => false, 'access' => 'admin', 'exclude' => array( 'useRoles' => array(), 'searchBot' => false, 'ips' => array(), 'slugs' => array(), ), 'template' => 0, 'deleteAll' => false, ); return apply_filters( 'acme_coming_soon_default_options', $default_options ); } endif; if ( ! function_exists( 'acme_coming_soon_get_options' ) ) : /** * Get the Plugin Saved Options. * * @since 1.0.0 * * @param string $key optional option key. * @return mixed All Options Array Or Options Value * @author codersantosh */ function acme_coming_soon_get_options( $key = '' ) { $options = get_option( ACME_COMING_SOON_OPTION_NAME ); $default_options = acme_coming_soon_default_options(); if ( ! empty( $key ) ) { if ( isset( $options[ $key ] ) ) { return $options[ $key ]; } return isset( $default_options[ $key ] ) ? $default_options[ $key ] : false; } else { if ( ! is_array( $options ) ) { $options = array(); } return array_merge( $default_options, $options ); } } endif; if ( ! function_exists( 'acme_coming_soon_update_options' ) ) : /** * Update the Plugin Options. * * @since 1.0.0 * * @param string|array $key_or_data array of options or single option key. * @param string $val value of option key. * * @return mixed All Options Array Or Options Value * * @author codersantosh */ function acme_coming_soon_update_options( $key_or_data, $val = '' ) { if ( is_string( $key_or_data ) ) { $options = acme_coming_soon_get_options(); $options[ $key_or_data ] = $val; } else { $options = $key_or_data; } update_option( ACME_COMING_SOON_OPTION_NAME, $options ); } endif; if ( ! function_exists( 'acme_coming_soon_file_system' ) ) { /** * * WordPress file system wrapper * * @since 1.0.0 * * @return string|WP_Error directory path or WP_Error object if no permission */ function acme_coming_soon_file_system() { global $wp_filesystem; if ( ! $wp_filesystem ) { require_once ABSPATH . 'wp-admin' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'file.php'; } WP_Filesystem(); return $wp_filesystem; } } if ( ! function_exists( 'acme_coming_soon_parse_changelog' ) ) { /** * Parse changelog * * @since 1.0.0 * @return string */ function acme_coming_soon_parse_changelog() { $wp_filesystem = acme_coming_soon_file_system(); $changelog_file = apply_filters( 'acme_coming_soon_changelog_file', ACME_COMING_SOON_PATH . 'readme.txt' ); /*Check if the changelog file exists and is readable.*/ if ( ! $changelog_file || ! is_readable( $changelog_file ) ) { return ''; } $content = $wp_filesystem->get_contents( $changelog_file ); if ( ! $content ) { return ''; } $matches = null; $regexp = '~==\s*Changelog\s*==(.*)($)~Uis'; $changelog = ''; if ( preg_match( $regexp, $content, $matches ) ) { $changes = explode( '\r\n', trim( $matches[1] ) ); foreach ( $changes as $index => $line ) { $changelog .= wp_kses_post( preg_replace( '~(=\s*Version\s*(\d+(?:\.\d+)+)\s*=|$)~Uis', '', $line ) ); } } return wp_kses_post( $changelog ); } } if ( ! function_exists( 'acme_coming_soon_get_white_label' ) ) : /** * Get white label options for this plugin. * * @since 1.0.0 * @param string $key optional option key. * @return mixed All Options Array Or Options Value * @author codersantosh */ function acme_coming_soon_get_white_label( $key = '' ) { $plugin_name = apply_filters( 'acme_coming_soon_white_label_plugin_name', esc_html__( 'Acme Coming Soon and Maintenance Mode Page', 'acme-coming-soon' ) ); $options = apply_filters( 'acme_coming_soon_white_label', array( 'admin_menu_page' => array( 'page_title' => esc_html__( 'Coming Soon Page', 'acme-coming-soon' ), 'menu_title' => esc_html__( 'Coming Soon', 'acme-coming-soon' ), 'menu_slug' => ACME_COMING_SOON_PLUGIN_NAME, 'icon_url' => ACME_COMING_SOON_URL . 'assets/img/logo-20-20.png', 'position' => null, ), 'dashboard' => array( 'logo' => ACME_COMING_SOON_URL . 'assets/img/logo.png', 'notice' => sprintf( /* translators: %s is the plugin name */ esc_html__( 'Congratulations on choosing the %s for your website Coming Soon or Maintenance Mode. We recommend taking a few minutes to read the following information on how the plugin works. Please read it carefully to fully understand capabilities of the plugin and how to use them effectively.', 'acme-coming-soon' ), $plugin_name ), ), 'landingPage' => array( 'banner' => array( 'heading' => $plugin_name, 'leadText' => sprintf( /* translators: %s is the plugin name */ esc_html__( 'Congratulations! You have successfully installed %s and it is ready for enabling or disabling coming soon or maintenance mode.', 'acme-coming-soon' ), $plugin_name ), 'normalText' => sprintf( /* translators: %s is the plugin name */ esc_html__( 'If you have any questions or need assistance, please do not hesitate to contact us for support. The %s plugin caters to WordPress site owners, developers and designers seeking to create and display Coming Soon page for their new site or display Maintenance Mode while updating existing sites.', 'acme-coming-soon' ), $plugin_name, ), 'buttons' => array( array( 'icon' => '', 'text' => esc_html__( 'Get started', 'acme-coming-soon' ), 'url' => 'https://patternswp.com/wp-plugins/coming-soon-and-maintenance-mode-page/', 'variant' => 'primary', ), array( 'icon' => '', 'text' => esc_html__( 'Docmentation', 'acme-coming-soon' ), 'url' => 'https://patternswp.com/wp-plugins/coming-soon-and-maintenance-mode-page/', 'variant' => 'outline-primary', ), array( 'icon' => '', 'text' => esc_html__( 'Get support', 'acme-coming-soon' ), 'url' => 'https://patternswp.com/wp-plugins/coming-soon-and-maintenance-mode-page/', 'variant' => 'secondary', ), ), 'image' => ACME_COMING_SOON_URL . 'assets/img/featured-image.png', ), 'identity' => array( 'logo' => ACME_COMING_SOON_URL . 'assets/img/logo.png', 'title' => $plugin_name, 'buttons' => array( array( 'text' => esc_html__( 'Visit site', 'acme-coming-soon' ), 'url' => 'https://patternswp.com/wp-plugins/coming-soon-and-maintenance-mode-page/', 'variant' => 'primary', ), array( 'text' => esc_html__( 'Get Support', 'acme-coming-soon' ), 'url' => 'https://patternswp.com/wp-plugins/coming-soon-and-maintenance-mode-page/', 'variant' => 'light', ), ), ), 'contact' => array( 'title' => esc_html__( 'Contact Information', 'acme-coming-soon' ), 'info' => array( array( 'icon' => '', 'title' => esc_html__( 'Support', 'acme-coming-soon' ), 'text' => esc_html__( 'Get Support', 'acme-coming-soon' ), 'url' => 'https://patternswp.com/wp-plugins/coming-soon-and-maintenance-mode-page/', 'variant' => 'link', ), array( 'icon' => '', 'title' => esc_html__( 'Location', 'acme-coming-soon' ), 'text' => esc_html__( 'Kathmandu, Nepal', 'acme-coming-soon' ), ), ), 'social' => array( array( 'icon' => '', 'url' => 'https://profiles.wordpress.org/patternswp/', 'variant' => 'outline-primary', ), array( 'icon' => '', 'url' => 'https://patternswp.com/', 'variant' => 'outline-primary', ), array( 'icon' => '', 'url' => 'https://twitter.com/patternswp', 'variant' => 'outline-primary', ), ), ), 'bannerColumns' => array( array( 'icon' => '', 'title' => esc_html__( 'Enable coming soon', 'acme-coming-soon' ), ), array( 'icon' => '', 'title' => esc_html__( 'Do few settings', 'acme-coming-soon' ), ), array( 'icon' => '', 'title' => esc_html__( 'Start developing your site', 'acme-coming-soon' ), ), ), 'normalColumns' => array( array( 'icon' => '', 'title' => esc_html__( 'Knowledge base', 'acme-coming-soon' ), 'content' => esc_html__( 'The utilization of this plugin can be facilitated by perusing comprehensive and well-documented articles.', 'acme-coming-soon' ), 'buttonText' => esc_html__( 'Visit knowledge base', 'acme-coming-soon' ), 'buttonLink' => 'https://patternswp.com/wp-plugins/coming-soon-and-maintenance-mode-page/', ), array( 'icon' => '', 'title' => esc_html__( 'Community', 'acme-coming-soon' ), 'content' => sprintf( /* translators: %s is the plugin name */ esc_html__( 'Our objective is to enhance the customer experience, we invite you to join our community where you can receive immediate support.', 'acme-coming-soon' ), $plugin_name, ), 'buttonText' => esc_html__( 'Visit community page', 'acme-coming-soon' ), 'buttonLink' => 'https://patternswp.com/wp-plugins/coming-soon-and-maintenance-mode-page/', ), array( 'icon' => '', 'title' => esc_html__( '24x7 support', 'acme-coming-soon' ), 'content' => sprintf( /* translators: %s is the plugin name */ esc_html__( 'Our support team is available 24/7 to assist you in the event that you encounter any problems while utilizing this plugin.', 'acme-coming-soon' ), $plugin_name, ), 'buttonText' => esc_html__( 'Create a support thread', 'acme-coming-soon' ), 'buttonLink' => 'https://patternswp.com/wp-plugins/coming-soon-and-maintenance-mode-page/', ), array( 'icon' => '', 'title' => esc_html__( 'Video guide', 'acme-coming-soon' ), 'content' => sprintf( /* translators: %s is the plugin name */ esc_html__( 'The plugin is accompanied by comprehensive video tutorials that provide practical demonstrations for most customization.', 'acme-coming-soon' ), $plugin_name, ), 'buttonText' => esc_html__( 'View video guide', 'acme-coming-soon' ), 'buttonLink' => 'https://patternswp.com/wp-plugins/coming-soon-and-maintenance-mode-page/', ), ), 'topicLinks' => array( 'icon' => '', 'title' => esc_html__( 'Quick links to settings', 'acme-coming-soon' ), 'columns' => array( array( 'icon' => '', 'title' => esc_html__( 'General settings', 'acme-coming-soon' ), 'link' => '#/maintenance/general', 'variant' => 'light', 'target' => '_self', ), ), ), 'changelog' => array( 'icon' => '', 'title' => esc_html__( 'Changelog', 'acme-coming-soon' ), 'content' => acme_coming_soon_parse_changelog(), ), ), ) ); if ( ! empty( $key ) ) { return $options[ $key ]; } else { return $options; } } endif; if ( ! function_exists( 'acme_coming_soon_sanitize_ip' ) ) { /** * Sanitize IP address. * * @since 1.0.0 * * @param string $ip IP address. * * @return string Sanitized IP address or empty string if invalid. */ function acme_coming_soon_sanitize_ip( $ip ) { $sanitized_ip = filter_var( $ip, FILTER_VALIDATE_IP ); if ( false !== $sanitized_ip ) { return $sanitized_ip; } else { return ''; } } }