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,159 @@
<?php
/**
* Fonts
*
* @package Powerkit
* @subpackage Extensions
*/
if ( class_exists( 'Powerkit_Module' ) ) {
/**
* Init module
*/
class Powerkit_Fonts extends Powerkit_Module {
/**
* Register module
*/
public function register() {
$this->name = 'fonts';
$this->slug = 'fonts';
$this->type = 'extension';
$this->category = 'basic';
$this->public = false;
$this->enabled = false;
}
/**
* Initialize module
*/
public function initialize() {
add_action( 'admin_menu', array( $this, 'register_options_page' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
add_filter( 'powerkit_fonts_choices', array( $this, 'kirki_fonts_choices' ) );
}
/**
* Register admin page
*
* @since 1.0.0
*/
public function register_options_page() {
add_theme_page( esc_html__( 'Fonts', 'powerkit' ), esc_html__( 'Fonts', 'powerkit' ), 'manage_options', powerkit_get_page_slug( $this->slug ), array( $this, 'settings_page' ) );
}
/**
* Build admin page
*
* @since 1.0.0
*/
public function settings_page() {
powerkit_uuid_hash();
// Check wpnonce.
if ( ! isset( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( $_REQUEST['_wpnonce'] ) ) { // Input var ok; sanitization ok.
return;
}
if ( ! current_user_can( 'manage_options' ) ) {
wp_die( esc_html__( 'You do not have sufficient rights to view this page.', 'powerkit' ) );
}
?>
<div class="wrap">
<h1 class="wp-heading-inline"><?php esc_html_e( 'Fonts', 'powerkit' ); ?></h1>
<hr class="wp-header-end">
<div class="settings">
<?php $fonts_settings = apply_filters( 'powerkit_fonts_register_settings', array() ); ?>
<?php if ( $fonts_settings ) : ?>
<div class="tabs">
<?php
$first_settings = current( $fonts_settings );
$tab = sanitize_title( isset( $_REQUEST['tab'] ) ? $_REQUEST['tab'] : $first_settings['id'] ); // Input var ok; sanitization ok.
?>
<nav class="nav-tab-wrapper">
<?php
foreach ( $fonts_settings as $item ) {
$class = ( $item['id'] === $tab ) ? 'nav-tab-active' : '';
printf( '<a class="nav-tab %4$s" href="%1$s&tab=%2$s">%3$s</a>',
esc_url( powerkit_get_page_url( $this->slug, 'themes' ) ), esc_attr( $item['id'] ), esc_html( $item['name'] ), esc_attr( $class )
);
}
?>
</nav>
<?php
foreach ( $fonts_settings as $item ) {
if ( $item['id'] === $tab ) {
?>
<div id="tab-<?php echo esc_attr( $item['id'] ); ?>" class="tab-wrap">
<?php
if ( is_callable( $item['function'] ) ) {
call_user_func( $item['function'] );
}
?>
</div>
<?php
}
}
?>
</div>
<?php endif; ?>
</div>
</div>
<?php
}
/**
* Add support wp-custom-fonts in Kirki.
*
* @param array $settings Pre settings.
*/
public function kirki_fonts_choices( $settings = array() ) {
$fonts_list = apply_filters( 'powerkit_fonts_list', array() );
if ( ! $fonts_list ) {
return $settings;
}
$fonts_settings = array(
'fonts' => array(
'google' => array(),
'families' => isset( $fonts_list['families'] ) ? $fonts_list['families'] : null,
'variants' => isset( $fonts_list['variants'] ) ? $fonts_list['variants'] : null,
),
);
$fonts_settings = array_merge( (array) $fonts_settings, (array) $settings );
return $fonts_settings;
}
/**
* Register the stylesheets and JavaScript for the admin area.
*
* @param string $page Current page.
*/
public function admin_enqueue_scripts( $page ) {
if ( 'appearance_page_' . powerkit_get_page_slug( $this->slug ) === $page ) {
wp_enqueue_media();
wp_enqueue_script( 'admin-powerkit-fonts', plugin_dir_url( __FILE__ ) . 'js/admin-powerkit-fonts.js', array( 'jquery' ), powerkit_get_setting( 'version' ), false );
wp_localize_script( 'admin-powerkit-fonts', 'powerkitFonts', array(
'delete' => esc_html__( 'Are you sure you want to delete this font and all the files downloaded from it?', 'powerkit' ),
'title' => esc_html__( 'Select or Upload Font', 'powerkit' ),
'button' => esc_html__( 'Use This File', 'powerkit' ),
) );
}
}
}
new Powerkit_Fonts();
}
@@ -0,0 +1,101 @@
( function( $ ) {
'use strict';
$( function() {
/* Set all variables to be used in scope */
var powerkitFontsMediaFrame;
/* Add Font Link */
$( document ).on( 'click', '.upload-font-container .upload-font-link', function( event ) {
event.preventDefault();
var parentContainer = $( this ).parents( '.upload-font-container' );
// Options.
var options = {
title: powerkitFonts.title,
button: {
text: powerkitFonts.button,
},
library: {
type: parentContainer.data( 'type' )
},
multiple: false
};
powerkitFontsMediaFrame = wp.media( options );
// When an image is selected in the media frame...
powerkitFontsMediaFrame.on( 'select', function() {
// Get media attachment details from the frame state.
var attachment = powerkitFontsMediaFrame.state().get( 'selection' ).first().toJSON();
parentContainer.find( '.filename' ).val( attachment.filename ).change();
parentContainer.find( '.uploaded-font-id' ).val( attachment.id ).change();
parentContainer.find( '.upload-font-link' ).addClass( 'hidden' );
parentContainer.find( '.delete-font-link' ).removeClass( 'hidden' );
powerkitFontsMediaFrame.close();
} );
powerkitFontsMediaFrame.open();
} );
/* Delete Font Link */
$( document ).on( 'click', '.upload-font-container .delete-font-link', function( event ) {
event.preventDefault();
var parentContainer = $( this ).parents( '.upload-font-container' );
parentContainer.find( '.filename' ).val( '' ).change();
parentContainer.find( '.uploaded-font-id' ).val( '' ).change();
parentContainer.find( '.upload-font-link' ).removeClass( 'hidden' );
parentContainer.find( '.delete-font-link' ).addClass( 'hidden' );
} );
/* Delete alert */
$( document ).on( 'click', '.powerkit-fonts-delete', function( event ) {
return confirm( powerkitFonts.delete ) ? true : false;
} );
/* View code */
$( document ).find( '.powerkit-fonts-view-code' ).each( function( index, el ) {
var obj = $( el ).closest( 'tr' ).next();
// Reset td padding.
$( obj ).find( 'td' ).css( 'padding', 0 );
// Show tr.
$( obj ).removeClass( 'hidden' );
// Set height textarea.
$( obj ).find( 'textarea' ).css( 'min-height', '110px' ).height( 110 );
} );
/* View code slide toggle */
$( document ).on( 'click', '.powerkit-fonts-view-code', function( event ) {
$( this ).closest( 'tr' ).prevAll().find( '.template-box' ).slideUp();
$( this ).closest( 'tr' ).next().nextAll().find( '.template-box' ).slideUp();
$( this ).closest( 'tr' ).next().find( '.template-box' ).slideToggle();
return false;
} );
/* View code outside */
$( document ).on( 'click', function( event ) {
if ( !$( event.target ).closest( '.wp-list-table' ).length ) {
$( '.template-box' ).slideUp();
}
} );
} );
} )( jQuery );