Initial commit: Atomaste website
This commit is contained in:
@@ -0,0 +1,153 @@
|
||||
<?php
|
||||
/**
|
||||
* Quick_Links Setup.
|
||||
*
|
||||
* @since 2.6.2
|
||||
* @package Astra Sites
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'BSF_Quick_Links' ) ) {
|
||||
|
||||
/**
|
||||
* Quick_Links.
|
||||
*/
|
||||
class BSF_Quick_Links {
|
||||
/**
|
||||
* Quick_Links version.
|
||||
*
|
||||
* @access private
|
||||
* @var array Quick_Links.
|
||||
* @since 2.6.2
|
||||
*/
|
||||
private static $version = '1.0.0';
|
||||
|
||||
/**
|
||||
* Quick_Links
|
||||
*
|
||||
* @access private
|
||||
* @var array Quick_Links.
|
||||
* @since 2.6.2
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
/**
|
||||
* Initiator
|
||||
*
|
||||
* @since 2.6.2
|
||||
* @return object initialized object of class.
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( ! isset( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @since 2.6.2
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue Scripts.
|
||||
*
|
||||
* @since 2.6.2
|
||||
* @return void
|
||||
*/
|
||||
public function enqueue_scripts() {
|
||||
wp_register_script( 'bsf-quick-links', $this->get_uri() . 'quicklinks.js', array( 'jquery' ), self::$version, true );
|
||||
wp_register_style( 'bsf-quick-links-css', $this->get_uri() . 'quicklink.css', array(), self::$version, 'screen' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get URI
|
||||
*
|
||||
* @return mixed URL.
|
||||
*/
|
||||
public function get_uri() {
|
||||
$path = wp_normalize_path( dirname( __FILE__ ) );
|
||||
$theme_dir = wp_normalize_path( get_template_directory() );
|
||||
|
||||
if ( strpos( $path, $theme_dir ) !== false ) {
|
||||
return trailingslashit( get_template_directory_uri() . str_replace( $theme_dir, '', $path ) );
|
||||
}
|
||||
|
||||
return plugin_dir_url( __FILE__ );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate Quick Links Markup.
|
||||
*
|
||||
* @param array $data links array.
|
||||
*/
|
||||
public function generate_quick_links_markup( $data ) {
|
||||
|
||||
wp_enqueue_script( 'bsf-quick-links' );
|
||||
wp_enqueue_style( 'bsf-quick-links-css' );
|
||||
|
||||
?>
|
||||
<div class="bsf-quick-link-wrap">
|
||||
<div class="bsf-quick-link-items-wrap hide-wrapper">
|
||||
<?php echo $this->get_links_html( $data ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- All attributes are escaped inside of this function. ?>
|
||||
</div>
|
||||
<a href="#" class="bsf-quick-link">
|
||||
<div class="quick-link-button-wrap">
|
||||
<img src="<?php echo esc_url( $data['default_logo']['url'] ); ?>">
|
||||
<span><?php esc_html_e( 'Quick Links', 'astra-sites' ); ?></span>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate links markup.
|
||||
*
|
||||
* @param array $data links array.
|
||||
*/
|
||||
private function get_links_html( $data ) {
|
||||
$items_html = '';
|
||||
|
||||
foreach ( $data['links'] as $item_key => $item ) {
|
||||
$items_html .= sprintf(
|
||||
'<a href="%1$s" target="_blank" rel="noopener noreferrer" class="bsf-quick-link-item bsf-quick-link-item-%4$s">
|
||||
<div class="bsf-quick-link-label">%2$s</div>
|
||||
<div class="dashicons %3$s menu-item-logo" %5$s></div>
|
||||
</a>',
|
||||
esc_url( $item['url'] ),
|
||||
esc_html( $item['label'] ),
|
||||
sanitize_html_class( $item['icon'] ),
|
||||
$item_key,
|
||||
! empty( $item['bgcolor'] ) ? ' style="background-color: ' . esc_attr( $item['bgcolor'] ) . '"' : ''
|
||||
);
|
||||
}
|
||||
|
||||
return $items_html;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Kicking this off by calling 'get_instance()' method
|
||||
*/
|
||||
BSF_Quick_Links::get_instance();
|
||||
|
||||
}
|
||||
if ( ! function_exists( 'bsf_quick_links' ) ) {
|
||||
/**
|
||||
* Add BSF Quick Links.
|
||||
*
|
||||
* @param array $args links array.
|
||||
*/
|
||||
function bsf_quick_links( $args ) {
|
||||
BSF_Quick_Links::get_instance()->generate_quick_links_markup( $args );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
.bsf-quick-link-items-wrap,
|
||||
.bsf-quick-link {
|
||||
position: fixed;
|
||||
z-index: 10;
|
||||
transition: all 0.2s ease-in-out;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.bsf-quick-link-items-wrap{
|
||||
right: 2.2rem;
|
||||
bottom: 8em;
|
||||
}
|
||||
|
||||
.bsf-quick-link{
|
||||
right: 25px;
|
||||
bottom: 40px;
|
||||
}
|
||||
|
||||
.bsf-quick-link-wrap a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.bsf-quick-link-wrap a:focus {
|
||||
text-decoration: none;
|
||||
box-shadow: unset;
|
||||
outline: unset;
|
||||
}
|
||||
|
||||
.bsf-quick-link-item {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.menu-item-logo {
|
||||
margin-left: 14px;
|
||||
font-size: 18px;
|
||||
color: white;
|
||||
background: #005e9b;
|
||||
padding: 12px;
|
||||
border-radius: 50%;
|
||||
height: 18px;
|
||||
width: 18px;
|
||||
}
|
||||
|
||||
.bsf-quick-link-label {
|
||||
color: #fff;
|
||||
background: #5C5C5C;
|
||||
white-space: nowrap;
|
||||
padding: 5px 10px;
|
||||
border-radius: 3px;
|
||||
-moz-border-radius: 3px;
|
||||
-webkit-border-radius: 3px;
|
||||
height: 14px;
|
||||
margin-top: 9px;
|
||||
font-size: 12px;
|
||||
border: 1px solid #959595;
|
||||
line-height: 1;
|
||||
position: absolute;
|
||||
right: 55px;
|
||||
}
|
||||
|
||||
.menu-item-logo:hover{
|
||||
filter:brightness(150%);
|
||||
}
|
||||
|
||||
.dashicons-star-filled.menu-item-logo:hover{
|
||||
filter:brightness(120%);
|
||||
}
|
||||
|
||||
.bsf-quick-link-items-wrap.hide-wrapper .bsf-quick-link-item {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.bsf-quick-link-item {
|
||||
-webkit-transition: -webkit-transform .2s;
|
||||
transition: -webkit-transform .2s;
|
||||
transition: transform .2s;
|
||||
transition: transform .2s,-webkit-transform .2s;
|
||||
}
|
||||
|
||||
.bsf-quick-link-items-wrap.show-popup .bsf-quick-link-item {
|
||||
-webkit-transform: scale(1);
|
||||
-ms-transform: scale(1);
|
||||
transform: scale(1);
|
||||
}
|
||||
|
||||
.bsf-quick-link-items-wrap .bsf-quick-link-item {
|
||||
-webkit-transform: scale(0);
|
||||
-ms-transform: scale(0);
|
||||
transform: scale(0);
|
||||
}
|
||||
|
||||
.quick-link-button-wrap {
|
||||
background: #ffffff;
|
||||
border-radius: 30px;
|
||||
color: #000;
|
||||
padding: 6px 18px;
|
||||
border: 2px solid #4400C1;
|
||||
font-weight: 500;
|
||||
box-shadow: 0px 8px 18px 0px rgb(0 0 0 / 25%);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height:30px;
|
||||
}
|
||||
|
||||
.quick-link-button-wrap img {
|
||||
height: auto;
|
||||
width: 22px;
|
||||
margin-right: 10px;
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
(function ($) {
|
||||
/**
|
||||
* BSFQuickLinks
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
BSFQuickLinks = {
|
||||
/**
|
||||
* Initializes Events.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @method init
|
||||
*/
|
||||
init: function () {
|
||||
this._bind();
|
||||
},
|
||||
|
||||
/**
|
||||
* Binds events for the BSF Quick Links
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access private
|
||||
* @method _bind
|
||||
*/
|
||||
_bind: function () {
|
||||
$(document).on("click", ".bsf-quick-link", BSFQuickLinks._toggle);
|
||||
$(document).on("click", BSFQuickLinks._onClickOutside);
|
||||
$(document).on("click", BSFQuickLinks._movePopUpToTop);
|
||||
$(document).ready(BSFQuickLinks._movePopUpToTop);
|
||||
},
|
||||
|
||||
_movePopUpToTop: function (e) {
|
||||
if ($('.single-site-footer').length) {
|
||||
$(".bsf-quick-link").css("bottom", "80px");
|
||||
$(".bsf-quick-link-items-wrap").css("bottom", "11em");
|
||||
} else {
|
||||
$(".bsf-quick-link").css("bottom", "40px");
|
||||
$(".bsf-quick-link-items-wrap").css("bottom", "8em");
|
||||
}
|
||||
if ($('.astra-sites-result-preview').length && !$('.astra-sites-result-preview').is(':empty')) {
|
||||
$(".bsf-quick-link").css("z-index", "-10");
|
||||
} else {
|
||||
$(".bsf-quick-link").css("z-index", "10");
|
||||
}
|
||||
},
|
||||
|
||||
_onClickOutside: function (e) {
|
||||
if ($(e.target).closest('.bsf-quick-link-wrap').length === 0) {
|
||||
$('.bsf-quick-link-items-wrap').removeClass('show-popup');
|
||||
}
|
||||
},
|
||||
|
||||
_toggle: function (event) {
|
||||
event.preventDefault();
|
||||
var wrap = $('.bsf-quick-link-items-wrap');
|
||||
wrap.removeClass('hide-wrapper');
|
||||
|
||||
if (wrap.hasClass('show-popup')) {
|
||||
wrap.removeClass('show-popup');
|
||||
} else {
|
||||
wrap.addClass('show-popup');
|
||||
}
|
||||
|
||||
var logoWrapper = $('.bsf-quick-link');
|
||||
if (logoWrapper.hasClass('show')) {
|
||||
logoWrapper.removeClass('show');
|
||||
} else {
|
||||
logoWrapper.addClass('show');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$(function () {
|
||||
BSFQuickLinks.init();
|
||||
});
|
||||
})(jQuery);
|
||||
@@ -0,0 +1,49 @@
|
||||
# BSF Quick Links
|
||||
|
||||
BSF Quick Links allows you to show a list of your most commonly used links and access them from our plugins settings page
|
||||
> Example
|
||||
> - Upgrade to Pro.
|
||||
> - Documentation
|
||||
> - Join our community and access them from our plugins settings page.
|
||||
|
||||
|
||||
### How to use? ###
|
||||
@see https://github.com/brainstormforce/astra-sites/blob/3c42ceeeb466a2f4e7656ba0d5b43a8a9909e6fd/inc/classes/class-astra-sites.php#L143
|
||||
|
||||
- Add below action into respective plugins settings page.
|
||||
```sh
|
||||
add_action( 'admin_footer', array( $this, 'add_quick_links' ) );
|
||||
```
|
||||
|
||||
- Callback function
|
||||
```sh
|
||||
public function add_quick_links() {
|
||||
$current_screen = get_current_screen();
|
||||
|
||||
if ( 'plugin_settings_screen_name' !== $current_screen->id ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( Astra_Sites_White_Label::get_instance()->is_white_labeled() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$data = array(
|
||||
'default_logo' => array(
|
||||
'title' => '', //title on logo hover.
|
||||
'url' => '',
|
||||
),
|
||||
'links' => array(
|
||||
array('label' => '','icon' => '','url' => ''),
|
||||
array('label' => '','icon' => '','url' => ''),
|
||||
array('label' => '','icon' => '','url' => ''),
|
||||
...
|
||||
)
|
||||
);
|
||||
if ( defined( 'ASTRA_PRO_SITES_VER' ) ) {
|
||||
array_shift( $data['links'] ); //Exclude upgrade to pro link.
|
||||
}
|
||||
|
||||
bsf_quick_links( $data );
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user