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,58 @@
<?php
/**
* Author Box
*
* @package Powerkit
* @subpackage Modules
*/
if ( class_exists( 'Powerkit_Module' ) ) {
/**
* Init module
*/
class Powerkit_Author_Box extends Powerkit_Module {
/**
* Register module
*/
public function register() {
$this->name = esc_html__( 'Author Box', 'powerkit' );
$this->desc = esc_html__( 'Display a post author box in your sidebar, including author name, bio and avatar in multiple available layouts.', 'powerkit' );
$this->slug = 'author_box';
$this->type = 'default';
$this->category = 'widget';
$this->priority = 160;
$this->public = true;
$this->enabled = true;
$this->links = array(
array(
'name' => esc_html__( 'View documentation', 'powerkit' ),
'url' => powerkit_get_setting( 'documentation' ) . '/author-box/',
'target' => '_blank',
),
);
}
/**
* Initialize module
*/
public function initialize() {
// Helpers Functions for the module.
require_once dirname( __FILE__ ) . '/helpers/helper-powerkit-author-box.php';
// The classes responsible for defining all actions.
require_once dirname( __FILE__ ) . '/public/class-powerkit-author-box-widget.php';
if ( function_exists( 'register_block_type' ) ) {
require_once dirname( __FILE__ ) . '/public/class-powerkit-author-box-block.php';
}
// Admin and public area.
require_once dirname( __FILE__ ) . '/public/class-powerkit-author-box-public.php';
new Powerkit_Author_Box_Public( $this->slug );
}
}
new Powerkit_Author_Box();
}
@@ -0,0 +1,26 @@
<?php
/**
* Helpers Featured Posts
*
* @package Powerkit
* @subpackage Modules/Helper
*/
/**
* Template handler
*
* @param string $name Specific template.
* @param int $author The author.
* @param array $args Array of args.
* @param array $params Array of params.
* @param array $instance Widget instance.
*/
function powerkit_widget_author_template_handler( $name, $author, $args, $params, $instance ) {
$templates = apply_filters( 'powerkit_widget_author_templates', array() );
if ( isset( $templates[ $name ] ) && function_exists( $templates[ $name ]['func'] ) ) {
call_user_func( $templates[ $name ]['func'], $author, $args, $params, $instance );
} else {
call_user_func( 'powerkit_widget_author_default_template', $author, $args, $params, $instance );
}
}
@@ -0,0 +1,87 @@
<?php
/**
* Author block template
*
* @var $attributes - block attributes
* @var $options - layout options
*
* @link https://codesupply.co
* @since 1.0.0
*
* @package PowerKit
* @subpackage PowerKit/templates
*/
$params = array(
'title' => '',
'author' => $attributes['author'],
'bg_image_id' => isset( $attributes['bgImage']['id'] ) ? $attributes['bgImage']['id'] : 0,
'avatar' => $attributes['showAvatar'],
'description' => $attributes['showDescription'],
'description_override' => $attributes['overrideDescription'],
'description_length' => isset( $attributes['descriptionLength'] ) ? $attributes['descriptionLength'] : 100,
'social_accounts' => $attributes['showSocialAccounts'],
'archive_btn' => $attributes['showArchiveBtn'],
'template' => 'default',
'is_block' => true,
'block_attrs' => $attributes,
);
echo '<div class="' . esc_attr( $attributes['className'] ) . '" ' . ( isset( $attributes['anchor'] ) ? ' id="' . esc_attr( $attributes['anchor'] ) . '"' : '' ) . '>';
// Title.
if ( $params['title'] ) {
$params['title'] = '<h5 class="pk-author-title">' . $params['title'] . '<h5>';
}
$authors = array();
// Get authors.
if ( 'current' === $params['author'] ) {
$params['posts_only'] = true;
$coauthors = array();
if ( function_exists( 'get_coauthors' ) ) {
$coauthors = get_coauthors();
}
if ( $coauthors ) {
// Get co authors.
foreach ( $coauthors as $author ) {
$authors[] = $author->ID;
}
} else {
// Get the default WP author.
$authors[] = get_the_author_meta( 'ID' );
}
} else {
if ( get_the_author_meta( 'display_name', $params['author'] ) ) {
$authors[] = $params['author'];
} elseif ( current_user_can( 'editor' ) || current_user_can( 'administrator' ) ) {
?>
<p class="pk-alert pk-alert-warning" role="alert">
<?php esc_html_e( 'Author not found.', 'powerkit' ); ?>
</p>
<?php
}
}
if ( ! empty( $authors ) ) {
foreach ( $authors as $author ) {
if ( ! @ is_author( $author ) ) {
$args = array(
'before_title' => '',
'after_title' => '',
'before_widget' => '',
'after_widget' => '',
);
powerkit_widget_author_template_handler( $params['template'], $author, $args, $params, array() );
}
}
}
echo '</div>';
@@ -0,0 +1,199 @@
<?php
/**
* The Gutenberg Block.
*
* @link https://codesupply.co
* @since 1.0.0
*
* @package Powerkit
* @subpackage Modules/public
*/
/**
* The initialize block.
*/
class Powerkit_Author_Block {
/**
* Initialize
*/
public function __construct() {
add_filter( 'powerkit_pinit_exclude_selectors', array( $this, 'pinit_disable' ) );
add_action( 'init', array( $this, 'block' ) );
add_filter( 'canvas_register_block_type', array( $this, 'register_block_type' ) );
}
/**
* PinIt disable
*
* @param string $selectors List selectors.
*/
public function pinit_disable( $selectors ) {
$selectors[] = '.pk-block-author';
return $selectors;
}
/**
* Enqueue the block's assets for the editor.
*/
public function block() {
// Styles.
wp_register_style(
'powerkit-author-block-editor-style',
plugins_url( 'css/public-powerkit-author-box.css', __FILE__ ),
array( 'wp-edit-blocks' ),
filemtime( plugin_dir_path( __FILE__ ) . 'css/public-powerkit-author-box.css' )
);
wp_style_add_data( 'powerkit-author-block-editor-style', 'rtl', 'replace' );
}
/**
* Register block
*
* @param array $blocks all registered blocks.
* @return array
*/
public function register_block_type( $blocks ) {
$users = powerkit_get_users();
$users_choices = array(
'current' => esc_html__( 'Current Posts Author' ),
);
foreach ( $users as $user ) {
$users_choices[ $user->ID ] = $user->display_name;
}
$blocks[] = array(
'name' => 'canvas/author',
'title' => esc_html__( 'Author', 'powerkit' ),
'description' => '',
'category' => 'canvas',
'keywords' => array(),
'icon' => '
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
<path d="M12 2C6.48 2 2 6.48 2 12C2 17.52 6.48 22 12 22C17.52 22 22 17.52 22 12C22 6.48 17.52 2 12 2ZM7.07 18.28C7.5 17.38 10.12 16.5 12 16.5C13.88 16.5 16.51 17.38 16.93 18.28C15.57 19.36 13.86 20 12 20C10.14 20 8.43 19.36 7.07 18.28ZM18.36 16.83C16.93 15.09 13.46 14.5 12 14.5C10.54 14.5 7.07 15.09 5.64 16.83C4.62 15.49 4 13.82 4 12C4 7.59 7.59 4 12 4C16.41 4 20 7.59 20 12C20 13.82 19.38 15.49 18.36 16.83V16.83ZM12 6C10.06 6 8.5 7.56 8.5 9.5C8.5 11.44 10.06 13 12 13C13.94 13 15.5 11.44 15.5 9.5C15.5 7.56 13.94 6 12 6ZM12 11C11.17 11 10.5 10.33 10.5 9.5C10.5 8.67 11.17 8 12 8C12.83 8 13.5 8.67 13.5 9.5C13.5 10.33 12.83 11 12 11Z" />
</svg>
',
'supports' => array(
'className' => true,
'anchor' => true,
'html' => false,
'canvasSpacings' => true,
'canvasBorder' => true,
'canvasResponsive' => true,
),
'styles' => array(),
'location' => array(),
'sections' => array(
'general' => array(
'title' => esc_html__( 'Block Settings', 'powerkit' ),
'priority' => 5,
'open' => true,
),
'buttonSettings' => array(
'title' => esc_html__( 'Button Settings', 'powerkit' ),
'priority' => 50,
),
),
'layouts' => array(),
'fields' => array_merge(
array(
array(
'key' => 'author',
'label' => esc_html__( 'Author', 'powerkit' ),
'section' => 'general',
'type' => 'select',
'choices' => $users_choices,
'default' => 'current',
),
array(
'key' => 'bgImage',
'label' => esc_html__( 'Background Image', 'powerkit' ),
'section' => 'general',
'type' => 'image',
'default' => '',
),
array(
'key' => 'showAvatar',
'label' => esc_html__( 'Display Avatar', 'powerkit' ),
'section' => 'general',
'type' => 'toggle',
'default' => true,
),
array(
'key' => 'showDescription',
'label' => esc_html__( 'Display Description', 'powerkit' ),
'section' => 'general',
'type' => 'toggle',
'default' => true,
),
array(
'key' => 'overrideDescription',
'label' => esc_html__( 'Override Description', 'powerkit' ),
'section' => 'general',
'type' => 'textarea',
'default' => '',
'active_callback' => array(
array(
'field' => 'showDescription',
'operator' => '==',
'value' => true,
),
),
),
array(
'key' => 'descriptionLength',
'label' => esc_html__( 'Description Length', 'powerkit' ),
'section' => 'general',
'type' => 'number',
'step' => 1,
'min' => 0,
'max' => 5000,
'default' => 100,
'active_callback' => array(
array(
'field' => 'showDescription',
'operator' => '==',
'value' => true,
),
),
),
array(
'key' => 'showSocialAccounts',
'label' => esc_html__( 'Display Social Accounts', 'powerkit' ),
'section' => 'general',
'type' => 'toggle',
'default' => true,
),
array(
'key' => 'showArchiveBtn',
'label' => esc_html__( 'Display Archive Button', 'powerkit' ),
'section' => 'general',
'type' => 'toggle',
'default' => false,
),
), powerkit_get_gutenberg_button_fields(
'button',
'buttonSettings',
array(
array(
'field' => 'showArchiveBtn',
'operator' => '==',
'value' => true,
),
)
)
),
'template' => dirname( __FILE__ ) . '/block/render.php',
// enqueue registered scripts/styles.
'editor_style' => 'powerkit-author-block-editor-style',
);
return $blocks;
}
}
new Powerkit_Author_Block();
@@ -0,0 +1,64 @@
<?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_Author_Box_Public extends Powerkit_Module_Public {
/**
* Initialize
*/
public function initialize() {
add_action( 'init', array( $this, 'register_templates' ) );
add_filter( 'powerkit_widget_author_templates', array( $this, 'list_templates' ) );
}
/**
* Register Templates
*
* @since 1.0.0
* @access private
*
* @param array $templates List of Templates.
*/
public function register_templates( $templates = array() ) {
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/widget-author-template.php';
}
/**
* Filter Register Templates
*
* @since 1.0.0
* @access private
*
* @param array $templates List of Templates.
*/
public function list_templates( $templates = array() ) {
$templates = array(
'default' => array(
'name' => esc_html__( 'Default', 'powerkit' ),
'func' => 'powerkit_widget_author_default_template',
),
);
return $templates;
}
/**
* Register the stylesheets for the public-facing side of the site.
*/
public function wp_enqueue_scripts() {
wp_enqueue_style( 'powerkit-author-box', powerkit_style( plugin_dir_url( __FILE__ ) . 'css/public-powerkit-author-box.css' ), array(), powerkit_get_setting( 'version' ), 'all' );
// Add RTL support.
wp_style_add_data( 'powerkit-author-box', 'rtl', 'replace' );
}
}
@@ -0,0 +1,344 @@
<?php
/**
* Widget Author
*
* @link https://codesupply.co
* @since 1.0.0
*
* @package Powerkit
* @subpackage Powerkit/widgets
*/
/**
* Widget Author
*/
class Powerkit_Widget_Author_Init extends WP_Widget {
/**
* Sets up a new widget instance.
*/
public function __construct() {
$this->default_settings = apply_filters( 'powerkit_widget_author_settings', array(
'title' => esc_html__( 'Author', 'powerkit' ),
'author' => 'current',
'template' => 'default',
'bg_image_id' => false,
'avatar' => true,
'description' => true,
'description_override' => '',
'description_length' => 100,
'social_accounts' => true,
'posts_only' => false,
'archive_btn' => false,
) );
$widget_details = array(
'classname' => 'powerkit_widget_author',
'description' => '',
);
// Actions.
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
parent::__construct( 'powerkit_widget_author', esc_html__( 'Author', 'powerkit' ), $widget_details );
}
/**
* Outputs the content for the current widget instance.
*
* @param array $args Display arguments including 'before_title', 'after_title',
* 'before_widget', and 'after_widget'.
* @param array $instance Settings for the current widget instance.
*/
public function widget( $args, $instance ) {
$params = array_merge( $this->default_settings, $instance );
$authors = array();
// Get authors.
if ( 'current' === $params['author'] || 'сurrent' === $params['author'] ) {
if ( is_single() ) {
$params['posts_only'] = true;
$coauthors = array();
if ( function_exists( 'get_coauthors' ) ) {
$coauthors = get_coauthors();
}
if ( $coauthors ) {
// Get co authors.
foreach ( $coauthors as $author ) {
$authors[] = $author->ID;
}
} else {
// Get the default WP author.
$authors[] = get_the_author_meta( 'ID' );
}
}
} else {
if ( get_the_author_meta( 'display_name', $params['author'] ) ) {
$authors[] = $params['author'];
} elseif ( current_user_can( 'editor' ) || current_user_can( 'administrator' ) ) {
?>
<p class="pk-alert pk-alert-warning" role="alert">
<?php esc_html_e( 'Author not found.', 'powerkit' ); ?>
</p>
<?php
}
}
if ( empty( $authors ) ) {
return;
}
foreach ( $authors as $author ) {
// Display on posts only.
if ( $params['posts_only'] ) {
if ( is_single() ) {
$post_id = get_queried_object_id();
if ( ! powerkit_check_post_author( $author, $post_id ) ) {
continue;
}
} else {
continue;
}
}
// Display author.
if ( ! @ is_author( $author ) ) {
powerkit_widget_author_template_handler( $params['template'], $author, $args, $params, $instance );
}
}
}
/**
* Handles updating settings for the current widget instance.
*
* @param array $new_instance New settings for this instance as input by the user via
* WP_Widget::form().
* @param array $old_instance Old settings for this instance.
* @return array Settings to save or bool false to cancel saving.
*/
public function update( $new_instance, $old_instance ) {
$instance = $new_instance;
// Display avatar.
if ( ! isset( $instance['avatar'] ) ) {
$instance['avatar'] = false;
}
// Display description.
if ( ! isset( $instance['description'] ) ) {
$instance['description'] = false;
}
// Display social accounts.
if ( ! isset( $instance['social_accounts'] ) ) {
$instance['social_accounts'] = false;
}
// Display on posts only.
if ( ! isset( $instance['posts_only'] ) ) {
$instance['posts_only'] = false;
}
// Display post archive button.
if ( ! isset( $instance['archive_btn'] ) ) {
$instance['archive_btn'] = false;
}
return $instance;
}
/**
* Outputs the widget settings form.
*
* @param array $instance Current settings.
*/
public function form( $instance ) {
$params = array_merge( $this->default_settings, $instance );
$bg_image_url = $params['bg_image_id'] ? wp_get_attachment_image_url( intval( $params['bg_image_id'] ), 'large' ) : '';
$templates = apply_filters( 'powerkit_widget_author_templates', array() );
?>
<!-- Title -->
<p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:', 'powerkit' ); ?></label>
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $params['title'] ); ?>" /></p>
<!-- Template -->
<?php if ( count( $templates ) > 1 ) { ?>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'template' ) ); ?>"><?php esc_html_e( 'Template:', 'powerkit' ); ?></label>
<select name="<?php echo esc_attr( $this->get_field_name( 'template' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'template' ) ); ?>" class="widefat">
<?php
foreach ( $templates as $slug => $template ) {
$name = isset( $template['name'] ) ? $template['name'] : $slug;
?>
<option value="<?php echo esc_attr( $slug ); ?>" <?php selected( $params['template'], $slug ); ?>><?php echo esc_html( $name ); ?></option>
<?php } ?>
</select>
</p>
<?php } ?>
<!-- Author -->
<p><label for="<?php echo esc_attr( $this->get_field_id( 'author' ) ); ?>"><?php esc_html_e( 'Author:', 'powerkit' ); ?></label>
<select name="<?php echo esc_attr( $this->get_field_name( 'author' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'author' ) ); ?>" class="widefat">
<option value="current" <?php selected( $params['author'], 'current' ); ?>><?php esc_html_e( 'Current Posts Author' ); ?></option>
<?php
$authors = powerkit_get_users();
if ( isset( $authors ) && ! empty( $authors ) ) {
foreach ( $authors as $author ) {
?>
<option value="<?php echo esc_attr( $author->ID ); ?>" <?php selected( $params['author'], $author->ID ); ?>><?php echo esc_html( $author->display_name ); ?></option>
<?php
}
}
?>
</select>
</p>
<!-- Background Image container -->
<div class="author-upload-image upload-img-container" data-frame-title="<?php esc_html_e( 'Select or upload background image', 'powerkit' ); ?>" data-frame-btn-text="<?php esc_html_e( 'Set background image', 'powerkit' ); ?>">
<p class="uploaded-img-box">
<label for="<?php echo esc_attr( $this->get_field_id( 'bg_image_id' ) ); ?>"><?php esc_html_e( 'Background image:', 'powerkit' ); ?></label>
<span class="uploaded-image">
<?php if ( $bg_image_url ) : ?>
<img src="<?php echo esc_url( $bg_image_url ); ?>" style="display: block; margin-top: 5px; max-width:100%;" />
<?php endif; ?>
</span>
<input id="<?php echo esc_attr( $this->get_field_id( 'bg_image_id' ) ); ?>" class="uploaded-img-id" name="<?php echo esc_attr( $this->get_field_name( 'bg_image_id' ) ); ?>" type="hidden" value="<?php echo esc_attr( $params['bg_image_id'] ); ?>" />
</p>
<!-- Add & remove image links -->
<p class="hide-if-no-js">
<a class="upload-img-link button button-primary <?php echo esc_attr( $bg_image_url ? 'hidden' : '' ); ?>" href="#"><?php esc_html_e( 'Add Image', 'powerkit' ); ?></a>
<a class="delete-img-link button button-secondary <?php echo esc_attr( ! $bg_image_url ? 'hidden' : '' ); ?>" href="#"><?php esc_html_e( 'Remove Image', 'powerkit' ); ?></a>
</p>
</div>
<!-- Display avatar -->
<p><input id="<?php echo esc_attr( $this->get_field_id( 'avatar' ) ); ?>" class="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'avatar' ) ); ?>" type="checkbox" <?php checked( (bool) $params['avatar'] ); ?> />
<label for="<?php echo esc_attr( $this->get_field_id( 'avatar' ) ); ?>"><?php esc_html_e( 'Display avatar', 'powerkit' ); ?></label></p>
<!-- Display description -->
<p><input id="<?php echo esc_attr( $this->get_field_id( 'description' ) ); ?>" class="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'description' ) ); ?>" type="checkbox" <?php checked( (bool) $params['description'] ); ?> />
<label for="<?php echo esc_attr( $this->get_field_id( 'description' ) ); ?>"><?php esc_html_e( 'Display description', 'powerkit' ); ?></label></p>
<!-- Override Description -->
<p><label for="<?php echo esc_attr( $this->get_field_id( 'description_override' ) ); ?>"><?php esc_html_e( 'Override Description', 'powerkit' ); ?></label>
<textarea class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'description_override' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'description_override' ) ); ?>" rows="10"><?php echo esc_textarea( $params['description_override'] ); ?></textarea></p>
<!-- Description Length -->
<p><label for="<?php echo esc_attr( $this->get_field_id( 'description_length' ) ); ?>"><?php esc_html_e( 'Description Length:', 'powerkit' ); ?></label>
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'description_length' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'description_length' ) ); ?>" type="text" value="<?php echo esc_attr( $params['description_length'] ); ?>" /></p>
<!-- Display social accounts -->
<?php if ( powerkit_module_enabled( 'social_links' ) ) : ?>
<p><input id="<?php echo esc_attr( $this->get_field_id( 'social_accounts' ) ); ?>" class="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'social_accounts' ) ); ?>" type="checkbox" <?php checked( (bool) $params['social_accounts'] ); ?> />
<label for="<?php echo esc_attr( $this->get_field_id( 'social_accounts' ) ); ?>"><?php esc_html_e( 'Display social accounts', 'powerkit' ); ?></label></p>
<?php endif; ?>
<!-- Display post archive button -->
<p><input id="<?php echo esc_attr( $this->get_field_id( 'archive_btn' ) ); ?>" class="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'archive_btn' ) ); ?>" type="checkbox" <?php checked( (bool) $params['archive_btn'] ); ?> />
<label for="<?php echo esc_attr( $this->get_field_id( 'archive_btn' ) ); ?>"><?php esc_html_e( 'Display post archive button', 'powerkit' ); ?></label></p>
<!-- Display on posts only -->
<p><input id="<?php echo esc_attr( $this->get_field_id( 'posts_only' ) ); ?>" class="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'posts_only' ) ); ?>" type="checkbox" <?php checked( (bool) $params['posts_only'] ); ?> />
<label for="<?php echo esc_attr( $this->get_field_id( 'posts_only' ) ); ?>"><?php esc_html_e( 'Display on posts of the author only', 'powerkit' ); ?></label></p>
<?php
}
/**
* Admin Enqunue Scripts
*
* @param string $page Current page.
*/
public function admin_enqueue_scripts( $page ) {
if ( 'widgets.php' === $page ) {
wp_enqueue_script( 'jquery' );
wp_enqueue_media();
ob_start();
?>
<script>
jQuery( document ).ready(function( $ ) {
var powerkitMediaFrame;
/* Set all variables to be used in scope */
var metaBox = '.author-upload-image';
/* Add Image Link */
$(document).on( 'click', metaBox + ' .upload-img-link', function( event ){
event.preventDefault();
var parentContainer = $( this ).parents( metaBox );
// Options.
var options = {
title: parentContainer.data( 'frame-title' ) ? parentContainer.data( 'frame-title' ) : 'Select or Upload Media',
button: {
text: parentContainer.data( 'frame-btn-text' ) ? parentContainer.data( 'frame-btn-text' ) : 'Use this media',
},
library : { type : 'image' },
multiple: false // Set to true to allow multiple files to be selected.
};
// Create a new media frame
powerkitMediaFrame = wp.media( options );
// When an image is selected in the media frame...
powerkitMediaFrame.on( 'select', function() {
// Get media attachment details from the frame state.
var attachment = powerkitMediaFrame.state().get('selection').first().toJSON();
// Send the attachment URL to our custom image input field.
parentContainer.find( '.uploaded-image' ).html( '<img src="' + attachment.url + '" style="display: block; margin-top: 5px; max-width:100%;"/>' );
parentContainer.find( '.uploaded-img-id' ).val( attachment.id ).change();
parentContainer.find( '.upload-img-link' ).addClass( 'hidden' );
parentContainer.find( '.delete-img-link' ).removeClass( 'hidden' );
powerkitMediaFrame.close();
});
// Finally, open the modal on click.
powerkitMediaFrame.open();
});
/* Delete Image Link */
$( document ).on( 'click', metaBox + ' .delete-img-link', function( event ){
event.preventDefault();
$( this ).parents( metaBox ).find( '.uploaded-image' ).html( '' );
$( this ).parents( metaBox ).find( '.upload-img-link' ).removeClass( 'hidden' );
$( this ).parents( metaBox ).find( '.delete-img-link' ).addClass( 'hidden' );
$( this ).parents( metaBox ).find( '.uploaded-img-id' ).val( '' ).change();
});
});
</script>
<?php
wp_add_inline_script( 'jquery', str_replace( array( '<script>', '</script>' ), '', ob_get_clean() ) );
}
}
}
/**
* Register Widget
*/
function powerkit_widget_author_init() {
register_widget( 'Powerkit_Widget_Author_Init' );
}
add_action( 'widgets_init', 'powerkit_widget_author_init' );
@@ -0,0 +1,107 @@
/**
* All of the CSS for your public-facing functionality should be
* included in this file.
*/
/**
* Environment for all styles (variables, additions, etc).
*/
/*--------------------------------------------------------------*/
/*--------------------------------------------------------------*/
.pk-widget-author {
--pk-author-social-link-color: #000000;
--pk-author-with-bg-color: #FFFFFF;
--pk-author-with-bg-links-color: #FFFFFF;
--pk-author-with-bg-links-hover-color: rgba(255,255,255, 0.6);
--pk-author-with-bg-decsription-color: #FFFFFF;
--pk-author-avatar-border-radius: 100%;
--pk-author-description-font-size: 90%;
}
/*--------------------------------------------------------------*/
.pk-widget-author {
position: relative;
text-align: center;
}
.pk-widget-author .pk-widget-author-bg {
position: absolute;
top: 0;
right: 0;
width: 100%;
height: 100%;
z-index: 1;
}
.pk-widget-author .pk-widget-author-bg img {
display: block;
width: 100%;
height: 100%;
-o-object-fit: cover;
object-fit: cover;
font-family: 'object-fit: cover;';
}
.pk-widget-author .pk-widget-author-container {
position: relative;
padding: 0 2rem;
z-index: 2;
}
.pk-widget-author .pk-author-avatar img {
border-radius: var(--pk-author-avatar-border-radius);
}
.pk-widget-author .pk-author-data {
margin-top: 1rem;
}
.pk-widget-author .pk-author-data .author-description {
font-size: var(--pk-author-description-font-size);
}
.pk-widget-author .pk-author-footer {
margin-top: 1rem;
}
.pk-widget-author .pk-author-button {
margin-top: 1rem;
}
.pk-widget-author .pk-social-links-wrap {
margin-top: 1rem;
}
.pk-widget-author .pk-social-links-items {
justify-content: center;
}
.pk-widget-author .pk-social-links-link {
color: var(--pk-author-social-link-color);
}
.pk-author-social-links .pk-social-links-link {
padding: 0 0.25rem;
}
.pk-widget-author-with-bg {
color: var(--pk-author-with-bg-color);
}
.pk-widget-author-with-bg a,
.pk-widget-author-with-bg .section-heading,
.pk-widget-author-with-bg .pk-social-links-link {
color: var(--pk-author-with-bg-links-color) !important;
}
.pk-widget-author-with-bg a:hover,
.pk-widget-author-with-bg .pk-social-links-link:hover {
color: var(--pk-author-with-bg-links-hover-color) !important;
}
.pk-widget-author-with-bg .author-description {
color: var(--pk-author-with-bg-decsription-color) !important;
}
.pk-widget-author-with-bg .pk-widget-author-container {
padding: 2rem;
}
@@ -0,0 +1,107 @@
/**
* All of the CSS for your public-facing functionality should be
* included in this file.
*/
/**
* Environment for all styles (variables, additions, etc).
*/
/*--------------------------------------------------------------*/
/*--------------------------------------------------------------*/
.pk-widget-author {
--pk-author-social-link-color: #000000;
--pk-author-with-bg-color: #FFFFFF;
--pk-author-with-bg-links-color: #FFFFFF;
--pk-author-with-bg-links-hover-color: rgba(255,255,255, 0.6);
--pk-author-with-bg-decsription-color: #FFFFFF;
--pk-author-avatar-border-radius: 100%;
--pk-author-description-font-size: 90%;
}
/*--------------------------------------------------------------*/
.pk-widget-author {
position: relative;
text-align: center;
}
.pk-widget-author .pk-widget-author-bg {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 1;
}
.pk-widget-author .pk-widget-author-bg img {
display: block;
width: 100%;
height: 100%;
-o-object-fit: cover;
object-fit: cover;
font-family: 'object-fit: cover;';
}
.pk-widget-author .pk-widget-author-container {
position: relative;
padding: 0 2rem;
z-index: 2;
}
.pk-widget-author .pk-author-avatar img {
border-radius: var(--pk-author-avatar-border-radius);
}
.pk-widget-author .pk-author-data {
margin-top: 1rem;
}
.pk-widget-author .pk-author-data .author-description {
font-size: var(--pk-author-description-font-size);
}
.pk-widget-author .pk-author-footer {
margin-top: 1rem;
}
.pk-widget-author .pk-author-button {
margin-top: 1rem;
}
.pk-widget-author .pk-social-links-wrap {
margin-top: 1rem;
}
.pk-widget-author .pk-social-links-items {
justify-content: center;
}
.pk-widget-author .pk-social-links-link {
color: var(--pk-author-social-link-color);
}
.pk-author-social-links .pk-social-links-link {
padding: 0 0.25rem;
}
.pk-widget-author-with-bg {
color: var(--pk-author-with-bg-color);
}
.pk-widget-author-with-bg a,
.pk-widget-author-with-bg .section-heading,
.pk-widget-author-with-bg .pk-social-links-link {
color: var(--pk-author-with-bg-links-color) !important;
}
.pk-widget-author-with-bg a:hover,
.pk-widget-author-with-bg .pk-social-links-link:hover {
color: var(--pk-author-with-bg-links-hover-color) !important;
}
.pk-widget-author-with-bg .author-description {
color: var(--pk-author-with-bg-decsription-color) !important;
}
.pk-widget-author-with-bg .pk-widget-author-container {
padding: 2rem;
}
@@ -0,0 +1,103 @@
<?php
/**
* Widget Author Template
*
* @link https://codesupply.co
* @since 1.0.0
*
* @package PowerKit
* @subpackage PowerKit/templates
*/
/**
* Default Template
*
* @param int $author The author.
* @param array $args Array of args.
* @param array $params Array of params.
* @param array $instance Widget instance.
*/
function powerkit_widget_author_default_template( $author, $args, $params, $instance ) {
// Before Widget.
echo $args['before_widget']; // XSS.
$avatar_size = apply_filters( 'powerkit_widget_author_avatar_size', 80 );
?>
<div class="widget-body">
<div class="pk-widget-author<?php echo esc_attr( $params['bg_image_id'] ? ' pk-widget-author-with-bg' : '' ); ?>">
<?php if ( $params['bg_image_id'] ) { ?>
<div class="pk-widget-author-bg">
<?php echo wp_get_attachment_image( $params['bg_image_id'], apply_filters( 'powerkit_widget_author_image_size', 'large' ) ); ?>
</div>
<?php } ?>
<div class="pk-widget-author-container<?php echo esc_attr( $params['bg_image_id'] ? ' pk-bg-overlay' : '' ); ?>">
<?php
// Title.
if ( $params['title'] ) {
$params['widget_title'] = $args['before_title'] . apply_filters( 'widget_title', $params['title'], $instance, 0 ) . $args['after_title']; // XSS.
echo wp_kses_post( apply_filters( 'powerkit_widget_author_title', $params['widget_title'], $params['title'] ) );
}
?>
<?php $tag = apply_filters( 'powerkit_widget_author_title_tag', 'h5' ); ?>
<<?php echo esc_html( $tag ); ?> class="pk-author-title">
<a href="<?php echo esc_url( get_author_posts_url( $author ) ); ?>" rel="author">
<?php echo esc_html( get_the_author_meta( 'display_name', $author ) ); ?>
</a>
</<?php echo esc_html( $tag ); ?>>
<?php if ( $params['avatar'] ) { ?>
<div class="pk-author-avatar">
<a href="<?php echo esc_url( get_author_posts_url( $author ) ); ?>" rel="author">
<?php echo get_avatar( $author, $avatar_size ); ?>
</a>
</div>
<?php } ?>
<div class="pk-author-data">
<?php
$description = $params['description_override'] ? $params['description_override'] : get_the_author_meta( 'description', $author );
if ( $params['description'] && $description ) {
?>
<div class="author-description pk-color-secondary">
<?php echo wp_kses_post( powerkit_str_truncate( $description, $params['description_length'] ) ); ?>
</div>
<?php
}
if ( $params['social_accounts'] && powerkit_module_enabled( 'social_links' ) ) {
powerkit_author_social_links( $author );
}
?>
<?php
if ( $params['archive_btn'] ) {
$href = get_author_posts_url( $author );
$text = apply_filters( 'powerkit_widget_author_button', esc_html__( 'View Posts', 'powerkit' ) );
if ( isset( $params['is_block'] ) && isset( $params['block_attrs'] ) && $params['is_block'] ) {
?>
<div class="pk-author-footer">
<?php powerkit_print_gutenberg_blocks_button( $text, $href, '', 'button', $params['block_attrs'] ); ?>
</div>
<?php
} else {
?>
<a href="<?php echo esc_url( $href ); ?>" class="pk-author-button button">
<?php echo wp_kses( $text, 'post' ); ?>
</a>
<?php
}
}
?>
</div>
</div>
</div>
</div>
<?php
// After Widget.
echo $args['after_widget']; // XSS.
}