first commit
This commit is contained in:
@@ -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>';
|
||||
+199
@@ -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 Post’s 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();
|
||||
+64
@@ -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' );
|
||||
}
|
||||
}
|
||||
+344
@@ -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 Post’s 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' );
|
||||
+107
@@ -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;
|
||||
}
|
||||
+107
@@ -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.
|
||||
}
|
||||
+463
@@ -0,0 +1,463 @@
|
||||
<?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_Basic_Elements_Admin extends Powerkit_Module_Admin {
|
||||
|
||||
/**
|
||||
* Initialize
|
||||
*/
|
||||
public function initialize() {
|
||||
add_action( 'wp_ajax_powerkit_basic_shortcodes_sections', array( $this, 'powerkit_basic_shortcodes_ajax_panel' ) );
|
||||
add_filter( 'mce_buttons', array( $this, 'powerkit_basic_shortcodes_register_buttons' ) );
|
||||
add_filter( 'mce_external_plugins', array( $this, 'powerkit_basic_shortcodes_register_plugin' ) );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Register shorcodes button for TinyMCE buttons (Visual tab).
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @param array $buttons First-row list of buttons.
|
||||
* @return array Buttons.
|
||||
*/
|
||||
public function powerkit_basic_shortcodes_register_buttons( $buttons ) {
|
||||
if ( current_user_can( 'edit_posts' ) ) {
|
||||
array_push( $buttons, 'powerkit_basic_shortcodes_button' );
|
||||
}
|
||||
|
||||
return $buttons;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register shortcodes plugin
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @param array $plugins An array of external TinyMCE plugins.
|
||||
* @return array Plugins.
|
||||
*/
|
||||
public function powerkit_basic_shortcodes_register_plugin( $plugins ) {
|
||||
if ( current_user_can( 'edit_posts' ) ) {
|
||||
$plugins['powerkit_basic_shortcodes'] = trailingslashit( plugin_dir_url( __FILE__ ) ) . 'js/admin-powerkit-basic-elements.js';
|
||||
}
|
||||
|
||||
return $plugins;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate Section Fileds
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @param array $section Sections Fields.
|
||||
* @param array $counter Unique field identifier.
|
||||
*/
|
||||
public function generate_section_fields( $section, $counter = 0 ) {
|
||||
if ( isset( $section['fields'] ) && is_array( $section['fields'] ) ) {
|
||||
|
||||
// Default Field Settings.
|
||||
$default_field = array(
|
||||
'type' => 'input',
|
||||
'name' => '',
|
||||
'label' => '',
|
||||
'desc' => '',
|
||||
'default' => '',
|
||||
'attrs' => array(),
|
||||
'style' => 'vertical', // For radio.
|
||||
'suffix' => '', // For inputs.
|
||||
'options' => array(), // For select, radio.
|
||||
'fields' => array(), // For repeater.
|
||||
);
|
||||
|
||||
foreach ( $section['fields'] as $field ) {
|
||||
|
||||
$counter++;
|
||||
|
||||
// Merge Settings.
|
||||
$field = array_merge( $default_field, $field );
|
||||
|
||||
// Attrs.
|
||||
$attrs = null;
|
||||
|
||||
if ( ! empty( $field['attrs'] ) ) {
|
||||
foreach ( $field['attrs'] as $key => $value ) {
|
||||
$attrs[] = sprintf( '%s="%s"', $key, $value );
|
||||
}
|
||||
$attrs = implode( ' ', $attrs );
|
||||
}
|
||||
|
||||
// Output by type.
|
||||
switch ( $field['type'] ) {
|
||||
case 'section':
|
||||
?>
|
||||
<tr>
|
||||
<th><h3><?php echo wp_kses_post( $field['label'] ); ?></h3></th><td> </td>
|
||||
</tr>
|
||||
<?php
|
||||
break;
|
||||
case 'input':
|
||||
?>
|
||||
<tr>
|
||||
<th><?php echo wp_kses_post( $field['label'] ); ?>:<small><?php echo wp_kses_post( $field['desc'] ); ?></small></th>
|
||||
<td>
|
||||
<input name="<?php echo esc_attr( $field['name'] ); ?>" type="text" value="<?php echo esc_attr( $field['default'] ); ?>" <?php echo wp_kses_data( $attrs ); ?>><?php echo esc_attr( $field['suffix'] ); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
break;
|
||||
case 'textarea':
|
||||
?>
|
||||
<tr>
|
||||
<th><?php echo wp_kses_post( $field['label'] ); ?>:<small><?php echo wp_kses_post( $field['desc'] ); ?></small></th>
|
||||
<td>
|
||||
<textarea name="<?php echo esc_attr( $field['name'] ); ?>" <?php echo wp_kses_data( $attrs ); ?>><?php echo wp_kses_post( $field['default'] ); ?></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
break;
|
||||
case 'select':
|
||||
?>
|
||||
<tr>
|
||||
<th><?php echo wp_kses_post( $field['label'] ); ?>:<small><?php echo wp_kses_post( $field['desc'] ); ?></small></th>
|
||||
<td>
|
||||
<select name="<?php echo esc_attr( $field['name'] ); ?>" <?php echo wp_kses_data( $attrs ); ?>>
|
||||
<?php if ( isset( $field['options'] ) && $field['options'] ) : ?>
|
||||
<?php foreach ( $field['options'] as $key => $option ) : ?>
|
||||
<option value="<?php echo esc_attr( $key ); ?>" <?php selected( $field['default'], esc_attr( $key ) ); ?>><?php echo esc_attr( $option ); ?></option>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
break;
|
||||
|
||||
case 'checkbox':
|
||||
?>
|
||||
<tr>
|
||||
<th><?php echo wp_kses_post( $field['label'] ); ?>:<small><?php echo wp_kses_post( $field['desc'] ); ?></small></th>
|
||||
<td>
|
||||
<input name="<?php echo esc_attr( $field['name'] ); ?>" type="checkbox" value="true" <?php checked( (bool) $field['default'], true ); ?> <?php echo wp_kses_data( $attrs ); ?>>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
break;
|
||||
|
||||
case 'radio':
|
||||
?>
|
||||
<tr>
|
||||
<th><?php echo wp_kses_post( $field['label'] ); ?>:<small><?php echo wp_kses_post( $field['desc'] ); ?></small></th>
|
||||
<td>
|
||||
<?php if ( isset( $field['options'] ) && $field['options'] ) : ?>
|
||||
<?php foreach ( $field['options'] as $key => $option ) : $counter++; ?>
|
||||
<?php $id = sprintf( 'field-%s-%s-%s', $section['name'], $field['name'], $counter ); ?>
|
||||
<input id="<?php echo esc_attr( $id ); ?>" name="<?php echo esc_attr( $field['name'] ); ?>" type="radio" value="<?php echo esc_attr( $key ); ?>" <?php checked( $field['default'], $key ); ?> <?php echo wp_kses_data( $attrs ); ?>>
|
||||
<label for="<?php echo esc_attr( $id ); ?>"><?php echo esc_attr( $option ); ?></label>
|
||||
<?php if ( 'vertical' === $field['style'] ) : ?>
|
||||
<br>
|
||||
<?php else : ?>
|
||||
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
break;
|
||||
|
||||
case 'content':
|
||||
?>
|
||||
<tr>
|
||||
<th><?php echo wp_kses_post( $field['label'] ); ?>:<small><?php echo wp_kses_post( $field['desc'] ); ?></small></th>
|
||||
<td>
|
||||
<textarea name="<?php echo esc_attr( $field['name'] ); ?>" <?php echo wp_kses_data( $attrs ); ?>><?php echo wp_kses_post( $field['default'] ); ?></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
break;
|
||||
|
||||
case 'repeater':
|
||||
?>
|
||||
<tr>
|
||||
<th><?php echo wp_kses_post( $field['label'] ); ?>:</label><small><?php echo wp_kses_post( $field['desc'] ); ?></small></th>
|
||||
<td class="basic-shortcodes-repeater-field">
|
||||
<div data-repeater-list="<?php echo esc_attr( $field['base'] ); ?>" >
|
||||
<table class="form-table" data-repeater-item>
|
||||
<tbody>
|
||||
<?php $this->generate_section_fields( $field, $counter ); ?>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th></th>
|
||||
<td>
|
||||
<span class="button-secondary" data-repeater-delete><?php esc_html_e( 'Delete Item', 'powerkit' ); ?></span>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
<span data-repeater-create class="button-primary"><?php esc_html_e( 'Add Item', 'powerkit' ); ?></span>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax Load Admin Shortcodes Panel
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function powerkit_basic_shortcodes_ajax_panel() {
|
||||
|
||||
// Allow themes and plugins to enable/disable specific shortcodes UI panel.
|
||||
$sections = apply_filters( 'powerkit_basic_shortcodes_ui_args', array() );
|
||||
|
||||
// Sort elements.
|
||||
usort( $sections, function ( $a, $b ) {
|
||||
return $a['priority'] - $b['priority'];
|
||||
} );
|
||||
?>
|
||||
<div class="wrap powerkit_basic_shortcodes_wrap">
|
||||
|
||||
<div class="powerkit_basic_shortcodes_tabs">
|
||||
|
||||
<ul>
|
||||
<?php foreach ( $sections as $section ) : ?>
|
||||
<li><a data-nav="<?php echo esc_attr( $section['name'] ); ?>" href="#"><?php echo esc_html( $section['title'] ); ?></a></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="powerkit_basic_shortcodes_tabs_sections">
|
||||
|
||||
<?php foreach ( $sections as $section ) : ?>
|
||||
<div class="hidable wrap tabs-<?php echo esc_attr( $section['name'] ); ?>" style="display: none;">
|
||||
|
||||
<form class="powerkit_basic_shortcodes_tab" enctype="multipart/form-data">
|
||||
<table class="form-table">
|
||||
<tbody>
|
||||
<?php $this->generate_section_fields( $section ); ?>
|
||||
|
||||
<tr>
|
||||
<th><input type="submit" class="button-primary" value="<?php esc_html_e( 'Insert', 'powerkit' ); ?>"></th>
|
||||
<td> </td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
/* <![CDATA[ */
|
||||
(function($) {
|
||||
|
||||
// Insert Shortcode.
|
||||
$('.tabs-<?php echo esc_attr( $section['name'] ); ?> form').submit( function( e ) {
|
||||
e.preventDefault();
|
||||
|
||||
// Hide Popup.
|
||||
tb_remove();
|
||||
|
||||
// Get input values from form.
|
||||
var fieldsObj = $( this ).serializeObject();
|
||||
|
||||
// Vars.
|
||||
var shortcodeContent = '',
|
||||
shortcodeAttrs = [];
|
||||
|
||||
<?php foreach ( (array) $section['fields'] as $field ) : ?>
|
||||
|
||||
var fieldName = '<?php echo esc_attr( isset( $field['name'] ) ? $field['name'] : '' ); ?>';
|
||||
<?php
|
||||
switch ( $field['type'] ) {
|
||||
case 'section':
|
||||
break;
|
||||
case 'repeater':
|
||||
?>
|
||||
var subContentVars = [],
|
||||
subCheckboxVars = [],
|
||||
shortcodeBase = '<?php echo esc_attr( $field['base'] ); ?>';
|
||||
|
||||
<?php foreach ( (array) $field['fields'] as $sub_field ) : ?>
|
||||
|
||||
<?php if ( 'content' === $sub_field['type'] ) : ?>
|
||||
subContentVars.push( '<?php echo esc_attr( $sub_field['name'] ); ?>' );
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( 'checkbox' === $sub_field['type'] ) : ?>
|
||||
subCheckboxVars.push( '<?php echo esc_attr( $sub_field['name'] ); ?>' );
|
||||
<?php endif; ?>
|
||||
|
||||
<?php endforeach; ?>
|
||||
|
||||
if( typeof fieldsObj[ shortcodeBase ] !== 'undefined' ) {
|
||||
|
||||
$.each( fieldsObj[ shortcodeBase ], function( key, obj ) {
|
||||
|
||||
var subShortcodeContent = '',
|
||||
subShortcodeAttrs = [];
|
||||
|
||||
$.each( obj, function( s_key, s_obj ) {
|
||||
if( typeof s_obj !== 'undefined' ) {
|
||||
|
||||
// Field "Content" fix.
|
||||
if( ! $.inArray( s_key, subContentVars ) ) {
|
||||
subShortcodeContent += s_obj;
|
||||
} else {
|
||||
|
||||
// Other fields.
|
||||
subShortcodeAttrs.push( s_key + '="' + s_obj + '"' );
|
||||
}
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
// Add Inner Shortcode.
|
||||
if( subShortcodeContent ) {
|
||||
shortcodeContent += '[' + shortcodeBase + ' ' + subShortcodeAttrs.join( ' ' ) + ']<br>' + subShortcodeContent + '<br>[/' + shortcodeBase + ']<br>';
|
||||
} else {
|
||||
shortcodeContent += '[' + shortcodeBase + ' ' + subShortcodeAttrs.join( ' ' ) + ']<br>';
|
||||
}
|
||||
|
||||
} );
|
||||
}
|
||||
<?php
|
||||
break;
|
||||
case 'content':
|
||||
?>
|
||||
if( typeof fieldsObj[ fieldName ] !== 'undefined' ) {
|
||||
shortcodeContent += fieldsObj[ fieldName ];
|
||||
}
|
||||
<?php
|
||||
break;
|
||||
case 'checkbox':
|
||||
?>
|
||||
if( typeof fieldsObj[ fieldName ] !== 'undefined' ) {
|
||||
var fieldAttr = fieldName + '="' + fieldsObj[ fieldName ] + '"';
|
||||
} else {
|
||||
var fieldAttr = fieldName + '="false"';
|
||||
}
|
||||
|
||||
shortcodeAttrs.push( fieldAttr );
|
||||
<?php
|
||||
break;
|
||||
default:
|
||||
?>
|
||||
if( typeof fieldsObj[ fieldName ] !== 'undefined' ) {
|
||||
var fieldAttr = fieldName + '="' + fieldsObj[ fieldName ] + '"';
|
||||
} else {
|
||||
var fieldAttr = fieldName + '=""';
|
||||
}
|
||||
|
||||
shortcodeAttrs.push( fieldAttr );
|
||||
<?php
|
||||
break;
|
||||
}
|
||||
?>
|
||||
<?php endforeach; ?>
|
||||
|
||||
// Add Shortcode.
|
||||
var shortcodeName = '<?php echo esc_attr( $section['base'] ); ?>';
|
||||
|
||||
if( shortcodeContent ) {
|
||||
|
||||
// Trim Line Breaks.
|
||||
shortcodeContent = shortcodeContent.replace( /^<br>|<br>$/gm, '' );
|
||||
|
||||
var content = '[' + shortcodeName + ' ' + shortcodeAttrs.join( ' ' ) + ']<br>' + shortcodeContent + '<br>[/' + shortcodeName + ']';
|
||||
} else {
|
||||
var content = '[' + shortcodeName + ' ' + shortcodeAttrs.join( ' ' ) + ']';
|
||||
}
|
||||
|
||||
// Remove odd space.
|
||||
content = content.replace(/\s\]/g, ']');
|
||||
|
||||
// Convert br.
|
||||
content = content.replace(/([^>])\n/g, '$1<br/>');
|
||||
|
||||
powerkit_basic_shortcodes.setContent( content );
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
/* ]]> */
|
||||
</script>
|
||||
<?php endforeach; ?>
|
||||
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
/* <![CDATA[ */
|
||||
( function( $ ) {
|
||||
|
||||
// Tabs Navigation.
|
||||
$( '.powerkit_basic_shortcodes_tabs a' ).click( function( e ) {
|
||||
e.preventDefault();
|
||||
powerkit_basic_shortcodes_tabs_switch( $( this ) );
|
||||
} );
|
||||
|
||||
powerkit_basic_shortcodes_tabs_switch( $( '.powerkit_basic_shortcodes_tabs a' ).first() );
|
||||
|
||||
function powerkit_basic_shortcodes_tabs_switch( obj ) {
|
||||
$( '.powerkit_basic_shortcodes_tabs_sections .hidable' ).hide();
|
||||
$( '.powerkit_basic_shortcodes_tabs_sections .tabs-' + obj.attr( 'data-nav' ) ).show();
|
||||
$( '.powerkit_basic_shortcodes_tabs li' ).removeClass( 'current' );
|
||||
obj.parent().addClass( 'current' );
|
||||
}
|
||||
|
||||
// Init Repeater.
|
||||
$( document ).ready( function() {
|
||||
$( '.basic-shortcodes-repeater-field' ).each( function() {
|
||||
$( this ).repeater( {
|
||||
show: function() {
|
||||
$( this ).slideDown();
|
||||
},
|
||||
hide: function( deleteElement ) {
|
||||
$( this ).fadeOut( 400 );
|
||||
},
|
||||
isFirstItemUndeletable: true,
|
||||
} );
|
||||
} );
|
||||
} );
|
||||
|
||||
} )( jQuery );
|
||||
/* ]]> */
|
||||
</script>
|
||||
</div>
|
||||
<?php
|
||||
die();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the stylesheets and JavaScript for the admin area.
|
||||
*
|
||||
* @param string $page Current page.
|
||||
*/
|
||||
public function admin_enqueue_scripts( $page ) {
|
||||
|
||||
add_thickbox();
|
||||
|
||||
wp_enqueue_style( 'wp-color-picker' );
|
||||
|
||||
// Styles.
|
||||
wp_enqueue_style( 'powerkit-basic-elements', powerkit_style( plugin_dir_url( __FILE__ ) . 'css/admin-powerkit-basic-elements.css' ), array(), powerkit_get_setting( 'version' ), 'all' );
|
||||
|
||||
wp_enqueue_script( 'wp-color-picker' );
|
||||
// Scripts.
|
||||
wp_enqueue_script( 'powerkit-jquery-serialize', plugin_dir_url( __FILE__ ) . 'js/jquery.serialize-to-json.min.js', array( 'jquery' ), powerkit_get_setting( 'version' ), false );
|
||||
wp_enqueue_script( 'powerkit-jquery-repeater', plugin_dir_url( __FILE__ ) . 'js/jquery.repeater.min.js', array( 'jquery' ), powerkit_get_setting( 'version' ), false );
|
||||
}
|
||||
}
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
.powerkit_basic_shortcodes_wrap {
|
||||
position: relative;
|
||||
margin: 0;
|
||||
height: 97.5%;
|
||||
}
|
||||
|
||||
.powerkit_basic_shortcodes_wrap .form-table td,
|
||||
.powerkit_basic_shortcodes_wrap .form-table th {
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
|
||||
.powerkit_basic_shortcodes_tabs {
|
||||
width: 200px;
|
||||
height: 100%;
|
||||
min-height: 100%;
|
||||
background: #f9f9f9;
|
||||
border-left: 1px solid #EEE;
|
||||
float: right;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
font-family: Helvetica, Arial;
|
||||
color: #333;
|
||||
font-size: 12px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.powerkit_basic_shortcodes_tabs ul {
|
||||
list-style: none;
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
.powerkit_basic_shortcodes_tabs ul li {
|
||||
width: 201px;
|
||||
font-weight: bold;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.powerkit_basic_shortcodes_tabs li.current {
|
||||
display: block;
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
.powerkit_basic_shortcodes_tabs li.current a {
|
||||
background: #FFF;
|
||||
box-shadow: 0 -1px 0 #eee;
|
||||
}
|
||||
|
||||
.powerkit_basic_shortcodes_tabs ul li a {
|
||||
display: block;
|
||||
padding: 14px 20px;
|
||||
font-size: 12px;
|
||||
color: #333;
|
||||
text-decoration: none;
|
||||
box-shadow: 0 -1px 0 #eee;
|
||||
}
|
||||
|
||||
.powerkit_basic_shortcodes_tabs ul li:last-child a {
|
||||
box-shadow: 0 -1px 0 #eee, 0 1px 0 #eee;
|
||||
}
|
||||
|
||||
.powerkit_basic_shortcodes_tabs_sections {
|
||||
overflow: auto;
|
||||
height: 100%;
|
||||
position: relative;
|
||||
padding: 0 20px 0 0;
|
||||
margin: 0;
|
||||
background: #FFF;
|
||||
}
|
||||
|
||||
.powerkit_basic_shortcodes_tabs_sections table tr th small {
|
||||
display: block;
|
||||
margin-top: 5px;
|
||||
color: #777777;
|
||||
}
|
||||
|
||||
/* Repeater */
|
||||
.powerkit_basic_shortcodes_wrap .basic-shortcodes-repeater-field .form-table th,
|
||||
.powerkit_basic_shortcodes_wrap .basic-shortcodes-repeater-field .form-table td {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.basic-shortcodes-repeater-field th,
|
||||
.basic-shortcodes-repeater-field td {
|
||||
display: block;
|
||||
padding: 0 0 10px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.basic-shortcodes-repeater-field tfoot {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.basic-shortcodes-repeater-field tfoot th {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* TB_window */
|
||||
#TB_window.powerkit_basic_shortcodes_window #TB_ajaxContent {
|
||||
padding: 0 0 30px 0;
|
||||
width: 100% !important;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#TB_window.powerkit_basic_shortcodes_window #TB_ajaxContent ul {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#TB_window.powerkit_basic_shortcodes_window #TB_ajaxContent li {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#TB_window.powerkit_basic_shortcodes_window #TB_ajaxContent li:before {
|
||||
display: none;
|
||||
}
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
.powerkit_basic_shortcodes_wrap {
|
||||
position: relative;
|
||||
margin: 0;
|
||||
height: 97.5%;
|
||||
}
|
||||
|
||||
.powerkit_basic_shortcodes_wrap .form-table td,
|
||||
.powerkit_basic_shortcodes_wrap .form-table th {
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
|
||||
.powerkit_basic_shortcodes_tabs {
|
||||
width: 200px;
|
||||
height: 100%;
|
||||
min-height: 100%;
|
||||
background: #f9f9f9;
|
||||
border-right: 1px solid #EEE;
|
||||
float: left;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
font-family: Helvetica, Arial;
|
||||
color: #333;
|
||||
font-size: 12px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.powerkit_basic_shortcodes_tabs ul {
|
||||
list-style: none;
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
.powerkit_basic_shortcodes_tabs ul li {
|
||||
width: 201px;
|
||||
font-weight: bold;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.powerkit_basic_shortcodes_tabs li.current {
|
||||
display: block;
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
.powerkit_basic_shortcodes_tabs li.current a {
|
||||
background: #FFF;
|
||||
box-shadow: 0 -1px 0 #eee;
|
||||
}
|
||||
|
||||
.powerkit_basic_shortcodes_tabs ul li a {
|
||||
display: block;
|
||||
padding: 14px 20px;
|
||||
font-size: 12px;
|
||||
color: #333;
|
||||
text-decoration: none;
|
||||
box-shadow: 0 -1px 0 #eee;
|
||||
}
|
||||
|
||||
.powerkit_basic_shortcodes_tabs ul li:last-child a {
|
||||
box-shadow: 0 -1px 0 #eee, 0 1px 0 #eee;
|
||||
}
|
||||
|
||||
.powerkit_basic_shortcodes_tabs_sections {
|
||||
overflow: auto;
|
||||
height: 100%;
|
||||
position: relative;
|
||||
padding: 0 0 0 20px;
|
||||
margin: 0;
|
||||
background: #FFF;
|
||||
}
|
||||
|
||||
.powerkit_basic_shortcodes_tabs_sections table tr th small {
|
||||
display: block;
|
||||
margin-top: 5px;
|
||||
color: #777777;
|
||||
}
|
||||
|
||||
/* Repeater */
|
||||
.powerkit_basic_shortcodes_wrap .basic-shortcodes-repeater-field .form-table th,
|
||||
.powerkit_basic_shortcodes_wrap .basic-shortcodes-repeater-field .form-table td {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.basic-shortcodes-repeater-field th,
|
||||
.basic-shortcodes-repeater-field td {
|
||||
display: block;
|
||||
padding: 0 0 10px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.basic-shortcodes-repeater-field tfoot {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.basic-shortcodes-repeater-field tfoot th {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* TB_window */
|
||||
#TB_window.powerkit_basic_shortcodes_window #TB_ajaxContent {
|
||||
padding: 0 0 30px 0;
|
||||
width: 100% !important;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#TB_window.powerkit_basic_shortcodes_window #TB_ajaxContent ul {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#TB_window.powerkit_basic_shortcodes_window #TB_ajaxContent li {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#TB_window.powerkit_basic_shortcodes_window #TB_ajaxContent li:before {
|
||||
display: none;
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 3.8 KiB |
+49
@@ -0,0 +1,49 @@
|
||||
"use strict";
|
||||
|
||||
var powerkit_basic_shortcodes;
|
||||
var powerkit_basic_shortcodes_content;
|
||||
|
||||
( function() {
|
||||
tinymce.create( 'tinymce.plugins.powerkit_basic_shortcodes', {
|
||||
init: function( ed, url ) {
|
||||
ed.addButton( 'powerkit_basic_shortcodes_button', {
|
||||
title: 'Basic Shortcodes',
|
||||
image: url.substring( 0, url.length - 3 ) + '/images/icon.png',
|
||||
onclick: function() {
|
||||
|
||||
powerkit_basic_shortcodes = ed.selection;
|
||||
powerkit_basic_shortcodes_content = ed.selection.getContent();
|
||||
|
||||
var width = jQuery( window ).width(),
|
||||
H = jQuery( window ).height(),
|
||||
W = ( 720 < width ) ? 720 : width;
|
||||
W = W - 80;
|
||||
H = H - 84;
|
||||
|
||||
|
||||
var shortcodes_loaded = jQuery( '#powerkit_basic_shortcodes_holder' ).length;
|
||||
|
||||
if ( shortcodes_loaded ) {
|
||||
|
||||
tb_show( 'Basic Shortcodes', '#TB_inline?width=' + W + '&height=' + H + '&inlineId=powerkit_basic_shortcodes' );
|
||||
jQuery( '#TB_window' ).addClass( 'powerkit_basic_shortcodes_window' );
|
||||
|
||||
} else {
|
||||
|
||||
jQuery( "body" ).append( '<div id="powerkit_basic_shortcodes_holder" style="display: none;"><div id="powerkit_basic_shortcodes"></div></div>' );
|
||||
|
||||
jQuery.get( 'admin-ajax.php?action=powerkit_basic_shortcodes_sections', function( data ) {
|
||||
jQuery( '#powerkit_basic_shortcodes' ).html( data );
|
||||
tb_show( 'Basic Shortcodes', '#TB_inline?width=' + W + '&height=' + H + '&inlineId=powerkit_basic_shortcodes' );
|
||||
jQuery( '#TB_window' ).addClass( 'powerkit_basic_shortcodes_window' );
|
||||
} );
|
||||
}
|
||||
}
|
||||
} );
|
||||
},
|
||||
createControl: function( n, cm ) {
|
||||
return null;
|
||||
},
|
||||
} );
|
||||
tinymce.PluginManager.add( 'powerkit_basic_shortcodes', tinymce.plugins.powerkit_basic_shortcodes );
|
||||
} )();
|
||||
+5
File diff suppressed because one or more lines are too long
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* jQuery serializeObject
|
||||
* @copyright 2014, macek <paulmacek@gmail.com>
|
||||
* @link https://github.com/macek/jquery-serialize-object
|
||||
* @license BSD
|
||||
* @version 2.5.0
|
||||
*/
|
||||
!function(e,i){if("function"==typeof define&&define.amd)define(["exports","jquery"],function(e,r){return i(e,r)});else if("undefined"!=typeof exports){var r=require("jquery");i(exports,r)}else i(e,e.jQuery||e.Zepto||e.ender||e.$)}(this,function(e,i){function r(e,r){function n(e,i,r){return e[i]=r,e}function a(e,i){for(var r,a=e.match(t.key);void 0!==(r=a.pop());)if(t.push.test(r)){var u=s(e.replace(/\[\]$/,""));i=n([],u,i)}else t.fixed.test(r)?i=n([],r,i):t.named.test(r)&&(i=n({},r,i));return i}function s(e){return void 0===h[e]&&(h[e]=0),h[e]++}function u(e){switch(i('[name="'+e.name+'"]',r).attr("type")){case"checkbox":return"on"===e.value?!0:e.value;default:return e.value}}function f(i){if(!t.validate.test(i.name))return this;var r=a(i.name,u(i));return l=e.extend(!0,l,r),this}function d(i){if(!e.isArray(i))throw new Error("formSerializer.addPairs expects an Array");for(var r=0,t=i.length;t>r;r++)this.addPair(i[r]);return this}function o(){return l}function c(){return JSON.stringify(o())}var l={},h={};this.addPair=f,this.addPairs=d,this.serialize=o,this.serializeJSON=c}var t={validate:/^[a-z_][a-z0-9_]*(?:\[(?:\d*|[a-z0-9_]+)\])*$/i,key:/[a-z0-9_]+|(?=\[\])/gi,push:/^$/,fixed:/^\d+$/,named:/^[a-z0-9_]+$/i};return r.patterns=t,r.serializeObject=function(){return new r(i,this).addPairs(this.serializeArray()).serialize()},r.serializeJSON=function(){return new r(i,this).addPairs(this.serializeArray()).serializeJSON()},"undefined"!=typeof i.fn&&(i.fn.serializeObject=r.serializeObject,i.fn.serializeJSON=r.serializeJSON),e.FormSerializer=r,r});
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* Basic Elements
|
||||
*
|
||||
* @package Powerkit
|
||||
* @subpackage Modules
|
||||
*/
|
||||
|
||||
if ( class_exists( 'Powerkit_Module' ) ) {
|
||||
/**
|
||||
* Init module
|
||||
*/
|
||||
class Powerkit_Basic_Elements extends Powerkit_Module {
|
||||
|
||||
/**
|
||||
* Register module
|
||||
*/
|
||||
public function register() {
|
||||
$this->name = esc_html__( 'Basic Elements', 'powerkit' );
|
||||
$this->desc = esc_html__( 'Basic shortcodes with a shortcode generator right in the WordPress editor.', 'powerkit' );
|
||||
$this->slug = 'basic_elements';
|
||||
$this->type = 'default';
|
||||
$this->category = 'basic';
|
||||
$this->priority = 80;
|
||||
$this->public = true;
|
||||
$this->enabled = true;
|
||||
|
||||
$this->links = array(
|
||||
array(
|
||||
'name' => esc_html__( 'View documentation', 'powerkit' ),
|
||||
'url' => powerkit_get_setting( 'documentation' ) . '/content-presentation/basic-elements/',
|
||||
'target' => '_blank',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize module
|
||||
*/
|
||||
public function initialize() {
|
||||
|
||||
/* Load the required dependencies for this module */
|
||||
|
||||
// Helpers Functions for the module.
|
||||
require_once dirname( __FILE__ ) . '/helpers/helper-basic-elements.php';
|
||||
|
||||
// Admin and public area.
|
||||
require_once dirname( __FILE__ ) . '/admin/class-powerkit-basic-elements-admin.php';
|
||||
require_once dirname( __FILE__ ) . '/public/class-powerkit-basic-elements-public.php';
|
||||
|
||||
// Include default templates.
|
||||
powerkit_basic_shortcodes_autoload( dirname( __FILE__ ) . '/templates' );
|
||||
|
||||
new Powerkit_Basic_Elements_Admin( $this->slug );
|
||||
new Powerkit_Basic_Elements_Public( $this->slug );
|
||||
}
|
||||
}
|
||||
|
||||
new Powerkit_Basic_Elements();
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/**
|
||||
* Helpers Social Links
|
||||
*
|
||||
* @package Powerkit
|
||||
* @subpackage Modules/Helper
|
||||
*/
|
||||
|
||||
/**
|
||||
* Register Shortcodes
|
||||
*
|
||||
* @param array $map Shortcode parameters.
|
||||
*/
|
||||
function powerkit_basic_shortcodes_register( $map ) {
|
||||
add_filter( 'powerkit_basic_shortcodes_ui_args', function( $sections ) use ( $map ) {
|
||||
$sections[] = $map;
|
||||
return $sections;
|
||||
} );
|
||||
}
|
||||
|
||||
/**
|
||||
* Autoload files in the directory.
|
||||
*
|
||||
* @param string $path Directory path.
|
||||
* @param string $pattern Regex pattern.
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function powerkit_basic_shortcodes_autoload( $path, $pattern = false ) {
|
||||
if ( is_dir( $path ) ) {
|
||||
$files = scandir( $path );
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
// loop folders.
|
||||
foreach ( $files as $file ) {
|
||||
$path_file = $path . '/' . basename( $file );
|
||||
|
||||
if ( $pattern && ! preg_match( "/$pattern/", basename( $file ) ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( file_exists( $path_file ) && 'index.php' !== $file ) {
|
||||
|
||||
if ( is_dir( $path_file ) && file_exists( $path_file . "/$file.php" ) ) {
|
||||
require_once $path_file . "/$file.php";
|
||||
} elseif ( is_file( $path_file ) && preg_match( '/\.php$/i', $path_file ) ) {
|
||||
require_once $path_file;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean shortcodes
|
||||
*
|
||||
* @param string $content Post content.
|
||||
* @return string Filtered Post content.
|
||||
*/
|
||||
function powerkit_basic_shortcodes_clean( $content ) {
|
||||
$array = array(
|
||||
'<p>[' => '[',
|
||||
']</p>' => ']',
|
||||
']<br />' => ']',
|
||||
);
|
||||
$content = strtr( $content, $array );
|
||||
return $content;
|
||||
}
|
||||
add_filter( 'the_content', 'powerkit_basic_shortcodes_clean' );
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
<?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_Basic_Elements_Public extends Powerkit_Module_Public {
|
||||
|
||||
/**
|
||||
* Initialize
|
||||
*/
|
||||
public function initialize() {
|
||||
add_action( 'init', array( $this, 'register_custom_shortcodes' ) );
|
||||
|
||||
$this->register_shortcodes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Shortcodes custom.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
*/
|
||||
public function register_custom_shortcodes() {
|
||||
|
||||
$dir_path = apply_filters( 'powerkit_basic_shortcodes_autoload_path', 'shortcodes' );
|
||||
|
||||
$custom_path = wp_normalize_path( get_template_directory() . '/' . $dir_path );
|
||||
|
||||
if ( file_exists( $custom_path ) ) {
|
||||
powerkit_basic_shortcodes_autoload( $custom_path );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register Shortcodes
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access private
|
||||
*/
|
||||
private function register_shortcodes() {
|
||||
|
||||
// Get all shortcodes.
|
||||
$sections = apply_filters( 'powerkit_basic_shortcodes_ui_args', array() );
|
||||
|
||||
// Add shortcodes.
|
||||
foreach ( $sections as $section ) {
|
||||
if ( true === $section['autoregister'] ) {
|
||||
add_shortcode( $section['base'], array( $this, 'shortcode_display' ) );
|
||||
}
|
||||
|
||||
// Repeat Shortcodes.
|
||||
if ( ! empty( $section['fields'] ) ) {
|
||||
foreach ( $section['fields'] as $field ) {
|
||||
if ( 'repeater' === $field['type'] && true === $field['autoregister'] ) {
|
||||
add_shortcode( $field['base'], array( $this, 'shortcode_display' ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Shortcode Public Display
|
||||
*
|
||||
* @param array $atts User defined attributes in shortcode tag.
|
||||
* @param string $content Shorcode Content.
|
||||
* @param string $shortcode The name of the shortcode.
|
||||
* @return string Shortcode result HTML.
|
||||
*/
|
||||
public function shortcode_display( $atts, $content = false, $shortcode = '' ) {
|
||||
// Get all shortcodes.
|
||||
$sections = apply_filters( 'powerkit_basic_shortcodes_ui_args', array() );
|
||||
|
||||
// Get Default Attrs.
|
||||
$default_attrs = array();
|
||||
foreach ( $sections as $section ) {
|
||||
if ( isset( $section['fields'] ) && is_array( $section['fields'] ) ) {
|
||||
foreach ( $section['fields'] as $field ) {
|
||||
switch ( $field['type'] ) {
|
||||
case 'section':
|
||||
break;
|
||||
case 'repeater':
|
||||
if ( $field['base'] === $shortcode ) {
|
||||
foreach ( $field['fields'] as $repeater_field ) {
|
||||
$default_attrs[ $repeater_field['name'] ] = $repeater_field['default'] ? $repeater_field['default'] : '';
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if ( $section['base'] === $shortcode ) {
|
||||
$default_attrs[ $field['name'] ] = $field['default'] ? $field['default'] : '';
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Merge Attrs.
|
||||
$atts = shortcode_atts( $default_attrs, $atts );
|
||||
|
||||
// Content.
|
||||
$content = do_shortcode( $content );
|
||||
|
||||
/**
|
||||
* Filters a shortcode's HTML.
|
||||
*
|
||||
* @param array $output Shortcode HTML.
|
||||
* @param array $atts User defined attributes in shortcode tag.
|
||||
* @param string $content Shorcode tag content.
|
||||
* @return string Shortcode result HTML.
|
||||
*/
|
||||
$output = apply_filters( $shortcode . '_shortcode', '', $atts, $content );
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the stylesheets for the public-facing side of the site.
|
||||
*/
|
||||
public function wp_enqueue_scripts() {
|
||||
// Styles.
|
||||
wp_enqueue_style( 'powerkit-basic-elements', powerkit_style( plugin_dir_url( __FILE__ ) . 'css/public-powerkit-basic-elements.css' ), false, powerkit_get_setting( 'version' ), 'screen' );
|
||||
|
||||
// Add RTL support.
|
||||
wp_style_add_data( 'powerkit-basic-elements', 'rtl', 'replace' );
|
||||
|
||||
// Scripts.
|
||||
wp_enqueue_script( 'powerkit-basic-elements', plugin_dir_url( __FILE__ ) . 'js/public-powerkit-basic-elements.js', array( 'jquery' ), '4.0.0', true );
|
||||
}
|
||||
}
|
||||
+882
@@ -0,0 +1,882 @@
|
||||
/**
|
||||
* All of the CSS for your public-facing functionality should be
|
||||
* included in this file.
|
||||
*/
|
||||
/**
|
||||
* Environment for all styles (variables, additions, etc).
|
||||
*/
|
||||
/*--------------------------------------------------------------*/
|
||||
/*--------------------------------------------------------------*/
|
||||
.pk-tabs,
|
||||
.pk-pills,
|
||||
.pk-accordion,
|
||||
.pk-progress,
|
||||
.pk-button.pk-button-block {
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
/* Buttons */
|
||||
/*--------------------------------------------------------------*/
|
||||
.pk-button {
|
||||
display: inline-block;
|
||||
font-weight: 400;
|
||||
text-align: center;
|
||||
white-space: nowrap;
|
||||
vertical-align: middle;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
padding: 0.375rem 0.75rem;
|
||||
font-size: 1rem;
|
||||
line-height: 1.5;
|
||||
border-radius: 0.25rem;
|
||||
transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
|
||||
color: white;
|
||||
border: none;
|
||||
box-shadow: none !important;
|
||||
text-decoration: none !important;
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.pk-button {
|
||||
transition: none;
|
||||
}
|
||||
}
|
||||
|
||||
.pk-button:hover, .pk-button:focus {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.pk-button:focus, .pk-button.focus {
|
||||
outline: 0;
|
||||
box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
|
||||
}
|
||||
|
||||
.pk-button-primary {
|
||||
color: #fff;
|
||||
background-color: #007bff;
|
||||
border-color: #007bff;
|
||||
}
|
||||
|
||||
.pk-button-primary:hover {
|
||||
color: #fff;
|
||||
background-color: #0069d9;
|
||||
border-color: #0062cc;
|
||||
}
|
||||
|
||||
.pk-button-primary:focus, .pk-button-primary.focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(38, 143, 255, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-primary.disabled, .pk-button-primary:disabled {
|
||||
color: #fff;
|
||||
background-color: #007bff;
|
||||
border-color: #007bff;
|
||||
}
|
||||
|
||||
.pk-button-primary:not(:disabled):not(.disabled):active, .pk-button-primary:not(:disabled):not(.disabled).active,
|
||||
.show > .pk-button-primary.dropdown-toggle {
|
||||
color: #fff;
|
||||
background-color: #0062cc;
|
||||
border-color: #005cbf;
|
||||
}
|
||||
|
||||
.pk-button-primary:not(:disabled):not(.disabled):active:focus, .pk-button-primary:not(:disabled):not(.disabled).active:focus,
|
||||
.show > .pk-button-primary.dropdown-toggle:focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(38, 143, 255, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-secondary {
|
||||
color: #212529;
|
||||
background-color: #A0A0A0;
|
||||
border-color: #A0A0A0;
|
||||
}
|
||||
|
||||
.pk-button-secondary:hover {
|
||||
color: #fff;
|
||||
background-color: #8d8d8d;
|
||||
border-color: #878686;
|
||||
}
|
||||
|
||||
.pk-button-secondary:focus, .pk-button-secondary.focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(141, 142, 142, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-secondary.disabled, .pk-button-secondary:disabled {
|
||||
color: #212529;
|
||||
background-color: #A0A0A0;
|
||||
border-color: #A0A0A0;
|
||||
}
|
||||
|
||||
.pk-button-secondary:not(:disabled):not(.disabled):active, .pk-button-secondary:not(:disabled):not(.disabled).active,
|
||||
.show > .pk-button-secondary.dropdown-toggle {
|
||||
color: #fff;
|
||||
background-color: #878686;
|
||||
border-color: gray;
|
||||
}
|
||||
|
||||
.pk-button-secondary:not(:disabled):not(.disabled):active:focus, .pk-button-secondary:not(:disabled):not(.disabled).active:focus,
|
||||
.show > .pk-button-secondary.dropdown-toggle:focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(141, 142, 142, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-success {
|
||||
color: #fff;
|
||||
background-color: #28a745;
|
||||
border-color: #28a745;
|
||||
}
|
||||
|
||||
.pk-button-success:hover {
|
||||
color: #fff;
|
||||
background-color: #218838;
|
||||
border-color: #1e7e34;
|
||||
}
|
||||
|
||||
.pk-button-success:focus, .pk-button-success.focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(72, 180, 97, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-success.disabled, .pk-button-success:disabled {
|
||||
color: #fff;
|
||||
background-color: #28a745;
|
||||
border-color: #28a745;
|
||||
}
|
||||
|
||||
.pk-button-success:not(:disabled):not(.disabled):active, .pk-button-success:not(:disabled):not(.disabled).active,
|
||||
.show > .pk-button-success.dropdown-toggle {
|
||||
color: #fff;
|
||||
background-color: #1e7e34;
|
||||
border-color: #1c7430;
|
||||
}
|
||||
|
||||
.pk-button-success:not(:disabled):not(.disabled):active:focus, .pk-button-success:not(:disabled):not(.disabled).active:focus,
|
||||
.show > .pk-button-success.dropdown-toggle:focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(72, 180, 97, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-info {
|
||||
color: #fff;
|
||||
background-color: #17a2b8;
|
||||
border-color: #17a2b8;
|
||||
}
|
||||
|
||||
.pk-button-info:hover {
|
||||
color: #fff;
|
||||
background-color: #138496;
|
||||
border-color: #117a8b;
|
||||
}
|
||||
|
||||
.pk-button-info:focus, .pk-button-info.focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(58, 176, 195, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-info.disabled, .pk-button-info:disabled {
|
||||
color: #fff;
|
||||
background-color: #17a2b8;
|
||||
border-color: #17a2b8;
|
||||
}
|
||||
|
||||
.pk-button-info:not(:disabled):not(.disabled):active, .pk-button-info:not(:disabled):not(.disabled).active,
|
||||
.show > .pk-button-info.dropdown-toggle {
|
||||
color: #fff;
|
||||
background-color: #117a8b;
|
||||
border-color: #10707f;
|
||||
}
|
||||
|
||||
.pk-button-info:not(:disabled):not(.disabled):active:focus, .pk-button-info:not(:disabled):not(.disabled).active:focus,
|
||||
.show > .pk-button-info.dropdown-toggle:focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(58, 176, 195, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-warning {
|
||||
color: #212529;
|
||||
background-color: #ffc107;
|
||||
border-color: #ffc107;
|
||||
}
|
||||
|
||||
.pk-button-warning:hover {
|
||||
color: #212529;
|
||||
background-color: #e0a800;
|
||||
border-color: #d39e00;
|
||||
}
|
||||
|
||||
.pk-button-warning:focus, .pk-button-warning.focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(222, 170, 12, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-warning.disabled, .pk-button-warning:disabled {
|
||||
color: #212529;
|
||||
background-color: #ffc107;
|
||||
border-color: #ffc107;
|
||||
}
|
||||
|
||||
.pk-button-warning:not(:disabled):not(.disabled):active, .pk-button-warning:not(:disabled):not(.disabled).active,
|
||||
.show > .pk-button-warning.dropdown-toggle {
|
||||
color: #212529;
|
||||
background-color: #d39e00;
|
||||
border-color: #c69500;
|
||||
}
|
||||
|
||||
.pk-button-warning:not(:disabled):not(.disabled):active:focus, .pk-button-warning:not(:disabled):not(.disabled).active:focus,
|
||||
.show > .pk-button-warning.dropdown-toggle:focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(222, 170, 12, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-danger {
|
||||
color: #fff;
|
||||
background-color: #dc3545;
|
||||
border-color: #dc3545;
|
||||
}
|
||||
|
||||
.pk-button-danger:hover {
|
||||
color: #fff;
|
||||
background-color: #c82333;
|
||||
border-color: #bd2130;
|
||||
}
|
||||
|
||||
.pk-button-danger:focus, .pk-button-danger.focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(225, 83, 97, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-danger.disabled, .pk-button-danger:disabled {
|
||||
color: #fff;
|
||||
background-color: #dc3545;
|
||||
border-color: #dc3545;
|
||||
}
|
||||
|
||||
.pk-button-danger:not(:disabled):not(.disabled):active, .pk-button-danger:not(:disabled):not(.disabled).active,
|
||||
.show > .pk-button-danger.dropdown-toggle {
|
||||
color: #fff;
|
||||
background-color: #bd2130;
|
||||
border-color: #b21f2d;
|
||||
}
|
||||
|
||||
.pk-button-danger:not(:disabled):not(.disabled):active:focus, .pk-button-danger:not(:disabled):not(.disabled).active:focus,
|
||||
.show > .pk-button-danger.dropdown-toggle:focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(225, 83, 97, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-light {
|
||||
color: #212529;
|
||||
background-color: #f8f9fa;
|
||||
border-color: #f8f9fa;
|
||||
}
|
||||
|
||||
.pk-button-light:hover {
|
||||
color: #212529;
|
||||
background-color: #e2e6ea;
|
||||
border-color: #dae0e5;
|
||||
}
|
||||
|
||||
.pk-button-light:focus, .pk-button-light.focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(216, 217, 219, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-light.disabled, .pk-button-light:disabled {
|
||||
color: #212529;
|
||||
background-color: #f8f9fa;
|
||||
border-color: #f8f9fa;
|
||||
}
|
||||
|
||||
.pk-button-light:not(:disabled):not(.disabled):active, .pk-button-light:not(:disabled):not(.disabled).active,
|
||||
.show > .pk-button-light.dropdown-toggle {
|
||||
color: #212529;
|
||||
background-color: #dae0e5;
|
||||
border-color: #d3d9df;
|
||||
}
|
||||
|
||||
.pk-button-light:not(:disabled):not(.disabled):active:focus, .pk-button-light:not(:disabled):not(.disabled).active:focus,
|
||||
.show > .pk-button-light.dropdown-toggle:focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(216, 217, 219, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-dark {
|
||||
color: #fff;
|
||||
background-color: #343a40;
|
||||
border-color: #343a40;
|
||||
}
|
||||
|
||||
.pk-button-dark:hover {
|
||||
color: #fff;
|
||||
background-color: #23272b;
|
||||
border-color: #1d2124;
|
||||
}
|
||||
|
||||
.pk-button-dark:focus, .pk-button-dark.focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(82, 88, 93, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-dark.disabled, .pk-button-dark:disabled {
|
||||
color: #fff;
|
||||
background-color: #343a40;
|
||||
border-color: #343a40;
|
||||
}
|
||||
|
||||
.pk-button-dark:not(:disabled):not(.disabled):active, .pk-button-dark:not(:disabled):not(.disabled).active,
|
||||
.show > .pk-button-dark.dropdown-toggle {
|
||||
color: #fff;
|
||||
background-color: #1d2124;
|
||||
border-color: #171a1d;
|
||||
}
|
||||
|
||||
.pk-button-dark:not(:disabled):not(.disabled):active:focus, .pk-button-dark:not(:disabled):not(.disabled).active:focus,
|
||||
.show > .pk-button-dark.dropdown-toggle:focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(82, 88, 93, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-outline-primary {
|
||||
color: #007bff;
|
||||
border-color: #007bff;
|
||||
}
|
||||
|
||||
.pk-button-outline-primary:hover {
|
||||
color: #fff;
|
||||
background-color: #007bff;
|
||||
border-color: #007bff;
|
||||
}
|
||||
|
||||
.pk-button-outline-primary:focus, .pk-button-outline-primary.focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-outline-primary.disabled, .pk-button-outline-primary:disabled {
|
||||
color: #007bff;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.pk-button-outline-primary:not(:disabled):not(.disabled):active, .pk-button-outline-primary:not(:disabled):not(.disabled).active,
|
||||
.show > .pk-button-outline-primary.dropdown-toggle {
|
||||
color: #fff;
|
||||
background-color: #007bff;
|
||||
border-color: #007bff;
|
||||
}
|
||||
|
||||
.pk-button-outline-primary:not(:disabled):not(.disabled):active:focus, .pk-button-outline-primary:not(:disabled):not(.disabled).active:focus,
|
||||
.show > .pk-button-outline-primary.dropdown-toggle:focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-outline-secondary {
|
||||
color: #A0A0A0;
|
||||
border-color: #A0A0A0;
|
||||
}
|
||||
|
||||
.pk-button-outline-secondary:hover {
|
||||
color: #212529;
|
||||
background-color: #A0A0A0;
|
||||
border-color: #A0A0A0;
|
||||
}
|
||||
|
||||
.pk-button-outline-secondary:focus, .pk-button-outline-secondary.focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(160, 160, 160, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-outline-secondary.disabled, .pk-button-outline-secondary:disabled {
|
||||
color: #A0A0A0;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.pk-button-outline-secondary:not(:disabled):not(.disabled):active, .pk-button-outline-secondary:not(:disabled):not(.disabled).active,
|
||||
.show > .pk-button-outline-secondary.dropdown-toggle {
|
||||
color: #212529;
|
||||
background-color: #A0A0A0;
|
||||
border-color: #A0A0A0;
|
||||
}
|
||||
|
||||
.pk-button-outline-secondary:not(:disabled):not(.disabled):active:focus, .pk-button-outline-secondary:not(:disabled):not(.disabled).active:focus,
|
||||
.show > .pk-button-outline-secondary.dropdown-toggle:focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(160, 160, 160, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-outline-success {
|
||||
color: #28a745;
|
||||
border-color: #28a745;
|
||||
}
|
||||
|
||||
.pk-button-outline-success:hover {
|
||||
color: #fff;
|
||||
background-color: #28a745;
|
||||
border-color: #28a745;
|
||||
}
|
||||
|
||||
.pk-button-outline-success:focus, .pk-button-outline-success.focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-outline-success.disabled, .pk-button-outline-success:disabled {
|
||||
color: #28a745;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.pk-button-outline-success:not(:disabled):not(.disabled):active, .pk-button-outline-success:not(:disabled):not(.disabled).active,
|
||||
.show > .pk-button-outline-success.dropdown-toggle {
|
||||
color: #fff;
|
||||
background-color: #28a745;
|
||||
border-color: #28a745;
|
||||
}
|
||||
|
||||
.pk-button-outline-success:not(:disabled):not(.disabled):active:focus, .pk-button-outline-success:not(:disabled):not(.disabled).active:focus,
|
||||
.show > .pk-button-outline-success.dropdown-toggle:focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-outline-info {
|
||||
color: #17a2b8;
|
||||
border-color: #17a2b8;
|
||||
}
|
||||
|
||||
.pk-button-outline-info:hover {
|
||||
color: #fff;
|
||||
background-color: #17a2b8;
|
||||
border-color: #17a2b8;
|
||||
}
|
||||
|
||||
.pk-button-outline-info:focus, .pk-button-outline-info.focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(23, 162, 184, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-outline-info.disabled, .pk-button-outline-info:disabled {
|
||||
color: #17a2b8;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.pk-button-outline-info:not(:disabled):not(.disabled):active, .pk-button-outline-info:not(:disabled):not(.disabled).active,
|
||||
.show > .pk-button-outline-info.dropdown-toggle {
|
||||
color: #fff;
|
||||
background-color: #17a2b8;
|
||||
border-color: #17a2b8;
|
||||
}
|
||||
|
||||
.pk-button-outline-info:not(:disabled):not(.disabled):active:focus, .pk-button-outline-info:not(:disabled):not(.disabled).active:focus,
|
||||
.show > .pk-button-outline-info.dropdown-toggle:focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(23, 162, 184, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-outline-warning {
|
||||
color: #ffc107;
|
||||
border-color: #ffc107;
|
||||
}
|
||||
|
||||
.pk-button-outline-warning:hover {
|
||||
color: #212529;
|
||||
background-color: #ffc107;
|
||||
border-color: #ffc107;
|
||||
}
|
||||
|
||||
.pk-button-outline-warning:focus, .pk-button-outline-warning.focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(255, 193, 7, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-outline-warning.disabled, .pk-button-outline-warning:disabled {
|
||||
color: #ffc107;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.pk-button-outline-warning:not(:disabled):not(.disabled):active, .pk-button-outline-warning:not(:disabled):not(.disabled).active,
|
||||
.show > .pk-button-outline-warning.dropdown-toggle {
|
||||
color: #212529;
|
||||
background-color: #ffc107;
|
||||
border-color: #ffc107;
|
||||
}
|
||||
|
||||
.pk-button-outline-warning:not(:disabled):not(.disabled):active:focus, .pk-button-outline-warning:not(:disabled):not(.disabled).active:focus,
|
||||
.show > .pk-button-outline-warning.dropdown-toggle:focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(255, 193, 7, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-outline-danger {
|
||||
color: #dc3545;
|
||||
border-color: #dc3545;
|
||||
}
|
||||
|
||||
.pk-button-outline-danger:hover {
|
||||
color: #fff;
|
||||
background-color: #dc3545;
|
||||
border-color: #dc3545;
|
||||
}
|
||||
|
||||
.pk-button-outline-danger:focus, .pk-button-outline-danger.focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-outline-danger.disabled, .pk-button-outline-danger:disabled {
|
||||
color: #dc3545;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.pk-button-outline-danger:not(:disabled):not(.disabled):active, .pk-button-outline-danger:not(:disabled):not(.disabled).active,
|
||||
.show > .pk-button-outline-danger.dropdown-toggle {
|
||||
color: #fff;
|
||||
background-color: #dc3545;
|
||||
border-color: #dc3545;
|
||||
}
|
||||
|
||||
.pk-button-outline-danger:not(:disabled):not(.disabled):active:focus, .pk-button-outline-danger:not(:disabled):not(.disabled).active:focus,
|
||||
.show > .pk-button-outline-danger.dropdown-toggle:focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-outline-light {
|
||||
color: #f8f9fa;
|
||||
border-color: #f8f9fa;
|
||||
}
|
||||
|
||||
.pk-button-outline-light:hover {
|
||||
color: #212529;
|
||||
background-color: #f8f9fa;
|
||||
border-color: #f8f9fa;
|
||||
}
|
||||
|
||||
.pk-button-outline-light:focus, .pk-button-outline-light.focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(248, 249, 250, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-outline-light.disabled, .pk-button-outline-light:disabled {
|
||||
color: #f8f9fa;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.pk-button-outline-light:not(:disabled):not(.disabled):active, .pk-button-outline-light:not(:disabled):not(.disabled).active,
|
||||
.show > .pk-button-outline-light.dropdown-toggle {
|
||||
color: #212529;
|
||||
background-color: #f8f9fa;
|
||||
border-color: #f8f9fa;
|
||||
}
|
||||
|
||||
.pk-button-outline-light:not(:disabled):not(.disabled):active:focus, .pk-button-outline-light:not(:disabled):not(.disabled).active:focus,
|
||||
.show > .pk-button-outline-light.dropdown-toggle:focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(248, 249, 250, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-outline-dark {
|
||||
color: #343a40;
|
||||
border-color: #343a40;
|
||||
}
|
||||
|
||||
.pk-button-outline-dark:hover {
|
||||
color: #fff;
|
||||
background-color: #343a40;
|
||||
border-color: #343a40;
|
||||
}
|
||||
|
||||
.pk-button-outline-dark:focus, .pk-button-outline-dark.focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(52, 58, 64, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-outline-dark.disabled, .pk-button-outline-dark:disabled {
|
||||
color: #343a40;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.pk-button-outline-dark:not(:disabled):not(.disabled):active, .pk-button-outline-dark:not(:disabled):not(.disabled).active,
|
||||
.show > .pk-button-outline-dark.dropdown-toggle {
|
||||
color: #fff;
|
||||
background-color: #343a40;
|
||||
border-color: #343a40;
|
||||
}
|
||||
|
||||
.pk-button-outline-dark:not(:disabled):not(.disabled):active:focus, .pk-button-outline-dark:not(:disabled):not(.disabled).active:focus,
|
||||
.show > .pk-button-outline-dark.dropdown-toggle:focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(52, 58, 64, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-lg {
|
||||
padding: 0.5rem 1rem;
|
||||
font-size: 1.25rem;
|
||||
line-height: 1.5;
|
||||
border-radius: 0.3rem;
|
||||
}
|
||||
|
||||
.pk-button-sm {
|
||||
padding: 0.25rem 0.5rem;
|
||||
font-size: 0.875rem;
|
||||
line-height: 1.5;
|
||||
border-radius: 0.2rem;
|
||||
}
|
||||
|
||||
.pk-button-block {
|
||||
display: block;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.pk-button-block + .pk-button-block {
|
||||
margin-top: 0.5rem;
|
||||
}
|
||||
|
||||
/* Tabs */
|
||||
/*--------------------------------------------------------------*/
|
||||
.pk-nav {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-wrap: wrap;
|
||||
padding-right: 0;
|
||||
margin-bottom: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.pk-fade {
|
||||
transition: opacity 0.15s linear;
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.pk-fade {
|
||||
transition: none;
|
||||
}
|
||||
}
|
||||
|
||||
.pk-nav-link {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.pk-nav-link:hover, .pk-nav-link:focus {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.pk-nav-tabs .pk-nav-item + .pk-nav-item .pk-nav-link {
|
||||
margin-top: 0.5rem;
|
||||
}
|
||||
|
||||
.pk-nav-tabs .pk-nav-link {
|
||||
border: 1px solid transparent;
|
||||
border-color: #dee2e6;
|
||||
color: #adb5bd;
|
||||
border-top-right-radius: 0.25rem;
|
||||
border-top-left-radius: 0.25rem;
|
||||
}
|
||||
|
||||
.pk-nav-tabs .pk-nav-link.pk-active {
|
||||
color: #000;
|
||||
background-color: #FFFFFF;
|
||||
}
|
||||
|
||||
.pk-nav-tabs .pk-nav-link:hover, .pk-nav-tabs .pk-nav-link:focus {
|
||||
color: #212529;
|
||||
}
|
||||
|
||||
.pk-tab-content > .pk-tab-pane {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.pk-tab-content > .pk-active {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.pk-tabs .pk-nav {
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.pk-tabs .pk-nav-link {
|
||||
padding: 1rem 1.5rem;
|
||||
line-height: 1;
|
||||
font-size: 1rem;
|
||||
text-decoration: none !important;
|
||||
box-shadow: none !important;
|
||||
}
|
||||
|
||||
.pk-tabs .pk-tab-pane > *:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.pk-tabs .pk-nav-tabs .pk-nav-link.pk-active {
|
||||
background-color: #f8f9fa;
|
||||
}
|
||||
|
||||
.pk-tabs .pk-nav-pills .pk-nav-link {
|
||||
border-radius: 0.25rem;
|
||||
padding: 0.75rem 1rem;
|
||||
line-height: 1;
|
||||
color: #adb5bd;
|
||||
}
|
||||
|
||||
.pk-tabs .pk-nav-pills .pk-nav-link.pk-active {
|
||||
color: #000;
|
||||
background-color: #e9ecef;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.pk-tabs .pk-nav-item + .pk-nav-item .pk-nav-link {
|
||||
margin-top: 0;
|
||||
}
|
||||
.pk-tabs .pk-nav-link:not(.pk-active) {
|
||||
border-color: transparent;
|
||||
}
|
||||
.pk-tabs .pk-nav-tabs .pk-nav-link.pk-active {
|
||||
background-color: transparent;
|
||||
}
|
||||
.pk-tabs-horizontal .pk-nav {
|
||||
flex-direction: row;
|
||||
}
|
||||
.pk-tabs-horizontal .pk-nav-tabs {
|
||||
border-bottom: 1px solid #dee2e6;
|
||||
}
|
||||
.pk-tabs-horizontal .pk-nav-item {
|
||||
transform: translateY(1px);
|
||||
}
|
||||
.pk-tabs-horizontal .pk-nav-link.pk-active {
|
||||
border-bottom-color: #fff;
|
||||
}
|
||||
.pk-tabs-vertical .pk-tabs-container {
|
||||
display: flex;
|
||||
}
|
||||
.pk-tabs-vertical .pk-tabs-navigation {
|
||||
flex: 0 0 30%;
|
||||
}
|
||||
.pk-tabs-vertical .pk-tabs-navigation .pk-nav {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.pk-tabs-vertical .pk-tabs-navigation .pk-nav-item {
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
transform: translateX(-1px);
|
||||
}
|
||||
.pk-tabs-vertical .pk-tabs-content {
|
||||
margin-right: 5%;
|
||||
flex: 0 0 65%;
|
||||
}
|
||||
.pk-tabs-vertical .pk-nav-tabs {
|
||||
border-left: 1px solid #dee2e6;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
}
|
||||
.pk-tabs-vertical .pk-nav-tabs .pk-nav-link {
|
||||
border-radius: 0 0.25rem 0.25rem 0;
|
||||
}
|
||||
.pk-tabs-vertical .pk-nav-tabs .pk-nav-link.pk-active {
|
||||
border-left-color: #fff;
|
||||
}
|
||||
.pk-tabs-vertical .pk-nav-pills {
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
|
||||
/* Collapsibles */
|
||||
/*--------------------------------------------------------------*/
|
||||
.pk-card {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
word-wrap: break-word;
|
||||
margin-bottom: 0;
|
||||
background-clip: border-box;
|
||||
}
|
||||
|
||||
.pk-card + .pk-card {
|
||||
border-top: 1px solid #e9ecef;
|
||||
}
|
||||
|
||||
.pk-collapsing {
|
||||
position: relative;
|
||||
height: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.pk-card-body {
|
||||
flex: 1 1 auto;
|
||||
padding: 0.75rem 0;
|
||||
}
|
||||
|
||||
.pk-card-header {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.pk-card-header .pk-card-title {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.pk-card-header a {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 0.75rem 0;
|
||||
border: none;
|
||||
color: #212529;
|
||||
transition: 0.3s;
|
||||
text-decoration: none !important;
|
||||
box-shadow: none !important;
|
||||
}
|
||||
|
||||
.pk-card-header a:hover {
|
||||
color: #adb5bd;
|
||||
}
|
||||
|
||||
.pk-card-header a:after {
|
||||
font-family: 'powerkit-icons';
|
||||
content: "\e90d";
|
||||
transition: 0.3s;
|
||||
}
|
||||
|
||||
.pk-card.expanded .pk-card-header a {
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.pk-card.expanded .pk-card-header a:after {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
|
||||
/* Progress */
|
||||
/*--------------------------------------------------------------*/
|
||||
@-webkit-keyframes progress-bar-stripes {
|
||||
from {
|
||||
background-position: 1rem 0;
|
||||
}
|
||||
to {
|
||||
background-position: 0 0;
|
||||
}
|
||||
}
|
||||
@keyframes progress-bar-stripes {
|
||||
from {
|
||||
background-position: 1rem 0;
|
||||
}
|
||||
to {
|
||||
background-position: 0 0;
|
||||
}
|
||||
}
|
||||
|
||||
.pk-progress {
|
||||
display: flex;
|
||||
height: 1rem;
|
||||
overflow: hidden;
|
||||
font-size: 0.75rem;
|
||||
background-color: #e9ecef;
|
||||
border-radius: 0.25rem;
|
||||
}
|
||||
|
||||
.pk-progress-bar {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
white-space: nowrap;
|
||||
transition: width 0.6s ease;
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.pk-progress-bar {
|
||||
transition: none;
|
||||
}
|
||||
}
|
||||
|
||||
.pk-progress-bar.pk-bg-primary {
|
||||
background-color: #007bff;
|
||||
}
|
||||
|
||||
.pk-progress-bar-striped {
|
||||
background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
|
||||
background-size: 1rem 1rem;
|
||||
}
|
||||
|
||||
.pk-progress-bar-animated {
|
||||
-webkit-animation: progress-bar-stripes 1s linear infinite;
|
||||
animation: progress-bar-stripes 1s linear infinite;
|
||||
}
|
||||
|
||||
/* Separators */
|
||||
/*--------------------------------------------------------------*/
|
||||
.pk-separator {
|
||||
border-bottom-color: #ddd;
|
||||
margin-top: 2rem;
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
+882
@@ -0,0 +1,882 @@
|
||||
/**
|
||||
* All of the CSS for your public-facing functionality should be
|
||||
* included in this file.
|
||||
*/
|
||||
/**
|
||||
* Environment for all styles (variables, additions, etc).
|
||||
*/
|
||||
/*--------------------------------------------------------------*/
|
||||
/*--------------------------------------------------------------*/
|
||||
.pk-tabs,
|
||||
.pk-pills,
|
||||
.pk-accordion,
|
||||
.pk-progress,
|
||||
.pk-button.pk-button-block {
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
/* Buttons */
|
||||
/*--------------------------------------------------------------*/
|
||||
.pk-button {
|
||||
display: inline-block;
|
||||
font-weight: 400;
|
||||
text-align: center;
|
||||
white-space: nowrap;
|
||||
vertical-align: middle;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
padding: 0.375rem 0.75rem;
|
||||
font-size: 1rem;
|
||||
line-height: 1.5;
|
||||
border-radius: 0.25rem;
|
||||
transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
|
||||
color: white;
|
||||
border: none;
|
||||
box-shadow: none !important;
|
||||
text-decoration: none !important;
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.pk-button {
|
||||
transition: none;
|
||||
}
|
||||
}
|
||||
|
||||
.pk-button:hover, .pk-button:focus {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.pk-button:focus, .pk-button.focus {
|
||||
outline: 0;
|
||||
box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
|
||||
}
|
||||
|
||||
.pk-button-primary {
|
||||
color: #fff;
|
||||
background-color: #007bff;
|
||||
border-color: #007bff;
|
||||
}
|
||||
|
||||
.pk-button-primary:hover {
|
||||
color: #fff;
|
||||
background-color: #0069d9;
|
||||
border-color: #0062cc;
|
||||
}
|
||||
|
||||
.pk-button-primary:focus, .pk-button-primary.focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(38, 143, 255, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-primary.disabled, .pk-button-primary:disabled {
|
||||
color: #fff;
|
||||
background-color: #007bff;
|
||||
border-color: #007bff;
|
||||
}
|
||||
|
||||
.pk-button-primary:not(:disabled):not(.disabled):active, .pk-button-primary:not(:disabled):not(.disabled).active,
|
||||
.show > .pk-button-primary.dropdown-toggle {
|
||||
color: #fff;
|
||||
background-color: #0062cc;
|
||||
border-color: #005cbf;
|
||||
}
|
||||
|
||||
.pk-button-primary:not(:disabled):not(.disabled):active:focus, .pk-button-primary:not(:disabled):not(.disabled).active:focus,
|
||||
.show > .pk-button-primary.dropdown-toggle:focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(38, 143, 255, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-secondary {
|
||||
color: #212529;
|
||||
background-color: #A0A0A0;
|
||||
border-color: #A0A0A0;
|
||||
}
|
||||
|
||||
.pk-button-secondary:hover {
|
||||
color: #fff;
|
||||
background-color: #8d8d8d;
|
||||
border-color: #878686;
|
||||
}
|
||||
|
||||
.pk-button-secondary:focus, .pk-button-secondary.focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(141, 142, 142, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-secondary.disabled, .pk-button-secondary:disabled {
|
||||
color: #212529;
|
||||
background-color: #A0A0A0;
|
||||
border-color: #A0A0A0;
|
||||
}
|
||||
|
||||
.pk-button-secondary:not(:disabled):not(.disabled):active, .pk-button-secondary:not(:disabled):not(.disabled).active,
|
||||
.show > .pk-button-secondary.dropdown-toggle {
|
||||
color: #fff;
|
||||
background-color: #878686;
|
||||
border-color: gray;
|
||||
}
|
||||
|
||||
.pk-button-secondary:not(:disabled):not(.disabled):active:focus, .pk-button-secondary:not(:disabled):not(.disabled).active:focus,
|
||||
.show > .pk-button-secondary.dropdown-toggle:focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(141, 142, 142, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-success {
|
||||
color: #fff;
|
||||
background-color: #28a745;
|
||||
border-color: #28a745;
|
||||
}
|
||||
|
||||
.pk-button-success:hover {
|
||||
color: #fff;
|
||||
background-color: #218838;
|
||||
border-color: #1e7e34;
|
||||
}
|
||||
|
||||
.pk-button-success:focus, .pk-button-success.focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(72, 180, 97, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-success.disabled, .pk-button-success:disabled {
|
||||
color: #fff;
|
||||
background-color: #28a745;
|
||||
border-color: #28a745;
|
||||
}
|
||||
|
||||
.pk-button-success:not(:disabled):not(.disabled):active, .pk-button-success:not(:disabled):not(.disabled).active,
|
||||
.show > .pk-button-success.dropdown-toggle {
|
||||
color: #fff;
|
||||
background-color: #1e7e34;
|
||||
border-color: #1c7430;
|
||||
}
|
||||
|
||||
.pk-button-success:not(:disabled):not(.disabled):active:focus, .pk-button-success:not(:disabled):not(.disabled).active:focus,
|
||||
.show > .pk-button-success.dropdown-toggle:focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(72, 180, 97, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-info {
|
||||
color: #fff;
|
||||
background-color: #17a2b8;
|
||||
border-color: #17a2b8;
|
||||
}
|
||||
|
||||
.pk-button-info:hover {
|
||||
color: #fff;
|
||||
background-color: #138496;
|
||||
border-color: #117a8b;
|
||||
}
|
||||
|
||||
.pk-button-info:focus, .pk-button-info.focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(58, 176, 195, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-info.disabled, .pk-button-info:disabled {
|
||||
color: #fff;
|
||||
background-color: #17a2b8;
|
||||
border-color: #17a2b8;
|
||||
}
|
||||
|
||||
.pk-button-info:not(:disabled):not(.disabled):active, .pk-button-info:not(:disabled):not(.disabled).active,
|
||||
.show > .pk-button-info.dropdown-toggle {
|
||||
color: #fff;
|
||||
background-color: #117a8b;
|
||||
border-color: #10707f;
|
||||
}
|
||||
|
||||
.pk-button-info:not(:disabled):not(.disabled):active:focus, .pk-button-info:not(:disabled):not(.disabled).active:focus,
|
||||
.show > .pk-button-info.dropdown-toggle:focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(58, 176, 195, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-warning {
|
||||
color: #212529;
|
||||
background-color: #ffc107;
|
||||
border-color: #ffc107;
|
||||
}
|
||||
|
||||
.pk-button-warning:hover {
|
||||
color: #212529;
|
||||
background-color: #e0a800;
|
||||
border-color: #d39e00;
|
||||
}
|
||||
|
||||
.pk-button-warning:focus, .pk-button-warning.focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(222, 170, 12, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-warning.disabled, .pk-button-warning:disabled {
|
||||
color: #212529;
|
||||
background-color: #ffc107;
|
||||
border-color: #ffc107;
|
||||
}
|
||||
|
||||
.pk-button-warning:not(:disabled):not(.disabled):active, .pk-button-warning:not(:disabled):not(.disabled).active,
|
||||
.show > .pk-button-warning.dropdown-toggle {
|
||||
color: #212529;
|
||||
background-color: #d39e00;
|
||||
border-color: #c69500;
|
||||
}
|
||||
|
||||
.pk-button-warning:not(:disabled):not(.disabled):active:focus, .pk-button-warning:not(:disabled):not(.disabled).active:focus,
|
||||
.show > .pk-button-warning.dropdown-toggle:focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(222, 170, 12, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-danger {
|
||||
color: #fff;
|
||||
background-color: #dc3545;
|
||||
border-color: #dc3545;
|
||||
}
|
||||
|
||||
.pk-button-danger:hover {
|
||||
color: #fff;
|
||||
background-color: #c82333;
|
||||
border-color: #bd2130;
|
||||
}
|
||||
|
||||
.pk-button-danger:focus, .pk-button-danger.focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(225, 83, 97, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-danger.disabled, .pk-button-danger:disabled {
|
||||
color: #fff;
|
||||
background-color: #dc3545;
|
||||
border-color: #dc3545;
|
||||
}
|
||||
|
||||
.pk-button-danger:not(:disabled):not(.disabled):active, .pk-button-danger:not(:disabled):not(.disabled).active,
|
||||
.show > .pk-button-danger.dropdown-toggle {
|
||||
color: #fff;
|
||||
background-color: #bd2130;
|
||||
border-color: #b21f2d;
|
||||
}
|
||||
|
||||
.pk-button-danger:not(:disabled):not(.disabled):active:focus, .pk-button-danger:not(:disabled):not(.disabled).active:focus,
|
||||
.show > .pk-button-danger.dropdown-toggle:focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(225, 83, 97, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-light {
|
||||
color: #212529;
|
||||
background-color: #f8f9fa;
|
||||
border-color: #f8f9fa;
|
||||
}
|
||||
|
||||
.pk-button-light:hover {
|
||||
color: #212529;
|
||||
background-color: #e2e6ea;
|
||||
border-color: #dae0e5;
|
||||
}
|
||||
|
||||
.pk-button-light:focus, .pk-button-light.focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(216, 217, 219, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-light.disabled, .pk-button-light:disabled {
|
||||
color: #212529;
|
||||
background-color: #f8f9fa;
|
||||
border-color: #f8f9fa;
|
||||
}
|
||||
|
||||
.pk-button-light:not(:disabled):not(.disabled):active, .pk-button-light:not(:disabled):not(.disabled).active,
|
||||
.show > .pk-button-light.dropdown-toggle {
|
||||
color: #212529;
|
||||
background-color: #dae0e5;
|
||||
border-color: #d3d9df;
|
||||
}
|
||||
|
||||
.pk-button-light:not(:disabled):not(.disabled):active:focus, .pk-button-light:not(:disabled):not(.disabled).active:focus,
|
||||
.show > .pk-button-light.dropdown-toggle:focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(216, 217, 219, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-dark {
|
||||
color: #fff;
|
||||
background-color: #343a40;
|
||||
border-color: #343a40;
|
||||
}
|
||||
|
||||
.pk-button-dark:hover {
|
||||
color: #fff;
|
||||
background-color: #23272b;
|
||||
border-color: #1d2124;
|
||||
}
|
||||
|
||||
.pk-button-dark:focus, .pk-button-dark.focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(82, 88, 93, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-dark.disabled, .pk-button-dark:disabled {
|
||||
color: #fff;
|
||||
background-color: #343a40;
|
||||
border-color: #343a40;
|
||||
}
|
||||
|
||||
.pk-button-dark:not(:disabled):not(.disabled):active, .pk-button-dark:not(:disabled):not(.disabled).active,
|
||||
.show > .pk-button-dark.dropdown-toggle {
|
||||
color: #fff;
|
||||
background-color: #1d2124;
|
||||
border-color: #171a1d;
|
||||
}
|
||||
|
||||
.pk-button-dark:not(:disabled):not(.disabled):active:focus, .pk-button-dark:not(:disabled):not(.disabled).active:focus,
|
||||
.show > .pk-button-dark.dropdown-toggle:focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(82, 88, 93, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-outline-primary {
|
||||
color: #007bff;
|
||||
border-color: #007bff;
|
||||
}
|
||||
|
||||
.pk-button-outline-primary:hover {
|
||||
color: #fff;
|
||||
background-color: #007bff;
|
||||
border-color: #007bff;
|
||||
}
|
||||
|
||||
.pk-button-outline-primary:focus, .pk-button-outline-primary.focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-outline-primary.disabled, .pk-button-outline-primary:disabled {
|
||||
color: #007bff;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.pk-button-outline-primary:not(:disabled):not(.disabled):active, .pk-button-outline-primary:not(:disabled):not(.disabled).active,
|
||||
.show > .pk-button-outline-primary.dropdown-toggle {
|
||||
color: #fff;
|
||||
background-color: #007bff;
|
||||
border-color: #007bff;
|
||||
}
|
||||
|
||||
.pk-button-outline-primary:not(:disabled):not(.disabled):active:focus, .pk-button-outline-primary:not(:disabled):not(.disabled).active:focus,
|
||||
.show > .pk-button-outline-primary.dropdown-toggle:focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-outline-secondary {
|
||||
color: #A0A0A0;
|
||||
border-color: #A0A0A0;
|
||||
}
|
||||
|
||||
.pk-button-outline-secondary:hover {
|
||||
color: #212529;
|
||||
background-color: #A0A0A0;
|
||||
border-color: #A0A0A0;
|
||||
}
|
||||
|
||||
.pk-button-outline-secondary:focus, .pk-button-outline-secondary.focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(160, 160, 160, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-outline-secondary.disabled, .pk-button-outline-secondary:disabled {
|
||||
color: #A0A0A0;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.pk-button-outline-secondary:not(:disabled):not(.disabled):active, .pk-button-outline-secondary:not(:disabled):not(.disabled).active,
|
||||
.show > .pk-button-outline-secondary.dropdown-toggle {
|
||||
color: #212529;
|
||||
background-color: #A0A0A0;
|
||||
border-color: #A0A0A0;
|
||||
}
|
||||
|
||||
.pk-button-outline-secondary:not(:disabled):not(.disabled):active:focus, .pk-button-outline-secondary:not(:disabled):not(.disabled).active:focus,
|
||||
.show > .pk-button-outline-secondary.dropdown-toggle:focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(160, 160, 160, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-outline-success {
|
||||
color: #28a745;
|
||||
border-color: #28a745;
|
||||
}
|
||||
|
||||
.pk-button-outline-success:hover {
|
||||
color: #fff;
|
||||
background-color: #28a745;
|
||||
border-color: #28a745;
|
||||
}
|
||||
|
||||
.pk-button-outline-success:focus, .pk-button-outline-success.focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-outline-success.disabled, .pk-button-outline-success:disabled {
|
||||
color: #28a745;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.pk-button-outline-success:not(:disabled):not(.disabled):active, .pk-button-outline-success:not(:disabled):not(.disabled).active,
|
||||
.show > .pk-button-outline-success.dropdown-toggle {
|
||||
color: #fff;
|
||||
background-color: #28a745;
|
||||
border-color: #28a745;
|
||||
}
|
||||
|
||||
.pk-button-outline-success:not(:disabled):not(.disabled):active:focus, .pk-button-outline-success:not(:disabled):not(.disabled).active:focus,
|
||||
.show > .pk-button-outline-success.dropdown-toggle:focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-outline-info {
|
||||
color: #17a2b8;
|
||||
border-color: #17a2b8;
|
||||
}
|
||||
|
||||
.pk-button-outline-info:hover {
|
||||
color: #fff;
|
||||
background-color: #17a2b8;
|
||||
border-color: #17a2b8;
|
||||
}
|
||||
|
||||
.pk-button-outline-info:focus, .pk-button-outline-info.focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(23, 162, 184, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-outline-info.disabled, .pk-button-outline-info:disabled {
|
||||
color: #17a2b8;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.pk-button-outline-info:not(:disabled):not(.disabled):active, .pk-button-outline-info:not(:disabled):not(.disabled).active,
|
||||
.show > .pk-button-outline-info.dropdown-toggle {
|
||||
color: #fff;
|
||||
background-color: #17a2b8;
|
||||
border-color: #17a2b8;
|
||||
}
|
||||
|
||||
.pk-button-outline-info:not(:disabled):not(.disabled):active:focus, .pk-button-outline-info:not(:disabled):not(.disabled).active:focus,
|
||||
.show > .pk-button-outline-info.dropdown-toggle:focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(23, 162, 184, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-outline-warning {
|
||||
color: #ffc107;
|
||||
border-color: #ffc107;
|
||||
}
|
||||
|
||||
.pk-button-outline-warning:hover {
|
||||
color: #212529;
|
||||
background-color: #ffc107;
|
||||
border-color: #ffc107;
|
||||
}
|
||||
|
||||
.pk-button-outline-warning:focus, .pk-button-outline-warning.focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(255, 193, 7, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-outline-warning.disabled, .pk-button-outline-warning:disabled {
|
||||
color: #ffc107;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.pk-button-outline-warning:not(:disabled):not(.disabled):active, .pk-button-outline-warning:not(:disabled):not(.disabled).active,
|
||||
.show > .pk-button-outline-warning.dropdown-toggle {
|
||||
color: #212529;
|
||||
background-color: #ffc107;
|
||||
border-color: #ffc107;
|
||||
}
|
||||
|
||||
.pk-button-outline-warning:not(:disabled):not(.disabled):active:focus, .pk-button-outline-warning:not(:disabled):not(.disabled).active:focus,
|
||||
.show > .pk-button-outline-warning.dropdown-toggle:focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(255, 193, 7, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-outline-danger {
|
||||
color: #dc3545;
|
||||
border-color: #dc3545;
|
||||
}
|
||||
|
||||
.pk-button-outline-danger:hover {
|
||||
color: #fff;
|
||||
background-color: #dc3545;
|
||||
border-color: #dc3545;
|
||||
}
|
||||
|
||||
.pk-button-outline-danger:focus, .pk-button-outline-danger.focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-outline-danger.disabled, .pk-button-outline-danger:disabled {
|
||||
color: #dc3545;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.pk-button-outline-danger:not(:disabled):not(.disabled):active, .pk-button-outline-danger:not(:disabled):not(.disabled).active,
|
||||
.show > .pk-button-outline-danger.dropdown-toggle {
|
||||
color: #fff;
|
||||
background-color: #dc3545;
|
||||
border-color: #dc3545;
|
||||
}
|
||||
|
||||
.pk-button-outline-danger:not(:disabled):not(.disabled):active:focus, .pk-button-outline-danger:not(:disabled):not(.disabled).active:focus,
|
||||
.show > .pk-button-outline-danger.dropdown-toggle:focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-outline-light {
|
||||
color: #f8f9fa;
|
||||
border-color: #f8f9fa;
|
||||
}
|
||||
|
||||
.pk-button-outline-light:hover {
|
||||
color: #212529;
|
||||
background-color: #f8f9fa;
|
||||
border-color: #f8f9fa;
|
||||
}
|
||||
|
||||
.pk-button-outline-light:focus, .pk-button-outline-light.focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(248, 249, 250, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-outline-light.disabled, .pk-button-outline-light:disabled {
|
||||
color: #f8f9fa;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.pk-button-outline-light:not(:disabled):not(.disabled):active, .pk-button-outline-light:not(:disabled):not(.disabled).active,
|
||||
.show > .pk-button-outline-light.dropdown-toggle {
|
||||
color: #212529;
|
||||
background-color: #f8f9fa;
|
||||
border-color: #f8f9fa;
|
||||
}
|
||||
|
||||
.pk-button-outline-light:not(:disabled):not(.disabled):active:focus, .pk-button-outline-light:not(:disabled):not(.disabled).active:focus,
|
||||
.show > .pk-button-outline-light.dropdown-toggle:focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(248, 249, 250, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-outline-dark {
|
||||
color: #343a40;
|
||||
border-color: #343a40;
|
||||
}
|
||||
|
||||
.pk-button-outline-dark:hover {
|
||||
color: #fff;
|
||||
background-color: #343a40;
|
||||
border-color: #343a40;
|
||||
}
|
||||
|
||||
.pk-button-outline-dark:focus, .pk-button-outline-dark.focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(52, 58, 64, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-outline-dark.disabled, .pk-button-outline-dark:disabled {
|
||||
color: #343a40;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.pk-button-outline-dark:not(:disabled):not(.disabled):active, .pk-button-outline-dark:not(:disabled):not(.disabled).active,
|
||||
.show > .pk-button-outline-dark.dropdown-toggle {
|
||||
color: #fff;
|
||||
background-color: #343a40;
|
||||
border-color: #343a40;
|
||||
}
|
||||
|
||||
.pk-button-outline-dark:not(:disabled):not(.disabled):active:focus, .pk-button-outline-dark:not(:disabled):not(.disabled).active:focus,
|
||||
.show > .pk-button-outline-dark.dropdown-toggle:focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(52, 58, 64, 0.5);
|
||||
}
|
||||
|
||||
.pk-button-lg {
|
||||
padding: 0.5rem 1rem;
|
||||
font-size: 1.25rem;
|
||||
line-height: 1.5;
|
||||
border-radius: 0.3rem;
|
||||
}
|
||||
|
||||
.pk-button-sm {
|
||||
padding: 0.25rem 0.5rem;
|
||||
font-size: 0.875rem;
|
||||
line-height: 1.5;
|
||||
border-radius: 0.2rem;
|
||||
}
|
||||
|
||||
.pk-button-block {
|
||||
display: block;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.pk-button-block + .pk-button-block {
|
||||
margin-top: 0.5rem;
|
||||
}
|
||||
|
||||
/* Tabs */
|
||||
/*--------------------------------------------------------------*/
|
||||
.pk-nav {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-wrap: wrap;
|
||||
padding-left: 0;
|
||||
margin-bottom: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.pk-fade {
|
||||
transition: opacity 0.15s linear;
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.pk-fade {
|
||||
transition: none;
|
||||
}
|
||||
}
|
||||
|
||||
.pk-nav-link {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.pk-nav-link:hover, .pk-nav-link:focus {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.pk-nav-tabs .pk-nav-item + .pk-nav-item .pk-nav-link {
|
||||
margin-top: 0.5rem;
|
||||
}
|
||||
|
||||
.pk-nav-tabs .pk-nav-link {
|
||||
border: 1px solid transparent;
|
||||
border-color: #dee2e6;
|
||||
color: #adb5bd;
|
||||
border-top-left-radius: 0.25rem;
|
||||
border-top-right-radius: 0.25rem;
|
||||
}
|
||||
|
||||
.pk-nav-tabs .pk-nav-link.pk-active {
|
||||
color: #000;
|
||||
background-color: #FFFFFF;
|
||||
}
|
||||
|
||||
.pk-nav-tabs .pk-nav-link:hover, .pk-nav-tabs .pk-nav-link:focus {
|
||||
color: #212529;
|
||||
}
|
||||
|
||||
.pk-tab-content > .pk-tab-pane {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.pk-tab-content > .pk-active {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.pk-tabs .pk-nav {
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.pk-tabs .pk-nav-link {
|
||||
padding: 1rem 1.5rem;
|
||||
line-height: 1;
|
||||
font-size: 1rem;
|
||||
text-decoration: none !important;
|
||||
box-shadow: none !important;
|
||||
}
|
||||
|
||||
.pk-tabs .pk-tab-pane > *:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.pk-tabs .pk-nav-tabs .pk-nav-link.pk-active {
|
||||
background-color: #f8f9fa;
|
||||
}
|
||||
|
||||
.pk-tabs .pk-nav-pills .pk-nav-link {
|
||||
border-radius: 0.25rem;
|
||||
padding: 0.75rem 1rem;
|
||||
line-height: 1;
|
||||
color: #adb5bd;
|
||||
}
|
||||
|
||||
.pk-tabs .pk-nav-pills .pk-nav-link.pk-active {
|
||||
color: #000;
|
||||
background-color: #e9ecef;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.pk-tabs .pk-nav-item + .pk-nav-item .pk-nav-link {
|
||||
margin-top: 0;
|
||||
}
|
||||
.pk-tabs .pk-nav-link:not(.pk-active) {
|
||||
border-color: transparent;
|
||||
}
|
||||
.pk-tabs .pk-nav-tabs .pk-nav-link.pk-active {
|
||||
background-color: transparent;
|
||||
}
|
||||
.pk-tabs-horizontal .pk-nav {
|
||||
flex-direction: row;
|
||||
}
|
||||
.pk-tabs-horizontal .pk-nav-tabs {
|
||||
border-bottom: 1px solid #dee2e6;
|
||||
}
|
||||
.pk-tabs-horizontal .pk-nav-item {
|
||||
transform: translateY(1px);
|
||||
}
|
||||
.pk-tabs-horizontal .pk-nav-link.pk-active {
|
||||
border-bottom-color: #fff;
|
||||
}
|
||||
.pk-tabs-vertical .pk-tabs-container {
|
||||
display: flex;
|
||||
}
|
||||
.pk-tabs-vertical .pk-tabs-navigation {
|
||||
flex: 0 0 30%;
|
||||
}
|
||||
.pk-tabs-vertical .pk-tabs-navigation .pk-nav {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.pk-tabs-vertical .pk-tabs-navigation .pk-nav-item {
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
transform: translateX(1px);
|
||||
}
|
||||
.pk-tabs-vertical .pk-tabs-content {
|
||||
margin-left: 5%;
|
||||
flex: 0 0 65%;
|
||||
}
|
||||
.pk-tabs-vertical .pk-nav-tabs {
|
||||
border-right: 1px solid #dee2e6;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
}
|
||||
.pk-tabs-vertical .pk-nav-tabs .pk-nav-link {
|
||||
border-radius: 0.25rem 0 0 0.25rem;
|
||||
}
|
||||
.pk-tabs-vertical .pk-nav-tabs .pk-nav-link.pk-active {
|
||||
border-right-color: #fff;
|
||||
}
|
||||
.pk-tabs-vertical .pk-nav-pills {
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
|
||||
/* Collapsibles */
|
||||
/*--------------------------------------------------------------*/
|
||||
.pk-card {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
word-wrap: break-word;
|
||||
margin-bottom: 0;
|
||||
background-clip: border-box;
|
||||
}
|
||||
|
||||
.pk-card + .pk-card {
|
||||
border-top: 1px solid #e9ecef;
|
||||
}
|
||||
|
||||
.pk-collapsing {
|
||||
position: relative;
|
||||
height: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.pk-card-body {
|
||||
flex: 1 1 auto;
|
||||
padding: 0.75rem 0;
|
||||
}
|
||||
|
||||
.pk-card-header {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.pk-card-header .pk-card-title {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.pk-card-header a {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 0.75rem 0;
|
||||
border: none;
|
||||
color: #212529;
|
||||
transition: 0.3s;
|
||||
text-decoration: none !important;
|
||||
box-shadow: none !important;
|
||||
}
|
||||
|
||||
.pk-card-header a:hover {
|
||||
color: #adb5bd;
|
||||
}
|
||||
|
||||
.pk-card-header a:after {
|
||||
font-family: 'powerkit-icons';
|
||||
content: "\e914";
|
||||
transition: 0.3s;
|
||||
}
|
||||
|
||||
.pk-card.expanded .pk-card-header a {
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.pk-card.expanded .pk-card-header a:after {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
|
||||
/* Progress */
|
||||
/*--------------------------------------------------------------*/
|
||||
@-webkit-keyframes progress-bar-stripes {
|
||||
from {
|
||||
background-position: 1rem 0;
|
||||
}
|
||||
to {
|
||||
background-position: 0 0;
|
||||
}
|
||||
}
|
||||
@keyframes progress-bar-stripes {
|
||||
from {
|
||||
background-position: 1rem 0;
|
||||
}
|
||||
to {
|
||||
background-position: 0 0;
|
||||
}
|
||||
}
|
||||
|
||||
.pk-progress {
|
||||
display: flex;
|
||||
height: 1rem;
|
||||
overflow: hidden;
|
||||
font-size: 0.75rem;
|
||||
background-color: #e9ecef;
|
||||
border-radius: 0.25rem;
|
||||
}
|
||||
|
||||
.pk-progress-bar {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
white-space: nowrap;
|
||||
transition: width 0.6s ease;
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.pk-progress-bar {
|
||||
transition: none;
|
||||
}
|
||||
}
|
||||
|
||||
.pk-progress-bar.pk-bg-primary {
|
||||
background-color: #007bff;
|
||||
}
|
||||
|
||||
.pk-progress-bar-striped {
|
||||
background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
|
||||
background-size: 1rem 1rem;
|
||||
}
|
||||
|
||||
.pk-progress-bar-animated {
|
||||
-webkit-animation: progress-bar-stripes 1s linear infinite;
|
||||
animation: progress-bar-stripes 1s linear infinite;
|
||||
}
|
||||
|
||||
/* Separators */
|
||||
/*--------------------------------------------------------------*/
|
||||
.pk-separator {
|
||||
border-bottom-color: #ddd;
|
||||
margin-top: 2rem;
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* Basic Shortcodes
|
||||
*/
|
||||
( function( $ ) {
|
||||
|
||||
$( document ).ready( function() {
|
||||
|
||||
/* Alerts */
|
||||
$( document ).on( 'click', '.pk-alert .pk-close', function() {
|
||||
$( this ).closest( '.pk-alert' ).remove();
|
||||
} );
|
||||
|
||||
/* Tabs */
|
||||
$( '.pk-tab-pane' ).removeClass( 'pk-fade' );
|
||||
|
||||
$( document ).on( 'click', '.pk-tabs .pk-nav-item .pk-nav-link', function() {
|
||||
// Nav.
|
||||
$( this ).parent().siblings().find( '.pk-active' ).removeClass( 'pk-active' );
|
||||
$( this ).addClass( 'pk-active' );
|
||||
|
||||
// Pane.
|
||||
$( this ).closest( '.pk-tabs' ).find( '.pk-tab-pane' ).removeClass( 'pk-show pk-active' );
|
||||
$( this ).closest( '.pk-tabs' ).find( '.pk-tab-content' ).find( $( this ).attr( 'href' ) ).addClass( 'pk-show pk-active' );
|
||||
|
||||
return false;
|
||||
} );
|
||||
|
||||
/* Collapsibles */
|
||||
$( document ).on( 'click', '.pk-card a[data-toggle="collapse"]', function() {
|
||||
|
||||
if ( $( this ).closest( '.pk-collapsibles' ).length > 0 ) {
|
||||
$( this ).closest( '.pk-card' ).siblings().removeClass( 'expanded' );
|
||||
$( this ).closest( '.pk-card' ).siblings().find( '.pk-collapse' ).slideUp();
|
||||
}
|
||||
|
||||
$( this ).closest( '.pk-card' ).toggleClass( 'expanded' ).find( $( this ).attr( 'href' ) ).slideToggle();
|
||||
|
||||
return false;
|
||||
} );
|
||||
} );
|
||||
} )( jQuery );
|
||||
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
/**
|
||||
* Shortcode Alerts config
|
||||
*
|
||||
* @package Powerkit
|
||||
* @subpackage Templates
|
||||
*/
|
||||
|
||||
/**
|
||||
* Alerts
|
||||
*/
|
||||
powerkit_basic_shortcodes_register( array(
|
||||
'name' => 'alerts',
|
||||
'title' => esc_html__( 'Alerts', 'powerkit' ),
|
||||
'priority' => 30,
|
||||
'base' => 'powerkit_alert',
|
||||
'autoregister' => true,
|
||||
'fields' => array(
|
||||
array(
|
||||
'type' => 'section',
|
||||
'label' => esc_html__( 'Options', 'powerkit' ),
|
||||
),
|
||||
array(
|
||||
'type' => 'radio',
|
||||
'name' => 'type',
|
||||
'label' => esc_html__( 'Type', 'powerkit' ),
|
||||
'style' => 'vertical',
|
||||
'default' => 'info',
|
||||
'options' => array(
|
||||
'danger' => esc_html__( 'Danger', 'powerkit' ),
|
||||
'info' => esc_html__( 'Info', 'powerkit' ),
|
||||
'link' => esc_html__( 'Link', 'powerkit' ),
|
||||
'success' => esc_html__( 'Success', 'powerkit' ),
|
||||
'warning' => esc_html__( 'Warning', 'powerkit' ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'checkbox',
|
||||
'name' => 'dismissible',
|
||||
'label' => esc_html__( 'Display close button', 'powerkit' ),
|
||||
'default' => false,
|
||||
),
|
||||
array(
|
||||
'type' => 'checkbox',
|
||||
'name' => 'multiline',
|
||||
'label' => esc_html__( 'Multiline', 'powerkit' ),
|
||||
'default' => false,
|
||||
),
|
||||
array(
|
||||
'type' => 'section',
|
||||
'label' => esc_html__( 'Content', 'powerkit' ),
|
||||
),
|
||||
array(
|
||||
'type' => 'content',
|
||||
'name' => 'content',
|
||||
'label' => esc_html__( 'Content', 'powerkit' ),
|
||||
'default' => '',
|
||||
'attrs' => array(
|
||||
'class' => 'widefat',
|
||||
'rows' => 6,
|
||||
),
|
||||
),
|
||||
),
|
||||
) );
|
||||
|
||||
|
||||
/**
|
||||
* Alert Shortcode
|
||||
*
|
||||
* @param array $output Shortcode HTML.
|
||||
* @param array $atts User defined attributes in shortcode tag.
|
||||
* @param string $content Shorcode tag content.
|
||||
* @return string Shortcode result HTML.
|
||||
*/
|
||||
function powerkit_basic_shortcodes_alert( $output, $atts, $content ) {
|
||||
$dm_class = null;
|
||||
$dm_button = null;
|
||||
|
||||
if ( 'true' === $atts['dismissible'] ) {
|
||||
$dm_class .= ' pk-alert-dismissible';
|
||||
$dm_button .= '
|
||||
<button type="button" class="pk-close" data-dismiss="alert" aria-label="' . esc_attr__( 'Close', 'powerkit' ) . '">
|
||||
<i class="pk-icon-x"></i>
|
||||
</button>';
|
||||
}
|
||||
|
||||
if ( 'true' === $atts['multiline'] ) {
|
||||
$dm_class .= ' pk-alert-multiline';
|
||||
}
|
||||
|
||||
$output = sprintf(
|
||||
'<div class="pk-alert pk-alert-%s%s" role="alert" >%s%s</div>',
|
||||
$atts['type'],
|
||||
$dm_class,
|
||||
$dm_button,
|
||||
$content
|
||||
);
|
||||
|
||||
return $output;
|
||||
}
|
||||
add_filter( 'powerkit_alert_shortcode', 'powerkit_basic_shortcodes_alert', 10, 3 );
|
||||
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
/**
|
||||
* Shortcode Buttons config
|
||||
*
|
||||
* @package Powerkit
|
||||
* @subpackage Templates
|
||||
*/
|
||||
|
||||
/**
|
||||
* Buttons
|
||||
*/
|
||||
powerkit_basic_shortcodes_register( array(
|
||||
'name' => 'buttons',
|
||||
'title' => esc_html__( 'Buttons', 'powerkit' ),
|
||||
'priority' => 20,
|
||||
'base' => 'powerkit_button',
|
||||
'autoregister' => true,
|
||||
'fields' => array(
|
||||
array(
|
||||
'type' => 'section',
|
||||
'label' => esc_html__( 'Style Options', 'powerkit' ),
|
||||
),
|
||||
array(
|
||||
'type' => 'radio',
|
||||
'name' => 'size',
|
||||
'label' => esc_html__( 'Size', 'powerkit' ),
|
||||
'style' => 'horizontal',
|
||||
'default' => 'md',
|
||||
'options' => array(
|
||||
'sm' => esc_html__( 'Small', 'powerkit' ),
|
||||
'md' => esc_html__( 'Default', 'powerkit' ),
|
||||
'lg' => esc_html__( 'Large', 'powerkit' ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'radio',
|
||||
'name' => 'style',
|
||||
'label' => esc_html__( 'Style', 'powerkit' ),
|
||||
'style' => 'vertical',
|
||||
'default' => 'primary',
|
||||
'options' => array(
|
||||
'primary' => esc_html__( 'Primary', 'powerkit' ),
|
||||
'secondary' => esc_html__( 'Secondary', 'powerkit' ),
|
||||
'success' => esc_html__( 'Success', 'powerkit' ),
|
||||
'info' => esc_html__( 'Info', 'powerkit' ),
|
||||
'warning' => esc_html__( 'Warning', 'powerkit' ),
|
||||
'danger' => esc_html__( 'Danger', 'powerkit' ),
|
||||
'link' => esc_html__( 'Link', 'powerkit' ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'checkbox',
|
||||
'name' => 'block',
|
||||
'label' => esc_html__( 'Block', 'powerkit' ),
|
||||
'default' => false,
|
||||
),
|
||||
array(
|
||||
'type' => 'section',
|
||||
'label' => esc_html__( 'Link Options', 'powerkit' ),
|
||||
),
|
||||
array(
|
||||
'type' => 'input',
|
||||
'name' => 'url',
|
||||
'label' => esc_html__( 'URL', 'powerkit' ),
|
||||
'default' => 'http://',
|
||||
),
|
||||
array(
|
||||
'type' => 'radio',
|
||||
'name' => 'target',
|
||||
'label' => esc_html__( 'Link target', 'powerkit' ),
|
||||
'style' => 'vertical',
|
||||
'default' => '_self',
|
||||
'options' => array(
|
||||
'_self' => esc_html__( 'Open in same window', 'powerkit' ),
|
||||
'_blank' => esc_html__( 'Open in new window/tab', 'powerkit' ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'content',
|
||||
'name' => 'title',
|
||||
'label' => esc_html__( 'Title', 'powerkit' ),
|
||||
'default' => 'Button',
|
||||
'attrs' => array(
|
||||
'class' => 'widefat',
|
||||
'rows' => 6,
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'checkbox',
|
||||
'name' => 'nofollow',
|
||||
'label' => esc_html__( 'Apply "nofollow" attribute', 'powerkit' ),
|
||||
'default' => false,
|
||||
),
|
||||
),
|
||||
) );
|
||||
|
||||
|
||||
/**
|
||||
* Button Shortcode
|
||||
*
|
||||
* @param array $output Shortcode HTML.
|
||||
* @param array $atts User defined attributes in shortcode tag.
|
||||
* @param string $content Shorcode tag content.
|
||||
* @return string Shortcode result HTML.
|
||||
*/
|
||||
function powerkit_basic_shortcodes_button( $output, $atts, $content ) {
|
||||
$nofollow = ( 'true' === $atts['nofollow'] ) ? 'rel="nofollow"' : '';
|
||||
$block = ( 'true' === $atts['block'] ) ? ' pk-button-block' : '';
|
||||
|
||||
if ( isset( $atts['title'] ) && $atts['title'] ) {
|
||||
$title = $atts['title'];
|
||||
}
|
||||
|
||||
if ( $content ) {
|
||||
$title = $content;
|
||||
}
|
||||
|
||||
$output = sprintf(
|
||||
'<a class="pk-button pk-button-%s pk-button-%s%s pk-font-primary" href="%s" target="%s" %s>
|
||||
%s
|
||||
</a>',
|
||||
$atts['size'],
|
||||
$atts['style'],
|
||||
$block,
|
||||
$atts['url'],
|
||||
$atts['target'],
|
||||
$nofollow,
|
||||
$title
|
||||
);
|
||||
|
||||
return $output;
|
||||
}
|
||||
add_filter( 'powerkit_button_shortcode', 'powerkit_basic_shortcodes_button', 10, 3 );
|
||||
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
/**
|
||||
* Shortcode Collapsibles config
|
||||
*
|
||||
* @package Powerkit
|
||||
* @subpackage Templates
|
||||
*/
|
||||
|
||||
/**
|
||||
* Collapsibles
|
||||
*/
|
||||
powerkit_basic_shortcodes_register( array(
|
||||
'name' => 'collapsibles',
|
||||
'title' => esc_html__( 'Collapsibles', 'powerkit' ),
|
||||
'priority' => 50,
|
||||
'base' => 'powerkit_collapsibles',
|
||||
'autoregister' => true,
|
||||
'fields' => array(
|
||||
array(
|
||||
'type' => 'section',
|
||||
'label' => esc_html__( 'Content', 'powerkit' ),
|
||||
),
|
||||
array(
|
||||
'type' => 'repeater',
|
||||
'base' => 'powerkit_collapsible',
|
||||
'autoregister' => true,
|
||||
'label' => esc_html__( 'Collapsibles', 'powerkit' ),
|
||||
'fields' => array(
|
||||
array(
|
||||
'type' => 'input',
|
||||
'name' => 'title',
|
||||
'label' => esc_html__( 'Title', 'powerkit' ),
|
||||
'default' => '',
|
||||
'attrs' => array(
|
||||
'class' => 'widefat',
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'content',
|
||||
'name' => 'content',
|
||||
'label' => esc_html__( 'Content', 'powerkit' ),
|
||||
'default' => '',
|
||||
'attrs' => array(
|
||||
'class' => 'widefat',
|
||||
'rows' => 6,
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'checkbox',
|
||||
'name' => 'opened',
|
||||
'label' => esc_html__( 'Opened', 'powerkit' ),
|
||||
'default' => false,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
) );
|
||||
|
||||
|
||||
/**
|
||||
* Collapsibles Shortcode
|
||||
*
|
||||
* @param array $output Shortcode HTML.
|
||||
* @param array $atts User defined attributes in shortcode tag.
|
||||
* @param string $content Shorcode tag content.
|
||||
* @return string Shortcode result HTML.
|
||||
*/
|
||||
function powerkit_basic_shortcodes_collapsibles( $output, $atts, $content ) {
|
||||
|
||||
$collapse_id = uniqid();
|
||||
|
||||
$output = sprintf(
|
||||
'<div id="collapsibles-%1$s" class="pk-collapsibles" role="tablist" aria-multiselectable="true">%2$s</div>
|
||||
',
|
||||
$collapse_id,
|
||||
str_replace( 'data-parent="#"', 'data-parent="#pk-collapsibles-' . $collapse_id . '"', $content )
|
||||
);
|
||||
|
||||
return $output;
|
||||
}
|
||||
add_filter( 'powerkit_collapsibles_shortcode', 'powerkit_basic_shortcodes_collapsibles', 10, 3 );
|
||||
|
||||
|
||||
/**
|
||||
* Collapsible Shortcode
|
||||
*
|
||||
* @param array $output Shortcode HTML.
|
||||
* @param array $atts User defined attributes in shortcode tag.
|
||||
* @param string $content Shorcode tag content.
|
||||
* @return string Shortcode result HTML.
|
||||
*/
|
||||
function powerkit_basic_shortcodes_collapsible( $output, $atts, $content ) {
|
||||
|
||||
$item_id = uniqid();
|
||||
$output = sprintf(
|
||||
'<div class="pk-collapsible pk-card %4$s">
|
||||
<div class="pk-card-header" role="tab" id="card-%1$s">
|
||||
<h6 class="pk-card-title pk-title">
|
||||
<a data-toggle="collapse" class="pk-font-heading" href="#pk-collapse-%1$s" data-parent="#" aria-controls="collapse-%1$s">
|
||||
%2$s
|
||||
</a>
|
||||
</h6>
|
||||
</div>
|
||||
|
||||
<div id="pk-collapse-%1$s" class="pk-collapse" style="%3$s" role="tabpanel" aria-labelledby="card-%1$s">
|
||||
<div class="pk-card-body">
|
||||
%5$s
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
',
|
||||
$item_id,
|
||||
$atts['title'],
|
||||
( 'true' === $atts['opened'] ) ? 'display:block;' : 'display:none;',
|
||||
( 'true' === $atts['opened'] ) ? 'expanded' : '',
|
||||
do_shortcode( $content )
|
||||
);
|
||||
|
||||
return $output;
|
||||
}
|
||||
add_filter( 'powerkit_collapsible_shortcode', 'powerkit_basic_shortcodes_collapsible', 10, 3 );
|
||||
@@ -0,0 +1,201 @@
|
||||
<?php
|
||||
/**
|
||||
* Shortcode Grid config
|
||||
*
|
||||
* @package Powerkit
|
||||
* @subpackage Templates
|
||||
*/
|
||||
|
||||
/**
|
||||
* Init module
|
||||
*/
|
||||
class Powerkit_Basic_Grid {
|
||||
|
||||
/**
|
||||
* Initialize.
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
if ( class_exists( 'Gridable' ) ) {
|
||||
add_filter( 'gridable_row_class', array( $this, 'gridable_row_class' ) );
|
||||
add_filter( 'gridable_column_class', array( $this, 'gridable_column_class' ), 10, 4 );
|
||||
add_filter( 'gridable_load_public_style', '__return_false' );
|
||||
|
||||
} else {
|
||||
|
||||
add_shortcode( 'powerkit_row', array( $this, 'add_row_shortcode' ) );
|
||||
add_shortcode( 'powerkit_col', array( $this, 'add_column_shortcode' ) );
|
||||
add_shortcode( 'row', array( $this, 'add_row_shortcode' ) );
|
||||
add_shortcode( 'col', array( $this, 'add_column_shortcode' ) );
|
||||
add_filter( 'the_content', array( $this, 'parse_content_for_nested_rows' ), 9 );
|
||||
add_filter( 'powerkit_the_column_content', array( $this, 'fix_lost_p_tags' ), 10, 2 );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the [powerkit-row]
|
||||
*
|
||||
* @param array $atts The atts.
|
||||
* @param string $content The content.
|
||||
*/
|
||||
public function add_row_shortcode( $atts, $content ) {
|
||||
ob_start();
|
||||
?>
|
||||
<div class="pk-row">
|
||||
<?php
|
||||
$row_content = apply_filters( 'powerkit_the_row_content', $content, $atts );
|
||||
|
||||
if ( apply_filters( 'powerkit_render_shortcodes_in_row', true, $content, $atts ) ) {
|
||||
echo do_shortcode( $row_content );
|
||||
} else {
|
||||
echo $row_content; // XSS.
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the [powerkit-col]
|
||||
*
|
||||
* @param array $atts The atts.
|
||||
* @param string $content The content.
|
||||
*/
|
||||
public function add_column_shortcode( $atts, $content ) {
|
||||
$size = 1;
|
||||
if ( ! empty( $atts['size'] ) ) {
|
||||
$size = (int) $atts['size'];
|
||||
}
|
||||
|
||||
ob_start();
|
||||
?>
|
||||
<div class="pk-col-md-<?php echo esc_attr( $size ); ?>">
|
||||
<?php
|
||||
$column_content = apply_filters( 'powerkit_the_column_content', $content, $atts );
|
||||
|
||||
if ( apply_filters( 'powerkit_render_shortcodes_in_column', true, $content, $atts ) ) {
|
||||
echo do_shortcode( $column_content );
|
||||
} else {
|
||||
echo $column_content; // XSS.
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
* This function strips unclosed p tags at a beggining and at the end of a row
|
||||
*
|
||||
* @param string $content The content.
|
||||
* @param array $atts The atts.
|
||||
*/
|
||||
public function fix_lost_p_tags( $content, $atts ) {
|
||||
if ( is_admin() ) {
|
||||
return $content;
|
||||
}
|
||||
|
||||
$first_4_chars = substr( $content, 0, 4 );
|
||||
|
||||
$last_3_chars = substr( $content, -3, 4 );
|
||||
|
||||
if ( '</p>' === $first_4_chars ) {
|
||||
$content = substr( $content, 5 );
|
||||
}
|
||||
|
||||
if ( '<p>' === $last_3_chars ) {
|
||||
$content = substr( $content, 0, -4 );
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to allow one level of nested rows
|
||||
*
|
||||
* @param string $content The content.
|
||||
* @param bool $rec The rec.
|
||||
*/
|
||||
public function parse_content_for_nested_rows( $content, $rec = false ) {
|
||||
$rows_matches = array();
|
||||
|
||||
preg_match_all( '#' . get_shortcode_regex( array( 'powerkit-row' ) ) . '#ims', $content, $rows_matches );
|
||||
|
||||
/**
|
||||
* Basically in the first group of matches are the plain row texts
|
||||
* If a row contains another row, we should render it before.
|
||||
*/
|
||||
if ( ! empty( $rows_matches[0] ) ) {
|
||||
|
||||
// Iterate through each row and check if anyone has a nested row.
|
||||
foreach ( $rows_matches[0] as $key => $match ) {
|
||||
|
||||
$row_pos = strpos( $rows_matches[0][ $key ], '[powerkit-row cols_nr="', 5 );
|
||||
|
||||
// If there is another row inside render it first.
|
||||
if ( false !== $row_pos ) {
|
||||
// Make a clone of the original row.
|
||||
$temp_row = $match;
|
||||
// If this row has an inner row, let's render it and replace it in the clone row.
|
||||
preg_match( '#' . get_shortcode_regex( array( 'powerkit-row' ) ) . '#', $match, $smatch );
|
||||
if ( substr_count( $smatch[0], '[powerkit-row ' ) > 1 ) {
|
||||
$inner_rows = array();
|
||||
|
||||
// Right now the row form is [powerkit-row] content [powerkit-row]content[/powerkit-row]
|
||||
// if we render the available rows we will have a nested-free row.
|
||||
$remove_starting_row = '~\[' . $smatch[1] . $smatch[2] . $smatch[3] . '\]~';
|
||||
|
||||
$temp_content = preg_replace( $remove_starting_row, '', $smatch[0], 1 );
|
||||
|
||||
preg_match_all( '#' . get_shortcode_regex( array( 'powerkit-row' ) ) . '#ms', $temp_content, $inner_rows );
|
||||
|
||||
// There may be more than one inner row, catch'em all.
|
||||
foreach ( $inner_rows[0] as $inner_row ) {
|
||||
$temp_row = str_replace( $inner_row, do_shortcode( $inner_row ), $temp_row );
|
||||
}
|
||||
}
|
||||
// Now we have a [powerkit-row] content <div class="pk-row"></div>
|
||||
// the closing [/powerkit-row] is definetly somewhere after.
|
||||
$content = str_replace( $match, $temp_row, $content );
|
||||
} else {
|
||||
if ( ! $rec ) {
|
||||
$content = $this->parse_content_for_nested_rows( $content, true );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------------
|
||||
* [ Support Gridable ]
|
||||
* -------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Row Class
|
||||
*/
|
||||
public function gridable_row_class() {
|
||||
return array( 'pk-row' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Column Class
|
||||
*
|
||||
* @param array $classes Available classes.
|
||||
* @param int $size Column size.
|
||||
* @param array $atts Attributes.
|
||||
* @param string $content Content.
|
||||
*/
|
||||
public function gridable_column_class( $classes, $size, $atts, $content ) {
|
||||
|
||||
$classes = array( 'pk-col-md-' . $size );
|
||||
|
||||
return $classes;
|
||||
}
|
||||
}
|
||||
|
||||
new Powerkit_Basic_Grid();
|
||||
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
/**
|
||||
* Shortcode Progress Bars config
|
||||
*
|
||||
* @package Powerkit
|
||||
* @subpackage Templates
|
||||
*/
|
||||
|
||||
/**
|
||||
* Progress Bars
|
||||
*/
|
||||
powerkit_basic_shortcodes_register( array(
|
||||
'name' => 'progressbars',
|
||||
'title' => esc_html__( 'Progress Bars', 'powerkit' ),
|
||||
'priority' => 60,
|
||||
'base' => 'powerkit_progressbar',
|
||||
'autoregister' => true,
|
||||
'fields' => array(
|
||||
array(
|
||||
'type' => 'section',
|
||||
'label' => esc_html__( 'Options', 'powerkit' ),
|
||||
),
|
||||
array(
|
||||
'type' => 'input',
|
||||
'name' => 'value',
|
||||
'label' => esc_html__( 'Value', 'powerkit' ),
|
||||
'default' => '25',
|
||||
'suffix' => ' %',
|
||||
'desc' => '(0-100)',
|
||||
),
|
||||
array(
|
||||
'type' => 'section',
|
||||
'label' => esc_html__( 'Style', 'powerkit' ),
|
||||
),
|
||||
array(
|
||||
'type' => 'input',
|
||||
'name' => 'height',
|
||||
'label' => esc_html__( 'Height (thickness)', 'powerkit' ),
|
||||
'default' => '20',
|
||||
'suffix' => ' px',
|
||||
),
|
||||
array(
|
||||
'type' => 'radio',
|
||||
'name' => 'color',
|
||||
'label' => esc_html__( 'Color', 'powerkit' ),
|
||||
'style' => 'vertical',
|
||||
'default' => 'primary',
|
||||
'options' => array(
|
||||
'primary' => esc_html__( 'Primary', 'powerkit' ),
|
||||
'secondary' => esc_html__( 'Secondary', 'powerkit' ),
|
||||
'success' => esc_html__( 'Success', 'powerkit' ),
|
||||
'info' => esc_html__( 'Info', 'powerkit' ),
|
||||
'warning' => esc_html__( 'Warning', 'powerkit' ),
|
||||
'danger' => esc_html__( 'Danger', 'powerkit' ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'checkbox',
|
||||
'name' => 'display_value',
|
||||
'label' => esc_html__( 'Display value', 'powerkit' ),
|
||||
'default' => false,
|
||||
),
|
||||
array(
|
||||
'type' => 'checkbox',
|
||||
'name' => 'striped',
|
||||
'label' => esc_html__( 'Striped', 'powerkit' ),
|
||||
'default' => false,
|
||||
),
|
||||
array(
|
||||
'type' => 'checkbox',
|
||||
'name' => 'animated',
|
||||
'label' => esc_html__( 'Animated', 'powerkit' ),
|
||||
'default' => false,
|
||||
),
|
||||
),
|
||||
) );
|
||||
|
||||
|
||||
/**
|
||||
* Progress Bar Shortcode
|
||||
*
|
||||
* @param array $output Shortcode HTML.
|
||||
* @param array $atts User defined attributes in shortcode tag.
|
||||
* @param string $content Shorcode tag content.
|
||||
* @return string Shortcode result HTML.
|
||||
*/
|
||||
function powerkit_basic_shortcodes_progressbar( $output, $atts, $content ) {
|
||||
|
||||
// Value.
|
||||
$atts['value'] = $atts['value'] > 100 ? 100 : $atts['value'];
|
||||
|
||||
// Display value.
|
||||
$display_value = ( 'true' === $atts['display_value'] ) ? $atts['value'] . '%' : '';
|
||||
|
||||
// Striped and animated.
|
||||
$class = 'pk-progress-bar';
|
||||
$class .= ( 'true' === $atts['striped'] ) ? ' pk-progress-bar-striped' : '';
|
||||
$class .= ( 'true' === $atts['animated'] ) ? ' pk-progress-bar-animated' : '';
|
||||
|
||||
// Color.
|
||||
$class .= sprintf( ' pk-bg-%s', $atts['color'] );
|
||||
|
||||
$output = sprintf(
|
||||
'<div class="pk-progress" style="height: %2$spx;">
|
||||
<div class="%s" role="progressbar" style="width: %3$s%%;" aria-valuenow="%3$s" aria-valuemin="0" aria-valuemax="100">%4$s</div>
|
||||
</div>',
|
||||
$class,
|
||||
$atts['height'],
|
||||
$atts['value'],
|
||||
$display_value
|
||||
);
|
||||
|
||||
return $output;
|
||||
}
|
||||
add_filter( 'powerkit_progressbar_shortcode', 'powerkit_basic_shortcodes_progressbar', 10, 3 );
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
/**
|
||||
* Shortcode Separators config
|
||||
*
|
||||
* @package Powerkit
|
||||
* @subpackage Templates
|
||||
*/
|
||||
|
||||
/**
|
||||
* Separators
|
||||
*/
|
||||
powerkit_basic_shortcodes_register( array(
|
||||
'name' => 'separators',
|
||||
'title' => esc_html__( 'Separators', 'powerkit' ),
|
||||
'priority' => 10,
|
||||
'base' => 'powerkit_separator',
|
||||
'autoregister' => true,
|
||||
'fields' => array(
|
||||
array(
|
||||
'type' => 'section',
|
||||
'label' => esc_html__( 'Options', 'powerkit' ),
|
||||
),
|
||||
array(
|
||||
'type' => 'radio',
|
||||
'name' => 'style',
|
||||
'label' => esc_html__( 'Style', 'powerkit' ),
|
||||
'style' => 'vertical',
|
||||
'default' => 'solid',
|
||||
'options' => array(
|
||||
'solid' => esc_html__( 'Solid', 'powerkit' ),
|
||||
'double' => esc_html__( 'Double', 'powerkit' ),
|
||||
'dotted' => esc_html__( 'Dotted', 'powerkit' ),
|
||||
'dashed' => esc_html__( 'Dashed', 'powerkit' ),
|
||||
'blank' => esc_html__( 'Blank (empty space)', 'powerkit' ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'input',
|
||||
'name' => 'height',
|
||||
'label' => esc_html__( 'Height', 'powerkit' ),
|
||||
'default' => '',
|
||||
'suffix' => ' px',
|
||||
),
|
||||
),
|
||||
) );
|
||||
|
||||
|
||||
/**
|
||||
* Separator Shortcode
|
||||
*
|
||||
* @param array $output Shortcode HTML.
|
||||
* @param array $atts User defined attributes in shortcode tag.
|
||||
* @param string $content Shorcode tag content.
|
||||
* @return string Shortcode result HTML.
|
||||
*/
|
||||
function powerkit_basic_shortcodes_separator( $output, $atts, $content ) {
|
||||
|
||||
if ( 'blank' === $atts['style'] ) {
|
||||
$inl_css = sprintf( 'style="height: %dpx;"', absint( $atts['height'] ) );
|
||||
} else {
|
||||
$inl_css = sprintf( 'style="border-bottom-width: %dpx; border-bottom-style: %s;"', absint( $atts['height'] ), $atts['style'] );
|
||||
}
|
||||
|
||||
$output = sprintf(
|
||||
'<div class="pk-separator" %s>%s</div>',
|
||||
$inl_css,
|
||||
$content
|
||||
);
|
||||
|
||||
return $output;
|
||||
}
|
||||
add_filter( 'powerkit_separator_shortcode', 'powerkit_basic_shortcodes_separator', 10, 3 );
|
||||
@@ -0,0 +1,160 @@
|
||||
<?php
|
||||
/**
|
||||
* Shortcode Tabs config
|
||||
*
|
||||
* @package Powerkit
|
||||
* @subpackage Templates
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tabs
|
||||
*/
|
||||
powerkit_basic_shortcodes_register( array(
|
||||
'name' => 'tabs',
|
||||
'title' => esc_html__( 'Tabs', 'powerkit' ),
|
||||
'priority' => 40,
|
||||
'base' => 'powerkit_tabs',
|
||||
'autoregister' => true,
|
||||
'fields' => array(
|
||||
array(
|
||||
'type' => 'section',
|
||||
'label' => esc_html__( 'Options', 'powerkit' ),
|
||||
),
|
||||
array(
|
||||
'type' => 'radio',
|
||||
'name' => 'type',
|
||||
'label' => esc_html__( 'Type', 'powerkit' ),
|
||||
'style' => 'horizontal',
|
||||
'default' => 'tabs',
|
||||
'options' => array(
|
||||
'tabs' => esc_html__( 'Tabs', 'powerkit' ),
|
||||
'pills' => esc_html__( 'Pills', 'powerkit' ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'radio',
|
||||
'name' => 'nav',
|
||||
'label' => esc_html__( 'Navigation type', 'powerkit' ),
|
||||
'style' => 'horizontal',
|
||||
'default' => 'horizontal',
|
||||
'options' => array(
|
||||
'horizontal' => esc_html__( 'Horizontal', 'powerkit' ),
|
||||
'vertical' => esc_html__( 'Vertical', 'powerkit' ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'section',
|
||||
'label' => esc_html__( 'Content', 'powerkit' ),
|
||||
),
|
||||
array(
|
||||
'type' => 'repeater',
|
||||
'base' => 'powerkit_tab',
|
||||
'autoregister' => true,
|
||||
'label' => esc_html__( 'Tabs', 'powerkit' ),
|
||||
'fields' => array(
|
||||
array(
|
||||
'type' => 'input',
|
||||
'name' => 'title',
|
||||
'label' => esc_html__( 'Title', 'powerkit' ),
|
||||
'default' => '',
|
||||
'attrs' => array(
|
||||
'class' => 'widefat',
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'content',
|
||||
'name' => 'content',
|
||||
'label' => esc_html__( 'Content', 'powerkit' ),
|
||||
'default' => '',
|
||||
'attrs' => array(
|
||||
'class' => 'widefat',
|
||||
'rows' => 6,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
) );
|
||||
|
||||
|
||||
/**
|
||||
* Tabs Wrap Shortcode
|
||||
*
|
||||
* @param array $output Shortcode HTML.
|
||||
* @param array $atts User defined attributes in shortcode tag.
|
||||
* @param string $content Shorcode tag content.
|
||||
* @return string Shortcode result HTML.
|
||||
*/
|
||||
function powerkit_basic_shortcodes_tabs( $output, $atts, $content ) {
|
||||
global $powerkit_basic_shortcodes_tabs;
|
||||
if ( ! is_array( $powerkit_basic_shortcodes_tabs ) ) {
|
||||
$powerkit_basic_shortcodes_tabs = array();
|
||||
}
|
||||
|
||||
// Output.
|
||||
$nav_items = '';
|
||||
$pane_items = '';
|
||||
$num = 1;
|
||||
|
||||
foreach ( $powerkit_basic_shortcodes_tabs as $tab ) {
|
||||
$data_toggle = ( 'tabs' === $atts['type'] ) ? 'tab' : 'pill';
|
||||
$item_id = uniqid();
|
||||
$content_id = $data_toggle . '-' . $item_id;
|
||||
|
||||
$nav_items .= sprintf(
|
||||
'<li class="pk-nav-item"><a class="pk-nav-link%s pk-font-heading" data-toggle="%s" href="#%s">%s</a></li>',
|
||||
( 1 === $num ) ? ' pk-active' : '',
|
||||
$data_toggle,
|
||||
$content_id,
|
||||
$tab['title']
|
||||
);
|
||||
|
||||
$pane_items .= sprintf(
|
||||
'<div id="%s" class="pk-tab-pane pk-fade%s" role="tabpanel">%s</div>',
|
||||
$content_id,
|
||||
( 1 === $num ) ? ' pk-show pk-active' : '',
|
||||
$tab['content']
|
||||
);
|
||||
|
||||
$num++;
|
||||
}
|
||||
|
||||
// Reset Tabs.
|
||||
$powerkit_basic_shortcodes_tabs = array();
|
||||
|
||||
// Tabs Output.
|
||||
$output = '';
|
||||
$output .= '<div class="pk-tabs pk-tabs-' . $atts['nav'] . '">';
|
||||
$output .= '<div class="pk-tabs-container">';
|
||||
$output .= '<div class="pk-tabs-navigation"><ul class="pk-nav pk-nav-' . $atts['type'] . '" role="tablist">' . $nav_items . '</ul></div>';
|
||||
$output .= '<div class="pk-tabs-content"><div class="pk-tab-content">' . $pane_items . '</div></div>';
|
||||
$output .= '</div>';
|
||||
$output .= '</div>';
|
||||
|
||||
return $output;
|
||||
}
|
||||
add_filter( 'powerkit_tabs_shortcode', 'powerkit_basic_shortcodes_tabs', 10, 3 );
|
||||
|
||||
|
||||
/**
|
||||
* Tab Item Shortcode
|
||||
*
|
||||
* @param array $output Shortcode HTML.
|
||||
* @param array $atts User defined attributes in shortcode tag.
|
||||
* @param string $content Shorcode tag content.
|
||||
* @return string Shortcode result HTML.
|
||||
*/
|
||||
function powerkit_basic_shortcodes_tab( $output, $atts, $content ) {
|
||||
global $powerkit_basic_shortcodes_tabs;
|
||||
if ( ! is_array( $powerkit_basic_shortcodes_tabs ) ) {
|
||||
$powerkit_basic_shortcodes_tabs = array();
|
||||
}
|
||||
|
||||
$powerkit_basic_shortcodes_tabs[] = array(
|
||||
'title' => $atts['title'],
|
||||
'content' => $content,
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
add_filter( 'powerkit_tab_shortcode', 'powerkit_basic_shortcodes_tab', 10, 3 );
|
||||
@@ -0,0 +1,712 @@
|
||||
<?php
|
||||
/**
|
||||
* Custom Fonts
|
||||
*
|
||||
* @package Powerkit
|
||||
* @subpackage Modules
|
||||
*/
|
||||
|
||||
if ( class_exists( 'Powerkit_Module' ) ) {
|
||||
/**
|
||||
* Init module
|
||||
*/
|
||||
class Powerkit_Custom_Fonts extends Powerkit_Module {
|
||||
|
||||
/**
|
||||
* Webfonts method
|
||||
*
|
||||
* @var string $load_method Webfonts method.
|
||||
*/
|
||||
public $load_method = 'async';
|
||||
|
||||
/**
|
||||
* Font base.
|
||||
*
|
||||
* This is used in case of Elementor's Font param
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private static $font_base = 'pk-custom-fonts';
|
||||
|
||||
/**
|
||||
* Register module
|
||||
*/
|
||||
public function register() {
|
||||
$this->name = esc_html__( 'Custom Fonts', 'powerkit' );
|
||||
$this->desc = esc_html__( 'Adds the ability to download custom fonts.', 'powerkit' );
|
||||
$this->slug = 'custom_fonts';
|
||||
$this->type = 'default';
|
||||
$this->category = 'basic';
|
||||
$this->priority = 1040;
|
||||
$this->public = true;
|
||||
$this->enabled = false;
|
||||
$this->badge = esc_html__( 'Advanced', 'powerkit' );
|
||||
$this->load_extensions = array(
|
||||
'fonts',
|
||||
);
|
||||
$this->links = array(
|
||||
array(
|
||||
'name' => esc_html__( 'Go to settings', 'powerkit' ),
|
||||
'url' => powerkit_get_page_url( 'fonts&tab=' . $this->slug, 'themes' ),
|
||||
),
|
||||
array(
|
||||
'name' => esc_html__( 'View documentation', 'powerkit' ),
|
||||
'url' => powerkit_get_setting( 'documentation' ) . '/content-presentation/custom-fonts/',
|
||||
'target' => '_blank',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize module
|
||||
*/
|
||||
public function initialize() {
|
||||
add_filter( 'powerkit_fonts_list', array( $this, 'custom_fonts' ), 10 );
|
||||
add_filter( 'csco_customizer_fonts_choices', array( $this, 'csco_custom_fonts' ), 20 );
|
||||
add_filter( 'upload_mimes', array( $this, 'allow_mimes' ) );
|
||||
add_filter( 'powerkit_fonts_register_settings', array( $this, 'register_settings' ), 10 );
|
||||
add_action( 'customize_controls_print_styles', array( $this, 'frontend_enqueue' ), 100 );
|
||||
add_action( 'wp_head', array( $this, 'frontend_enqueue' ), 100 );
|
||||
add_action( 'admin_head', array( $this, 'editor_enqueue' ), 100 );
|
||||
add_filter( 'init', array( $this, 'set_load_method' ) );
|
||||
add_filter( 'elementor/fonts/groups', array( $this, 'elementor_group' ) );
|
||||
add_filter( 'elementor/fonts/additional_fonts', array( $this, 'add_elementor_fonts' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Webfonts method
|
||||
*/
|
||||
public function set_load_method() {
|
||||
$this->load_method = apply_filters( 'powerkit_webfonts_load_method', 'async' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add custom fonts
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @param array $fonts List fonts.
|
||||
* @return array
|
||||
*/
|
||||
public function custom_fonts( $fonts ) {
|
||||
|
||||
if ( is_customize_preview() ) {
|
||||
|
||||
$custom_fonts = get_option( 'powerkit_custom_fonts_list' );
|
||||
|
||||
if ( is_array( $custom_fonts ) && $custom_fonts ) {
|
||||
|
||||
$exclude = array();
|
||||
|
||||
$fonts['families']['custom_fonts'] = array(
|
||||
'text' => esc_html__( 'Custom Fonts', 'powerkit' ),
|
||||
'children' => array(),
|
||||
);
|
||||
|
||||
foreach ( $custom_fonts as $key => $item ) {
|
||||
if ( 'clone' === $key ) {
|
||||
continue;
|
||||
}
|
||||
$id = sanitize_title( $item['name'] );
|
||||
|
||||
if ( $id ) {
|
||||
if ( ! in_array( $id, $exclude, true ) ) {
|
||||
$fonts['families']['custom_fonts']['children'][] = array(
|
||||
'id' => $id,
|
||||
'text' => $item['name'],
|
||||
);
|
||||
|
||||
$exclude[] = $id;
|
||||
}
|
||||
|
||||
$variant = str_replace( '400', 'regular', $item['weight'] );
|
||||
|
||||
if ( 'italic' === $item['style'] ) {
|
||||
$variant .= 'italic';
|
||||
}
|
||||
|
||||
if ( isset( $fonts['variants'][ $id ] ) && $fonts['variants'][ $id ] ) {
|
||||
if ( ! in_array( $variant, $fonts['variants'][ $id ], true ) ) {
|
||||
$fonts['variants'][ $id ][] = $variant;
|
||||
}
|
||||
} else {
|
||||
$fonts['variants'][ $id ][] = $variant;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $fonts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add custom fonts to csco theme
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @param array $fonts List fonts.
|
||||
* @return array
|
||||
*/
|
||||
public function csco_custom_fonts( $fonts ) {
|
||||
|
||||
if ( is_customize_preview() ) {
|
||||
|
||||
$custom_fonts = get_option( 'powerkit_custom_fonts_list' );
|
||||
|
||||
if ( is_array( $custom_fonts ) && $custom_fonts ) {
|
||||
|
||||
$exclude = array();
|
||||
|
||||
$fonts['fonts']['families']['custom_fonts'] = array(
|
||||
'text' => esc_html__( 'Custom Fonts', 'powerkit' ),
|
||||
'children' => array(),
|
||||
);
|
||||
|
||||
foreach ( $custom_fonts as $key => $item ) {
|
||||
if ( 'clone' === $key ) {
|
||||
continue;
|
||||
}
|
||||
$id = sanitize_title( $item['name'] );
|
||||
|
||||
if ( $id ) {
|
||||
if ( ! in_array( $id, $exclude, true ) ) {
|
||||
$fonts['fonts']['families']['custom_fonts']['children'][] = array(
|
||||
'id' => $id,
|
||||
'text' => $item['name'],
|
||||
);
|
||||
|
||||
$exclude[] = $id;
|
||||
}
|
||||
|
||||
$variant = str_replace( '400', 'regular', $item['weight'] );
|
||||
|
||||
if ( 'italic' === $item['style'] ) {
|
||||
$variant .= 'italic';
|
||||
}
|
||||
|
||||
if ( isset( $fonts['fonts']['variants'][ $id ] ) && $fonts['fonts']['variants'][ $id ] ) {
|
||||
if ( ! in_array( $variant, $fonts['fonts']['variants'][ $id ], true ) ) {
|
||||
$fonts['fonts']['variants'][ $id ][] = $variant;
|
||||
}
|
||||
} else {
|
||||
$fonts['fonts']['variants'][ $id ][] = $variant;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $fonts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Custom Font group to elementor font list.
|
||||
*
|
||||
* Group name "Custom" is added as the first element in the array.
|
||||
*
|
||||
* @param Array $font_groups default font groups in elementor.
|
||||
* @return Array Modified font groups with newly added font group.
|
||||
*/
|
||||
public function elementor_group( $font_groups ) {
|
||||
$new_group[ self::$font_base ] = esc_html__( 'Custom Fonts', 'powerkit' );
|
||||
|
||||
$font_groups = $new_group + $font_groups;
|
||||
|
||||
return $font_groups;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Custom Fonts to the Elementor Page builder's font param.
|
||||
*
|
||||
* @param Array $fonts Custom Font's array.
|
||||
*/
|
||||
public function add_elementor_fonts( $fonts ) {
|
||||
|
||||
$fonts_list = get_option( 'powerkit_custom_fonts_list' );
|
||||
|
||||
if ( is_array( $fonts_list ) && $fonts_list ) {
|
||||
foreach ( $fonts_list as $item ) {
|
||||
$id = sanitize_title( $item['name'] );
|
||||
|
||||
if ( $id ) {
|
||||
$fonts[ $id ] = self::$font_base;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $fonts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register new mime types and file extensions.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @param array $mimes Current array of mime types..
|
||||
*/
|
||||
public function allow_mimes( $mimes ) {
|
||||
$mimes['woff'] = 'application/x-font-woff';
|
||||
$mimes['woff2'] = 'application/x-font-woff2';
|
||||
|
||||
return $mimes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register settings
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @param array $settings List settings.
|
||||
* @return array
|
||||
*/
|
||||
public function register_settings( $settings ) {
|
||||
|
||||
$settings[] = array(
|
||||
'id' => $this->slug,
|
||||
'name' => esc_html__( 'Custom Fonts', 'powerkit' ),
|
||||
'function' => array( $this, 'build_setting_page' ),
|
||||
);
|
||||
|
||||
return $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build admin page
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function build_setting_page() {
|
||||
|
||||
powerkit_uuid_hash();
|
||||
|
||||
$this->save_options_page();
|
||||
|
||||
$powerkit_custom_fonts_id = get_option( 'powerkit_custom_fonts_counter', 1 );
|
||||
|
||||
$params = array(
|
||||
'name' => '',
|
||||
'weight' => '400',
|
||||
'style' => 'normal',
|
||||
'file_woff' => '',
|
||||
'file_woff2' => '',
|
||||
);
|
||||
|
||||
$action = 'new';
|
||||
|
||||
// Check wpnonce.
|
||||
if ( ! isset( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( $_REQUEST['_wpnonce'] ) ) { // Input var ok; sanitization ok.
|
||||
return;
|
||||
}
|
||||
|
||||
// Check custom action.
|
||||
if ( isset( $_REQUEST['action'] ) ) { // Input var ok; sanitization ok.
|
||||
$action = sanitize_title( $_REQUEST['action'] ); // Input var ok; sanitization ok.
|
||||
|
||||
if ( isset( $_REQUEST['powerkit_custom_fonts_id'] ) && 'edit' === $action ) { // Input var ok.
|
||||
$powerkit_custom_fonts_id = sanitize_key( $_REQUEST['powerkit_custom_fonts_id'] ); // Input var ok.
|
||||
}
|
||||
}
|
||||
|
||||
// Edit font.
|
||||
if ( 'edit' === $action ) {
|
||||
$font_list = get_option( 'powerkit_custom_fonts_list' );
|
||||
|
||||
if ( isset( $font_list[ $powerkit_custom_fonts_id ] ) ) {
|
||||
$params = array_merge( (array) $params, (array) $font_list[ $powerkit_custom_fonts_id ] );
|
||||
}
|
||||
}
|
||||
|
||||
// Delete font.
|
||||
if ( 'delete' === $action ) {
|
||||
$this->delete_font();
|
||||
}
|
||||
|
||||
// Settings page link.
|
||||
$powerkit_custom_fonts_link = powerkit_get_page_url( 'fonts&tab=' . $this->slug, 'themes' );
|
||||
?>
|
||||
<form method="post" action="<?php echo esc_url( $powerkit_custom_fonts_link ); ?>">
|
||||
<div class="col-container">
|
||||
<div id="col-left">
|
||||
<div class="col-wrap">
|
||||
<div class="form-wrap">
|
||||
<div class="form-field">
|
||||
<h2><?php esc_html_e( 'Instructions', 'powerkit' ); ?></h2>
|
||||
<ol>
|
||||
<li>
|
||||
<?php
|
||||
$link_webfont = sprintf( '<a href="%1$s" target="_blank">%2$s</a>', esc_url( 'https://www.fontsquirrel.com/tools/webfont-generator' ), esc_html__( 'Font Squirrel', 'powerkit' ) );
|
||||
|
||||
// translators: args - format woff, format woff, format woff2, link webfont-generator.
|
||||
echo sprintf( esc_html__( 'Prepare your webfont files in %1$s and %2$s formats. You may convert your %3$s fonts at %4$s.', 'powerkit' ), '<code>woff</code>', '<code>woff2</code>', '<code>ttf</code>', wp_kses( $link_webfont, 'post' ) );
|
||||
?>
|
||||
</li>
|
||||
<li><?php esc_html_e( 'Upload your font files.', 'powerkit' ); ?></li>
|
||||
<li><?php esc_html_e( 'Navigate to Appearance → Customise → Typography and select your font in typography controls under Custom Fonts.', 'powerkit' ); ?></li>
|
||||
</ol>
|
||||
</div>
|
||||
|
||||
<?php if ( 'edit' === $action ) : ?>
|
||||
<h3>
|
||||
<?php esc_html_e( 'Edit Font', 'powerkit' ); ?>
|
||||
|
||||
<small><a href="<?php echo esc_url( $powerkit_custom_fonts_link ); ?>"><?php esc_html_e( ' cancel ', 'powerkit' ); ?></a></small>
|
||||
</h3>
|
||||
<?php else : ?>
|
||||
<h3><?php esc_html_e( 'Add New Font', 'powerkit' ); ?></h3>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- Name -->
|
||||
<div class="form-field form-required">
|
||||
<label for="powerkit_custom_fonts_name"><?php esc_html_e( 'Name', 'powerkit' ); ?></label>
|
||||
|
||||
<input id="powerkit_custom_fonts_name" name="powerkit_custom_fonts_name" type="text" aria-required="true" value="<?php echo esc_attr( stripslashes( $params['name'] ) ); ?>" />
|
||||
</div>
|
||||
|
||||
<!-- Font File [WOFF] -->
|
||||
<div class="form-field">
|
||||
<label><?php esc_html_e( 'Font .woff', 'powerkit' ); ?></label>
|
||||
|
||||
<div class="upload-font-container" data-type="application/x-font-woff">
|
||||
|
||||
<?php $file_woff = $params['file_woff'] ? basename( get_attached_file( $params['file_woff'] ) ) : null; ?>
|
||||
|
||||
<p><input class="filename" type="text" placeholder="<?php esc_html_e( 'Choose file..', 'powerkit' ); ?>" readonly value="<?php echo esc_html( $file_woff ); ?>"></p>
|
||||
|
||||
<!-- Add & remove file links -->
|
||||
<div class="submitbox">
|
||||
<a class="upload-font-link button <?php echo esc_attr( $params['file_woff'] ? 'hidden' : '' ); ?>" href="#"><?php esc_html_e( 'Add File', 'powerkit' ); ?></a>
|
||||
<a class="delete-font-link submitdelete <?php echo esc_attr( ! $params['file_woff'] ? 'hidden' : '' ); ?>" href="#"><?php esc_html_e( 'Remove', 'powerkit' ); ?></a>
|
||||
</div>
|
||||
|
||||
<input class="uploaded-font-id" id="powerkit_custom_fonts_file_woff" name="powerkit_custom_fonts_file_woff" type="hidden" value="<?php echo esc_attr( stripslashes( $params['file_woff'] ) ); ?>" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Font File [WOFF2] -->
|
||||
<div class="form-field">
|
||||
<label><?php esc_html_e( 'Font .woff2', 'powerkit' ); ?></label>
|
||||
|
||||
<div class="upload-font-container" data-type="application/x-font-woff2">
|
||||
|
||||
<?php $file_woff2 = $params['file_woff2'] ? basename( get_attached_file( $params['file_woff2'] ) ) : null; ?>
|
||||
|
||||
<p><input class="filename" type="text" placeholder="<?php esc_html_e( 'Choose file..', 'powerkit' ); ?>" readonly value="<?php echo esc_html( $file_woff2 ); ?>"></p>
|
||||
|
||||
<!-- Add & remove file links -->
|
||||
<div class="submitbox">
|
||||
<a class="upload-font-link button <?php echo esc_attr( $params['file_woff2'] ? 'hidden' : '' ); ?>" href="#"><?php esc_html_e( 'Add File', 'powerkit' ); ?></a>
|
||||
<a class="delete-font-link submitdelete <?php echo esc_attr( ! $params['file_woff2'] ? 'hidden' : '' ); ?>" href="#"><?php esc_html_e( 'Remove', 'powerkit' ); ?></a>
|
||||
</div>
|
||||
|
||||
<input class="uploaded-font-id" id="powerkit_custom_fonts_file_woff2" name="powerkit_custom_fonts_file_woff2" type="hidden" value="<?php echo esc_attr( stripslashes( $params['file_woff2'] ) ); ?>" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Font Weight -->
|
||||
<div class="form-field">
|
||||
<label for="powerkit_custom_fonts_weight"><?php esc_html_e( 'Weight', 'powerkit' ); ?></label>
|
||||
|
||||
<select class="regular-text" id="powerkit_custom_fonts_weight" name="powerkit_custom_fonts_weight">
|
||||
<option value="100" <?php selected( '100', $params['weight'] ); ?>><?php esc_html_e( '100', 'powerkit' ); ?></option>
|
||||
<option value="200" <?php selected( '200', $params['weight'] ); ?>><?php esc_html_e( '200', 'powerkit' ); ?></option>
|
||||
<option value="300" <?php selected( '300', $params['weight'] ); ?>><?php esc_html_e( '300', 'powerkit' ); ?></option>
|
||||
<option value="400" <?php selected( '400', $params['weight'] ); ?>><?php esc_html_e( '400 (regular)', 'powerkit' ); ?></option>
|
||||
<option value="500" <?php selected( '500', $params['weight'] ); ?>><?php esc_html_e( '500', 'powerkit' ); ?></option>
|
||||
<option value="600" <?php selected( '600', $params['weight'] ); ?>><?php esc_html_e( '600', 'powerkit' ); ?></option>
|
||||
<option value="700" <?php selected( '700', $params['weight'] ); ?>><?php esc_html_e( '700', 'powerkit' ); ?></option>
|
||||
<option value="800" <?php selected( '800', $params['weight'] ); ?>><?php esc_html_e( '800', 'powerkit' ); ?></option>
|
||||
<option value="900" <?php selected( '900', $params['weight'] ); ?>><?php esc_html_e( '900', 'powerkit' ); ?></option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- Font Style -->
|
||||
<div class="form-field">
|
||||
<label for="powerkit_custom_fonts_style"><?php esc_html_e( 'Style', 'powerkit' ); ?></label>
|
||||
|
||||
<select class="regular-text" id="powerkit_custom_fonts_style" name="powerkit_custom_fonts_style">
|
||||
<option value="normal" <?php selected( 'normal', $params['style'] ); ?>><?php esc_html_e( 'normal', 'powerkit' ); ?></option>
|
||||
<option value="italic" <?php selected( 'italic', $params['style'] ); ?>><?php esc_html_e( 'italic', 'powerkit' ); ?></option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<input name="powerkit_custom_fonts_id" type="hidden" value="<?php echo esc_html( $powerkit_custom_fonts_id ); ?>" />
|
||||
|
||||
<?php wp_nonce_field(); ?>
|
||||
|
||||
<?php if ( 'edit' === $action ) : ?>
|
||||
<p class="submit"><input class="button button-primary" name="edit_settings" type="submit" value="<?php esc_html_e( 'Save Change', 'powerkit' ); ?>" /></p>
|
||||
<?php else : ?>
|
||||
<p class="submit"><input class="button button-primary" name="save_settings" type="submit" value="<?php esc_html_e( 'Add Font', 'powerkit' ); ?>" /></p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="col-right">
|
||||
<div class="col-wrap wrap">
|
||||
<table class="wrap wp-list-table widefat fixed striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<td scope="col" class="manage-column"><?php esc_html_e( 'Name', 'powerkit' ); ?></td>
|
||||
<td scope="col" class="manage-column"><?php esc_html_e( 'Font Family', 'powerkit' ); ?></td>
|
||||
<td scope="col" class="manage-column"><?php esc_html_e( 'Font Weight', 'powerkit' ); ?></td>
|
||||
<td scope="col" class="manage-column"><?php esc_html_e( 'Font Style', 'powerkit' ); ?></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="the-list">
|
||||
<?php
|
||||
$families = get_option( 'powerkit_custom_fonts_list', array() );
|
||||
|
||||
// Sort families.
|
||||
if ( is_array( $families ) && $families ) {
|
||||
$families_keys = array_keys( $families );
|
||||
|
||||
foreach ( $families as $key => $row ) {
|
||||
$families_value[ $key ] = $row['name'];
|
||||
$families_name[ $key ] = $row['weight'];
|
||||
$families_order[ $key ] = $row['style'];
|
||||
}
|
||||
array_multisort( $families_value, SORT_DESC, $families_order, SORT_DESC, $families_name, SORT_ASC, $families, $families_keys );
|
||||
|
||||
$families = array_combine( $families_keys, $families );
|
||||
}
|
||||
|
||||
// Loop families.
|
||||
if ( $families ) {
|
||||
foreach ( $families as $key => $family ) {
|
||||
|
||||
$edit_link = add_query_arg(
|
||||
array(
|
||||
'_wpnonce' => wp_create_nonce(),
|
||||
'powerkit_custom_fonts_id' => $key,
|
||||
'action' => 'edit',
|
||||
), $powerkit_custom_fonts_link
|
||||
);
|
||||
|
||||
$delete_link = add_query_arg(
|
||||
array(
|
||||
'_wpnonce' => wp_create_nonce(),
|
||||
'powerkit_custom_fonts_id' => $key,
|
||||
'action' => 'delete',
|
||||
), $powerkit_custom_fonts_link
|
||||
);
|
||||
?>
|
||||
<tr>
|
||||
<td scope="col" class="manage-column">
|
||||
<a class="row-title" href="<?php echo esc_url( $edit_link ); ?>"><?php echo esc_html( $family['name'] ); ?></a>
|
||||
|
||||
<div class="row-actions">
|
||||
<span class="edit">
|
||||
<a href="<?php echo esc_url( $edit_link ); ?>" role="button"><?php esc_html_e( 'Edit', 'powerkit' ); ?></a> |
|
||||
</span>
|
||||
<span class="delete">
|
||||
<a href="<?php echo esc_url( $delete_link ); ?>" class="powerkit-fonts-delete" role="button"><?php esc_html_e( 'Delete', 'powerkit' ); ?></a> |
|
||||
</span>
|
||||
<span class="view">
|
||||
<a href="#" class="powerkit-fonts-view-code" role="button"><?php esc_html_e( 'View Code', 'powerkit' ); ?></a>
|
||||
</span>
|
||||
</div>
|
||||
</td>
|
||||
<td scope="col" class="manage-column"><?php echo esc_html( $family['slug'] ); ?></td>
|
||||
<td scope="col" class="manage-column"><?php echo esc_html( $family['weight'] ); ?></td>
|
||||
<td scope="col" class="manage-column"><?php echo esc_html( $family['style'] ); ?></td>
|
||||
</tr>
|
||||
<tr class="template-code hidden">
|
||||
<td scope="col" class="manage-column" colspan="4">
|
||||
<?php
|
||||
// Example code.
|
||||
$code = sprintf(
|
||||
'h1 {
|
||||
font-family: "%s";
|
||||
font-weight: %s;
|
||||
font-style: %s;
|
||||
}',
|
||||
$family['slug'],
|
||||
$family['weight'],
|
||||
$family['style']
|
||||
);
|
||||
|
||||
$code = str_replace( "\t\t", '', $code );
|
||||
?>
|
||||
<div id="template" class="template-box hidden">
|
||||
<textarea readonly="readonly"><?php echo wp_kses( $code, 'post' ); ?></textarea>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="hidden"></tr>
|
||||
<?php
|
||||
}
|
||||
} else {
|
||||
?>
|
||||
<tr>
|
||||
<td scope="col" colspan="4"><?php esc_html_e( 'No fonts found. Add new fonts with the form to the left.', 'powerkit' ); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete font
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected function delete_font() {
|
||||
if ( ! isset( $_GET['_wpnonce'] ) || ! wp_verify_nonce( $_GET['_wpnonce'] ) ) { // Input var ok; sanitization ok.
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! isset( $_GET['powerkit_custom_fonts_id'] ) ) { // Input var ok.
|
||||
return;
|
||||
}
|
||||
|
||||
// ID Font.
|
||||
$id = sanitize_key( $_GET['powerkit_custom_fonts_id'] ); // Input var ok.
|
||||
|
||||
// Custom List.
|
||||
$font_list = (array) get_option( 'powerkit_custom_fonts_list', array() );
|
||||
|
||||
// If exist font.
|
||||
if ( isset( $font_list[ $id ] ) ) {
|
||||
|
||||
// Attachments delete.
|
||||
if ( isset( $font_list[ $id ]['file_woff'] ) ) {
|
||||
wp_delete_attachment( $font_list[ $id ]['file_woff'], true );
|
||||
}
|
||||
if ( isset( $font_list[ $id ]['file_woff2'] ) ) {
|
||||
wp_delete_attachment( $font_list[ $id ]['file_woff2'], true );
|
||||
}
|
||||
|
||||
// Delete font.
|
||||
unset( $font_list[ $id ] );
|
||||
|
||||
// Save list.
|
||||
update_option( 'powerkit_custom_fonts_list', $font_list );
|
||||
|
||||
// Output message.
|
||||
printf( '<div id="message" class="updated fade"><p><strong>%s</strong></p></div>', esc_html__( 'Font successfully deleted.', 'powerkit' ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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['powerkit_custom_fonts_id'] ) ) { // Input var ok.
|
||||
return;
|
||||
}
|
||||
|
||||
// Update id counter.
|
||||
if ( isset( $_POST['save_settings'] ) ) { // Input var ok.
|
||||
update_option( 'powerkit_custom_fonts_counter', intval( get_option( 'powerkit_custom_fonts_counter', 1 ) ) + 1 );
|
||||
}
|
||||
|
||||
// ID Font.
|
||||
$id = sanitize_key( $_POST['powerkit_custom_fonts_id'] ); // Input var ok.
|
||||
|
||||
// Custom List.
|
||||
$font_list = (array) get_option( 'powerkit_custom_fonts_list', array() );
|
||||
|
||||
// Reset current settings.
|
||||
$font_list[ $id ] = array();
|
||||
|
||||
// Set new settings.
|
||||
if ( isset( $_POST['powerkit_custom_fonts_name'] ) ) { // Input var ok.
|
||||
$font_list[ $id ]['slug'] = sanitize_title( $_POST['powerkit_custom_fonts_name'] ); // Input var ok; sanitization ok.
|
||||
}
|
||||
if ( isset( $_POST['powerkit_custom_fonts_name'] ) ) { // Input var ok.
|
||||
$font_list[ $id ]['name'] = sanitize_text_field( $_POST['powerkit_custom_fonts_name'] ); // Input var ok; sanitization ok.
|
||||
}
|
||||
if ( isset( $_POST['powerkit_custom_fonts_file_woff'] ) ) { // Input var ok.
|
||||
$font_list[ $id ]['file_woff'] = sanitize_text_field( $_POST['powerkit_custom_fonts_file_woff'] ); // Input var ok; sanitization ok.
|
||||
}
|
||||
if ( isset( $_POST['powerkit_custom_fonts_file_woff2'] ) ) { // Input var ok.
|
||||
$font_list[ $id ]['file_woff2'] = sanitize_text_field( $_POST['powerkit_custom_fonts_file_woff2'] ); // Input var ok; sanitization ok.
|
||||
}
|
||||
if ( isset( $_POST['powerkit_custom_fonts_weight'] ) ) { // Input var ok.
|
||||
$font_list[ $id ]['weight'] = sanitize_text_field( $_POST['powerkit_custom_fonts_weight'] ); // Input var ok; sanitization ok.
|
||||
}
|
||||
if ( isset( $_POST['powerkit_custom_fonts_style'] ) ) { // Input var ok.
|
||||
$font_list[ $id ]['style'] = sanitize_text_field( $_POST['powerkit_custom_fonts_style'] ); // Input var ok; sanitization ok.
|
||||
}
|
||||
|
||||
// Save list.
|
||||
update_option( 'powerkit_custom_fonts_list', $font_list );
|
||||
|
||||
// Output message.
|
||||
printf( '<div id="message" class="updated fade"><p><strong>%s</strong></p></div>', esc_html__( 'Settings saved.', 'powerkit' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register fonts in the editor.
|
||||
*/
|
||||
public function editor_enqueue() {
|
||||
global $pagenow;
|
||||
|
||||
if ( 'post.php' === $pagenow || 'post-new.php' === $pagenow ) {
|
||||
$this->frontend_enqueue();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Frontend enqueue
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function frontend_enqueue() {
|
||||
|
||||
$custom_fonts = get_option( 'powerkit_custom_fonts_list' );
|
||||
|
||||
if ( is_array( $custom_fonts ) && $custom_fonts ) {
|
||||
|
||||
$exclude = array();
|
||||
|
||||
$font_face = null;
|
||||
|
||||
foreach ( $custom_fonts as $key => $item ) {
|
||||
|
||||
$id = sanitize_title( $item['name'] );
|
||||
|
||||
if ( $id ) {
|
||||
$src = array();
|
||||
$files = array();
|
||||
|
||||
$files['woff'] = wp_get_attachment_url( $item['file_woff'] );
|
||||
$files['woff2'] = wp_get_attachment_url( $item['file_woff2'] );
|
||||
|
||||
foreach ( $files as $key_file => $file_url ) {
|
||||
if ( $file_url ) {
|
||||
$src[] = sprintf( 'url("%1$s") format("%2$s")', $file_url, $key_file );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $src ) {
|
||||
$src_line = implode( ',', $src );
|
||||
|
||||
$display = 'async' === $this->load_method ? 'swap' : 'auto';
|
||||
|
||||
$font_face .= sprintf( '@font-face { font-family: "%1$s"; src: %2$s; font-display: %3$s; font-weight: %4$s; font-style: %5$s;}', $id, $src_line, $display, $item['weight'], $item['style'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $font_face ) {
|
||||
?>
|
||||
<style><?php print( $font_face ); // XSS. ?></style>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
new Powerkit_Custom_Fonts();
|
||||
}
|
||||
+220
@@ -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();
|
||||
}
|
||||
+55
@@ -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();
|
||||
}
|
||||
+112
@@ -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' );
|
||||
}
|
||||
}
|
||||
+78
@@ -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;
|
||||
}
|
||||
+78
@@ -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>
|
||||
+216
@@ -0,0 +1,216 @@
|
||||
<?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_Content_Formatting_Admin extends Powerkit_Module_Admin {
|
||||
|
||||
/**
|
||||
* Initialize
|
||||
*/
|
||||
public function initialize() {
|
||||
add_action( 'mce_buttons_2', array( $this, 'mce_buttons_2' ) );
|
||||
add_filter( 'tiny_mce_before_init', array( $this, 'mce_before_init_insert_formats' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Unshift Styleselect.
|
||||
*
|
||||
* @param array $buttons array of buttons.
|
||||
*/
|
||||
public function mce_buttons_2( $buttons ) {
|
||||
array_unshift( $buttons, 'styleselect' );
|
||||
return $buttons;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert formats
|
||||
*
|
||||
* @param array $init_array array of style formats.
|
||||
*/
|
||||
public function mce_before_init_insert_formats( $init_array ) {
|
||||
|
||||
$style_formats = array(
|
||||
array(
|
||||
'title' => esc_html__( 'Drop Cap', 'powerkit' ),
|
||||
'items' => array(
|
||||
array(
|
||||
'title' => esc_html__( 'Simple', 'powerkit' ),
|
||||
'block' => 'p',
|
||||
'classes' => 'pk-dropcap pk-dropcap-simple',
|
||||
'wrapper' => false,
|
||||
),
|
||||
array(
|
||||
'title' => esc_html__( 'Bordered', 'powerkit' ),
|
||||
'block' => 'p',
|
||||
'classes' => 'pk-dropcap pk-dropcap-borders',
|
||||
'wrapper' => false,
|
||||
),
|
||||
array(
|
||||
'title' => esc_html__( 'Border Right', 'powerkit' ),
|
||||
'block' => 'p',
|
||||
'classes' => 'pk-dropcap pk-dropcap-border-right',
|
||||
'wrapper' => false,
|
||||
),
|
||||
array(
|
||||
'title' => esc_html__( 'Background Light', 'powerkit' ),
|
||||
'block' => 'p',
|
||||
'classes' => 'pk-dropcap pk-block-bg pk-dropcap-bg-light',
|
||||
'wrapper' => false,
|
||||
),
|
||||
array(
|
||||
'title' => esc_html__( 'Background Inverse', 'powerkit' ),
|
||||
'block' => 'p',
|
||||
'classes' => 'pk-dropcap pk-block-bg pk-dropcap-bg-inverse',
|
||||
'wrapper' => false,
|
||||
),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'title' => esc_html__( 'Callout', 'powerkit' ),
|
||||
'block' => 'div',
|
||||
'classes' => 'pk-callout',
|
||||
),
|
||||
array(
|
||||
'title' => esc_html__( 'Block', 'powerkit' ),
|
||||
'items' => array(
|
||||
array(
|
||||
'title' => esc_html__( 'Borders', 'powerkit' ),
|
||||
'items' => array(
|
||||
array(
|
||||
'title' => esc_html__( 'Top', 'powerkit' ),
|
||||
'block' => 'div',
|
||||
'classes' => 'pk-content-block pk-block-border-top',
|
||||
),
|
||||
array(
|
||||
'title' => esc_html__( 'Bottom', 'powerkit' ),
|
||||
'block' => 'div',
|
||||
'classes' => 'pk-content-block pk-block-border-bottom',
|
||||
),
|
||||
array(
|
||||
'title' => esc_html__( 'Left', 'powerkit' ),
|
||||
'block' => 'div',
|
||||
'classes' => 'pk-content-block pk-block-border-left',
|
||||
),
|
||||
array(
|
||||
'title' => esc_html__( 'Right', 'powerkit' ),
|
||||
'block' => 'div',
|
||||
'classes' => 'pk-content-block pk-block-border-right',
|
||||
),
|
||||
array(
|
||||
'title' => esc_html__( 'All', 'powerkit' ),
|
||||
'block' => 'div',
|
||||
'classes' => 'pk-content-block pk-block-border-all',
|
||||
),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'title' => esc_html__( 'Background', 'powerkit' ),
|
||||
'block' => 'div',
|
||||
'items' => array(
|
||||
array(
|
||||
'title' => esc_html__( 'Light', 'powerkit' ),
|
||||
'block' => 'div',
|
||||
'classes' => 'pk-content-block pk-block-bg pk-block-bg-light',
|
||||
),
|
||||
array(
|
||||
'title' => esc_html__( 'Inverse', 'powerkit' ),
|
||||
'block' => 'div',
|
||||
'classes' => 'pk-content-block pk-block-bg pk-block-bg-inverse',
|
||||
),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'title' => esc_html__( 'Shadows', 'powerkit' ),
|
||||
'block' => 'div',
|
||||
'classes' => 'pk-content-block pk-block-shadows',
|
||||
),
|
||||
array(
|
||||
'title' => esc_html__( 'Alignment', 'powerkit' ),
|
||||
'items' => array(
|
||||
array(
|
||||
'title' => esc_html__( 'Left', 'powerkit' ),
|
||||
'block' => 'div',
|
||||
'classes' => 'pk-content-block pk-block-alignment-left',
|
||||
),
|
||||
array(
|
||||
'title' => esc_html__( 'Right', 'powerkit' ),
|
||||
'block' => 'div',
|
||||
'classes' => 'pk-content-block pk-block-alignment-right',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'title' => esc_html__( 'Numbered Headings', 'powerkit' ),
|
||||
'items' => array(
|
||||
array(
|
||||
'title' => esc_html__( 'Heading 2', 'powerkit' ),
|
||||
'block' => 'h2',
|
||||
'classes' => 'pk-heading-numbered',
|
||||
),
|
||||
array(
|
||||
'title' => esc_html__( 'Heading 3', 'powerkit' ),
|
||||
'block' => 'h3',
|
||||
'classes' => 'pk-heading-numbered',
|
||||
),
|
||||
array(
|
||||
'title' => esc_html__( 'Heading 4', 'powerkit' ),
|
||||
'block' => 'h4',
|
||||
'classes' => 'pk-heading-numbered',
|
||||
),
|
||||
array(
|
||||
'title' => esc_html__( 'Heading 5', 'powerkit' ),
|
||||
'block' => 'h5',
|
||||
'classes' => 'pk-heading-numbered',
|
||||
),
|
||||
array(
|
||||
'title' => esc_html__( 'Heading 6', 'powerkit' ),
|
||||
'block' => 'h6',
|
||||
'classes' => 'pk-heading-numbered',
|
||||
),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'title' => esc_html__( 'Lists', 'powerkit' ),
|
||||
'items' => array(
|
||||
array(
|
||||
'title' => esc_html__( 'Style', 'powerkit' ),
|
||||
'selector' => 'ol,ul',
|
||||
'attributes' => array(
|
||||
'class' => 'pk-list-styled',
|
||||
),
|
||||
),
|
||||
array(
|
||||
'title' => esc_html__( 'Positive', 'powerkit' ),
|
||||
'selector' => 'ol,ul',
|
||||
'attributes' => array(
|
||||
'class' => 'pk-list-positive',
|
||||
),
|
||||
),
|
||||
array(
|
||||
'title' => esc_html__( 'Negative', 'powerkit' ),
|
||||
'selector' => 'ol,ul',
|
||||
'attributes' => array(
|
||||
'class' => 'pk-list-negative',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$init_array['style_formats'] = wp_json_encode( $style_formats );
|
||||
|
||||
return $init_array;
|
||||
}
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/**
|
||||
* Content Formatting
|
||||
*
|
||||
* @package Powerkit
|
||||
* @subpackage Modules
|
||||
*/
|
||||
|
||||
if ( class_exists( 'Powerkit_Module' ) ) {
|
||||
/**
|
||||
* Init module
|
||||
*/
|
||||
class Powerkit_Content_Formatting extends Powerkit_Module {
|
||||
|
||||
/**
|
||||
* Register module
|
||||
*/
|
||||
public function register() {
|
||||
$this->name = esc_html__( 'Content Formatting', 'powerkit' );
|
||||
$this->desc = esc_html__( 'A few nice extra content formatting features: numbered headings, styled lists, badges, drop-caps, and content blocks.', 'powerkit' );
|
||||
$this->slug = 'content_formatting';
|
||||
$this->type = 'default';
|
||||
$this->category = 'content';
|
||||
$this->priority = 140;
|
||||
$this->public = true;
|
||||
$this->enabled = true;
|
||||
$this->links = array(
|
||||
array(
|
||||
'name' => esc_html__( 'View documentation', 'powerkit' ),
|
||||
'url' => powerkit_get_setting( 'documentation' ) . '/content-presentation/content-formatting/',
|
||||
'target' => '_blank',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize module
|
||||
*/
|
||||
public function initialize() {
|
||||
|
||||
/* Load the required dependencies for this module */
|
||||
|
||||
// Admin and public area.
|
||||
require_once dirname( __FILE__ ) . '/admin/class-powerkit-content-formatting-admin.php';
|
||||
require_once dirname( __FILE__ ) . '/public/class-powerkit-content-formatting-public.php';
|
||||
|
||||
new Powerkit_Content_Formatting_Admin( $this->slug );
|
||||
new Powerkit_Content_Formatting_Public( $this->slug );
|
||||
}
|
||||
}
|
||||
|
||||
new Powerkit_Content_Formatting();
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
<?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_Content_Formatting_Public extends Powerkit_Module_Public {
|
||||
/**
|
||||
* Initialize
|
||||
*/
|
||||
public function initialize() {
|
||||
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ), 6 );
|
||||
add_action( 'after_setup_theme', array( $this, 'after_setup_theme' ), 6 );
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will register scripts and styles for admin dashboard.
|
||||
*
|
||||
* @param string $page Current page.
|
||||
*/
|
||||
public function admin_enqueue_scripts( $page ) {
|
||||
wp_enqueue_style( 'powerkit-content-formatting', powerkit_style( plugin_dir_url( __FILE__ ) . 'css/public-powerkit-content-formatting.css' ), array(), powerkit_get_setting( 'version' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up theme defaults and registers support for various WordPress features.
|
||||
*/
|
||||
public function after_setup_theme() {
|
||||
add_editor_style( powerkit_style( plugin_dir_url( __FILE__ ) . 'css/public-powerkit-content-formatting.css' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the stylesheets for the public-facing side of the site.
|
||||
*/
|
||||
public function wp_enqueue_scripts() {
|
||||
wp_enqueue_style( 'powerkit-content-formatting', powerkit_style( plugin_dir_url( __FILE__ ) . 'css/public-powerkit-content-formatting.css' ), array(), powerkit_get_setting( 'version' ), 'all' );
|
||||
|
||||
// Add RTL support.
|
||||
wp_style_add_data( 'powerkit-content-formatting', 'rtl', 'replace' );
|
||||
}
|
||||
}
|
||||
+422
@@ -0,0 +1,422 @@
|
||||
/**
|
||||
* All of the CSS for your public-facing functionality should be
|
||||
* included in this file.
|
||||
*/
|
||||
/**
|
||||
* Environment for all styles (variables, additions, etc).
|
||||
*/
|
||||
/*--------------------------------------------------------------*/
|
||||
/*--------------------------------------------------------------*/
|
||||
.content,
|
||||
.entry-content,
|
||||
.mce-content-body {
|
||||
counter-reset: h2;
|
||||
}
|
||||
|
||||
.content h2,
|
||||
.entry-content h2,
|
||||
.mce-content-body h2 {
|
||||
counter-reset: h3;
|
||||
}
|
||||
|
||||
.content h3,
|
||||
.entry-content h3,
|
||||
.mce-content-body h3 {
|
||||
counter-reset: h4;
|
||||
}
|
||||
|
||||
.content h4,
|
||||
.entry-content h4,
|
||||
.mce-content-body h4 {
|
||||
counter-reset: h5;
|
||||
}
|
||||
|
||||
.content h5,
|
||||
.entry-content h5,
|
||||
.mce-content-body h5 {
|
||||
counter-reset: h6;
|
||||
}
|
||||
|
||||
.pk-list-styled,
|
||||
.pk-list-positive,
|
||||
.pk-list-negative {
|
||||
line-height: 1.5;
|
||||
list-style: none;
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.pk-list-styled:not(:first-child),
|
||||
.pk-list-positive:not(:first-child),
|
||||
.pk-list-negative:not(:first-child) {
|
||||
margin-top: 1.5rem;
|
||||
}
|
||||
|
||||
.pk-list-styled:not(:last-child),
|
||||
.pk-list-positive:not(:last-child),
|
||||
.pk-list-negative:not(:last-child) {
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.pk-list-styled li:not(:first-child),
|
||||
.pk-list-positive li:not(:first-child),
|
||||
.pk-list-negative li:not(:first-child) {
|
||||
margin-top: 0.5rem;
|
||||
}
|
||||
|
||||
.pk-list-styled > li,
|
||||
.pk-list-positive > li,
|
||||
.pk-list-negative > li {
|
||||
position: relative;
|
||||
padding-right: 2.5rem;
|
||||
}
|
||||
|
||||
.pk-list-styled > li:before,
|
||||
.pk-list-positive > li:before,
|
||||
.pk-list-negative > li:before {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
ol.pk-list-styled,
|
||||
ol.pk-list-positive,
|
||||
ol.pk-list-negative {
|
||||
counter-reset: ol;
|
||||
}
|
||||
|
||||
ol.pk-list-styled > li:before,
|
||||
ol.pk-list-positive > li:before,
|
||||
ol.pk-list-negative > li:before {
|
||||
width: 1.5rem;
|
||||
height: 1.5rem;
|
||||
content: counter(ol);
|
||||
counter-increment: ol;
|
||||
color: #495057;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 600;
|
||||
background-color: #e9ecef;
|
||||
border-radius: 50%;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
ul.pk-list-styled > li:before {
|
||||
content: '';
|
||||
width: 0.25rem;
|
||||
height: 0.25rem;
|
||||
background: #ced4da;
|
||||
margin-top: 0.75rem;
|
||||
right: 1rem;
|
||||
}
|
||||
|
||||
ol.pk-list-styled ul,
|
||||
ol.pk-list-styled ol,
|
||||
ul.pk-list-styled ol,
|
||||
ul.pk-list-styled ul {
|
||||
margin-top: 0.5rem;
|
||||
margin-bottom: 0.5rem;
|
||||
padding-right: 0;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
ol.pk-list-styled ul > li:not(:first-child),
|
||||
ol.pk-list-styled ol > li:not(:first-child),
|
||||
ul.pk-list-styled ol > li:not(:first-child),
|
||||
ul.pk-list-styled ul > li:not(:first-child) {
|
||||
margin-top: 0.25rem;
|
||||
}
|
||||
|
||||
ol.pk-list-positive > li:before {
|
||||
background-color: #28a745;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
ol.pk-list-negative > li:before {
|
||||
background-color: #dc3545;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
ul.pk-list-positive > li:before,
|
||||
ul.pk-list-negative > li:before {
|
||||
width: 1.5rem;
|
||||
font-family: 'powerkit-icons';
|
||||
}
|
||||
|
||||
ul.pk-list-positive > li:before {
|
||||
content: "\e912";
|
||||
color: #28a745;
|
||||
}
|
||||
|
||||
ul.pk-list-negative > li:before {
|
||||
content: "\e913";
|
||||
color: #dc3545;
|
||||
}
|
||||
|
||||
.pk-heading-numbered {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.pk-heading-numbered:before {
|
||||
margin-left: 1rem;
|
||||
}
|
||||
|
||||
h2.pk-heading-numbered:before {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 2.5rem;
|
||||
flex: 0 0 2.5rem;
|
||||
border-radius: 50%;
|
||||
background: #ced4da;
|
||||
color: white;
|
||||
counter-increment: h2;
|
||||
content: counter(h2);
|
||||
}
|
||||
|
||||
h3.pk-heading-numbered:before {
|
||||
counter-increment: h3;
|
||||
content: counter(h3);
|
||||
}
|
||||
|
||||
h2.pk-heading-numbered ~ h3.pk-heading-numbered:before {
|
||||
content: counter(h2) "." counter(h3);
|
||||
}
|
||||
|
||||
h4.pk-heading-numbered:before {
|
||||
counter-increment: h4;
|
||||
content: counter(h4);
|
||||
}
|
||||
|
||||
h3.pk-heading-numbered ~ h4.pk-heading-numbered:before {
|
||||
content: counter(h3) "." counter(h4);
|
||||
}
|
||||
|
||||
h2.pk-heading-numbered ~ h3.pk-heading-numbered ~ h4.pk-heading-numbered:before {
|
||||
content: counter(h2) "." counter(h3) "." counter(h4);
|
||||
}
|
||||
|
||||
h5.pk-heading-numbered:before {
|
||||
counter-increment: h5;
|
||||
content: counter(h5);
|
||||
}
|
||||
|
||||
h4.pk-heading-numbered ~ h5.pk-heading-numbered:before {
|
||||
content: counter(h4) "." counter(h5);
|
||||
}
|
||||
|
||||
h3.pk-heading-numbered ~ h4.pk-heading-numbered ~ h5.pk-heading-numbered:before {
|
||||
content: counter(h3) "." counter(h4) "." counter(h5);
|
||||
}
|
||||
|
||||
h2.pk-heading-numbered ~ h3.pk-heading-numbered ~ h4.pk-heading-numbered ~ h5.pk-heading-numbered:before {
|
||||
content: counter(h2) "." counter(h3) "." counter(h4) "." counter(h5);
|
||||
}
|
||||
|
||||
h6.pk-heading-numbered:before {
|
||||
counter-increment: h6;
|
||||
content: counter(h6);
|
||||
}
|
||||
|
||||
h5.pk-heading-numbered ~ h6.pk-heading-numbered:before {
|
||||
content: counter(h5) "." counter(h6);
|
||||
}
|
||||
|
||||
h4.pk-heading-numbered ~ h5.pk-heading-numbered ~ h6.pk-heading-numbered:before {
|
||||
content: counter(h4) "." counter(h5) "." counter(h6);
|
||||
}
|
||||
|
||||
h3.pk-heading-numbered ~ h4.pk-heading-numbered ~ h5.pk-heading-numbered ~ h6.pk-heading-numbered:before {
|
||||
content: counter(h3) "." counter(h4) "." counter(h5) "." counter(h6);
|
||||
}
|
||||
|
||||
h2.pk-heading-numbered ~ h3.pk-heading-numbered ~ h4.pk-heading-numbered ~ h5.pk-heading-numbered ~ h6.pk-heading-numbered:before {
|
||||
content: counter(h2) "." counter(h3) "." counter(h4) "." counter(h5) "." counter(h6);
|
||||
}
|
||||
|
||||
.content .pk-dropcap,
|
||||
.entry-content .pk-dropcap,
|
||||
.mce-content-body .pk-dropcap {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.content .pk-dropcap:after,
|
||||
.entry-content .pk-dropcap:after,
|
||||
.mce-content-body .pk-dropcap:after {
|
||||
content: "";
|
||||
display: table;
|
||||
clear: both;
|
||||
padding-top: 14px;
|
||||
}
|
||||
|
||||
.content .pk-dropcap:first-letter,
|
||||
.entry-content .pk-dropcap:first-letter,
|
||||
.mce-content-body .pk-dropcap:first-letter {
|
||||
display: block;
|
||||
float: right;
|
||||
margin-top: 0.5rem;
|
||||
margin-left: 2rem;
|
||||
margin-bottom: 1rem;
|
||||
color: black;
|
||||
font-size: 2.5rem;
|
||||
line-height: 1;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.content .pk-dropcap-bg-inverse:first-letter,
|
||||
.entry-content .pk-dropcap-bg-inverse:first-letter,
|
||||
.mce-content-body .pk-dropcap-bg-inverse:first-letter {
|
||||
padding: 0.5rem 1rem;
|
||||
background: black;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.content .pk-dropcap-bg-light:first-letter,
|
||||
.entry-content .pk-dropcap-bg-light:first-letter,
|
||||
.mce-content-body .pk-dropcap-bg-light:first-letter {
|
||||
padding: 0.5rem 1rem;
|
||||
background: #f8f9fa;
|
||||
}
|
||||
|
||||
.content .pk-dropcap-borders:first-letter,
|
||||
.entry-content .pk-dropcap-borders:first-letter,
|
||||
.mce-content-body .pk-dropcap-borders:first-letter {
|
||||
margin-top: 0.25rem;
|
||||
padding: 0.5rem 1rem;
|
||||
border: 1px solid #dee2e6;
|
||||
}
|
||||
|
||||
.content .pk-dropcap-border-right:first-letter,
|
||||
.entry-content .pk-dropcap-border-right:first-letter,
|
||||
.mce-content-body .pk-dropcap-border-right:first-letter {
|
||||
padding-left: 2rem;
|
||||
border-left: 1px solid #dee2e6;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.content .pk-callout,
|
||||
.entry-content .pk-callout,
|
||||
.mce-content-body .pk-callout {
|
||||
font-size: 1.25rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.content .pk-content-block,
|
||||
.entry-content .pk-content-block,
|
||||
.mce-content-body .pk-content-block {
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
.content .pk-content-block > *:last-child,
|
||||
.entry-content .pk-content-block > *:last-child,
|
||||
.mce-content-body .pk-content-block > *:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.content .pk-block-alignment-left,
|
||||
.entry-content .pk-block-alignment-left,
|
||||
.mce-content-body .pk-block-alignment-left {
|
||||
float: right;
|
||||
max-width: 50%;
|
||||
margin-left: 2rem;
|
||||
}
|
||||
|
||||
.content .pk-block-alignment-right,
|
||||
.entry-content .pk-block-alignment-right,
|
||||
.mce-content-body .pk-block-alignment-right {
|
||||
float: left;
|
||||
max-width: 50%;
|
||||
margin-right: 2rem;
|
||||
}
|
||||
|
||||
.content .pk-block-border-left,
|
||||
.entry-content .pk-block-border-left,
|
||||
.mce-content-body .pk-block-border-left {
|
||||
padding-right: 2rem;
|
||||
border-right: 1px solid #dee2e6;
|
||||
}
|
||||
|
||||
.content .pk-block-border-right,
|
||||
.entry-content .pk-block-border-right,
|
||||
.mce-content-body .pk-block-border-right {
|
||||
padding-left: 2rem;
|
||||
border-left: 1px solid #dee2e6;
|
||||
}
|
||||
|
||||
.content .pk-block-border-top:before,
|
||||
.entry-content .pk-block-border-top:before,
|
||||
.mce-content-body .pk-block-border-top:before {
|
||||
background-color: #dee2e6;
|
||||
display: block;
|
||||
width: 4rem;
|
||||
height: 1px;
|
||||
margin: 2rem auto;
|
||||
content: "";
|
||||
}
|
||||
|
||||
.content .pk-block-border-bottom:after,
|
||||
.entry-content .pk-block-border-bottom:after,
|
||||
.mce-content-body .pk-block-border-bottom:after {
|
||||
background-color: #dee2e6;
|
||||
display: block;
|
||||
width: 4rem;
|
||||
height: 1px;
|
||||
margin: 2rem auto;
|
||||
content: "";
|
||||
}
|
||||
|
||||
.content .pk-block-border-all,
|
||||
.entry-content .pk-block-border-all,
|
||||
.mce-content-body .pk-block-border-all {
|
||||
padding: 2rem;
|
||||
border: 1px solid #dee2e6;
|
||||
}
|
||||
|
||||
.content .pk-block-bg-light,
|
||||
.entry-content .pk-block-bg-light,
|
||||
.mce-content-body .pk-block-bg-light {
|
||||
background: #f8f9fa;
|
||||
padding: 2rem;
|
||||
}
|
||||
|
||||
.content .pk-block-bg-inverse,
|
||||
.entry-content .pk-block-bg-inverse,
|
||||
.mce-content-body .pk-block-bg-inverse {
|
||||
background: black;
|
||||
padding: 2rem;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.content .pk-block-bg .pk-alert,
|
||||
.entry-content .pk-block-bg .pk-alert,
|
||||
.mce-content-body .pk-block-bg .pk-alert {
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
.content .pk-block-bg .pk-subscribe-form-wrap form,
|
||||
.entry-content .pk-block-bg .pk-subscribe-form-wrap form,
|
||||
.mce-content-body .pk-block-bg .pk-subscribe-form-wrap form {
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.content .pk-block-shadows,
|
||||
.entry-content .pk-block-shadows,
|
||||
.mce-content-body .pk-block-shadows {
|
||||
padding: 2rem;
|
||||
box-shadow: 0 0 1rem rgba(0, 0, 0, 0.075);
|
||||
}
|
||||
|
||||
@media (max-width: 767.98px) {
|
||||
.content .pk-content-block,
|
||||
.entry-content .pk-content-block,
|
||||
.mce-content-body .pk-content-block {
|
||||
float: none;
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
border-right: none;
|
||||
border-left: none;
|
||||
margin-right: 0;
|
||||
margin-left: 0;
|
||||
}
|
||||
}
|
||||
+422
@@ -0,0 +1,422 @@
|
||||
/**
|
||||
* All of the CSS for your public-facing functionality should be
|
||||
* included in this file.
|
||||
*/
|
||||
/**
|
||||
* Environment for all styles (variables, additions, etc).
|
||||
*/
|
||||
/*--------------------------------------------------------------*/
|
||||
/*--------------------------------------------------------------*/
|
||||
.content,
|
||||
.entry-content,
|
||||
.mce-content-body {
|
||||
counter-reset: h2;
|
||||
}
|
||||
|
||||
.content h2,
|
||||
.entry-content h2,
|
||||
.mce-content-body h2 {
|
||||
counter-reset: h3;
|
||||
}
|
||||
|
||||
.content h3,
|
||||
.entry-content h3,
|
||||
.mce-content-body h3 {
|
||||
counter-reset: h4;
|
||||
}
|
||||
|
||||
.content h4,
|
||||
.entry-content h4,
|
||||
.mce-content-body h4 {
|
||||
counter-reset: h5;
|
||||
}
|
||||
|
||||
.content h5,
|
||||
.entry-content h5,
|
||||
.mce-content-body h5 {
|
||||
counter-reset: h6;
|
||||
}
|
||||
|
||||
.pk-list-styled,
|
||||
.pk-list-positive,
|
||||
.pk-list-negative {
|
||||
line-height: 1.5;
|
||||
list-style: none;
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.pk-list-styled:not(:first-child),
|
||||
.pk-list-positive:not(:first-child),
|
||||
.pk-list-negative:not(:first-child) {
|
||||
margin-top: 1.5rem;
|
||||
}
|
||||
|
||||
.pk-list-styled:not(:last-child),
|
||||
.pk-list-positive:not(:last-child),
|
||||
.pk-list-negative:not(:last-child) {
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.pk-list-styled li:not(:first-child),
|
||||
.pk-list-positive li:not(:first-child),
|
||||
.pk-list-negative li:not(:first-child) {
|
||||
margin-top: 0.5rem;
|
||||
}
|
||||
|
||||
.pk-list-styled > li,
|
||||
.pk-list-positive > li,
|
||||
.pk-list-negative > li {
|
||||
position: relative;
|
||||
padding-left: 2.5rem;
|
||||
}
|
||||
|
||||
.pk-list-styled > li:before,
|
||||
.pk-list-positive > li:before,
|
||||
.pk-list-negative > li:before {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
ol.pk-list-styled,
|
||||
ol.pk-list-positive,
|
||||
ol.pk-list-negative {
|
||||
counter-reset: ol;
|
||||
}
|
||||
|
||||
ol.pk-list-styled > li:before,
|
||||
ol.pk-list-positive > li:before,
|
||||
ol.pk-list-negative > li:before {
|
||||
width: 1.5rem;
|
||||
height: 1.5rem;
|
||||
content: counter(ol);
|
||||
counter-increment: ol;
|
||||
color: #495057;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 600;
|
||||
background-color: #e9ecef;
|
||||
border-radius: 50%;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
ul.pk-list-styled > li:before {
|
||||
content: '';
|
||||
width: 0.25rem;
|
||||
height: 0.25rem;
|
||||
background: #ced4da;
|
||||
margin-top: 0.75rem;
|
||||
left: 1rem;
|
||||
}
|
||||
|
||||
ol.pk-list-styled ul,
|
||||
ol.pk-list-styled ol,
|
||||
ul.pk-list-styled ol,
|
||||
ul.pk-list-styled ul {
|
||||
margin-top: 0.5rem;
|
||||
margin-bottom: 0.5rem;
|
||||
padding-left: 0;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
ol.pk-list-styled ul > li:not(:first-child),
|
||||
ol.pk-list-styled ol > li:not(:first-child),
|
||||
ul.pk-list-styled ol > li:not(:first-child),
|
||||
ul.pk-list-styled ul > li:not(:first-child) {
|
||||
margin-top: 0.25rem;
|
||||
}
|
||||
|
||||
ol.pk-list-positive > li:before {
|
||||
background-color: #28a745;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
ol.pk-list-negative > li:before {
|
||||
background-color: #dc3545;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
ul.pk-list-positive > li:before,
|
||||
ul.pk-list-negative > li:before {
|
||||
width: 1.5rem;
|
||||
font-family: 'powerkit-icons';
|
||||
}
|
||||
|
||||
ul.pk-list-positive > li:before {
|
||||
content: "\e912";
|
||||
color: #28a745;
|
||||
}
|
||||
|
||||
ul.pk-list-negative > li:before {
|
||||
content: "\e913";
|
||||
color: #dc3545;
|
||||
}
|
||||
|
||||
.pk-heading-numbered {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.pk-heading-numbered:before {
|
||||
margin-right: 1rem;
|
||||
}
|
||||
|
||||
h2.pk-heading-numbered:before {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 2.5rem;
|
||||
flex: 0 0 2.5rem;
|
||||
border-radius: 50%;
|
||||
background: #ced4da;
|
||||
color: white;
|
||||
counter-increment: h2;
|
||||
content: counter(h2);
|
||||
}
|
||||
|
||||
h3.pk-heading-numbered:before {
|
||||
counter-increment: h3;
|
||||
content: counter(h3);
|
||||
}
|
||||
|
||||
h2.pk-heading-numbered ~ h3.pk-heading-numbered:before {
|
||||
content: counter(h2) "." counter(h3);
|
||||
}
|
||||
|
||||
h4.pk-heading-numbered:before {
|
||||
counter-increment: h4;
|
||||
content: counter(h4);
|
||||
}
|
||||
|
||||
h3.pk-heading-numbered ~ h4.pk-heading-numbered:before {
|
||||
content: counter(h3) "." counter(h4);
|
||||
}
|
||||
|
||||
h2.pk-heading-numbered ~ h3.pk-heading-numbered ~ h4.pk-heading-numbered:before {
|
||||
content: counter(h2) "." counter(h3) "." counter(h4);
|
||||
}
|
||||
|
||||
h5.pk-heading-numbered:before {
|
||||
counter-increment: h5;
|
||||
content: counter(h5);
|
||||
}
|
||||
|
||||
h4.pk-heading-numbered ~ h5.pk-heading-numbered:before {
|
||||
content: counter(h4) "." counter(h5);
|
||||
}
|
||||
|
||||
h3.pk-heading-numbered ~ h4.pk-heading-numbered ~ h5.pk-heading-numbered:before {
|
||||
content: counter(h3) "." counter(h4) "." counter(h5);
|
||||
}
|
||||
|
||||
h2.pk-heading-numbered ~ h3.pk-heading-numbered ~ h4.pk-heading-numbered ~ h5.pk-heading-numbered:before {
|
||||
content: counter(h2) "." counter(h3) "." counter(h4) "." counter(h5);
|
||||
}
|
||||
|
||||
h6.pk-heading-numbered:before {
|
||||
counter-increment: h6;
|
||||
content: counter(h6);
|
||||
}
|
||||
|
||||
h5.pk-heading-numbered ~ h6.pk-heading-numbered:before {
|
||||
content: counter(h5) "." counter(h6);
|
||||
}
|
||||
|
||||
h4.pk-heading-numbered ~ h5.pk-heading-numbered ~ h6.pk-heading-numbered:before {
|
||||
content: counter(h4) "." counter(h5) "." counter(h6);
|
||||
}
|
||||
|
||||
h3.pk-heading-numbered ~ h4.pk-heading-numbered ~ h5.pk-heading-numbered ~ h6.pk-heading-numbered:before {
|
||||
content: counter(h3) "." counter(h4) "." counter(h5) "." counter(h6);
|
||||
}
|
||||
|
||||
h2.pk-heading-numbered ~ h3.pk-heading-numbered ~ h4.pk-heading-numbered ~ h5.pk-heading-numbered ~ h6.pk-heading-numbered:before {
|
||||
content: counter(h2) "." counter(h3) "." counter(h4) "." counter(h5) "." counter(h6);
|
||||
}
|
||||
|
||||
.content .pk-dropcap,
|
||||
.entry-content .pk-dropcap,
|
||||
.mce-content-body .pk-dropcap {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.content .pk-dropcap:after,
|
||||
.entry-content .pk-dropcap:after,
|
||||
.mce-content-body .pk-dropcap:after {
|
||||
content: "";
|
||||
display: table;
|
||||
clear: both;
|
||||
padding-top: 14px;
|
||||
}
|
||||
|
||||
.content .pk-dropcap:first-letter,
|
||||
.entry-content .pk-dropcap:first-letter,
|
||||
.mce-content-body .pk-dropcap:first-letter {
|
||||
display: block;
|
||||
float: left;
|
||||
margin-top: 0.5rem;
|
||||
margin-right: 2rem;
|
||||
margin-bottom: 1rem;
|
||||
color: black;
|
||||
font-size: 2.5rem;
|
||||
line-height: 1;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.content .pk-dropcap-bg-inverse:first-letter,
|
||||
.entry-content .pk-dropcap-bg-inverse:first-letter,
|
||||
.mce-content-body .pk-dropcap-bg-inverse:first-letter {
|
||||
padding: 0.5rem 1rem;
|
||||
background: black;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.content .pk-dropcap-bg-light:first-letter,
|
||||
.entry-content .pk-dropcap-bg-light:first-letter,
|
||||
.mce-content-body .pk-dropcap-bg-light:first-letter {
|
||||
padding: 0.5rem 1rem;
|
||||
background: #f8f9fa;
|
||||
}
|
||||
|
||||
.content .pk-dropcap-borders:first-letter,
|
||||
.entry-content .pk-dropcap-borders:first-letter,
|
||||
.mce-content-body .pk-dropcap-borders:first-letter {
|
||||
margin-top: 0.25rem;
|
||||
padding: 0.5rem 1rem;
|
||||
border: 1px solid #dee2e6;
|
||||
}
|
||||
|
||||
.content .pk-dropcap-border-right:first-letter,
|
||||
.entry-content .pk-dropcap-border-right:first-letter,
|
||||
.mce-content-body .pk-dropcap-border-right:first-letter {
|
||||
padding-right: 2rem;
|
||||
border-right: 1px solid #dee2e6;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.content .pk-callout,
|
||||
.entry-content .pk-callout,
|
||||
.mce-content-body .pk-callout {
|
||||
font-size: 1.25rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.content .pk-content-block,
|
||||
.entry-content .pk-content-block,
|
||||
.mce-content-body .pk-content-block {
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
.content .pk-content-block > *:last-child,
|
||||
.entry-content .pk-content-block > *:last-child,
|
||||
.mce-content-body .pk-content-block > *:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.content .pk-block-alignment-left,
|
||||
.entry-content .pk-block-alignment-left,
|
||||
.mce-content-body .pk-block-alignment-left {
|
||||
float: left;
|
||||
max-width: 50%;
|
||||
margin-right: 2rem;
|
||||
}
|
||||
|
||||
.content .pk-block-alignment-right,
|
||||
.entry-content .pk-block-alignment-right,
|
||||
.mce-content-body .pk-block-alignment-right {
|
||||
float: right;
|
||||
max-width: 50%;
|
||||
margin-left: 2rem;
|
||||
}
|
||||
|
||||
.content .pk-block-border-left,
|
||||
.entry-content .pk-block-border-left,
|
||||
.mce-content-body .pk-block-border-left {
|
||||
padding-left: 2rem;
|
||||
border-left: 1px solid #dee2e6;
|
||||
}
|
||||
|
||||
.content .pk-block-border-right,
|
||||
.entry-content .pk-block-border-right,
|
||||
.mce-content-body .pk-block-border-right {
|
||||
padding-right: 2rem;
|
||||
border-right: 1px solid #dee2e6;
|
||||
}
|
||||
|
||||
.content .pk-block-border-top:before,
|
||||
.entry-content .pk-block-border-top:before,
|
||||
.mce-content-body .pk-block-border-top:before {
|
||||
background-color: #dee2e6;
|
||||
display: block;
|
||||
width: 4rem;
|
||||
height: 1px;
|
||||
margin: 2rem auto;
|
||||
content: "";
|
||||
}
|
||||
|
||||
.content .pk-block-border-bottom:after,
|
||||
.entry-content .pk-block-border-bottom:after,
|
||||
.mce-content-body .pk-block-border-bottom:after {
|
||||
background-color: #dee2e6;
|
||||
display: block;
|
||||
width: 4rem;
|
||||
height: 1px;
|
||||
margin: 2rem auto;
|
||||
content: "";
|
||||
}
|
||||
|
||||
.content .pk-block-border-all,
|
||||
.entry-content .pk-block-border-all,
|
||||
.mce-content-body .pk-block-border-all {
|
||||
padding: 2rem;
|
||||
border: 1px solid #dee2e6;
|
||||
}
|
||||
|
||||
.content .pk-block-bg-light,
|
||||
.entry-content .pk-block-bg-light,
|
||||
.mce-content-body .pk-block-bg-light {
|
||||
background: #f8f9fa;
|
||||
padding: 2rem;
|
||||
}
|
||||
|
||||
.content .pk-block-bg-inverse,
|
||||
.entry-content .pk-block-bg-inverse,
|
||||
.mce-content-body .pk-block-bg-inverse {
|
||||
background: black;
|
||||
padding: 2rem;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.content .pk-block-bg .pk-alert,
|
||||
.entry-content .pk-block-bg .pk-alert,
|
||||
.mce-content-body .pk-block-bg .pk-alert {
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
.content .pk-block-bg .pk-subscribe-form-wrap form,
|
||||
.entry-content .pk-block-bg .pk-subscribe-form-wrap form,
|
||||
.mce-content-body .pk-block-bg .pk-subscribe-form-wrap form {
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.content .pk-block-shadows,
|
||||
.entry-content .pk-block-shadows,
|
||||
.mce-content-body .pk-block-shadows {
|
||||
padding: 2rem;
|
||||
box-shadow: 0 0 1rem rgba(0, 0, 0, 0.075);
|
||||
}
|
||||
|
||||
@media (max-width: 767.98px) {
|
||||
.content .pk-content-block,
|
||||
.entry-content .pk-content-block,
|
||||
.mce-content-body .pk-content-block {
|
||||
float: none;
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
border-left: none;
|
||||
border-right: none;
|
||||
margin-left: 0;
|
||||
margin-right: 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/**
|
||||
* Contributors
|
||||
*
|
||||
* @package Powerkit
|
||||
* @subpackage Modules
|
||||
*/
|
||||
|
||||
if ( class_exists( 'Powerkit_Module' ) ) {
|
||||
/**
|
||||
* Init module
|
||||
*/
|
||||
class Powerkit_Contributors extends Powerkit_Module {
|
||||
|
||||
/**
|
||||
* Register module
|
||||
*/
|
||||
public function register() {
|
||||
$this->name = esc_html__( 'Contributors', 'powerkit' );
|
||||
$this->desc = esc_html__( 'Display a list of your site authors (contributors) in your sidebar, including author name, bio, and avatar in multiple available layouts.', 'powerkit' );
|
||||
$this->slug = 'contributors';
|
||||
$this->type = 'default';
|
||||
$this->category = 'content';
|
||||
$this->priority = 150;
|
||||
$this->public = true;
|
||||
$this->enabled = true;
|
||||
$this->links = array(
|
||||
array(
|
||||
'name' => esc_html__( 'View documentation', 'powerkit' ),
|
||||
'url' => powerkit_get_setting( 'documentation' ) . '/contributors/',
|
||||
'target' => '_blank',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize module
|
||||
*/
|
||||
public function initialize() {
|
||||
// Helpers Functions for the module.
|
||||
require_once dirname( __FILE__ ) . '/helpers/helper-powerkit-contributors.php';
|
||||
|
||||
// The classes responsible for defining all actions.
|
||||
require_once dirname( __FILE__ ) . '/public/class-powerkit-contributors-widget.php';
|
||||
|
||||
if ( function_exists( 'register_block_type' ) ) {
|
||||
require_once dirname( __FILE__ ) . '/public/class-powerkit-contributors-block.php';
|
||||
}
|
||||
|
||||
// Admin and public area.
|
||||
require_once dirname( __FILE__ ) . '/public/class-powerkit-contributors-public.php';
|
||||
|
||||
new Powerkit_Contributors_Public( $this->slug );
|
||||
}
|
||||
}
|
||||
|
||||
new Powerkit_Contributors();
|
||||
}
|
||||
+137
@@ -0,0 +1,137 @@
|
||||
<?php
|
||||
/**
|
||||
* Helpers Contributors
|
||||
*
|
||||
* @package Powerkit
|
||||
* @subpackage Modules/Helper
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get html of contributors block
|
||||
*
|
||||
* @param array $params Recent options.
|
||||
* @param string $args Widget args.
|
||||
*/
|
||||
function powerkit_contributors_get_html( $params, $args ) {
|
||||
|
||||
$params = array_merge(
|
||||
array(
|
||||
'title' => '',
|
||||
'filter_ids' => '',
|
||||
'avatar' => true,
|
||||
'social_accounts' => true,
|
||||
'bio' => true,
|
||||
'recent_posts' => false,
|
||||
'recent_posts_count' => 3,
|
||||
),
|
||||
$params
|
||||
);
|
||||
|
||||
// Before Widget.
|
||||
echo $args['before_widget']; // XSS.
|
||||
|
||||
// Title.
|
||||
if ( $params['title'] ) {
|
||||
echo $args['before_title'] . wp_kses( $params['title'], 'pk-title' ) . $args['after_title']; // XSS.
|
||||
}
|
||||
|
||||
// Content.
|
||||
?>
|
||||
<div class="widget-body">
|
||||
<?php
|
||||
$authors = powerkit_get_users();
|
||||
|
||||
$avatar_size = apply_filters( 'powerkit_widget_coauthors_avatar_size', 80 );
|
||||
|
||||
if ( isset( $authors ) && ! empty( $authors ) ) {
|
||||
?>
|
||||
<div class="pk-widget-contributors">
|
||||
<?php
|
||||
foreach ( $authors as $author ) {
|
||||
|
||||
// Filters ids.
|
||||
if ( $params['filter_ids'] ) {
|
||||
$filter_ids = explode( ',', str_replace( ' ', '', $params['filter_ids'] ) );
|
||||
|
||||
if ( ! in_array( (string) $author->ID, $filter_ids, true ) ) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<div class="pk-author-item">
|
||||
<?php if ( $params['avatar'] ) { ?>
|
||||
<div class="pk-author-avatar">
|
||||
<a href="<?php echo esc_url( get_author_posts_url( $author->ID ) ); ?>" rel="author">
|
||||
<?php echo get_avatar( $author->ID, $avatar_size ); ?>
|
||||
</a>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<div class="pk-author-data">
|
||||
<?php $tag = apply_filters( 'powerkit_widget_contributors_author_name', 'h6' ); ?>
|
||||
|
||||
<<?php echo esc_html( $tag ); ?> class="author-name">
|
||||
<a href="<?php echo esc_url( get_author_posts_url( $author->ID ) ); ?>" rel="author">
|
||||
<?php echo esc_html( get_the_author_meta( 'display_name', $author->ID ) ); ?>
|
||||
</a>
|
||||
</<?php echo esc_html( $tag ); ?>>
|
||||
|
||||
<?php
|
||||
if ( $params['bio'] ) :
|
||||
$author_description = get_the_author_meta( 'description', $author->ID );
|
||||
?>
|
||||
<div class="author-description pk-color-secondary">
|
||||
<?php echo wp_kses_post( powerkit_str_truncate( $author_description, apply_filters( 'powerkit_widget_contributors_description_length', 100 ) ) ); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php
|
||||
if ( $params['social_accounts'] && powerkit_module_enabled( 'social_links' ) ) {
|
||||
powerkit_author_social_links( $author->ID, 'template-nav' );
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
if ( $params['recent_posts'] && $params['recent_posts_count'] ) {
|
||||
$author_posts = get_posts(
|
||||
array(
|
||||
'author' => $author->ID,
|
||||
'posts_per_page' => $params['recent_posts_count'],
|
||||
)
|
||||
);
|
||||
|
||||
if ( ! empty( $author_posts ) ) {
|
||||
?>
|
||||
<div class="pk-author-posts">
|
||||
<h6><?php echo sprintf( esc_html__( 'Latest from %s:', 'powerkit' ), get_the_author_meta( 'display_name', $author->ID ) ); ?></h6>
|
||||
<?php
|
||||
|
||||
foreach ( $author_posts as $post ) {
|
||||
?>
|
||||
<div class="pk-author-posts-single">
|
||||
<a href="<?php echo esc_url( get_permalink( $post->ID ) ); ?>"><?php echo esc_html( get_the_title( $post->ID ) ); ?></a>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
// After Widget.
|
||||
echo $args['after_widget']; // XSS.
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
* Contributors 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' => '',
|
||||
'filter_ids' => implode( ',', (array) $attributes['contributors'] ),
|
||||
'avatar' => $attributes['showAvatar'],
|
||||
'social_accounts' => $attributes['showSocialAccounts'],
|
||||
'bio' => $attributes['showBio'],
|
||||
'recent_posts' => $attributes['showRecentPosts'],
|
||||
'recent_posts_count' => isset( $attributes['countRecentPosts'] ) ? $attributes['countRecentPosts'] : 0,
|
||||
);
|
||||
|
||||
echo '<div class="' . esc_attr( $attributes['className'] ) . '" ' . ( isset( $attributes['anchor'] ) ? ' id="' . esc_attr( $attributes['anchor'] ) . '"' : '' ) . '>';
|
||||
|
||||
// Title.
|
||||
if ( $params['title'] ) {
|
||||
$params['title'] = '<h5 class="pk-contributors-title">' . $params['title'] . '<h5>';
|
||||
}
|
||||
|
||||
$args = array(
|
||||
'before_title' => '',
|
||||
'after_title' => '',
|
||||
'before_widget' => '',
|
||||
'after_widget' => '',
|
||||
);
|
||||
|
||||
powerkit_contributors_get_html( $params, $args );
|
||||
|
||||
echo '</div>';
|
||||
+151
@@ -0,0 +1,151 @@
|
||||
<?php
|
||||
/**
|
||||
* The Gutenberg Block.
|
||||
*
|
||||
* @link https://codesupply.co
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package Powerkit
|
||||
* @subpackage Modules/public
|
||||
*/
|
||||
|
||||
/**
|
||||
* The initialize block.
|
||||
*/
|
||||
class Powerkit_Contributors_Block {
|
||||
|
||||
/**
|
||||
* Initialize
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'init', array( $this, 'block' ) );
|
||||
add_filter( 'canvas_register_block_type', array( $this, 'register_block_type' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue the block's assets for the editor.
|
||||
*/
|
||||
public function block() {
|
||||
// Styles.
|
||||
wp_register_style(
|
||||
'powerkit-contributors-block-editor-style',
|
||||
plugins_url( 'css/public-powerkit-contributors.css', __FILE__ ),
|
||||
array( 'wp-edit-blocks' ),
|
||||
filemtime( plugin_dir_path( __FILE__ ) . 'css/public-powerkit-contributors.css' )
|
||||
);
|
||||
|
||||
wp_style_add_data( 'powerkit-contributors-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();
|
||||
|
||||
foreach ( $users as $user ) {
|
||||
$users_choices[ $user->ID ] = $user->display_name;
|
||||
}
|
||||
|
||||
$blocks[] = array(
|
||||
'name' => 'canvas/contributors',
|
||||
'title' => esc_html__( 'Contributors', '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.51 9.99C12.51 8.34 11.16 6.99 9.51 6.99C7.86 6.99 6.51 8.34 6.51 9.99C6.51 11.64 7.86 12.99 9.51 12.99C11.16 12.99 12.51 11.64 12.51 9.99ZM9.51 10.99C8.96 10.99 8.51 10.54 8.51 9.99C8.51 9.44 8.96 8.99 9.51 8.99C10.06 8.99 10.51 9.44 10.51 9.99C10.51 10.54 10.06 10.99 9.51 10.99ZM16.01 12.99C17.12 12.99 18.01 12.1 18.01 10.99C18.01 9.88 17.12 8.99 16.01 8.99C14.9 8.99 14 9.88 14.01 10.99C14.01 12.1 14.9 12.99 16.01 12.99ZM12 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 2V2ZM5.85 17.11C6.53 16.57 8.12 16 9.51 16C9.58 16 9.66 16.01 9.74 16.01C9.98 15.37 10.41 14.72 11.04 14.15C10.48 14.05 9.95 13.99 9.51 13.99C8.21 13.99 6.12 14.44 4.78 15.42C4.28 14.38 4 13.22 4 11.99C4 7.58 7.59 3.99 12 3.99C16.41 3.99 20 7.58 20 11.99C20 13.19 19.73 14.33 19.25 15.36C18.25 14.77 16.89 14.49 16.01 14.49C14.49 14.49 11.51 15.3 11.51 17.19V19.97C9.24 19.84 7.22 18.76 5.85 17.11V17.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,
|
||||
),
|
||||
),
|
||||
'layouts' => array(),
|
||||
'fields' => array(
|
||||
array(
|
||||
'key' => 'contributors',
|
||||
'label' => esc_html__( 'Contributors', 'powerkit' ),
|
||||
'section' => 'general',
|
||||
'type' => 'react-select',
|
||||
'choices' => $users_choices,
|
||||
'multiple' => true,
|
||||
'default' => array(),
|
||||
'items' => array(
|
||||
'type' => 'integer',
|
||||
),
|
||||
),
|
||||
array(
|
||||
'key' => 'showAvatar',
|
||||
'label' => esc_html__( 'Display Avatar', 'powerkit' ),
|
||||
'section' => 'general',
|
||||
'type' => 'toggle',
|
||||
'default' => true,
|
||||
),
|
||||
array(
|
||||
'key' => 'showSocialAccounts',
|
||||
'label' => esc_html__( 'Display Social Links', 'powerkit' ),
|
||||
'section' => 'general',
|
||||
'type' => 'toggle',
|
||||
'default' => true,
|
||||
),
|
||||
array(
|
||||
'key' => 'showBio',
|
||||
'label' => esc_html__( 'Display Bio', 'powerkit' ),
|
||||
'section' => 'general',
|
||||
'type' => 'toggle',
|
||||
'default' => true,
|
||||
),
|
||||
array(
|
||||
'key' => 'showRecentPosts',
|
||||
'label' => esc_html__( 'Display Recent Posts', 'powerkit' ),
|
||||
'section' => 'general',
|
||||
'type' => 'toggle',
|
||||
'default' => false,
|
||||
),
|
||||
array(
|
||||
'key' => 'countRecentPosts',
|
||||
'label' => esc_html__( 'Number of Recent Posts', 'powerkit' ),
|
||||
'section' => 'general',
|
||||
'type' => 'number',
|
||||
'step' => 1,
|
||||
'min' => 0,
|
||||
'max' => 1000,
|
||||
'default' => 3,
|
||||
'active_callback' => array(
|
||||
array(
|
||||
'field' => 'showRecentPosts',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
'template' => dirname( __FILE__ ) . '/block/render.php',
|
||||
|
||||
// enqueue registered scripts/styles.
|
||||
'editor_style' => 'powerkit-contributors-block-editor-style',
|
||||
);
|
||||
|
||||
return $blocks;
|
||||
}
|
||||
}
|
||||
|
||||
new Powerkit_Contributors_Block();
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
<?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_Contributors_Public extends Powerkit_Module_Public {
|
||||
|
||||
/**
|
||||
* Register the stylesheets for the public-facing side of the site.
|
||||
*/
|
||||
public function wp_enqueue_scripts() {
|
||||
wp_enqueue_style( 'powerkit-сontributors', powerkit_style( plugin_dir_url( __FILE__ ) . 'css/public-powerkit-contributors.css' ), array(), powerkit_get_setting( 'version' ), 'all' );
|
||||
|
||||
// Add RTL support.
|
||||
wp_style_add_data( 'powerkit-сontributors', 'rtl', 'replace' );
|
||||
}
|
||||
}
|
||||
+119
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
/**
|
||||
* Widget Contributors
|
||||
*
|
||||
* @link https://codesupply.co
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package Powerkit
|
||||
* @subpackage Powerkit/widgets
|
||||
*/
|
||||
|
||||
/**
|
||||
* Contributors
|
||||
*/
|
||||
class Powerkit_Contributors_Widget extends WP_Widget {
|
||||
|
||||
|
||||
/**
|
||||
* Sets up a new widget instance.
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
$this->default_settings = apply_filters( 'powerkit_widget_contributors_settings', array(
|
||||
'title' => esc_html__( 'Contributors', 'powerkit' ),
|
||||
'filter_ids' => '',
|
||||
'avatar' => true,
|
||||
'social_accounts' => true,
|
||||
) );
|
||||
|
||||
$widget_details = array(
|
||||
'classname' => 'powerkit_widget_contributors',
|
||||
'description' => '',
|
||||
);
|
||||
|
||||
parent::__construct( 'powerkit_widget_contributors', esc_html__( 'Contributors', '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 );
|
||||
|
||||
// Title.
|
||||
if ( $params['title'] ) {
|
||||
$params['title'] = apply_filters( 'widget_title', $params['title'], $instance, $this->id_base );
|
||||
}
|
||||
|
||||
powerkit_contributors_get_html( $params, $args );
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 social accounts.
|
||||
if ( ! isset( $instance['social_accounts'] ) ) {
|
||||
$instance['social_accounts'] = false;
|
||||
}
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs the widget settings form.
|
||||
*
|
||||
* @param array $instance Current settings.
|
||||
*/
|
||||
public function form( $instance ) {
|
||||
$params = array_merge( $this->default_settings, $instance );
|
||||
?>
|
||||
<!-- 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>
|
||||
|
||||
<!-- Filter by Authors -->
|
||||
<p>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'filter_ids' ) ); ?>"><?php esc_html_e( 'Filter by authors:', 'powerkit' ); ?></label>
|
||||
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'filter_ids' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'filter_ids' ) ); ?>" type="text" value="<?php echo esc_attr( $params['filter_ids'] ); ?>" />
|
||||
</p>
|
||||
|
||||
<p class="help"><?php esc_html_e( 'Add comma-separated list of authors IDs. For example: 1, 2, 3. Leave empty for all authors.' ); ?></p>
|
||||
|
||||
<!-- 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>
|
||||
|
||||
<?php if ( powerkit_module_enabled( 'social_links' ) ) : ?>
|
||||
<!-- Display social accounts -->
|
||||
<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; ?>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register Widget
|
||||
*/
|
||||
function powerkit_widget_init_contributors() {
|
||||
register_widget( 'Powerkit_Contributors_Widget' );
|
||||
}
|
||||
add_action( 'widgets_init', 'powerkit_widget_init_contributors' );
|
||||
+107
@@ -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-contributors {
|
||||
--pk-contributors-item-border-color: #eeeeee;
|
||||
--pk-contributors-post-arrow-color: #ced4da;
|
||||
--pk-contributors-post-arrow-color-hover: #fff;
|
||||
--pk-contributors-post-arrow-backgroynd-hover: #6c757d;
|
||||
--pk-contributors-avatar-border-radius: 100%;
|
||||
--pk-contributors-post-arrow-border-radius: 100%;
|
||||
--pk-contributors-description-font-size: 80%;
|
||||
--pk-contributors-post-link-font-size: 0.875rem;
|
||||
--pk-contributors-post-link-line-height: 1.25rem;
|
||||
--pk-contributors-post-arrow-font-size: 14px;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------*/
|
||||
.pk-widget-contributors .pk-author-item {
|
||||
display: flex;
|
||||
margin-top: 1rem;
|
||||
padding-top: 1rem;
|
||||
border-top: 1px var(--pk-contributors-item-border-color) solid;
|
||||
}
|
||||
|
||||
.pk-widget-contributors .pk-author-item:first-child {
|
||||
margin-top: 0;
|
||||
padding-top: 0;
|
||||
border-top: none;
|
||||
}
|
||||
|
||||
.pk-widget-contributors .pk-author-avatar {
|
||||
flex: 0 0 80px;
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
margin-left: 1rem;
|
||||
-o-object-fit: cover;
|
||||
object-fit: cover;
|
||||
font-family: 'object-fit: cover;';
|
||||
}
|
||||
|
||||
.pk-widget-contributors .pk-author-avatar img {
|
||||
border-radius: var(--pk-contributors-avatar-border-radius);
|
||||
}
|
||||
|
||||
.pk-widget-contributors .pk-author-data {
|
||||
flex-grow: 1;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.pk-widget-contributors .pk-author-data .author-name {
|
||||
margin-top: 0;
|
||||
margin-bottom: .5rem;
|
||||
}
|
||||
|
||||
.pk-widget-contributors .pk-author-data .author-description {
|
||||
font-size: var(--pk-contributors-description-font-size);
|
||||
margin-bottom: .5rem;
|
||||
}
|
||||
|
||||
.pk-widget-contributors .pk-social-links-wrap {
|
||||
margin-top: .5rem;
|
||||
}
|
||||
|
||||
.pk-widget-contributors .pk-author-posts {
|
||||
margin-top: 2rem;
|
||||
}
|
||||
|
||||
.pk-widget-contributors .pk-author-posts > .pk-author-posts-single > a {
|
||||
display: flex;
|
||||
padding-top: 0.25rem;
|
||||
padding-bottom: 0.25rem;
|
||||
position: relative;
|
||||
padding-right: 2rem;
|
||||
font-size: var(--pk-contributors-post-link-font-size);
|
||||
line-height: var(--pk-contributors-post-link-line-height);
|
||||
}
|
||||
|
||||
.pk-widget-contributors .pk-author-posts > .pk-author-posts-single > a:before {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 4px;
|
||||
font-family: 'powerkit-icons';
|
||||
content: "\e940";
|
||||
color: var(--pk-contributors-post-arrow-color);
|
||||
font-size: var(--pk-contributors-post-arrow-font-size);
|
||||
margin-left: 1rem;
|
||||
display: inline-block;
|
||||
transition: .2s ease all;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border-radius: var(--pk-contributors-post-arrow-border-radius);
|
||||
}
|
||||
|
||||
.pk-widget-contributors .pk-author-posts > .pk-author-posts-single > a:hover:before {
|
||||
color: var(--pk-contributors-post-arrow-color-hover);
|
||||
transition: .2s ease all;
|
||||
background: var(--pk-contributors-post-arrow-backgroynd-hover);
|
||||
}
|
||||
+107
@@ -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-contributors {
|
||||
--pk-contributors-item-border-color: #eeeeee;
|
||||
--pk-contributors-post-arrow-color: #ced4da;
|
||||
--pk-contributors-post-arrow-color-hover: #fff;
|
||||
--pk-contributors-post-arrow-backgroynd-hover: #6c757d;
|
||||
--pk-contributors-avatar-border-radius: 100%;
|
||||
--pk-contributors-post-arrow-border-radius: 100%;
|
||||
--pk-contributors-description-font-size: 80%;
|
||||
--pk-contributors-post-link-font-size: 0.875rem;
|
||||
--pk-contributors-post-link-line-height: 1.25rem;
|
||||
--pk-contributors-post-arrow-font-size: 14px;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------*/
|
||||
.pk-widget-contributors .pk-author-item {
|
||||
display: flex;
|
||||
margin-top: 1rem;
|
||||
padding-top: 1rem;
|
||||
border-top: 1px var(--pk-contributors-item-border-color) solid;
|
||||
}
|
||||
|
||||
.pk-widget-contributors .pk-author-item:first-child {
|
||||
margin-top: 0;
|
||||
padding-top: 0;
|
||||
border-top: none;
|
||||
}
|
||||
|
||||
.pk-widget-contributors .pk-author-avatar {
|
||||
flex: 0 0 80px;
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
margin-right: 1rem;
|
||||
-o-object-fit: cover;
|
||||
object-fit: cover;
|
||||
font-family: 'object-fit: cover;';
|
||||
}
|
||||
|
||||
.pk-widget-contributors .pk-author-avatar img {
|
||||
border-radius: var(--pk-contributors-avatar-border-radius);
|
||||
}
|
||||
|
||||
.pk-widget-contributors .pk-author-data {
|
||||
flex-grow: 1;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.pk-widget-contributors .pk-author-data .author-name {
|
||||
margin-top: 0;
|
||||
margin-bottom: .5rem;
|
||||
}
|
||||
|
||||
.pk-widget-contributors .pk-author-data .author-description {
|
||||
font-size: var(--pk-contributors-description-font-size);
|
||||
margin-bottom: .5rem;
|
||||
}
|
||||
|
||||
.pk-widget-contributors .pk-social-links-wrap {
|
||||
margin-top: .5rem;
|
||||
}
|
||||
|
||||
.pk-widget-contributors .pk-author-posts {
|
||||
margin-top: 2rem;
|
||||
}
|
||||
|
||||
.pk-widget-contributors .pk-author-posts > .pk-author-posts-single > a {
|
||||
display: flex;
|
||||
padding-top: 0.25rem;
|
||||
padding-bottom: 0.25rem;
|
||||
position: relative;
|
||||
padding-left: 2rem;
|
||||
font-size: var(--pk-contributors-post-link-font-size);
|
||||
line-height: var(--pk-contributors-post-link-line-height);
|
||||
}
|
||||
|
||||
.pk-widget-contributors .pk-author-posts > .pk-author-posts-single > a:before {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 4px;
|
||||
font-family: 'powerkit-icons';
|
||||
content: "\e940";
|
||||
color: var(--pk-contributors-post-arrow-color);
|
||||
font-size: var(--pk-contributors-post-arrow-font-size);
|
||||
margin-right: 1rem;
|
||||
display: inline-block;
|
||||
transition: .2s ease all;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border-radius: var(--pk-contributors-post-arrow-border-radius);
|
||||
}
|
||||
|
||||
.pk-widget-contributors .pk-author-posts > .pk-author-posts-single > a:hover:before {
|
||||
color: var(--pk-contributors-post-arrow-color-hover);
|
||||
transition: .2s ease all;
|
||||
background: var(--pk-contributors-post-arrow-backgroynd-hover);
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
<?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_Facebook_Admin extends Powerkit_Module_Admin {
|
||||
|
||||
/**
|
||||
* Initialize
|
||||
*/
|
||||
public function initialize() {
|
||||
add_action( 'admin_init', array( $this, 'register_settings_section' ) );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Register admin page
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function register_settings_section() {
|
||||
|
||||
add_settings_section( 'powerkit_facebook_settings', sprintf( '<span id="%s">%s</span>', powerkit_get_page_slug( $this->slug ), esc_html__( 'Facebook Comments', 'powerkit' ) ), array( $this, 'powerkit_facebook_settings_callback' ), 'discussion' );
|
||||
|
||||
add_settings_field( 'powerkit_facebook_enable_comments', esc_html__( 'Enable Facebook Comments', 'powerkit' ), array( $this, 'powerkit_facebook_enable_comments_callback' ), 'discussion', 'powerkit_facebook_settings' );
|
||||
add_settings_field( 'powerkit_facebook_number_comments', esc_html__( 'Number of Comments', 'powerkit' ), array( $this, 'powerkit_facebook_number_comments_callback' ), 'discussion', 'powerkit_facebook_settings' );
|
||||
|
||||
register_setting( 'discussion', 'powerkit_facebook_enable_comments' );
|
||||
register_setting( 'discussion', 'powerkit_facebook_number_comments_callback' );
|
||||
|
||||
$locations = apply_filters( 'powerkit_facebook_comments_location', array() );
|
||||
|
||||
// If locations > 1.
|
||||
if ( count( (array) $locations ) > 1 ) {
|
||||
add_settings_field( 'powerkit_facebook_location', esc_html__( 'Location', 'powerkit' ), array( $this, 'powerkit_facebook_location_callback' ), 'discussion', 'powerkit_facebook_settings' );
|
||||
register_setting( 'discussion', 'powerkit_facebook_location' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Section Description.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function powerkit_facebook_settings_callback() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Field | Enable Facebook Comments.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function powerkit_facebook_enable_comments_callback() {
|
||||
?>
|
||||
<input class="regular-text" id="powerkit_facebook_enable_comments" name="powerkit_facebook_enable_comments" type="checkbox" value="true" <?php checked( (bool) get_option( 'powerkit_facebook_enable_comments', false ) ); ?>>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Field | Number of Comments.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function powerkit_facebook_number_comments_callback() {
|
||||
?>
|
||||
<input class="small-text" id="powerkit_facebook_number_comments" name="powerkit_facebook_number_comments" type="number" value="<?php echo esc_attr( get_option( 'powerkit_facebook_number_comments', 10 ) ); ?>" /> <?php esc_html_e( 'items', 'powerkit' ); ?>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Field | Location.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function powerkit_facebook_location_callback() {
|
||||
$locations = apply_filters( 'powerkit_facebook_comments_location', array() );
|
||||
?>
|
||||
<select class="regular-text" name="powerkit_facebook_location" id="powerkit_facebook_location">
|
||||
<?php
|
||||
if ( $locations ) {
|
||||
foreach ( $locations as $key => $item ) {
|
||||
?>
|
||||
<option value="<?php echo esc_attr( $key ); ?>" <?php selected( get_option( 'powerkit_facebook_location' ), $key ); ?>><?php echo esc_attr( $item['name'] ); ?></option>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
/**
|
||||
* Facebook Integration
|
||||
*
|
||||
* @package Powerkit
|
||||
* @subpackage Modules
|
||||
*/
|
||||
|
||||
if ( class_exists( 'Powerkit_Module' ) ) {
|
||||
/**
|
||||
* Init module
|
||||
*/
|
||||
class Powerkit_Facebook extends Powerkit_Module {
|
||||
|
||||
/**
|
||||
* Register module
|
||||
*/
|
||||
public function register() {
|
||||
$this->name = esc_html__( 'Facebook Integration', 'powerkit' );
|
||||
$this->desc = esc_html__( 'Display your Facebook Fanpage widget in your sidebar or post content via a shortcode. Enable Facebook comments next to or instead of WordPress comments.', 'powerkit' );
|
||||
$this->slug = 'facebook_integration';
|
||||
$this->type = 'default';
|
||||
$this->category = 'social';
|
||||
$this->priority = 30;
|
||||
$this->public = true;
|
||||
$this->enabled = true;
|
||||
$this->load_extensions = array(
|
||||
'connect',
|
||||
);
|
||||
$this->links = array(
|
||||
array(
|
||||
'name' => esc_html__( 'Go to settings', 'powerkit' ),
|
||||
'url' => admin_url( sprintf( 'options-discussion.php#%s', powerkit_get_page_slug( $this->slug ) ) ),
|
||||
),
|
||||
array(
|
||||
'name' => esc_html__( 'View documentation', 'powerkit' ),
|
||||
'url' => powerkit_get_setting( 'documentation' ) . '/social-integrations/facebook-integration/',
|
||||
'target' => '_blank',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize module
|
||||
*/
|
||||
public function initialize() {
|
||||
|
||||
/* Load the required dependencies for this module */
|
||||
|
||||
// Helpers Functions for the module.
|
||||
require_once dirname( __FILE__ ) . '/helpers/helper-powerkit-facebook.php';
|
||||
|
||||
// The classes responsible for defining all actions.
|
||||
require_once dirname( __FILE__ ) . '/public/class-powerkit-facebook-public.php';
|
||||
require_once dirname( __FILE__ ) . '/public/class-powerkit-facebook-fanpage-widget.php';
|
||||
require_once dirname( __FILE__ ) . '/public/class-powerkit-facebook-fanpage-shortcode.php';
|
||||
|
||||
// Gutenberg blocks.
|
||||
if ( function_exists( 'register_block_type' ) ) {
|
||||
require_once dirname( __FILE__ ) . '/public/class-powerkit-facebook-fanpage-block.php';
|
||||
}
|
||||
|
||||
// Admin and public area.
|
||||
require_once dirname( __FILE__ ) . '/admin/class-powerkit-facebook-admin.php';
|
||||
require_once dirname( __FILE__ ) . '/public/class-powerkit-facebook-public.php';
|
||||
|
||||
new Powerkit_Facebook_Admin( $this->slug );
|
||||
new Powerkit_Facebook_Public( $this->slug );
|
||||
}
|
||||
}
|
||||
|
||||
new Powerkit_Facebook();
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
* Helpers Facebook
|
||||
*
|
||||
* @package Powerkit
|
||||
* @subpackage Modules/Helper
|
||||
*/
|
||||
|
||||
/**
|
||||
* Facebook load sdk.
|
||||
*/
|
||||
function powerkit_facebook_load_sdk() {
|
||||
?>
|
||||
<div id="fb-root"></div>
|
||||
<script>( function( d, s, id ) {
|
||||
var js, fjs = d.getElementsByTagName( s )[0];
|
||||
if ( d.getElementById( id ) ) return;
|
||||
js = d.createElement( s ); js.id = id;
|
||||
js.src = "//connect.facebook.net/<?php echo esc_html( powerkit_get_locale() ); ?>/sdk.js#xfbml=1&version=v2.5&appId=<?php echo esc_html( powerkit_connect( 'facebook_app_id' ) ); ?>";
|
||||
fjs.parentNode.insertBefore( js, fjs );
|
||||
}( document, 'script', 'facebook-jssdk' ) );</script>
|
||||
<?php
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=2)}([function(e,t,n){var r;
|
||||
/*!
|
||||
Copyright (c) 2018 Jed Watson.
|
||||
Licensed under the MIT License (MIT), see
|
||||
http://jedwatson.github.io/classnames
|
||||
*/!function(){"use strict";var n={}.hasOwnProperty;function o(){for(var e=[],t=0;t<arguments.length;t++){var r=arguments[t];if(r){var a=typeof r;if("string"===a||"number"===a)e.push(r);else if(Array.isArray(r)){if(r.length){var i=o.apply(null,r);i&&e.push(i)}}else if("object"===a)if(r.toString===Object.prototype.toString)for(var u in r)n.call(r,u)&&r[u]&&e.push(u);else e.push(r.toString())}}return e.join(" ")}e.exports?(o.default=o,e.exports=o):void 0===(r=function(){return o}.apply(t,[]))||(e.exports=r)}()},function(e,t,n){!function(e){"use strict";function t(e,t,n,r){var o,a=!1,i=0;function u(){o&&clearTimeout(o)}function f(){for(var f=arguments.length,c=new Array(f),l=0;l<f;l++)c[l]=arguments[l];var s=this,p=Date.now()-i;function b(){i=Date.now(),n.apply(s,c)}function d(){o=void 0}a||(r&&!o&&b(),u(),void 0===r&&p>e?b():!0!==t&&(o=setTimeout(r?d:b,void 0===r?e-p:e)))}return"boolean"!=typeof t&&(r=n,n=t,t=void 0),f.cancel=function(){u(),a=!0},f}e.debounce=function(e,n,r){return void 0===r?t(e,n,!1):t(e,r,!1!==n)},e.throttle=t,Object.defineProperty(e,"__esModule",{value:!0})}(t)},function(e,t,n){e.exports=n(6)},,,,function(e,t,n){"use strict";n.r(t);var r=n(0),o=n.n(r),a=n(1);function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function f(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function l(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=b(e);if(t){var o=b(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return s(this,n)}}function s(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?p(e):t}function p(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function b(e){return(b=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var d=wp.i18n.__,y=wp.element,h=y.Component,m=y.Fragment,v=y.createRef,w=wp.components,g=w.Placeholder,O=w.Disabled,_=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&c(e,t)}(s,e);var t,n,r,i=l(s);function s(){var e;return u(this,s),(e=i.apply(this,arguments)).fbRef=v(),e.maybeInit=Object(a.debounce)(300,e.maybeInit.bind(p(e))),e}return t=s,(n=[{key:"componentDidMount",value:function(){this.maybeInit()}},{key:"componentDidUpdate",value:function(){this.maybeInit()}},{key:"maybeInit",value:function(){var e=this.props.attributes.href;if(this.fbRef&&this.fbRef.current&&e&&window.FB&&window.FB.XFBML){var t=this.fbRef.current,n=this.props.attributes,r=n.showCover,o=n.showFacepile,a=n.showPosts,i=n.smallHeader,u=r?"false":"true";o=o?"true":"false",a=a?"true":"false",i=i?"true":"false";var f=t.getAttribute("fb-iframe-plugin-query");if(f){var c=!1;try{c=JSON.parse('{"'+decodeURIComponent(f).replace(/"/g,'\\"').replace(/&/g,'","').replace(/=/g,'":"')+'"}')}catch(e){c=!1}if(c&&c.href===e&&c.hide_cover===u&&c.show_facepile===o&&c.show_posts===a&&c.small_header===i)return}t.attributes["fb-xfbml-state"]&&(t.attributes["fb-xfbml-state"]="re-rendering"),FB.XFBML.parse(t.parentNode)}}},{key:"render",value:function(){this.props.setAttributes;var e=this.props.className,t=this.props.attributes,n=t.href,r=t.showCover,a=t.showFacepile,i=t.showPosts,u=t.smallHeader,f=t.canvasClassName;return e=o()("fb-page-wrapper",f,e),wp.element.createElement(m,null,n?wp.element.createElement(O,null,wp.element.createElement("div",{className:e},wp.element.createElement("div",{className:"fb-page",ref:this.fbRef,"data-href":n,"data-hide-cover":r?"false":"true","data-show-facepile":a?"true":"false","data-show-posts":i?"true":"false","data-small-header":u?"true":"false","data-adapt-container-width":"true"}))):wp.element.createElement(g,null,d("Please, enter Facebook Fanpage URL.")))}}])&&f(t.prototype,n),r&&f(t,r),s}(h);(0,wp.hooks.addFilter)("canvas.customBlock.editRender","canvas/facebook-fanpage/editRender",(function(e,t){return"canvas/facebook-fanpage"===t.name?wp.element.createElement(_,t):e}))}]);
|
||||
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
const {
|
||||
addFilter,
|
||||
} = wp.hooks;
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
import FacebookFanpageBlockEdit from './edit.jsx';
|
||||
|
||||
/**
|
||||
* Custom block Edit output for FacebookFanpage block.
|
||||
*
|
||||
* @param {JSX} edit Original block edit.
|
||||
* @param {Object} blockProps Block data.
|
||||
*
|
||||
* @return {JSX} Block edit.
|
||||
*/
|
||||
function editRender(edit, blockProps) {
|
||||
if ('canvas/facebook-fanpage' === blockProps.name) {
|
||||
return (
|
||||
<FacebookFanpageBlockEdit {...blockProps} />
|
||||
);
|
||||
}
|
||||
|
||||
return edit;
|
||||
}
|
||||
|
||||
addFilter('canvas.customBlock.editRender', 'canvas/facebook-fanpage/editRender', editRender);
|
||||
@@ -0,0 +1,152 @@
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
import classnames from 'classnames';
|
||||
import { debounce } from 'throttle-debounce';
|
||||
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
const { __ } = wp.i18n;
|
||||
|
||||
const {
|
||||
Component,
|
||||
Fragment,
|
||||
createRef,
|
||||
} = wp.element;
|
||||
|
||||
const {
|
||||
Placeholder,
|
||||
Disabled,
|
||||
} = wp.components;
|
||||
|
||||
/**
|
||||
* Component
|
||||
*/
|
||||
export default class FacebookFanpageBlockEdit extends Component {
|
||||
constructor() {
|
||||
super( ...arguments );
|
||||
|
||||
this.fbRef = createRef();
|
||||
|
||||
this.maybeInit = debounce( 300, this.maybeInit.bind( this ) );
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.maybeInit();
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
this.maybeInit();
|
||||
}
|
||||
|
||||
maybeInit() {
|
||||
const {
|
||||
href,
|
||||
} = this.props.attributes;
|
||||
|
||||
if ( ! this.fbRef || ! this.fbRef.current ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! href || ! window.FB || ! window.FB.XFBML ) {
|
||||
return;
|
||||
}
|
||||
|
||||
const $ref = this.fbRef.current;
|
||||
|
||||
let {
|
||||
showCover,
|
||||
showFacepile,
|
||||
showPosts,
|
||||
smallHeader,
|
||||
} = this.props.attributes;
|
||||
|
||||
const hideCover = showCover ? 'false' : 'true';
|
||||
showFacepile = showFacepile ? 'true' : 'false';
|
||||
showPosts = showPosts ? 'true' : 'false';
|
||||
smallHeader = smallHeader ? 'true' : 'false';
|
||||
|
||||
// check if already rendered
|
||||
const $query = $ref.getAttribute( 'fb-iframe-plugin-query' );
|
||||
if ( $query ) {
|
||||
let queryObj = false;
|
||||
|
||||
try {
|
||||
// thanks https://stackoverflow.com/questions/8648892/convert-url-parameters-to-a-javascript-object
|
||||
queryObj = JSON.parse('{"' + decodeURIComponent( $query ).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g,'":"') + '"}');
|
||||
} catch( e ) {
|
||||
queryObj = false;
|
||||
}
|
||||
|
||||
if (
|
||||
queryObj &&
|
||||
queryObj.href === href &&
|
||||
queryObj.hide_cover === hideCover &&
|
||||
queryObj.show_facepile === showFacepile &&
|
||||
queryObj.show_posts === showPosts &&
|
||||
queryObj.small_header === smallHeader
|
||||
) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// try to re-render
|
||||
if ( $ref.attributes['fb-xfbml-state'] ) {
|
||||
$ref.attributes['fb-xfbml-state'] = 're-rendering';
|
||||
}
|
||||
|
||||
FB.XFBML.parse( $ref.parentNode );
|
||||
}
|
||||
|
||||
render() {
|
||||
const {
|
||||
setAttributes,
|
||||
} = this.props;
|
||||
|
||||
let {
|
||||
className,
|
||||
} = this.props;
|
||||
|
||||
const {
|
||||
href,
|
||||
showCover,
|
||||
showFacepile,
|
||||
showPosts,
|
||||
smallHeader,
|
||||
canvasClassName,
|
||||
} = this.props.attributes;
|
||||
|
||||
className = classnames(
|
||||
'fb-page-wrapper',
|
||||
canvasClassName,
|
||||
className
|
||||
);
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
{ href ? (
|
||||
<Disabled>
|
||||
<div
|
||||
className={ className }
|
||||
>
|
||||
<div className="fb-page"
|
||||
ref={ this.fbRef }
|
||||
data-href={ href }
|
||||
data-hide-cover={ showCover ? 'false' : 'true' }
|
||||
data-show-facepile={ showFacepile ? 'true' : 'false' }
|
||||
data-show-posts={ showPosts ? 'true' : 'false' }
|
||||
data-small-header={ smallHeader ? 'true' : 'false' }
|
||||
data-adapt-container-width="true"
|
||||
/>
|
||||
</div>
|
||||
</Disabled>
|
||||
) : (
|
||||
<Placeholder>
|
||||
{ __( 'Please, enter Facebook Fanpage URL.' ) }
|
||||
</Placeholder>
|
||||
) }
|
||||
</Fragment>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* Facebook Fanpage block template
|
||||
*
|
||||
* @var $attributes - block attributes
|
||||
* @var $options - layout options
|
||||
*
|
||||
* @link https://codesupply.co
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package PowerKit
|
||||
* @subpackage PowerKit/templates
|
||||
*/
|
||||
|
||||
?>
|
||||
|
||||
<div class="<?php echo esc_attr( $attributes['className'] ); ?>" <?php echo ( isset( $attributes['anchor'] ) ? ' id="' . esc_attr( $attributes['anchor'] ) . '"' : '' ); ?>>
|
||||
<div class="fb-page"
|
||||
data-href="<?php echo esc_url( $attributes['href'] ); ?>"
|
||||
data-hide-cover="<?php echo esc_attr( $attributes['showCover'] ? 'false' : 'true' ); ?>"
|
||||
data-show-facepile="<?php echo esc_attr( $attributes['showFacepile'] ? 'true' : 'false' ); ?>"
|
||||
data-show-posts="<?php echo esc_attr( $attributes['showPosts'] ? 'true' : 'false' ); ?>"
|
||||
data-small-header="<?php echo esc_attr( $attributes['smallHeader'] ? 'true' : 'false' ); ?>"
|
||||
data-adapt-container-width="true"
|
||||
></div>
|
||||
</div>
|
||||
+125
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
/**
|
||||
* Facebook Fanpage Block.
|
||||
*
|
||||
* @link https://codesupply.co
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package Powerkit
|
||||
* @subpackage Modules/public
|
||||
*/
|
||||
|
||||
/**
|
||||
* Initialize Facebook Fanpage block.
|
||||
*/
|
||||
class Powerkit_Block_Facebook_Fanpage {
|
||||
|
||||
/**
|
||||
* Initialize
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'init', array( $this, 'init' ) );
|
||||
add_filter( 'canvas_register_block_type', array( $this, 'register_block_type' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue the block's assets for the editor.
|
||||
*/
|
||||
public function init() {
|
||||
// Editor Scripts.
|
||||
wp_register_script(
|
||||
'powerkit-block-facebook-fanpage-editor-script',
|
||||
plugins_url( 'block/block.js', __FILE__ ),
|
||||
array( 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-editor', 'lodash', 'jquery' ),
|
||||
filemtime( plugin_dir_path( __FILE__ ) . 'block/block.js' ),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register block
|
||||
*
|
||||
* @param array $blocks all registered blocks.
|
||||
* @return array
|
||||
*/
|
||||
public function register_block_type( $blocks ) {
|
||||
$blocks[] = array(
|
||||
'name' => 'canvas/facebook-fanpage',
|
||||
'title' => esc_html__( 'Facebook Fanpage', 'powerkit' ),
|
||||
'description' => '',
|
||||
'category' => 'canvas',
|
||||
'keywords' => array( 'facebook', 'fanpage' ),
|
||||
'icon' => '
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
|
||||
<path d="M20 3H4C3.4 3 3 3.4 3 4V20C3 20.5 3.4 21 4 21H12.6V14H10.3V11.3H12.6V9.3C12.6 7 14 5.7 16.1 5.7C17.1 5.7 17.9 5.8 18.2 5.8V8.2H16.8C15.7 8.2 15.5 8.7 15.5 9.5V11.2H18.2L17.8 14H15.5V21H20C20.5 21 21 20.6 21 20V4C21 3.4 20.6 3 20 3Z" />
|
||||
</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,
|
||||
),
|
||||
),
|
||||
'layouts' => array(),
|
||||
|
||||
// Set fields just for add block attributes.
|
||||
// Editor render for this block is custom JSX
|
||||
// so we don't need to render fields automatically.
|
||||
'fields' => array(
|
||||
array(
|
||||
'key' => 'href',
|
||||
'label' => esc_html__( 'Facebook Fanpage URL', 'powerkit' ),
|
||||
'type' => 'text',
|
||||
'section' => 'general',
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'key' => 'showCover',
|
||||
'label' => esc_html__( 'Display Cover', 'powerkit' ),
|
||||
'type' => 'toggle',
|
||||
'section' => 'general',
|
||||
'default' => true,
|
||||
),
|
||||
array(
|
||||
'key' => 'showFacepile',
|
||||
'label' => esc_html__( 'Display Facepile', 'powerkit' ),
|
||||
'type' => 'toggle',
|
||||
'section' => 'general',
|
||||
'default' => false,
|
||||
),
|
||||
array(
|
||||
'key' => 'showPosts',
|
||||
'label' => esc_html__( 'Display Posts', 'powerkit' ),
|
||||
'type' => 'toggle',
|
||||
'section' => 'general',
|
||||
'default' => false,
|
||||
),
|
||||
array(
|
||||
'key' => 'smallHeader',
|
||||
'label' => esc_html__( 'Small Header', 'powerkit' ),
|
||||
'type' => 'toggle',
|
||||
'section' => 'general',
|
||||
'default' => false,
|
||||
),
|
||||
),
|
||||
'template' => dirname( __FILE__ ) . '/block/render.php',
|
||||
// enqueue registered scripts/styles.
|
||||
'editor_script' => 'powerkit-block-facebook-fanpage-editor-script',
|
||||
);
|
||||
|
||||
return $blocks;
|
||||
}
|
||||
}
|
||||
|
||||
new Powerkit_Block_Facebook_Fanpage();
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
/**
|
||||
* Shortcode Facebook Fanpage
|
||||
*
|
||||
* @link https://codesupply.co
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package PowerKit
|
||||
* @subpackage PowerKit/shortcodes
|
||||
*/
|
||||
|
||||
/**
|
||||
* Facebook Fanpage Shortcode
|
||||
*
|
||||
* @param array $atts User defined attributes in shortcode tag.
|
||||
* @param string $content Shorcode tag content.
|
||||
* @return string Shortcode result HTML.
|
||||
*/
|
||||
function powerkit_facebook_fanpage_shortcode( $atts, $content = '' ) {
|
||||
|
||||
$params = powerkit_shortcode_atts( shortcode_atts( array(
|
||||
'href' => '',
|
||||
'hide_cover' => false,
|
||||
'show_facepile' => false,
|
||||
'show_posts' => false,
|
||||
'small_header' => false,
|
||||
'adapt_container_width' => true,
|
||||
), $atts ) );
|
||||
|
||||
$params['hide_cover'] = filter_var( $params['hide_cover'], FILTER_VALIDATE_BOOLEAN );
|
||||
$params['show_facepile'] = filter_var( $params['show_facepile'], FILTER_VALIDATE_BOOLEAN );
|
||||
$params['show_posts'] = filter_var( $params['show_posts'], FILTER_VALIDATE_BOOLEAN );
|
||||
$params['small_header'] = filter_var( $params['small_header'], FILTER_VALIDATE_BOOLEAN );
|
||||
$params['adapt_container_width'] = filter_var( $params['adapt_container_width'], FILTER_VALIDATE_BOOLEAN );
|
||||
|
||||
ob_start();
|
||||
|
||||
if ( $params['href'] ) {
|
||||
?>
|
||||
<div class="fb-page-wrapper">
|
||||
<div class="fb-page"
|
||||
data-href="<?php echo esc_attr( $params['href'] ); ?>"
|
||||
data-hide-cover="<?php echo esc_attr( $params['hide_cover'] ? 'true' : 'false' ); ?>"
|
||||
data-show-facepile="<?php echo esc_attr( $params['show_facepile'] ? 'true' : 'false' ); ?>"
|
||||
data-show-posts="<?php echo esc_attr( $params['show_posts'] ? 'true' : 'false' ); ?>"
|
||||
data-small-header="<?php echo esc_attr( $params['small_header'] ? 'true' : 'false' ); ?>"
|
||||
data-adapt-container-width="<?php echo esc_attr( $params['adapt_container_width'] ? 'true' : 'false' ); ?>">
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
} else {
|
||||
powerkit_alert_warning( esc_html__( 'The "Facebook Fanpage URL" field is required!', 'powerkit' ) );
|
||||
}
|
||||
|
||||
return ob_get_clean();
|
||||
}
|
||||
add_shortcode( 'powerkit_facebook_fanpage', 'powerkit_facebook_fanpage_shortcode' );
|
||||
|
||||
/**
|
||||
* Map Facebook Fanpage Shortcode into the Basic Shortcodes Plugin
|
||||
*/
|
||||
if ( function_exists( 'powerkit_basic_shortcodes_register' ) ) :
|
||||
|
||||
powerkit_basic_shortcodes_register( array(
|
||||
'name' => 'facebook_fanpage',
|
||||
'title' => esc_html__( 'Facebook Fanpage', 'powerkit' ),
|
||||
'priority' => 150,
|
||||
'base' => 'powerkit_facebook_fanpage',
|
||||
'autoregister' => false,
|
||||
'fields' => array(
|
||||
array(
|
||||
'type' => 'input',
|
||||
'name' => 'href',
|
||||
'label' => esc_html__( 'Facebook fanpage URL', 'powerkit' ),
|
||||
),
|
||||
array(
|
||||
'type' => 'checkbox',
|
||||
'name' => 'hide_cover',
|
||||
'label' => esc_html__( 'Hide cover', 'powerkit' ),
|
||||
'default' => false,
|
||||
),
|
||||
array(
|
||||
'type' => 'checkbox',
|
||||
'name' => 'show_facepile',
|
||||
'label' => esc_html__( 'Show facepile', 'powerkit' ),
|
||||
'default' => false,
|
||||
),
|
||||
array(
|
||||
'type' => 'checkbox',
|
||||
'name' => 'show_posts',
|
||||
'label' => esc_html__( 'Show posts', 'powerkit' ),
|
||||
'default' => false,
|
||||
),
|
||||
array(
|
||||
'type' => 'checkbox',
|
||||
'name' => 'small_header',
|
||||
'label' => esc_html__( 'Small header', 'powerkit' ),
|
||||
'default' => false,
|
||||
),
|
||||
),
|
||||
) );
|
||||
|
||||
endif;
|
||||
+162
@@ -0,0 +1,162 @@
|
||||
<?php
|
||||
/**
|
||||
* Widget Facebook Fanpage
|
||||
*
|
||||
* @link https://codesupply.co
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package PowerKit
|
||||
* @subpackage PowerKit/widgets
|
||||
*/
|
||||
|
||||
/**
|
||||
* Widget Facebook Fanpage Class
|
||||
*/
|
||||
class Powerkit_Facebook_Fanpage_Widget extends WP_Widget {
|
||||
|
||||
/**
|
||||
* Sets up a new widget instance.
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
$this->default_settings = apply_filters( 'powerkit_facebook_fanpage_widget_settings', array(
|
||||
'title' => esc_html__( 'Facebook Fanpage', 'powerkit' ),
|
||||
'href' => '',
|
||||
'hide_cover' => false,
|
||||
'show_facepile' => false,
|
||||
'show_posts' => false,
|
||||
'small_header' => false,
|
||||
'adapt_container_width' => true,
|
||||
) );
|
||||
|
||||
$widget_details = array(
|
||||
'classname' => 'powerkit_facebook_fanpage_widget',
|
||||
'description' => esc_html__( 'A Facebook Fanpage widget.', 'powerkit' ),
|
||||
);
|
||||
parent::__construct( 'powerkit_facebook_fanpage_widget', esc_html__( 'Facebook Fanpage', '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 );
|
||||
|
||||
// Before Widget.
|
||||
echo $args['before_widget']; // XSS OK.
|
||||
?>
|
||||
|
||||
<div class="widget-body">
|
||||
<?php
|
||||
|
||||
// Title.
|
||||
if ( $params['title'] ) {
|
||||
echo $args['before_title'] . apply_filters( 'widget_title', wp_kses( $params['title'], 'pk-title' ), $instance, $this->id_base ) . $args['after_title']; // XSS.
|
||||
}
|
||||
|
||||
if ( $params['href'] ) {
|
||||
?>
|
||||
<div class="fb-page-wrapper">
|
||||
<div class="fb-page"
|
||||
data-href="<?php echo esc_attr( $params['href'] ); ?>"
|
||||
data-hide-cover="<?php echo esc_attr( $params['hide_cover'] ? 'true' : 'false' ); ?>"
|
||||
data-show-facepile="<?php echo esc_attr( $params['show_facepile'] ? 'true' : 'false' ); ?>"
|
||||
data-show-posts="<?php echo esc_attr( $params['show_posts'] ? 'true' : 'false' ); ?>"
|
||||
data-small-header="<?php echo esc_attr( $params['small_header'] ? 'true' : 'false' ); ?>"
|
||||
data-adapt-container-width="<?php echo esc_attr( $params['adapt_container_width'] ? 'true' : 'false' ); ?>"
|
||||
data-width="500px">
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
} else {
|
||||
powerkit_alert_warning( esc_html__( 'The "Facebook Fanpage URL" field is required!', 'powerkit' ) );
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
||||
// After Widget.
|
||||
echo $args['after_widget']; // XSS OK.
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
// Hide cover.
|
||||
if ( ! isset( $instance['hide_cover'] ) ) {
|
||||
$instance['hide_cover'] = false;
|
||||
}
|
||||
|
||||
// Show facepile.
|
||||
if ( ! isset( $instance['show_facepile'] ) ) {
|
||||
$instance['show_facepile'] = false;
|
||||
}
|
||||
|
||||
// Show posts.
|
||||
if ( ! isset( $instance['show_posts'] ) ) {
|
||||
$instance['show_posts'] = false;
|
||||
}
|
||||
|
||||
// Small header.
|
||||
if ( ! isset( $instance['small_header'] ) ) {
|
||||
$instance['small_header'] = false;
|
||||
}
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs the widget settings form.
|
||||
*
|
||||
* @param array $instance Current settings.
|
||||
*/
|
||||
public function form( $instance ) {
|
||||
$params = array_merge( $this->default_settings, $instance );
|
||||
?>
|
||||
<!-- 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>
|
||||
|
||||
<!-- Facebook Fanpage URL -->
|
||||
<p><label for="<?php echo esc_attr( $this->get_field_id( 'href' ) ); ?>"><?php esc_html_e( 'Facebook fanpage URL:', 'powerkit' ); ?></label>
|
||||
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'href' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'href' ) ); ?>" type="text" value="<?php echo esc_attr( $params['href'] ); ?>" /></p>
|
||||
|
||||
<!-- Hide Cover -->
|
||||
<p><input id="<?php echo esc_attr( $this->get_field_id( 'hide_cover' ) ); ?>" class="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'hide_cover' ) ); ?>" type="checkbox" <?php checked( (bool) $params['hide_cover'] ); ?> />
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'hide_cover' ) ); ?>"><?php esc_html_e( 'Hide cover', 'powerkit' ); ?></label></p>
|
||||
|
||||
<!-- Show Facepile -->
|
||||
<p><input id="<?php echo esc_attr( $this->get_field_id( 'show_facepile' ) ); ?>" class="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'show_facepile' ) ); ?>" type="checkbox" <?php checked( (bool) $params['show_facepile'] ); ?> />
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'show_facepile' ) ); ?>"><?php esc_html_e( 'Show facepile', 'powerkit' ); ?></label></p>
|
||||
|
||||
<!-- Show Posts -->
|
||||
<p><input id="<?php echo esc_attr( $this->get_field_id( 'show_posts' ) ); ?>" class="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'show_posts' ) ); ?>" type="checkbox" <?php checked( (bool) $params['show_posts'] ); ?> />
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'show_posts' ) ); ?>"><?php esc_html_e( 'Show posts', 'powerkit' ); ?></label></p>
|
||||
|
||||
<!-- Small Header -->
|
||||
<p><input id="<?php echo esc_attr( $this->get_field_id( 'small_header' ) ); ?>" class="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'small_header' ) ); ?>" type="checkbox" <?php checked( (bool) $params['small_header'] ); ?> />
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'small_header' ) ); ?>"><?php esc_html_e( 'Small header', 'powerkit' ); ?></label></p>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register Widget
|
||||
*/
|
||||
function powerkit_widget_init_facebook() {
|
||||
register_widget( 'Powerkit_Facebook_Fanpage_Widget' );
|
||||
}
|
||||
add_action( 'widgets_init', 'powerkit_widget_init_facebook' );
|
||||
+157
@@ -0,0 +1,157 @@
|
||||
<?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_Facebook_Public extends Powerkit_Module_Public {
|
||||
|
||||
/**
|
||||
* Initialize
|
||||
*/
|
||||
public function initialize() {
|
||||
add_action( 'init', array( $this, 'facebook_load_sdk' ) );
|
||||
add_action( 'current_screen', array( $this, 'facebook_load_sdk_gutenberg' ) );
|
||||
add_action( 'init', array( $this, 'register_locations' ) );
|
||||
add_filter( 'powerkit_facebook_comments_location', array( $this, 'location_default' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Init Facebook
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access private
|
||||
*/
|
||||
public function facebook_load_sdk() {
|
||||
add_action( 'wp_footer', 'powerkit_facebook_load_sdk' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Init Facebook in Gutenberg editor
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access private
|
||||
*/
|
||||
public function facebook_load_sdk_gutenberg() {
|
||||
global $current_screen;
|
||||
|
||||
$current_screen = get_current_screen();
|
||||
|
||||
// add on the editor page.
|
||||
if ( method_exists( $current_screen, 'is_block_editor' ) && $current_screen->is_block_editor() ) {
|
||||
add_action( 'admin_footer', 'powerkit_facebook_load_sdk' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Facebook Register Locations
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access private
|
||||
*/
|
||||
public function register_locations() {
|
||||
|
||||
$locations = apply_filters( 'powerkit_facebook_comments_location', array() );
|
||||
|
||||
$powerkit_facebook_enable_comments = get_option( 'powerkit_facebook_enable_comments' );
|
||||
$powerkit_facebook_location = get_option( 'powerkit_facebook_location' );
|
||||
|
||||
// Select location.
|
||||
if ( isset( $locations[ $powerkit_facebook_location ] ) ) {
|
||||
|
||||
$location = $locations[ $powerkit_facebook_location ];
|
||||
|
||||
} elseif ( isset( $locations['default'] ) ) {
|
||||
|
||||
$location = $locations['default'];
|
||||
|
||||
} else {
|
||||
$location = false;
|
||||
}
|
||||
|
||||
if ( $powerkit_facebook_enable_comments && $location ) {
|
||||
$priority = (int) isset( $location['priority'] ) ? $location['priority'] : 99;
|
||||
|
||||
if ( 'comments_template' === $location['action'] ) {
|
||||
|
||||
add_filter( 'comments_template', function () {
|
||||
return plugin_dir_path( dirname( __FILE__ ) ) . 'public/facebook-comments-template.php';
|
||||
}, $priority );
|
||||
|
||||
} elseif ( 'before_comments' === $location['action'] ) {
|
||||
|
||||
add_action( 'comments_template', function () {
|
||||
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/facebook-comments-template.php';
|
||||
}, $priority );
|
||||
|
||||
} elseif ( 'after_comments' === $location['action'] ) {
|
||||
/**
|
||||
* Filter After WordPress Comments
|
||||
*/
|
||||
function powerkit_filter_comments_template() {
|
||||
remove_filter( 'comments_template', 'powerkit_filter_comments_template', 99 );
|
||||
|
||||
comments_template();
|
||||
|
||||
return plugin_dir_path( dirname( __FILE__ ) ) . 'public/facebook-comments-template.php';
|
||||
}
|
||||
add_filter( 'comments_template', 'powerkit_filter_comments_template', 99 );
|
||||
|
||||
} else {
|
||||
|
||||
add_action( $location['action'], function () {
|
||||
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/facebook-comments-template.php';
|
||||
}, $priority );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter Register Locations
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access private
|
||||
*
|
||||
* @param array $locations List of Locations.
|
||||
*/
|
||||
public function location_default( $locations = array() ) {
|
||||
|
||||
$locations = array(
|
||||
'before_comments' => array(
|
||||
'name' => 'Before WordPress Comments',
|
||||
'action' => 'before_comments',
|
||||
'priority' => 99,
|
||||
),
|
||||
'after_comments' => array(
|
||||
'name' => 'After WordPress Comments',
|
||||
'action' => 'after_comments',
|
||||
'priority' => 99,
|
||||
),
|
||||
'default' => array(
|
||||
'name' => 'In place of WordPress Comments',
|
||||
'action' => 'comments_template',
|
||||
'priority' => 99,
|
||||
),
|
||||
);
|
||||
|
||||
return $locations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the stylesheets for the public-facing side of the site.
|
||||
*/
|
||||
public function wp_enqueue_scripts() {
|
||||
wp_enqueue_style( 'powerkit-facebook', powerkit_style( plugin_dir_url( __FILE__ ) . 'css/public-powerkit-facebook.css' ), array(), powerkit_get_setting( 'version' ), 'all' );
|
||||
|
||||
// Add RTL support.
|
||||
wp_style_add_data( 'powerkit-facebook', 'rtl', 'replace' );
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* All of the CSS for your public-facing functionality should be
|
||||
* included in this file.
|
||||
*/
|
||||
/**
|
||||
* Environment for all styles (variables, additions, etc).
|
||||
*/
|
||||
/*--------------------------------------------------------------*/
|
||||
/*--------------------------------------------------------------*/
|
||||
.fb-page-wrapper {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.fb-comments {
|
||||
margin-top: 3rem;
|
||||
}
|
||||
|
||||
.fb-comments,
|
||||
.fb-comments iframe[style],
|
||||
.fb-comments span {
|
||||
width: 100% !important;
|
||||
right: 0;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* All of the CSS for your public-facing functionality should be
|
||||
* included in this file.
|
||||
*/
|
||||
/**
|
||||
* Environment for all styles (variables, additions, etc).
|
||||
*/
|
||||
/*--------------------------------------------------------------*/
|
||||
/*--------------------------------------------------------------*/
|
||||
.fb-page-wrapper {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.fb-comments {
|
||||
margin-top: 3rem;
|
||||
}
|
||||
|
||||
.fb-comments,
|
||||
.fb-comments iframe[style],
|
||||
.fb-comments span {
|
||||
width: 100% !important;
|
||||
left: 0;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/**
|
||||
* Facebook Comments Template
|
||||
*
|
||||
* @link https://codesupply.co
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package PowerKit
|
||||
* @subpackage PowerKit/templates
|
||||
*/
|
||||
|
||||
?>
|
||||
|
||||
<?php
|
||||
if ( powerkit_connect( 'facebook_app_id' ) ) {
|
||||
?>
|
||||
<div class="fb-comments" data-width="100%" data-href="<?php the_permalink(); ?>" data-numposts="<?php get_option( 'powerkit_facebook_number_comments', 10 ); ?>"></div>
|
||||
<?php
|
||||
} else {
|
||||
/* translators: Facebook API Link. */
|
||||
powerkit_alert_warning( __( 'Warning: Facebook ID not specified!', 'powerkit' ) );
|
||||
}
|
||||
+211
@@ -0,0 +1,211 @@
|
||||
<?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_Featured_Categories_Admin extends Powerkit_Module_Admin {
|
||||
|
||||
/**
|
||||
* Initialize
|
||||
*/
|
||||
public function initialize() {
|
||||
add_action( 'category_add_form_fields', array( $this, 'category_add_form_fields' ), 10 );
|
||||
add_action( 'category_edit_form_fields', array( $this, 'category_edit_form_fields' ), 10, 2 );
|
||||
add_action( 'created_category', array( $this, 'save_category' ), 10, 2 );
|
||||
add_action( 'edited_category', array( $this, 'save_category' ), 10, 2 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add fields to Category
|
||||
*
|
||||
* @param string $taxonomy The taxonomy slug.
|
||||
*/
|
||||
public function category_add_form_fields( $taxonomy ) {
|
||||
wp_nonce_field( 'category_options', 'powerkit_category' );
|
||||
?>
|
||||
<div class="form-field">
|
||||
<label><?php esc_html_e( 'Featured Image', 'powerkit' ); ?></label>
|
||||
|
||||
<div class="pk-featured-image" data-frame-title="<?php esc_html_e( 'Select or upload image', 'powerkit' ); ?>" data-frame-btn-text="<?php esc_html_e( 'Set image', 'powerkit' ); ?>">
|
||||
<p class="uploaded-img-box">
|
||||
<span class="uploaded-image"></span>
|
||||
<input id="powerkit_featured_image" class="uploaded-img-id" name="powerkit_featured_image" type="hidden"/>
|
||||
</p>
|
||||
<p class="hide-if-no-js">
|
||||
<a class="upload-img-link button button-primary" href="#"><?php esc_html_e( 'Upload image', 'powerkit' ); ?></a>
|
||||
<a class="delete-img-link button button-secondary hidden" href="#"><?php esc_html_e( 'Remove image', 'powerkit' ); ?></a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<p><?php esc_html_e( 'This image is used in the category blocks.', 'powerkit' ); ?></p>
|
||||
</div>
|
||||
<br>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit fields from Category
|
||||
*
|
||||
* @param object $tag Current taxonomy term object.
|
||||
* @param string $taxonomy Current taxonomy slug.
|
||||
*/
|
||||
public function category_edit_form_fields( $tag, $taxonomy ) {
|
||||
wp_nonce_field( 'category_options', 'powerkit_category' );
|
||||
|
||||
$powerkit_featured_image = get_term_meta( $tag->term_id, 'powerkit_featured_image', true );
|
||||
?>
|
||||
<tr class="form-field">
|
||||
<th scope="row" valign="top">
|
||||
<label for="powerkit_featured_image"><?php esc_html_e( 'Featured Image', 'powerkit' ); ?></label>
|
||||
</th>
|
||||
<td>
|
||||
<div class="pk-featured-image" data-frame-title="<?php esc_html_e( 'Select or upload image', 'powerkit' ); ?>" data-frame-btn-text="<?php esc_html_e( 'Set image', 'powerkit' ); ?>">
|
||||
<p class="uploaded-img-box">
|
||||
<span class="uploaded-image">
|
||||
<?php if ( $powerkit_featured_image ) : ?>
|
||||
<?php
|
||||
echo wp_get_attachment_image( $powerkit_featured_image, 'large', false, array(
|
||||
'style' => 'max-width:100%; height: auto;',
|
||||
) );
|
||||
?>
|
||||
<?php endif; ?>
|
||||
</span>
|
||||
|
||||
<input id="powerkit_featured_image" class="uploaded-img-id" name="powerkit_featured_image" type="hidden" value="<?php echo esc_attr( $powerkit_featured_image ); ?>" />
|
||||
</p>
|
||||
<p class="hide-if-no-js">
|
||||
<a class="upload-img-link button button-primary <?php echo esc_attr( $powerkit_featured_image ? 'hidden' : '' ); ?>" href="#"><?php esc_html_e( 'Upload image', 'powerkit' ); ?></a>
|
||||
<a class="delete-img-link button button-secondary <?php echo esc_attr( ! $powerkit_featured_image ? 'hidden' : '' ); ?>" href="#"><?php esc_html_e( 'Remove image', 'powerkit' ); ?></a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<p class="description"><?php esc_html_e( 'This image is used in the category blocks.', 'powerkit' ); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Save category fields
|
||||
*
|
||||
* @param int $term_id ID of the term about to be edited.
|
||||
* @param string $taxonomy Taxonomy slug of the related term.
|
||||
*/
|
||||
public function save_category( $term_id, $taxonomy ) {
|
||||
|
||||
// Bail if we're doing an auto save.
|
||||
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// if our nonce isn't there, or we can't verify it, bail.
|
||||
if ( ! isset( $_POST['powerkit_category'] ) || ! wp_verify_nonce( $_POST['powerkit_category'], 'category_options' ) ) { // Input var ok; sanitization ok.
|
||||
return;
|
||||
}
|
||||
|
||||
if ( isset( $_POST['powerkit_featured_image'] ) ) { // Input var ok; sanitization ok.
|
||||
$powerkit_featured_image = sanitize_text_field( $_POST['powerkit_featured_image'] ); // Input var ok; sanitization ok.
|
||||
|
||||
update_term_meta( $term_id, 'powerkit_featured_image', $powerkit_featured_image );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the stylesheets and JavaScript for the admin area.
|
||||
*
|
||||
* @param string $page Current page.
|
||||
*/
|
||||
public function admin_enqueue_scripts( $page ) {
|
||||
if ( 'edit-tags.php' === $page || 'term.php' === $page ) {
|
||||
wp_enqueue_script( 'jquery' );
|
||||
|
||||
wp_enqueue_media();
|
||||
|
||||
ob_start();
|
||||
?>
|
||||
<script>
|
||||
( function() {
|
||||
|
||||
var powerkitFeaturedContainer = '.pk-featured-image';
|
||||
|
||||
var powerkitFeaturedFrame;
|
||||
|
||||
|
||||
jQuery( document ).ready( function( $ ) {
|
||||
|
||||
/* Add Image Link */
|
||||
jQuery( powerkitFeaturedContainer ).find( '.upload-img-link' ).on( 'click', function( event ){
|
||||
event.preventDefault();
|
||||
|
||||
var parentContainer = $( this ).parents( powerkitFeaturedContainer );
|
||||
|
||||
// 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
|
||||
powerkitFeaturedFrame = wp.media( options );
|
||||
|
||||
// When an image is selected in the media frame...
|
||||
powerkitFeaturedFrame.on( 'select', function() {
|
||||
|
||||
// Get media attachment details from the frame state.
|
||||
var attachment = powerkitFeaturedFrame.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="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' );
|
||||
|
||||
powerkitFeaturedFrame.close();
|
||||
});
|
||||
|
||||
// Finally, open the modal on click.
|
||||
powerkitFeaturedFrame.open();
|
||||
});
|
||||
|
||||
|
||||
/* Delete Image Link */
|
||||
$( powerkitFeaturedContainer ).find( '.delete-img-link' ).on( 'click', function( event ){
|
||||
event.preventDefault();
|
||||
|
||||
$( this ).parents( powerkitFeaturedContainer ).find( '.uploaded-image' ).html( '' );
|
||||
$( this ).parents( powerkitFeaturedContainer ).find( '.upload-img-link' ).removeClass( 'hidden' );
|
||||
$( this ).parents( powerkitFeaturedContainer ).find( '.delete-img-link' ).addClass( 'hidden' );
|
||||
$( this ).parents( powerkitFeaturedContainer ).find( '.uploaded-img-id' ).val( '' ).change();
|
||||
});
|
||||
});
|
||||
|
||||
jQuery( document ).ajaxSuccess(function(e, request, settings){
|
||||
let action = settings.data.indexOf( 'action=add-tag' );
|
||||
let screen = settings.data.indexOf( 'screen=edit-category' );
|
||||
let taxonomy = settings.data.indexOf( 'taxonomy=category' );
|
||||
|
||||
if( action > -1 && screen > -1 && taxonomy > -1 ){
|
||||
$( powerkitFeaturedContainer ).find( '.delete-img-link' ).click();
|
||||
}
|
||||
});
|
||||
|
||||
} )();
|
||||
</script>
|
||||
<?php
|
||||
wp_add_inline_script( 'jquery', str_replace( array( '<script>', '</script>' ), '', ob_get_clean() ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* Featured Categories
|
||||
*
|
||||
* @package Powerkit
|
||||
* @subpackage Modules
|
||||
*/
|
||||
|
||||
if ( class_exists( 'Powerkit_Module' ) ) {
|
||||
/**
|
||||
* Init module
|
||||
*/
|
||||
class Powerkit_Featured_Categories extends Powerkit_Module {
|
||||
|
||||
/**
|
||||
* Register module
|
||||
*/
|
||||
public function register() {
|
||||
$this->name = esc_html__( 'Featured Categories', 'powerkit' );
|
||||
$this->desc = esc_html__( 'Display Featured Categories.', 'powerkit' );
|
||||
$this->slug = 'featured_categories';
|
||||
$this->type = 'default';
|
||||
$this->category = 'content';
|
||||
$this->priority = 150;
|
||||
$this->public = true;
|
||||
$this->enabled = true;
|
||||
$this->links = array(
|
||||
array(
|
||||
'name' => esc_html__( 'View documentation', 'powerkit' ),
|
||||
'url' => powerkit_get_setting( 'documentation' ) . '/featured-categories/',
|
||||
'target' => '_blank',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize module
|
||||
*/
|
||||
public function initialize() {
|
||||
// Helpers Functions for the module.
|
||||
require_once dirname( __FILE__ ) . '/helpers/helper-powerkit-featured-categories.php';
|
||||
|
||||
// The classes responsible for defining all actions.
|
||||
require_once dirname( __FILE__ ) . '/public/class-powerkit-featured-categories-widget.php';
|
||||
|
||||
if ( function_exists( 'register_block_type' ) ) {
|
||||
require_once dirname( __FILE__ ) . '/public/class-powerkit-featured-categories-block.php';
|
||||
}
|
||||
|
||||
// Admin and public area.
|
||||
require_once dirname( __FILE__ ) . '/admin/class-powerkit-featured-categories-admin.php';
|
||||
require_once dirname( __FILE__ ) . '/public/class-powerkit-featured-categories-public.php';
|
||||
|
||||
new Powerkit_Featured_Categories_Admin( $this->slug );
|
||||
new Powerkit_Featured_Categories_Public( $this->slug );
|
||||
}
|
||||
}
|
||||
|
||||
new Powerkit_Featured_Categories();
|
||||
}
|
||||
+111
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
/**
|
||||
* Helpers
|
||||
*
|
||||
* @package Powerkit
|
||||
* @subpackage Modules/Helper
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get locations of featured categories
|
||||
*/
|
||||
function powerkit_featured_categories_locations() {
|
||||
|
||||
$locations = apply_filters( 'powerkit_featured_categories_locations', array(
|
||||
'tiles' => array(
|
||||
'name' => esc_html__( 'Tiles', 'powerkit' ),
|
||||
'icon' => '<svg width="52" height="44" xmlns="http://www.w3.org/2000/svg"><g transform="translate(1 1)" stroke="#2D2D2D" fill="none" fill-rule="evenodd"><rect stroke-width="1.5" width="50" height="42" rx="3"/><g transform="translate(7 9)"><rect stroke-width="1.5" width="36" height="24" rx="1"/><path d="M11 10.5h14m-11 3h9" stroke-linecap="round" stroke-linejoin="round"/></g></g></svg>',
|
||||
'location' => array(),
|
||||
'template' => dirname( __FILE__ ) . '/block/tiles.php',
|
||||
'sections' => array(),
|
||||
'fields' => array(),
|
||||
),
|
||||
'vertical-list' => array(
|
||||
'name' => esc_html__( 'Vertical List', 'powerkit' ),
|
||||
'icon' => '<svg width="52" height="44" xmlns="http://www.w3.org/2000/svg"><g transform="translate(1 1)" fill="none" fill-rule="evenodd"><rect stroke="#2D2D2D" stroke-width="1.5" width="50" height="42" rx="3"/><g transform="translate(5 5)"><rect stroke="#2D2D2D" stroke-width="1.5" width="40" height="8" rx="1"/><path fill="#2D2D2D" d="M34 2h4v4h-4z"/></g><g transform="translate(5 17)"><rect stroke="#2D2D2D" stroke-width="1.5" width="40" height="8" rx="1"/><path fill="#2D2D2D" d="M34 2h4v4h-4z"/></g><g transform="translate(5 29)"><rect stroke="#2D2D2D" stroke-width="1.5" width="40" height="8" rx="1"/><path fill="#2D2D2D" d="M34 2h4v4h-4z"/></g></g></svg>',
|
||||
'location' => array(),
|
||||
'template' => dirname( __FILE__ ) . '/block/vertical-list.php',
|
||||
'sections' => array(),
|
||||
'fields' => array(),
|
||||
),
|
||||
) );
|
||||
|
||||
return $locations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Output featured categories
|
||||
*
|
||||
* @param array $params Recent options.
|
||||
*/
|
||||
function powerkit_featured_categories_output( $params ) {
|
||||
|
||||
$params = array_merge( array(
|
||||
'title' => '',
|
||||
'layout' => 'tiles',
|
||||
'filter_ids' => '',
|
||||
'orderby' => 'name',
|
||||
'order' => 'ASC',
|
||||
'maximum' => 0,
|
||||
'number' => true,
|
||||
), $params );
|
||||
|
||||
$params = apply_filters( 'powerkit_featured_categories_params_output', $params );
|
||||
|
||||
// Set class.
|
||||
$class = 'pk-featured-categories';
|
||||
|
||||
// Add class of layout.
|
||||
$class .= ' pk-featured-categories-' . $params['layout'];
|
||||
|
||||
// Content.
|
||||
?>
|
||||
<div class="<?php echo esc_attr( $class ); ?>">
|
||||
<?php
|
||||
$params['maximum'] = intval( $params['maximum'] );
|
||||
|
||||
// Get terms.
|
||||
$categories = get_terms( array(
|
||||
'include' => $params['filter_ids'],
|
||||
'orderby' => $params['orderby'],
|
||||
'order' => $params['order'],
|
||||
'number' => $params['maximum'] > 0 ? $params['maximum'] : '',
|
||||
'taxonomy' => 'category',
|
||||
'hide_empty' => true,
|
||||
) );
|
||||
|
||||
foreach ( $categories as $category ) {
|
||||
$featured_image = get_term_meta( $category->term_id, 'powerkit_featured_image', true );
|
||||
?>
|
||||
<div class="pk-featured-item">
|
||||
<?php if ( $featured_image ) { ?>
|
||||
<div class="pk-featured-image">
|
||||
<?php echo wp_get_attachment_image( $featured_image, 'large' ); ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<div class="pk-featured-content">
|
||||
<div class="pk-featured-inner">
|
||||
<div class="pk-featured-name">
|
||||
<?php echo esc_html( $category->name ); ?>
|
||||
</div>
|
||||
|
||||
<?php if ( $params['number'] ) { ?>
|
||||
<div class="pk-featured-count">
|
||||
<span class="pk-featured-number"><?php echo esc_html( $category->count ); ?></span>
|
||||
<span class="pk-featured-label"><?php esc_html_e( ' Posts', 'powerkit' ); ?></span>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<a class="pk-featured-link" href="<?php echo esc_url( get_term_link( $category->term_id ) ); ?>">
|
||||
<span><?php esc_html_e( 'View Posts', 'powerkit' ); ?></span>
|
||||
</a>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* Featured Categories 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(
|
||||
'layout' => $attributes['layout'],
|
||||
'filter_ids' => $attributes['filter_ids'],
|
||||
'orderby' => $attributes['orderby'],
|
||||
'order' => $attributes['order'],
|
||||
'maximum' => $attributes['maximum'],
|
||||
'number' => $attributes['number'],
|
||||
);
|
||||
|
||||
echo '<div class="' . esc_attr( $attributes['className'] ) . '" ' . ( isset( $attributes['anchor'] ) ? ' id="' . esc_attr( $attributes['anchor'] ) . '"' : '' ) . '>';
|
||||
|
||||
// Convert filter ids.
|
||||
if ( $params['filter_ids'] ) {
|
||||
|
||||
$params['filter_ids'] = wp_parse_list( $params['filter_ids'] );
|
||||
|
||||
foreach ( $params['filter_ids'] as $key => $slug ) {
|
||||
$term = get_term_by( 'slug', $slug, apply_filters( 'powerkit_featured_categories_filter_taxonomy', 'category', $attributes, $params ) );
|
||||
|
||||
if ( isset( $term->term_id ) ) {
|
||||
$params['filter_ids'][ $key ] = $term->term_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
powerkit_featured_categories_output( $params );
|
||||
|
||||
echo '</div>';
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
/**
|
||||
* Featured Categories tiles template
|
||||
*
|
||||
* @var $attributes - block attributes
|
||||
* @var $options - layout options
|
||||
*
|
||||
* @link https://codesupply.co
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package PowerKit
|
||||
* @subpackage PowerKit/templates
|
||||
*/
|
||||
|
||||
require dirname( __FILE__ ) . '/render.php';
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
/**
|
||||
* Featured Categories vertical list template
|
||||
*
|
||||
* @var $attributes - block attributes
|
||||
* @var $options - layout options
|
||||
*
|
||||
* @link https://codesupply.co
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package PowerKit
|
||||
* @subpackage PowerKit/templates
|
||||
*/
|
||||
|
||||
require dirname( __FILE__ ) . '/render.php';
|
||||
+168
@@ -0,0 +1,168 @@
|
||||
<?php
|
||||
/**
|
||||
* The Featured Categories Block.
|
||||
*
|
||||
* @link https://codesupply.co
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package Powerkit
|
||||
* @subpackage Modules/public
|
||||
*/
|
||||
|
||||
/**
|
||||
* The initialize block.
|
||||
*/
|
||||
class Powerkit_Featured_Categories_Block {
|
||||
|
||||
/**
|
||||
* Initialize
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'init', array( $this, 'block' ) );
|
||||
add_filter( 'canvas_register_block_type', array( $this, 'register_block_type' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue the block's assets for the editor.
|
||||
*/
|
||||
public function block() {
|
||||
// Styles.
|
||||
wp_register_style(
|
||||
'powerkit-featured-categories-block-editor-style',
|
||||
plugins_url( 'css/public-powerkit-featured-categories.css', __FILE__ ),
|
||||
array( 'wp-edit-blocks' ),
|
||||
filemtime( plugin_dir_path( __FILE__ ) . 'css/public-powerkit-featured-categories.css' )
|
||||
);
|
||||
|
||||
wp_style_add_data( 'powerkit-featured-categories-block-editor-style', 'rtl', 'replace' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register block
|
||||
*
|
||||
* @param array $blocks all registered blocks.
|
||||
* @return array
|
||||
*/
|
||||
public function register_block_type( $blocks ) {
|
||||
|
||||
$blocks[] = array(
|
||||
'name' => 'canvas/featured-categories',
|
||||
'title' => esc_html__( 'Featured Categories', 'powerkit' ),
|
||||
'description' => '',
|
||||
'category' => 'canvas',
|
||||
'keywords' => array(),
|
||||
'icon' => '<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><path fill="#000" d="M3 5h6v6H3z"/><path stroke="#000" stroke-width="2" stroke-linejoin="round" d="M11 6h10M11 10h10"/><g><path fill="#000" d="M3 13h6v6H3z"/><path stroke="#000" stroke-width="2" stroke-linejoin="round" d="M11 14h10M11 18h10"/></g></g></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,
|
||||
),
|
||||
'color' => array(
|
||||
'title' => esc_html__( 'Color Settings', 'powerkit' ),
|
||||
'priority' => 60,
|
||||
),
|
||||
),
|
||||
'layouts' => powerkit_featured_categories_locations(),
|
||||
'fields' => array(
|
||||
array(
|
||||
'key' => 'filter_ids',
|
||||
'label' => esc_html__( 'Filter by Categories', 'powerkit' ),
|
||||
'section' => 'general',
|
||||
'type' => 'categories-selector',
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'key' => 'orderby',
|
||||
'label' => esc_html__( 'Order By', 'powerkit' ),
|
||||
'section' => 'general',
|
||||
'type' => 'select',
|
||||
'multiple' => false,
|
||||
'choices' => array(
|
||||
'name' => esc_html__( 'Name', 'powerkit' ),
|
||||
'count' => esc_html__( 'Posts count', 'powerkit' ),
|
||||
'include' => esc_html__( 'Filter include', 'powerkit' ),
|
||||
'id' => esc_html__( 'ID', 'powerkit' ),
|
||||
),
|
||||
'default' => 'tile',
|
||||
),
|
||||
array(
|
||||
'key' => 'order',
|
||||
'label' => esc_html__( 'Order', 'powerkit' ),
|
||||
'section' => 'general',
|
||||
'type' => 'select',
|
||||
'multiple' => false,
|
||||
'choices' => array(
|
||||
'ASC' => esc_html__( 'ASC', 'powerkit' ),
|
||||
'DESC' => esc_html__( 'DESC', 'powerkit' ),
|
||||
),
|
||||
'default' => 'ASC',
|
||||
),
|
||||
array(
|
||||
'key' => 'maximum',
|
||||
'label' => esc_html__( 'Maximum count', 'powerkit' ),
|
||||
'section' => 'general',
|
||||
'type' => 'number',
|
||||
'default' => 0,
|
||||
'step' => 1,
|
||||
'min' => 0,
|
||||
'max' => 1000,
|
||||
),
|
||||
array(
|
||||
'key' => 'number',
|
||||
'label' => esc_html__( 'Display number posts', 'powerkit' ),
|
||||
'section' => 'general',
|
||||
'type' => 'toggle',
|
||||
'default' => true,
|
||||
),
|
||||
array(
|
||||
'key' => 'bgOverlay',
|
||||
'label' => esc_html__( 'Background Overlay', 'powerkit' ),
|
||||
'section' => 'color',
|
||||
'type' => 'color',
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '$ .pk-featured-item .pk-featured-content:before',
|
||||
'property' => 'background-color',
|
||||
'suffix' => '!important',
|
||||
),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'key' => 'bgOpacityOverlay',
|
||||
'label' => esc_html__( 'Background Overlay Opacity', 'powerkit' ),
|
||||
'section' => 'color',
|
||||
'type' => 'number',
|
||||
'step' => 0.1,
|
||||
'min' => 0,
|
||||
'max' => 1,
|
||||
'default' => 0.3,
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '$ .pk-featured-item .pk-featured-content:before',
|
||||
'property' => 'opacity',
|
||||
'suffix' => '!important',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
'template' => dirname( __FILE__ ) . '/block/tiles.php',
|
||||
// enqueue registered scripts/styles.
|
||||
'editor_style' => 'powerkit-featured-categories-block-editor-style',
|
||||
);
|
||||
|
||||
return $blocks;
|
||||
}
|
||||
}
|
||||
|
||||
new Powerkit_Featured_Categories_Block();
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
<?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_Featured_Categories_Public extends Powerkit_Module_Public {
|
||||
|
||||
/**
|
||||
* Initialize
|
||||
*/
|
||||
public function initialize() {
|
||||
// PinIt exclude selectors.
|
||||
add_filter( 'powerkit_pinit_exclude_selectors', array( $this, 'pinit_disable' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* PinIt exclude selectors
|
||||
*
|
||||
* @param string $selectors List selectors.
|
||||
*/
|
||||
public function pinit_disable( $selectors ) {
|
||||
$selectors[] = '.pk-featured-categories img';
|
||||
|
||||
return $selectors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the stylesheets for the public-facing side of the site.
|
||||
*/
|
||||
public function wp_enqueue_scripts() {
|
||||
wp_enqueue_style( 'powerkit-featured-categories', powerkit_style( plugin_dir_url( __FILE__ ) . 'css/public-powerkit-featured-categories.css' ), array(), powerkit_get_setting( 'version' ), 'all' );
|
||||
|
||||
// Add RTL support.
|
||||
wp_style_add_data( 'powerkit-featured-categories', 'rtl', 'replace' );
|
||||
}
|
||||
}
|
||||
+170
@@ -0,0 +1,170 @@
|
||||
<?php
|
||||
/**
|
||||
* Widget Featured Categories
|
||||
*
|
||||
* @link https://codesupply.co
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package Powerkit
|
||||
* @subpackage Powerkit/widgets
|
||||
*/
|
||||
|
||||
/**
|
||||
* Widget Featured Categories
|
||||
*/
|
||||
class Powerkit_Featured_Categories_Widget extends WP_Widget {
|
||||
|
||||
|
||||
/**
|
||||
* Sets up a new widget instance.
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
$this->default_settings = apply_filters( 'powerkit_widget_featured_categories_settings', array(
|
||||
'title' => esc_html__( 'Featured Categories', 'powerkit' ),
|
||||
'layout' => 'tiles',
|
||||
'filter_ids' => '',
|
||||
'orderby' => 'name',
|
||||
'order' => 'ASC',
|
||||
'maximum' => 0,
|
||||
'number' => true,
|
||||
) );
|
||||
|
||||
$widget_details = array(
|
||||
'classname' => 'powerkit_widget_featured_categories',
|
||||
'description' => '',
|
||||
);
|
||||
|
||||
parent::__construct( 'powerkit_widget_featured_categories', esc_html__( 'Featured Categories', '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 );
|
||||
|
||||
// Title.
|
||||
if ( $params['title'] ) {
|
||||
$params['title'] = apply_filters( 'widget_title', $params['title'], $instance, $this->id_base );
|
||||
}
|
||||
|
||||
// Before Widget.
|
||||
echo $args['before_widget']; // XSS.
|
||||
|
||||
// Title.
|
||||
if ( $params['title'] ) {
|
||||
echo $args['before_title'] . wp_kses( $params['title'], 'pk-title') . $args['after_title']; // XSS.
|
||||
}
|
||||
|
||||
?>
|
||||
<div class="widget-body">
|
||||
<?php
|
||||
powerkit_featured_categories_output( $params );
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
// After Widget.
|
||||
echo $args['after_widget']; // XSS.
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 number posts.
|
||||
if ( ! isset( $instance['number'] ) ) {
|
||||
$instance['number'] = false;
|
||||
}
|
||||
|
||||
return apply_filters( 'powerkit_widget_featured_categories_update', $instance );
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs the widget settings form.
|
||||
*
|
||||
* @param array $instance Current settings.
|
||||
*/
|
||||
public function form( $instance ) {
|
||||
$params = array_merge( $this->default_settings, $instance );
|
||||
|
||||
$layouts = powerkit_featured_categories_locations();
|
||||
?>
|
||||
<?php do_action( 'powerkit_widget_featured_categories_form_title_before', $this, $params, $instance ); ?>
|
||||
|
||||
<!-- 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>
|
||||
|
||||
<?php do_action( 'powerkit_widget_featured_categories_form_layouts_before', $this, $params, $instance ); ?>
|
||||
|
||||
<!-- Layouts -->
|
||||
<?php if ( $layouts ) { ?>
|
||||
<p>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'layout' ) ); ?>"><?php esc_html_e( 'Layouts', 'powerkit' ); ?></label>
|
||||
<select class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'layout' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'layout' ) ); ?>">
|
||||
<?php foreach ( $layouts as $slug => $layout ) { ?>
|
||||
<option value="<?php echo esc_attr( $slug ); ?>" <?php echo selected( $params['layout'], $slug ); ?>><?php echo esc_html( $layout['name'] ); ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</p>
|
||||
<?php } ?>
|
||||
|
||||
<!-- Filter by Categories -->
|
||||
<p>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'filter_ids' ) ); ?>"><?php esc_html_e( 'Filter by categories:', 'powerkit' ); ?></label>
|
||||
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'filter_ids' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'filter_ids' ) ); ?>" type="text" value="<?php echo esc_attr( $params['filter_ids'] ); ?>" />
|
||||
</p>
|
||||
|
||||
<p class="help"><?php esc_html_e( 'Add comma-separated list of categories IDs. For example: 1, 2, 3. Leave empty for all categories.' ); ?></p>
|
||||
|
||||
<!-- Order By -->
|
||||
<p>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'orderby' ) ); ?>"><?php esc_html_e( 'Order By', 'powerkit' ); ?></label>
|
||||
<select class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'orderby' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'orderby' ) ); ?>">
|
||||
<option value="name" <?php echo selected( $params['orderby'], 'name' ); ?>><?php esc_html_e( 'Name', 'powerkit' ); ?></option>
|
||||
<option value="count" <?php echo selected( $params['orderby'], 'count' ); ?>><?php esc_html_e( 'Posts count', 'powerkit' ); ?></option>
|
||||
<option value="include" <?php echo selected( $params['orderby'], 'include' ); ?>><?php esc_html_e( 'Filter include', 'powerkit' ); ?></option>
|
||||
<option value="id" <?php echo selected( $params['orderby'], 'id' ); ?>><?php esc_html_e( 'ID', 'powerkit' ); ?></option>
|
||||
</select>
|
||||
</p>
|
||||
|
||||
<!-- Order -->
|
||||
<p>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'order' ) ); ?>"><?php esc_html_e( 'Order', 'powerkit' ); ?></label>
|
||||
<select class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'order' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'order' ) ); ?>">
|
||||
<option value="ASC" <?php echo selected( $params['order'], 'ASC' ); ?>><?php esc_html_e( 'ASC', 'powerkit' ); ?></option>
|
||||
<option value="DESC" <?php echo selected( $params['order'], 'DESC' ); ?>><?php esc_html_e( 'DESC', 'powerkit' ); ?></option>
|
||||
</select>
|
||||
</p>
|
||||
|
||||
<!-- Maximum count -->
|
||||
<p><label for="<?php echo esc_attr( $this->get_field_id( 'maximum' ) ); ?>"><?php esc_html_e( 'Maximum count', 'powerkit' ); ?></label>
|
||||
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'maximum' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'maximum' ) ); ?>" type="number" value="<?php echo esc_attr( $params['maximum'] ); ?>" /></p>
|
||||
|
||||
<!-- Display number posts -->
|
||||
<p><input id="<?php echo esc_attr( $this->get_field_id( 'number' ) ); ?>" class="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'number' ) ); ?>" type="checkbox" <?php checked( (bool) $params['number'] ); ?> />
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'number' ) ); ?>"><?php esc_html_e( 'Display number posts', 'powerkit' ); ?></label></p>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register Widget
|
||||
*/
|
||||
function powerkit_widget_init_featured_categories() {
|
||||
register_widget( 'Powerkit_Featured_Categories_Widget' );
|
||||
}
|
||||
add_action( 'widgets_init', 'powerkit_widget_init_featured_categories' );
|
||||
+207
@@ -0,0 +1,207 @@
|
||||
|
||||
/**
|
||||
* All of the CSS for your public-facing functionality should be
|
||||
* included in this file.
|
||||
*/
|
||||
/**
|
||||
* Environment for all styles (variables, additions, etc).
|
||||
*/
|
||||
/*--------------------------------------------------------------*/
|
||||
/*--------------------------------------------------------------*/
|
||||
.pk-featured-categories {
|
||||
--pk-featured-image-background: #f8f9fa;
|
||||
--pk-featured-content-color: #FFFFFF;
|
||||
--pk-featured-overlay-background: #000000;
|
||||
--pk-featured-link-color: #FFFFFF;
|
||||
--pk-featured-list-count-background: #000000;
|
||||
--pk-featured-overlay-opacity: 0.3;
|
||||
--pk-featured-name-font-weight: bold;
|
||||
--pk-featured-tiles-count-font-size: 0.75rem;
|
||||
--pk-featured-list-count-font-size: 0.6875rem;
|
||||
--pk-featured-list-count-size: 1.5rem;
|
||||
--pk-featured-list-number-font-weight: bold;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------*/
|
||||
.pk-featured-categories .pk-featured-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.pk-featured-categories .pk-featured-image {
|
||||
background: var(--pk-featured-image-background);
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.pk-featured-categories .pk-featured-image img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
-o-object-fit: cover;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.pk-featured-categories .pk-featured-content {
|
||||
position: relative;
|
||||
padding: 40px;
|
||||
color: var(--pk-featured-content-color);
|
||||
}
|
||||
|
||||
.pk-featured-categories .pk-featured-content:before {
|
||||
position: absolute;
|
||||
background: var(--pk-featured-overlay-background);
|
||||
opacity: var(--pk-featured-overlay-opacity);
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
top: 0;
|
||||
right: 0;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
content: '';
|
||||
}
|
||||
|
||||
.pk-featured-categories .pk-featured-inner {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.pk-featured-categories .pk-featured-link {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.pk-featured-categories .pk-featured-link span {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.pk-featured-categories-tiles {
|
||||
display: grid;
|
||||
grid-gap: 40px;
|
||||
grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
|
||||
}
|
||||
|
||||
.pk-featured-categories-tiles .pk-featured-item {
|
||||
min-height: 170px;
|
||||
}
|
||||
|
||||
.pk-featured-categories-tiles .pk-featured-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
text-align: center;
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
.pk-featured-categories-tiles .pk-featured-inner {
|
||||
opacity: 1;
|
||||
transform: translate3d(0, 0, 0);
|
||||
transition: 0.25s;
|
||||
}
|
||||
|
||||
.pk-featured-categories-tiles .pk-featured-item:hover .pk-featured-inner {
|
||||
transform: translate3d(0, -20%, 0);
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.pk-featured-categories-tiles .pk-featured-name {
|
||||
font-weight: var(--pk-featured-name-font-weight);
|
||||
}
|
||||
|
||||
.pk-featured-categories-tiles .pk-featured-link {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: var(--pk-featured-link-color);
|
||||
}
|
||||
|
||||
.pk-featured-categories-tiles .pk-featured-link span {
|
||||
display: inline-block;
|
||||
opacity: 0;
|
||||
transform: translate3d(0, 20%, 0);
|
||||
transition: 0.25s ease 0s;
|
||||
}
|
||||
|
||||
.pk-featured-categories-tiles .pk-featured-link span:after {
|
||||
content: ' →';
|
||||
}
|
||||
|
||||
.pk-featured-categories-tiles .pk-featured-link:hover span {
|
||||
opacity: 1;
|
||||
transform: translate3d(0, 0, 0);
|
||||
transition: 0.25s ease 0.15s;
|
||||
}
|
||||
|
||||
.pk-featured-categories-tiles .pk-featured-count {
|
||||
font-size: var(--pk-featured-tiles-count-font-size);
|
||||
}
|
||||
|
||||
.pk-featured-categories-vertical-list .pk-featured-item {
|
||||
margin-top: 0.5rem;
|
||||
}
|
||||
|
||||
.pk-featured-categories-vertical-list .pk-featured-item:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.pk-featured-categories-vertical-list .pk-featured-content {
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.pk-featured-categories-vertical-list .pk-featured-inner {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.pk-featured-categories-vertical-list .pk-featured-name {
|
||||
font-weight: var(--pk-featured-name-font-weight);
|
||||
}
|
||||
|
||||
.pk-featured-categories-vertical-list .pk-featured-count {
|
||||
position: relative;
|
||||
background: var(--pk-featured-list-count-background);
|
||||
min-width: var(--pk-featured-list-count-size);
|
||||
height: var(--pk-featured-list-count-size);
|
||||
padding: 0 0.25rem;
|
||||
font-size: var(--pk-featured-list-count-font-size);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.pk-featured-categories-vertical-list .pk-featured-count:after {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
height: var(--pk-featured-list-count-size);
|
||||
content: '→';
|
||||
}
|
||||
|
||||
.pk-featured-categories-vertical-list .pk-featured-count .pk-featured-number {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
height: var(--pk-featured-list-count-size);
|
||||
font-weight: var(--pk-featured-list-number-font-weight);
|
||||
margin-top: 0;
|
||||
transition: 0.25s ease;
|
||||
}
|
||||
|
||||
.pk-featured-categories-vertical-list .pk-featured-count .pk-featured-label {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.pk-featured-categories-vertical-list .pk-featured-item:hover .pk-featured-number {
|
||||
margin-top: calc(var(--pk-featured-list-count-size) * -1);
|
||||
}
|
||||
+207
@@ -0,0 +1,207 @@
|
||||
|
||||
/**
|
||||
* All of the CSS for your public-facing functionality should be
|
||||
* included in this file.
|
||||
*/
|
||||
/**
|
||||
* Environment for all styles (variables, additions, etc).
|
||||
*/
|
||||
/*--------------------------------------------------------------*/
|
||||
/*--------------------------------------------------------------*/
|
||||
.pk-featured-categories {
|
||||
--pk-featured-image-background: #f8f9fa;
|
||||
--pk-featured-content-color: #FFFFFF;
|
||||
--pk-featured-overlay-background: #000000;
|
||||
--pk-featured-link-color: #FFFFFF;
|
||||
--pk-featured-list-count-background: #000000;
|
||||
--pk-featured-overlay-opacity: 0.3;
|
||||
--pk-featured-name-font-weight: bold;
|
||||
--pk-featured-tiles-count-font-size: 0.75rem;
|
||||
--pk-featured-list-count-font-size: 0.6875rem;
|
||||
--pk-featured-list-count-size: 1.5rem;
|
||||
--pk-featured-list-number-font-weight: bold;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------*/
|
||||
.pk-featured-categories .pk-featured-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.pk-featured-categories .pk-featured-image {
|
||||
background: var(--pk-featured-image-background);
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.pk-featured-categories .pk-featured-image img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
-o-object-fit: cover;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.pk-featured-categories .pk-featured-content {
|
||||
position: relative;
|
||||
padding: 40px;
|
||||
color: var(--pk-featured-content-color);
|
||||
}
|
||||
|
||||
.pk-featured-categories .pk-featured-content:before {
|
||||
position: absolute;
|
||||
background: var(--pk-featured-overlay-background);
|
||||
opacity: var(--pk-featured-overlay-opacity);
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
content: '';
|
||||
}
|
||||
|
||||
.pk-featured-categories .pk-featured-inner {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.pk-featured-categories .pk-featured-link {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.pk-featured-categories .pk-featured-link span {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.pk-featured-categories-tiles {
|
||||
display: grid;
|
||||
grid-gap: 40px;
|
||||
grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
|
||||
}
|
||||
|
||||
.pk-featured-categories-tiles .pk-featured-item {
|
||||
min-height: 170px;
|
||||
}
|
||||
|
||||
.pk-featured-categories-tiles .pk-featured-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
text-align: center;
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
.pk-featured-categories-tiles .pk-featured-inner {
|
||||
opacity: 1;
|
||||
transform: translate3d(0, 0, 0);
|
||||
transition: 0.25s;
|
||||
}
|
||||
|
||||
.pk-featured-categories-tiles .pk-featured-item:hover .pk-featured-inner {
|
||||
transform: translate3d(0, -20%, 0);
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.pk-featured-categories-tiles .pk-featured-name {
|
||||
font-weight: var(--pk-featured-name-font-weight);
|
||||
}
|
||||
|
||||
.pk-featured-categories-tiles .pk-featured-link {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: var(--pk-featured-link-color);
|
||||
}
|
||||
|
||||
.pk-featured-categories-tiles .pk-featured-link span {
|
||||
display: inline-block;
|
||||
opacity: 0;
|
||||
transform: translate3d(0, 20%, 0);
|
||||
transition: 0.25s ease 0s;
|
||||
}
|
||||
|
||||
.pk-featured-categories-tiles .pk-featured-link span:after {
|
||||
content: ' →';
|
||||
}
|
||||
|
||||
.pk-featured-categories-tiles .pk-featured-link:hover span {
|
||||
opacity: 1;
|
||||
transform: translate3d(0, 0, 0);
|
||||
transition: 0.25s ease 0.15s;
|
||||
}
|
||||
|
||||
.pk-featured-categories-tiles .pk-featured-count {
|
||||
font-size: var(--pk-featured-tiles-count-font-size);
|
||||
}
|
||||
|
||||
.pk-featured-categories-vertical-list .pk-featured-item {
|
||||
margin-top: 0.5rem;
|
||||
}
|
||||
|
||||
.pk-featured-categories-vertical-list .pk-featured-item:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.pk-featured-categories-vertical-list .pk-featured-content {
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.pk-featured-categories-vertical-list .pk-featured-inner {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.pk-featured-categories-vertical-list .pk-featured-name {
|
||||
font-weight: var(--pk-featured-name-font-weight);
|
||||
}
|
||||
|
||||
.pk-featured-categories-vertical-list .pk-featured-count {
|
||||
position: relative;
|
||||
background: var(--pk-featured-list-count-background);
|
||||
min-width: var(--pk-featured-list-count-size);
|
||||
height: var(--pk-featured-list-count-size);
|
||||
padding: 0 0.25rem;
|
||||
font-size: var(--pk-featured-list-count-font-size);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.pk-featured-categories-vertical-list .pk-featured-count:after {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
height: var(--pk-featured-list-count-size);
|
||||
content: '→';
|
||||
}
|
||||
|
||||
.pk-featured-categories-vertical-list .pk-featured-count .pk-featured-number {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
height: var(--pk-featured-list-count-size);
|
||||
font-weight: var(--pk-featured-list-number-font-weight);
|
||||
margin-top: 0;
|
||||
transition: 0.25s ease;
|
||||
}
|
||||
|
||||
.pk-featured-categories-vertical-list .pk-featured-count .pk-featured-label {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.pk-featured-categories-vertical-list .pk-featured-item:hover .pk-featured-number {
|
||||
margin-top: calc(var(--pk-featured-list-count-size) * -1);
|
||||
}
|
||||
+108
@@ -0,0 +1,108 @@
|
||||
<?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_Headers_Footers_Admin extends Powerkit_Module_Admin {
|
||||
|
||||
/**
|
||||
* Initialize
|
||||
*/
|
||||
public function initialize() {
|
||||
add_action( 'admin_menu', array( $this, 'register_options_page' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register admin page
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function register_options_page() {
|
||||
add_options_page( esc_html__( 'Insert Headers & Footers', 'powerkit' ), esc_html__( 'Insert Headers & Footers', '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( 'Insert Headers & Footers', 'powerkit' ); ?></h1>
|
||||
|
||||
<div class="pk-settings">
|
||||
<form method="post">
|
||||
<table class="form-table">
|
||||
<tbody>
|
||||
<!-- Scripts in Header -->
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<label for="powerkit_insert_header_code">
|
||||
<?php esc_html_e( 'Scripts in Header', 'powerkit' ); ?>
|
||||
<p class="description"><?php esc_html_e( 'These scripts will be printed in the <head> section.', 'powerkit' ); ?></p>
|
||||
</label>
|
||||
</th>
|
||||
<td><textarea style="width:100%" id="powerkit_insert_header_code" name="powerkit_insert_header_code" rows="8"><?php echo (string) get_option( 'powerkit_insert_header_code' ); // XSS. ?></textarea></td>
|
||||
</tr>
|
||||
|
||||
<!-- Scripts in Footer -->
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<label for="powerkit_insert_footer_code">
|
||||
<?php esc_html_e( 'Scripts in Footer', 'powerkit' ); ?>
|
||||
<p class="description"><?php esc_html_e( 'These scripts will be printed above the </body> tag.', 'powerkit' ); ?></p>
|
||||
</label>
|
||||
</th>
|
||||
<td><textarea style="width:100%" id="powerkit_insert_footer_code" name="powerkit_insert_footer_code" rows="8"><?php echo (string) get_option( 'powerkit_insert_footer_code' ); // XSS. ?></textarea></td>
|
||||
</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_insert_header_code'] ) ) { // Input var ok.
|
||||
update_option( 'powerkit_insert_header_code', wp_unslash( $_POST['powerkit_insert_header_code'] ) ); // Input var ok. sanitization ok.
|
||||
}
|
||||
if ( isset( $_POST['powerkit_insert_footer_code'] ) ) { // Input var ok.
|
||||
update_option( 'powerkit_insert_footer_code', wp_unslash( $_POST['powerkit_insert_footer_code'] ) ); // Input var ok. sanitization ok.
|
||||
}
|
||||
printf( '<div id="message" class="updated fade"><p><strong>%s</strong></p></div>', esc_html__( 'Settings saved.', 'powerkit' ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* Headers Footers
|
||||
*
|
||||
* @package Powerkit
|
||||
* @subpackage Modules
|
||||
*/
|
||||
|
||||
if ( class_exists( 'Powerkit_Module' ) ) {
|
||||
/**
|
||||
* Init module
|
||||
*/
|
||||
class Powerkit_Headers_Footers extends Powerkit_Module {
|
||||
|
||||
/**
|
||||
* Register module
|
||||
*/
|
||||
public function register() {
|
||||
$this->name = esc_html__( 'Header and Footer Scripts', 'powerkit' );
|
||||
$this->desc = esc_html__( 'You insert code like Google Analytics, custom CSS, Facebook Pixel, and more to your WordPress site header and footer.', 'powerkit' );
|
||||
$this->slug = 'headers_footers';
|
||||
$this->type = 'default';
|
||||
$this->category = 'tools';
|
||||
$this->priority = 140;
|
||||
$this->public = false;
|
||||
$this->enabled = false;
|
||||
$this->links = array(
|
||||
array(
|
||||
'name' => esc_html__( 'View documentation', 'powerkit' ),
|
||||
'url' => powerkit_get_setting( 'documentation' ) . '/headers-footers/',
|
||||
'target' => '_blank',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize module
|
||||
*/
|
||||
public function initialize() {
|
||||
|
||||
// Admin and public area.
|
||||
require_once dirname( __FILE__ ) . '/admin/class-powerkit-headers-footers-admin.php';
|
||||
require_once dirname( __FILE__ ) . '/public/class-powerkit-headers-footers-public.php';
|
||||
|
||||
new Powerkit_Headers_Footers_Admin( $this->slug );
|
||||
new Powerkit_Headers_Footers_Public( $this->slug );
|
||||
}
|
||||
}
|
||||
|
||||
new Powerkit_Headers_Footers();
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
<?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_Headers_Footers_Public extends Powerkit_Module_Public {
|
||||
|
||||
/**
|
||||
* Initialize
|
||||
*/
|
||||
public function initialize() {
|
||||
add_action( 'wp_head', array( $this, 'header' ) );
|
||||
add_action( 'wp_footer', array( $this, 'footer' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs script / CSS to the frontend header.
|
||||
*/
|
||||
public function header() {
|
||||
$this->output( 'powerkit_insert_header_code' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs script / CSS to the frontend footer.
|
||||
*/
|
||||
public function footer() {
|
||||
$this->output( 'powerkit_insert_footer_code' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs the given setting, if conditions are met.
|
||||
*
|
||||
* @param string $setting Setting Name.
|
||||
*/
|
||||
public function output( $setting ) {
|
||||
// Ignore admin, feed, robots or trackbacks.
|
||||
if ( is_admin() || is_feed() || is_robots() || is_trackback() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get code.
|
||||
$code = get_option( $setting );
|
||||
|
||||
// Output.
|
||||
echo (string) $code; // XSS.
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/**
|
||||
* Inline Posts
|
||||
*
|
||||
* @package Powerkit
|
||||
* @subpackage Modules
|
||||
*/
|
||||
|
||||
if ( class_exists( 'Powerkit_Module' ) ) {
|
||||
/**
|
||||
* Init module
|
||||
*/
|
||||
class Powerkit_Inline_Posts extends Powerkit_Module {
|
||||
|
||||
/**
|
||||
* Register module
|
||||
*/
|
||||
public function register() {
|
||||
$this->name = esc_html__( 'Inline Posts', 'powerkit' );
|
||||
$this->desc = esc_html__( 'Display related posts inline with other post content for ultra-high conversion rate and user engagement in multiple different layouts.', 'powerkit' );
|
||||
$this->slug = 'inline_posts';
|
||||
$this->type = 'default';
|
||||
$this->category = 'content';
|
||||
$this->priority = 120;
|
||||
$this->public = true;
|
||||
$this->enabled = true;
|
||||
$this->links = array(
|
||||
array(
|
||||
'name' => esc_html__( 'View documentation', 'powerkit' ),
|
||||
'url' => powerkit_get_setting( 'documentation' ) . '/content-presentation/inline-posts/',
|
||||
'target' => '_blank',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize module
|
||||
*/
|
||||
public function initialize() {
|
||||
|
||||
/* Load the required dependencies for this module */
|
||||
|
||||
// Helpers Functions for the module.
|
||||
require_once dirname( __FILE__ ) . '/helpers/class-powerkit-inline-posts-snippet.php';
|
||||
|
||||
// The classes responsible for defining all actions.
|
||||
require_once dirname( __FILE__ ) . '/public/class-powerkit-inline-posts-shortcode.php';
|
||||
|
||||
// Admin and public area.
|
||||
require_once dirname( __FILE__ ) . '/public/class-powerkit-inline-posts-public.php';
|
||||
|
||||
new Powerkit_Inline_Posts_Public( $this->slug );
|
||||
}
|
||||
}
|
||||
|
||||
new Powerkit_Inline_Posts();
|
||||
}
|
||||
+576
@@ -0,0 +1,576 @@
|
||||
<?php
|
||||
/**
|
||||
* Inline Posts Snippet
|
||||
*
|
||||
* @package Powerkit
|
||||
* @subpackage Modules
|
||||
*/
|
||||
|
||||
/**
|
||||
* Inline Posts Class
|
||||
*/
|
||||
class Powerkit_Inline_Posts_Snippet {
|
||||
|
||||
/**
|
||||
* Post ID
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $post_id = null;
|
||||
|
||||
/**
|
||||
* Options
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $args = array();
|
||||
|
||||
/**
|
||||
* Need Posts Count
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $need_posts_count = 0;
|
||||
|
||||
/**
|
||||
* Posts Offset
|
||||
*
|
||||
* @var int|bool
|
||||
*/
|
||||
public $founded_posts = false;
|
||||
|
||||
/**
|
||||
* Parent Terms
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $parent_terms = array();
|
||||
|
||||
/**
|
||||
* Posts List
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $posts_list = array();
|
||||
|
||||
/**
|
||||
* Exclude Posts
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $exclude_posts = array();
|
||||
|
||||
/**
|
||||
* Exclude Cats
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $exclude_cats = array();
|
||||
|
||||
/**
|
||||
* Constructor. Set up cacheable values and settings.
|
||||
*
|
||||
* @param array $args Related posts options.
|
||||
*/
|
||||
public function __construct( $args = array() ) {
|
||||
global $post;
|
||||
|
||||
// Set Post ID.
|
||||
if ( is_object( $post ) ) {
|
||||
$this->args['post_id'] = intval( $post->ID );
|
||||
}
|
||||
|
||||
$this->args = array_merge( array(
|
||||
'ids' => null,
|
||||
'category' => null,
|
||||
'tag' => null,
|
||||
'time_frame' => null,
|
||||
'orderby' => 'date',
|
||||
'order' => 'DESC',
|
||||
'count' => 1,
|
||||
'offset' => 0,
|
||||
'exclude_posts' => array(),
|
||||
'exclude_cats' => array(),
|
||||
'output_type' => 'term, parent_term', // Variables: all, posts, tags, term, parent_term, post_type.
|
||||
'post_id' => $this->args['post_id'],
|
||||
), $args );
|
||||
|
||||
// Check Post ID.
|
||||
if ( (int) $this->args['post_id'] <= 0 ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set Options.
|
||||
$this->ids = $this->args['ids'];
|
||||
$this->cats = $this->args['category'];
|
||||
$this->tags = $this->args['tag'];
|
||||
$this->time_frame = $this->args['time_frame'];
|
||||
$this->orderby = $this->args['orderby'];
|
||||
$this->order = $this->args['order'];
|
||||
$this->need_posts_count = $this->args['count'] + intval( $this->args['offset'] );
|
||||
$this->offset = $this->args['offset'];
|
||||
$this->post_terms = $this->get_post_terms( $this->args['post_id'] );
|
||||
$this->post_type = get_post_type( $this->args['post_id'] );
|
||||
|
||||
// Exclude Options.
|
||||
$this->exclude_cats = is_array( $this->args['exclude_cats'] ) ? array_map( 'intval', $this->args['exclude_cats'] ) : array();
|
||||
$this->exclude_posts = is_array( $this->args['exclude_posts'] ) ? array_map( 'intval', $this->args['exclude_posts'] ) : array();
|
||||
$this->exclude_posts[] = (int) $this->args['post_id'];
|
||||
|
||||
// Check Output Type.
|
||||
if ( is_string( $this->args['output_type'] ) ) {
|
||||
$output_type = explode( ',', $this->args['output_type'] );
|
||||
} elseif ( is_array( $this->args['output_type'] ) ) {
|
||||
$output_type = $this->args['output_type'];
|
||||
} else {
|
||||
$output_type = array();
|
||||
}
|
||||
|
||||
// Set Output Type.
|
||||
if ( trim( $this->ids ) ) {
|
||||
$output_type = array( 'posts' );
|
||||
|
||||
} elseif ( trim( $this->cats ) ) {
|
||||
|
||||
$output_type = array( 'posts' );
|
||||
|
||||
} elseif ( trim( $this->tags ) ) {
|
||||
|
||||
$output_type = array( 'posts' );
|
||||
|
||||
} elseif ( in_array( 'all', $output_type, true ) ) {
|
||||
|
||||
$output_type = array( 'tags', 'term', 'parent_term', 'post_type' );
|
||||
}
|
||||
|
||||
$this->args['output_type'] = array_map( 'trim', $output_type );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Posts
|
||||
*
|
||||
* @param array $args Query args.
|
||||
*/
|
||||
private function query_get_posts( $args ) {
|
||||
|
||||
// Set Query Params.
|
||||
$args['no_found_rows'] = true;
|
||||
$args['ignore_sticky_posts'] = 1;
|
||||
$args['category__not_in'] = $this->exclude_cats;
|
||||
|
||||
$args = $this->query_filter_args( $args );
|
||||
|
||||
// Result.
|
||||
$new_posts_list = new WP_Query( $args );
|
||||
|
||||
if ( isset( $new_posts_list->posts ) && is_array( $new_posts_list->posts ) ) {
|
||||
$this->posts_list = array_merge( $this->posts_list, $new_posts_list->posts );
|
||||
|
||||
// Exclude posts list.
|
||||
foreach ( $new_posts_list->posts as $obj_post ) {
|
||||
$this->exclude_posts[] = $obj_post->ID;
|
||||
}
|
||||
|
||||
// Needed count posts.
|
||||
$this->need_posts_count -= $this->args['count'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Pre posts process.
|
||||
*/
|
||||
public function posts_process() {
|
||||
if ( count( $this->args['output_type'] ) <= 1 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Process.
|
||||
if ( $this->posts_list ) {
|
||||
$ids = array();
|
||||
foreach ( $this->posts_list as $post ) {
|
||||
$ids[] = $post->ID;
|
||||
}
|
||||
|
||||
// Set new args.
|
||||
$args = array(
|
||||
'post__in' => $ids,
|
||||
);
|
||||
|
||||
// Filter args.
|
||||
$args = $this->query_filter_args( $args );
|
||||
|
||||
$the_query = new WP_Query( $args );
|
||||
|
||||
// Rewrite posts.
|
||||
$this->posts_list = $the_query->posts;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set custom args.
|
||||
*
|
||||
* @param array $args The query args.
|
||||
*/
|
||||
public function query_filter_args( $args = array() ) {
|
||||
// Post offset.
|
||||
$args['offset'] = $this->offset;
|
||||
|
||||
// Post order.
|
||||
$args['order'] = $this->order;
|
||||
$args['orderby'] = $this->orderby;
|
||||
|
||||
$type_post_views = powerkit_post_views_enabled();
|
||||
|
||||
// Post Views.
|
||||
if ( $type_post_views && 'post_views' === $this->orderby ) {
|
||||
$args['orderby'] = $type_post_views;
|
||||
// Don't hide posts without views.
|
||||
$args['views_query']['hide_empty'] = false;
|
||||
}
|
||||
|
||||
// Time Frame.
|
||||
if ( $this->time_frame ) {
|
||||
$args['date_query'] = array(
|
||||
array(
|
||||
'column' => 'post_date_gmt',
|
||||
'after' => $this->time_frame . ' ago',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return $args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Posts by filters
|
||||
*/
|
||||
public function get_posts_by_filters() {
|
||||
|
||||
$args = array();
|
||||
|
||||
// Count.
|
||||
$args['posts_per_page'] = $this->args['count'];
|
||||
|
||||
// Filter by posts.
|
||||
if ( $this->ids ) {
|
||||
$ids = explode( ',', $this->ids );
|
||||
|
||||
$args['post__in'] = array_map( 'trim', $ids );
|
||||
}
|
||||
|
||||
// Filter by categories.
|
||||
if ( $this->cats ) {
|
||||
$cats = str_replace( ' ', '', $this->cats );
|
||||
|
||||
$args['category_name'] = $cats;
|
||||
}
|
||||
|
||||
// Filter by tags.
|
||||
if ( $this->tags ) {
|
||||
$tags = str_replace( ' ', '', $this->tags );
|
||||
|
||||
$args['tag'] = $tags;
|
||||
}
|
||||
|
||||
// Result.
|
||||
$this->query_get_posts( $args );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Related By Tags
|
||||
*/
|
||||
public function get_output_type_tags() {
|
||||
if ( $this->need_posts_count <= 0 ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get Tags.
|
||||
$tags = get_the_terms( $this->args['post_id'], 'post_tag' );
|
||||
|
||||
if ( ! is_wp_error( $tags ) && ! empty( $tags ) ) {
|
||||
|
||||
if ( 'video' === get_post_type( $this->args['post_id'] ) ) {
|
||||
$terms_array = array();
|
||||
$tax_data = array();
|
||||
|
||||
// Terms array.
|
||||
foreach ( $tags as $post_term ) {
|
||||
$terms_array[ $post_term->taxonomy ][] = $post_term->term_id;
|
||||
}
|
||||
|
||||
// Tax data.
|
||||
foreach ( $terms_array as $p_tax => $p_terms ) {
|
||||
|
||||
if ( is_array( $p_terms ) ) {
|
||||
$terms_array[ $p_tax ] = array_unique( $terms_array[ $p_tax ] );
|
||||
}
|
||||
|
||||
$tax_data[] = array(
|
||||
'taxonomy' => $p_tax,
|
||||
'field' => 'id',
|
||||
'terms' => $terms_array[ $p_tax ],
|
||||
);
|
||||
}
|
||||
|
||||
// Query.
|
||||
if ( ! empty( $tax_data ) ) {
|
||||
$args = array(
|
||||
'post__not_in' => $this->exclude_posts,
|
||||
'posts_per_page' => $this->need_posts_count,
|
||||
'post_type' => $this->post_type,
|
||||
'tax_query' => array(
|
||||
'relation' => 'OR',
|
||||
),
|
||||
);
|
||||
|
||||
$args['tax_query'] = array_merge( $args['tax_query'], $tax_data );
|
||||
|
||||
// Result.
|
||||
$this->query_get_posts( $args );
|
||||
}
|
||||
} else {
|
||||
// Tags ID's.
|
||||
$tag_ids = array();
|
||||
foreach ( $tags as $individual_tag ) {
|
||||
$tag_ids[] = $individual_tag->term_id;
|
||||
}
|
||||
|
||||
// Query.
|
||||
$args = array(
|
||||
'tag__in' => $tag_ids,
|
||||
'post__not_in' => $this->exclude_posts,
|
||||
'posts_per_page' => $this->need_posts_count,
|
||||
'post_type' => $this->post_type,
|
||||
);
|
||||
|
||||
// Result.
|
||||
$this->query_get_posts( $args );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Related By Current Term
|
||||
*/
|
||||
public function get_output_type_current_term() {
|
||||
if ( $this->need_posts_count <= 0 ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Post terms.
|
||||
if ( ! empty( $this->post_terms ) ) {
|
||||
$terms_array = array();
|
||||
$tax_data = array();
|
||||
$exclude_parent = array();
|
||||
|
||||
// Terms array.
|
||||
foreach ( $this->post_terms as $post_term ) {
|
||||
if ( $post_term->parent ) {
|
||||
$exclude_parent[ $post_term->taxonomy ][] = $post_term->parent;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( $this->post_terms as $post_term ) {
|
||||
$exclude = isset( $exclude_parent[ $post_term->taxonomy ] ) ? $exclude_parent[ $post_term->taxonomy ] : array();
|
||||
|
||||
if ( ! in_array( $post_term->term_id, (array) $exclude, true ) ) {
|
||||
$terms_array[ $post_term->taxonomy ][] = $post_term->term_id;
|
||||
}
|
||||
}
|
||||
|
||||
// Tax data.
|
||||
foreach ( $terms_array as $p_tax => $p_terms ) {
|
||||
|
||||
if ( is_array( $p_terms ) ) {
|
||||
$terms_array[ $p_tax ] = array_unique( $terms_array[ $p_tax ] );
|
||||
}
|
||||
|
||||
$tax_data[] = array(
|
||||
'taxonomy' => $p_tax,
|
||||
'field' => 'id',
|
||||
'terms' => $terms_array[ $p_tax ],
|
||||
);
|
||||
}
|
||||
|
||||
// Query.
|
||||
if ( ! empty( $tax_data ) ) {
|
||||
$args = array(
|
||||
'post__not_in' => $this->exclude_posts,
|
||||
'posts_per_page' => $this->need_posts_count,
|
||||
'post_type' => $this->post_type,
|
||||
'tax_query' => array(
|
||||
'relation' => 'OR',
|
||||
),
|
||||
);
|
||||
|
||||
$args['tax_query'] = array_merge( $args['tax_query'], $tax_data );
|
||||
|
||||
// Result.
|
||||
$this->query_get_posts( $args );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Related By Parent Term
|
||||
*/
|
||||
public function get_output_type_parent_term() {
|
||||
if ( $this->need_posts_count <= 0 ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Parent terms.
|
||||
if ( ! empty( $this->post_terms ) ) {
|
||||
$terms_array = array();
|
||||
$tax_data = array();
|
||||
|
||||
// Terms array.
|
||||
foreach ( $this->post_terms as $post_term ) {
|
||||
if ( 0 !== $post_term->parent ) {
|
||||
$terms_array[ $post_term->taxonomy ][] = $post_term->parent;
|
||||
}
|
||||
}
|
||||
|
||||
// Tax data.
|
||||
foreach ( $terms_array as $p_tax => $p_terms ) {
|
||||
if ( is_array( $p_terms ) ) {
|
||||
$terms_array[ $p_tax ] = array_unique( $terms_array[ $p_tax ] );
|
||||
}
|
||||
|
||||
$tax_data[] = array(
|
||||
'taxonomy' => $p_tax,
|
||||
'field' => 'id',
|
||||
'terms' => $terms_array[ $p_tax ],
|
||||
);
|
||||
}
|
||||
|
||||
// Query.
|
||||
if ( ! empty( $tax_data ) ) {
|
||||
$args = array(
|
||||
'post__not_in' => $this->exclude_posts,
|
||||
'posts_per_page' => $this->need_posts_count,
|
||||
'post_type' => $this->post_type,
|
||||
'tax_query' => array(
|
||||
'relation' => 'OR',
|
||||
),
|
||||
);
|
||||
|
||||
$args['tax_query'] = array_merge( $args['tax_query'], $tax_data );
|
||||
|
||||
// Result.
|
||||
$this->query_get_posts( $args );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Related By Post Type
|
||||
*/
|
||||
public function get_output_type_post_type() {
|
||||
if ( $this->need_posts_count <= 0 ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Posts by Post type.
|
||||
$args = array(
|
||||
'post__not_in' => $this->exclude_posts,
|
||||
'posts_per_page' => $this->need_posts_count,
|
||||
'post_type' => $this->post_type,
|
||||
);
|
||||
|
||||
// Result.
|
||||
$this->query_get_posts( $args );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Post terms
|
||||
*
|
||||
* @param array $post_id Post ID.
|
||||
* @param array $exclude_tags Exclude post tags taxonomy. Optional.
|
||||
* @return array Post Terms.
|
||||
*/
|
||||
public function get_post_terms( $post_id, $exclude_tags = true ) {
|
||||
|
||||
// Get Taxonomies.
|
||||
$taxonomies = get_taxonomies( array(
|
||||
'public' => true,
|
||||
), 'names' );
|
||||
|
||||
if ( ! is_array( $taxonomies ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Exclude post tags.
|
||||
if ( $exclude_tags ) {
|
||||
if ( isset( $taxonomies['post_tag'] ) ) {
|
||||
unset( $taxonomies['post_tag'] );
|
||||
}
|
||||
}
|
||||
|
||||
// Add Post Terms.
|
||||
$post_terms = array();
|
||||
foreach ( $taxonomies as $tax_name => $tax_data ) {
|
||||
$tax_terms = get_the_terms( $post_id, $tax_name );
|
||||
|
||||
if ( is_array( $tax_terms ) && ! is_wp_error( $tax_terms ) ) {
|
||||
$post_terms = array_merge( $post_terms, $tax_terms );
|
||||
}
|
||||
}
|
||||
|
||||
return $post_terms;
|
||||
}
|
||||
|
||||
/**
|
||||
* Output posts
|
||||
*
|
||||
* @return array Inline posts
|
||||
*/
|
||||
public function output() {
|
||||
|
||||
// Check Post ID.
|
||||
if ( intval( $this->args['post_id'] ) <= 0 ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
// Get Related Posts.
|
||||
foreach ( $this->args['output_type'] as $related ) {
|
||||
switch ( $related ) {
|
||||
case 'posts':
|
||||
$this->get_posts_by_filters();
|
||||
break;
|
||||
case 'tags':
|
||||
$this->get_output_type_tags();
|
||||
break;
|
||||
case 'term':
|
||||
$this->get_output_type_current_term();
|
||||
break;
|
||||
case 'parent_term':
|
||||
$this->get_output_type_parent_term();
|
||||
break;
|
||||
case 'post_type':
|
||||
$this->get_output_type_post_type();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Posts process.
|
||||
$this->posts_process();
|
||||
|
||||
// Return posts.
|
||||
return $this->posts_list;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Inline Posts
|
||||
*
|
||||
* @param array $args Inline posts settings.
|
||||
*/
|
||||
function powerkit_get_inline_posts( $args = array() ) {
|
||||
|
||||
// Create Related Posts Object.
|
||||
$related = new Powerkit_Inline_Posts_Snippet( $args );
|
||||
|
||||
return $related->output();
|
||||
}
|
||||
+113
@@ -0,0 +1,113 @@
|
||||
<?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_Inline_Posts_Public extends Powerkit_Module_Public {
|
||||
|
||||
/**
|
||||
* Initialize
|
||||
*/
|
||||
public function initialize() {
|
||||
// PinIt exclude selectors.
|
||||
add_filter( 'powerkit_pinit_exclude_selectors', array( $this, 'pinit_disable' ) );
|
||||
|
||||
// Reset global related variable.
|
||||
add_filter( 'the_content', array( $this, 'reset_related' ), 1 );
|
||||
|
||||
// Register Templates.
|
||||
add_action( 'init', array( $this, 'register_templates' ) );
|
||||
add_filter( 'powerkit_inline_posts_templates', array( $this, 'list_templates' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset global $powerkit_inline_posts.
|
||||
*
|
||||
* @param string $content Content of the current post.
|
||||
*/
|
||||
public function reset_related( $content ) {
|
||||
global $powerkit_inline_posts;
|
||||
|
||||
$powerkit_inline_posts = null;
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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/inline-posts-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(
|
||||
'list' => array(
|
||||
'name' => esc_html__( 'List', 'powerkit' ),
|
||||
'func' => 'powerkit_inline_posts_default_template',
|
||||
),
|
||||
'grid' => array(
|
||||
'name' => esc_html__( 'Grid', 'powerkit' ),
|
||||
'func' => 'powerkit_inline_posts_default_template',
|
||||
),
|
||||
'grid-2' => array(
|
||||
'name' => esc_html__( 'Grid 2', 'powerkit' ),
|
||||
'func' => 'powerkit_inline_posts_default_template',
|
||||
),
|
||||
'grid-3' => array(
|
||||
'name' => esc_html__( 'Grid 3', 'powerkit' ),
|
||||
'func' => 'powerkit_inline_posts_default_template',
|
||||
),
|
||||
'grid-4' => array(
|
||||
'name' => esc_html__( 'Grid 4', 'powerkit' ),
|
||||
'func' => 'powerkit_inline_posts_default_template',
|
||||
),
|
||||
);
|
||||
|
||||
return $templates;
|
||||
}
|
||||
|
||||
/**
|
||||
* PinIt exclude selectors
|
||||
*
|
||||
* @param string $selectors List selectors.
|
||||
*/
|
||||
public function pinit_disable( $selectors ) {
|
||||
$selectors[] = '.pk-inline-posts-container img';
|
||||
|
||||
return $selectors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the stylesheets for the public-facing side of the site.
|
||||
*/
|
||||
public function wp_enqueue_scripts() {
|
||||
wp_enqueue_style( 'powerkit-inline-posts', powerkit_style( plugin_dir_url( __FILE__ ) . 'css/public-powerkit-inline-posts.css' ), array(), powerkit_get_setting( 'version' ), 'all' );
|
||||
|
||||
// Add RTL support.
|
||||
wp_style_add_data( 'powerkit-inline-posts', 'rtl', 'replace' );
|
||||
}
|
||||
}
|
||||
+245
@@ -0,0 +1,245 @@
|
||||
<?php
|
||||
/**
|
||||
* Shortcode
|
||||
*
|
||||
* @link https://codesupply.co
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package Powerkit
|
||||
* @subpackage Powerkit/shortcodes
|
||||
*/
|
||||
|
||||
/**
|
||||
* Template handler
|
||||
*
|
||||
* @param string $name Specific template.
|
||||
* @param array $posts Array of posts.
|
||||
* @param array $settings Array of settings.
|
||||
*/
|
||||
function powerkit_inline_posts_template_handler( $name, $posts, $settings ) {
|
||||
$templates = apply_filters( 'powerkit_inline_posts_templates', array() );
|
||||
|
||||
if ( isset( $templates[ $name ] ) && function_exists( $templates[ $name ]['func'] ) ) {
|
||||
call_user_func( $templates[ $name ]['func'], $posts, $settings );
|
||||
} else {
|
||||
call_user_func( 'powerkit_inline_posts_default_template', $posts, $settings );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Shortcode
|
||||
*
|
||||
* @param array $atts User defined attributes in shortcode tag.
|
||||
* @param string $content Shorcode tag content.
|
||||
* @return string Shortcode result HTML.
|
||||
*/
|
||||
function powerkit_inline_posts_shortcode( $atts, $content = '' ) {
|
||||
|
||||
if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
global $post;
|
||||
|
||||
ob_start();
|
||||
|
||||
global $powerkit_inline_posts;
|
||||
|
||||
// Attributes.
|
||||
$atts = powerkit_shortcode_atts( shortcode_atts( array(
|
||||
'title' => '',
|
||||
'count' => 1,
|
||||
'offset' => 0,
|
||||
'ids' => null,
|
||||
'category' => null,
|
||||
'tag' => null,
|
||||
'time_frame' => null,
|
||||
'orderby' => 'date',
|
||||
'order' => 'DESC',
|
||||
'template' => 'list',
|
||||
'image_size' => 'pk-thumbnail',
|
||||
'exclude_posts' => $powerkit_inline_posts,
|
||||
), $atts ) );
|
||||
|
||||
$posts = powerkit_get_inline_posts( $atts );
|
||||
|
||||
$columns = 1;
|
||||
$template = $atts['template'];
|
||||
|
||||
// Check grid template.
|
||||
switch ( $atts['template'] ) {
|
||||
case 'grid-2':
|
||||
$template = 'grid';
|
||||
$columns = 2;
|
||||
break;
|
||||
case 'grid-3':
|
||||
$template = 'grid';
|
||||
$columns = 3;
|
||||
break;
|
||||
case 'grid-4':
|
||||
$template = 'grid';
|
||||
$columns = 4;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( $posts ) {
|
||||
?>
|
||||
<div class="pk-inline-posts">
|
||||
<?php
|
||||
$tag = apply_filters( 'powerkit_section_title_tag', 'h5' );
|
||||
|
||||
if ( $atts['title'] ) {
|
||||
?>
|
||||
<<?php echo esc_html( $tag ); ?> class="pk-inline-posts-title pk-title pk-font-block">
|
||||
<?php echo esc_html( $atts['title'] ); ?>
|
||||
</<?php echo esc_html( $tag ); ?>>
|
||||
<?php } ?>
|
||||
|
||||
<div class="pk-inline-posts-container pk-inline-posts-template-<?php echo esc_attr( $template ); ?>"
|
||||
data-columns="<?php echo esc_attr( $columns ); ?>">
|
||||
<?php
|
||||
foreach ( $posts as $post ) {
|
||||
|
||||
setup_postdata( $post );
|
||||
// Exclude current post ID.
|
||||
$powerkit_inline_posts[] = $post->ID;
|
||||
|
||||
// Output template.
|
||||
powerkit_inline_posts_template_handler( $atts['template'], $posts, $atts );
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
wp_reset_postdata();
|
||||
|
||||
return ob_get_clean();
|
||||
}
|
||||
add_shortcode( 'powerkit_posts', 'powerkit_inline_posts_shortcode' );
|
||||
|
||||
/**
|
||||
* Map Social Links Shortcode into the Basic Shortcodes Plugin
|
||||
*/
|
||||
if ( function_exists( 'powerkit_basic_shortcodes_register' ) ) :
|
||||
|
||||
add_action( 'init', function() {
|
||||
|
||||
$shortcode_map = array(
|
||||
'name' => 'inline_posts',
|
||||
'title' => esc_html__( 'Inline Posts', 'powerkit' ),
|
||||
'priority' => 200,
|
||||
'base' => 'powerkit_posts',
|
||||
'autoregister' => false,
|
||||
'fields' => array(
|
||||
array(
|
||||
'type' => 'input',
|
||||
'name' => 'title',
|
||||
'label' => esc_html__( 'Title', 'powerkit' ),
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'input',
|
||||
'name' => 'count',
|
||||
'label' => esc_html__( 'Count', 'powerkit' ),
|
||||
'default' => 1,
|
||||
),
|
||||
array(
|
||||
'type' => 'input',
|
||||
'name' => 'offset',
|
||||
'label' => esc_html__( 'Offset', 'powerkit' ),
|
||||
'default' => 0,
|
||||
),
|
||||
array(
|
||||
'type' => 'input',
|
||||
'name' => 'image_size',
|
||||
'label' => esc_html__( 'Image size', 'powerkit' ),
|
||||
'default' => 'pk-thumbnail',
|
||||
),
|
||||
array(
|
||||
'type' => 'input',
|
||||
'name' => 'category',
|
||||
'label' => esc_html__( 'Filter by categories', 'powerkit' ),
|
||||
'desc' => esc_html__( 'Add comma-separated list of category slugs. For example: «travel, lifestyle, food». Leave empty for all categories.', 'powerkit' ),
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'input',
|
||||
'name' => 'tag',
|
||||
'label' => esc_html__( 'Filter by tags', 'powerkit' ),
|
||||
'desc' => esc_html__( 'Add comma-separated list of tag slugs. For example: «worth-reading, top-5, playlists». Leave empty for all tags.', 'powerkit' ),
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'input',
|
||||
'name' => 'ids',
|
||||
'label' => esc_html__( 'Filter by posts', 'powerkit' ),
|
||||
'desc' => esc_html__( 'Add comma-separated list of post IDs. For example: 12, 34, 145. Leave empty for all posts.', 'powerkit' ),
|
||||
'default' => '',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// Add fields order and time frame.
|
||||
if ( powerkit_post_views_enabled() ) {
|
||||
$shortcode_map['fields'][] = array(
|
||||
'type' => 'radio',
|
||||
'name' => 'orderby',
|
||||
'label' => esc_html__( 'Order posts by', 'powerkit' ),
|
||||
'style' => 'vertical',
|
||||
'default' => 'date',
|
||||
'options' => array(
|
||||
'date' => esc_html__( 'Date', 'powerkit' ),
|
||||
'post_views' => esc_html__( 'Views', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
$shortcode_map['fields'][] = array(
|
||||
'type' => 'radio',
|
||||
'name' => 'order',
|
||||
'label' => esc_html__( 'Order', 'powerkit' ),
|
||||
'style' => 'vertical',
|
||||
'default' => 'DESC',
|
||||
'options' => array(
|
||||
'DESC' => esc_html__( 'DESC', 'powerkit' ),
|
||||
'ASC' => esc_html__( 'ASC', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
$shortcode_map['fields'][] = array(
|
||||
'type' => 'input',
|
||||
'name' => 'time_frame',
|
||||
'label' => esc_html__( 'Filter by time frame', 'powerkit' ),
|
||||
'desc' => esc_html__( 'Work only if Order by Views', 'powerkit' ) . '<br>' .
|
||||
esc_html__( 'Add period of posts in English. For example: «2 months», «14 days» or even «1 year»', 'powerkit' ),
|
||||
'default' => '',
|
||||
);
|
||||
}
|
||||
|
||||
// Add field template.
|
||||
$templates = apply_filters( 'powerkit_inline_posts_templates', array() );
|
||||
|
||||
if ( count( (array) $templates ) > 1 ) {
|
||||
$options = array();
|
||||
|
||||
foreach ( $templates as $key => $item ) {
|
||||
if ( isset( $item['name'] ) ) {
|
||||
$options[ $key ] = $item['name'];
|
||||
}
|
||||
}
|
||||
|
||||
$shortcode_map['fields'][] = array(
|
||||
'type' => 'select',
|
||||
'name' => 'template',
|
||||
'label' => esc_html__( 'Template', 'powerkit' ),
|
||||
'default' => 'list',
|
||||
'options' => $options,
|
||||
);
|
||||
}
|
||||
|
||||
powerkit_basic_shortcodes_register( $shortcode_map );
|
||||
|
||||
});
|
||||
|
||||
endif;
|
||||
+171
@@ -0,0 +1,171 @@
|
||||
/**
|
||||
* All of the CSS for your public-facing functionality should be
|
||||
* included in this file.
|
||||
*/
|
||||
/**
|
||||
* Environment for all styles (variables, additions, etc).
|
||||
*/
|
||||
/*--------------------------------------------------------------*/
|
||||
/*--------------------------------------------------------------*/
|
||||
.pk-inline-posts .pk-inline-posts-title {
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.pk-inline-posts:not(:last-child) {
|
||||
padding-bottom: 40px;
|
||||
margin-bottom: 3rem;
|
||||
border-bottom: 1px #e9ecef solid;
|
||||
}
|
||||
|
||||
.pk-inline-posts:not(:first-child) {
|
||||
padding-top: 40px;
|
||||
margin-top: 3rem;
|
||||
border-top: 1px #e9ecef solid;
|
||||
}
|
||||
|
||||
.pk-inline-posts-container .pk-overlay {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: flex-start;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.pk-inline-posts-container .pk-overlay-background {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 0;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
.pk-inline-posts-container .pk-overlay-background figure {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.pk-inline-posts-container .pk-overlay-background img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
-o-object-fit: cover;
|
||||
object-fit: cover;
|
||||
font-family: 'object-fit: cover;';
|
||||
}
|
||||
|
||||
.pk-inline-posts-container .pk-overlay-ratio:before {
|
||||
content: '';
|
||||
display: table;
|
||||
box-sizing: border-box;
|
||||
width: 0;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.pk-inline-posts-container .pk-ratio-landscape:before {
|
||||
padding-bottom: 75%;
|
||||
}
|
||||
|
||||
.pk-inline-posts-container .pk-overlay-link {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.pk-inline-posts-container .pk-post-inner:not(:last-child) {
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.pk-inline-posts-container .pk-post-meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.pk-inline-posts-container .pk-post-meta .sep {
|
||||
display: inline-block;
|
||||
padding: 0 0.5rem;
|
||||
}
|
||||
|
||||
.pk-inline-posts-container article:not(:first-child) {
|
||||
margin-top: 40px;
|
||||
}
|
||||
|
||||
@media (min-width: 576px) {
|
||||
.pk-inline-posts-template-list .pk-post-outer {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
margin-left: -20px;
|
||||
margin-right: -20px;
|
||||
}
|
||||
.pk-inline-posts-template-list .pk-post-inner {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
padding-left: 20px;
|
||||
padding-right: 20px;
|
||||
flex: 0 0 50%;
|
||||
max-width: 50%;
|
||||
}
|
||||
.pk-inline-posts-template-list .pk-post-inner:not(:last-child) {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.pk-inline-posts-template-list .pk-post-inner:first-child:last-child {
|
||||
flex: 0 0 100%;
|
||||
max-width: 100%;
|
||||
}
|
||||
.pk-inline-posts-template-list .pk-post-inner + .pk-post-inner {
|
||||
margin-top: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
|
||||
.pk-inline-posts-template-grid .pk-post-inner + .pk-post-inner {
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
@media (min-width: 576px) {
|
||||
.pk-inline-posts-template-grid {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
margin-left: -20px;
|
||||
margin-right: -20px;
|
||||
}
|
||||
.pk-inline-posts-template-grid article {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
padding-left: 20px;
|
||||
padding-right: 20px;
|
||||
flex: 0 0 50%;
|
||||
max-width: 50%;
|
||||
}
|
||||
.pk-inline-posts-template-grid article:nth-child(-n+2) {
|
||||
margin-top: 0;
|
||||
}
|
||||
.pk-inline-posts-template-grid[data-columns="1"] {
|
||||
flex-direction: column;
|
||||
}
|
||||
.pk-inline-posts-template-grid[data-columns="1"] article {
|
||||
flex: 0 0 100%;
|
||||
max-width: 100%;
|
||||
}
|
||||
.pk-inline-posts-template-grid[data-columns="1"] article:not(:first-child) {
|
||||
margin-top: 40px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 1200px) {
|
||||
.pk-inline-posts-template-grid[data-columns="3"] article {
|
||||
flex: 0 0 33.3333333333%;
|
||||
max-width: 33.3333333333%;
|
||||
}
|
||||
.pk-inline-posts-template-grid[data-columns="3"] article:nth-child(-n+3) {
|
||||
margin-top: 0;
|
||||
}
|
||||
.pk-inline-posts-template-grid[data-columns="4"] article {
|
||||
flex: 0 0 25%;
|
||||
max-width: 25%;
|
||||
}
|
||||
.pk-inline-posts-template-grid[data-columns="4"] article:nth-child(-n+4) {
|
||||
margin-top: 0;
|
||||
}
|
||||
}
|
||||
+171
@@ -0,0 +1,171 @@
|
||||
/**
|
||||
* All of the CSS for your public-facing functionality should be
|
||||
* included in this file.
|
||||
*/
|
||||
/**
|
||||
* Environment for all styles (variables, additions, etc).
|
||||
*/
|
||||
/*--------------------------------------------------------------*/
|
||||
/*--------------------------------------------------------------*/
|
||||
.pk-inline-posts .pk-inline-posts-title {
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.pk-inline-posts:not(:last-child) {
|
||||
padding-bottom: 40px;
|
||||
margin-bottom: 3rem;
|
||||
border-bottom: 1px #e9ecef solid;
|
||||
}
|
||||
|
||||
.pk-inline-posts:not(:first-child) {
|
||||
padding-top: 40px;
|
||||
margin-top: 3rem;
|
||||
border-top: 1px #e9ecef solid;
|
||||
}
|
||||
|
||||
.pk-inline-posts-container .pk-overlay {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: flex-start;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.pk-inline-posts-container .pk-overlay-background {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
.pk-inline-posts-container .pk-overlay-background figure {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.pk-inline-posts-container .pk-overlay-background img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
-o-object-fit: cover;
|
||||
object-fit: cover;
|
||||
font-family: 'object-fit: cover;';
|
||||
}
|
||||
|
||||
.pk-inline-posts-container .pk-overlay-ratio:before {
|
||||
content: '';
|
||||
display: table;
|
||||
box-sizing: border-box;
|
||||
width: 0;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.pk-inline-posts-container .pk-ratio-landscape:before {
|
||||
padding-bottom: 75%;
|
||||
}
|
||||
|
||||
.pk-inline-posts-container .pk-overlay-link {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.pk-inline-posts-container .pk-post-inner:not(:last-child) {
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.pk-inline-posts-container .pk-post-meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.pk-inline-posts-container .pk-post-meta .sep {
|
||||
display: inline-block;
|
||||
padding: 0 0.5rem;
|
||||
}
|
||||
|
||||
.pk-inline-posts-container article:not(:first-child) {
|
||||
margin-top: 40px;
|
||||
}
|
||||
|
||||
@media (min-width: 576px) {
|
||||
.pk-inline-posts-template-list .pk-post-outer {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
margin-right: -20px;
|
||||
margin-left: -20px;
|
||||
}
|
||||
.pk-inline-posts-template-list .pk-post-inner {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
padding-right: 20px;
|
||||
padding-left: 20px;
|
||||
flex: 0 0 50%;
|
||||
max-width: 50%;
|
||||
}
|
||||
.pk-inline-posts-template-list .pk-post-inner:not(:last-child) {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.pk-inline-posts-template-list .pk-post-inner:first-child:last-child {
|
||||
flex: 0 0 100%;
|
||||
max-width: 100%;
|
||||
}
|
||||
.pk-inline-posts-template-list .pk-post-inner + .pk-post-inner {
|
||||
margin-top: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
|
||||
.pk-inline-posts-template-grid .pk-post-inner + .pk-post-inner {
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
@media (min-width: 576px) {
|
||||
.pk-inline-posts-template-grid {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
margin-right: -20px;
|
||||
margin-left: -20px;
|
||||
}
|
||||
.pk-inline-posts-template-grid article {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
padding-right: 20px;
|
||||
padding-left: 20px;
|
||||
flex: 0 0 50%;
|
||||
max-width: 50%;
|
||||
}
|
||||
.pk-inline-posts-template-grid article:nth-child(-n+2) {
|
||||
margin-top: 0;
|
||||
}
|
||||
.pk-inline-posts-template-grid[data-columns="1"] {
|
||||
flex-direction: column;
|
||||
}
|
||||
.pk-inline-posts-template-grid[data-columns="1"] article {
|
||||
flex: 0 0 100%;
|
||||
max-width: 100%;
|
||||
}
|
||||
.pk-inline-posts-template-grid[data-columns="1"] article:not(:first-child) {
|
||||
margin-top: 40px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 1200px) {
|
||||
.pk-inline-posts-template-grid[data-columns="3"] article {
|
||||
flex: 0 0 33.3333333333%;
|
||||
max-width: 33.3333333333%;
|
||||
}
|
||||
.pk-inline-posts-template-grid[data-columns="3"] article:nth-child(-n+3) {
|
||||
margin-top: 0;
|
||||
}
|
||||
.pk-inline-posts-template-grid[data-columns="4"] article {
|
||||
flex: 0 0 25%;
|
||||
max-width: 25%;
|
||||
}
|
||||
.pk-inline-posts-template-grid[data-columns="4"] article:nth-child(-n+4) {
|
||||
margin-top: 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
/**
|
||||
* Posts Template
|
||||
*
|
||||
* @link https://codesupply.co
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package PowerKit
|
||||
* @subpackage PowerKit/templates
|
||||
*/
|
||||
|
||||
/**
|
||||
* Default Template
|
||||
*
|
||||
* @param array $posts Array of posts.
|
||||
* @param array $settings Array of settings.
|
||||
*/
|
||||
function powerkit_inline_posts_default_template( $posts, $settings ) {
|
||||
?>
|
||||
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
|
||||
<div class="pk-post-outer">
|
||||
|
||||
<?php if ( has_post_thumbnail() ) { ?>
|
||||
<div class="pk-post-inner">
|
||||
<div class="entry-thumbnail">
|
||||
<div class="pk-overlay pk-overlay-ratio pk-ratio-landscape">
|
||||
<div class="pk-overlay-background">
|
||||
<a href="<?php the_permalink(); ?>" class="pk-overlay-link">
|
||||
<?php the_post_thumbnail( $settings['image_size'] ); ?>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<div class="pk-post-inner">
|
||||
<header>
|
||||
<?php
|
||||
if ( function_exists( 'csco_get_post_meta' ) ) {
|
||||
csco_get_post_meta( array( 'category' ), false, true, array( 'category' ) );
|
||||
}
|
||||
|
||||
// Post Title.
|
||||
switch ( $settings['template'] ) {
|
||||
case 'list':
|
||||
$tag = 'h3';
|
||||
break;
|
||||
case 'grid-2':
|
||||
$tag = 'h3';
|
||||
break;
|
||||
default:
|
||||
$tag = 'h5';
|
||||
break;
|
||||
}
|
||||
|
||||
$tag = apply_filters( 'powerkit_widget_inline_posts_title_tag', $tag, $settings );
|
||||
|
||||
the_title( '<' . $tag . ' class="pk-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></' . $tag . '>' );
|
||||
|
||||
// Post Meta.
|
||||
if ( function_exists( 'csco_get_post_meta' ) ) {
|
||||
csco_get_post_meta( array( 'author', 'date' ), false, true, array( 'author', 'date' ) );
|
||||
} else {
|
||||
?>
|
||||
<div class="pk-post-meta">
|
||||
<?php echo powerkit_get_meta_author(); // XSS. ?>
|
||||
<span class="sep">·</span>
|
||||
<?php echo powerkit_get_meta_date(); // XSS. ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</header><!-- .entry-header -->
|
||||
</div><!-- .post-inner -->
|
||||
|
||||
</div><!-- .post-outer -->
|
||||
</article>
|
||||
<?php
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
<?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_Instagram_Admin extends Powerkit_Module_Admin {
|
||||
|
||||
/**
|
||||
* Initialize
|
||||
*/
|
||||
public function initialize() {
|
||||
add_filter( 'powerkit_reset_cache', array( $this, 'register_reset_cache' ) );
|
||||
add_filter( 'powerkit_ajax_reset_cache', array( $this, 'register_reset_cache' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register Reset Cache
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @param array $list Change list reset cache.
|
||||
* @access private
|
||||
*/
|
||||
public function register_reset_cache( $list ) {
|
||||
$slug = powerkit_get_page_slug( $this->slug );
|
||||
|
||||
$list[ $slug ] = array(
|
||||
'powerkit_instagram_data',
|
||||
'powerkit_instagram_recent',
|
||||
);
|
||||
|
||||
return $list;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
/**
|
||||
* Instagram
|
||||
*
|
||||
* @package Powerkit
|
||||
* @subpackage Modules
|
||||
*/
|
||||
|
||||
if ( class_exists( 'Powerkit_Module' ) ) {
|
||||
/**
|
||||
* Init module
|
||||
*/
|
||||
class Powerkit_Instagram extends Powerkit_Module {
|
||||
|
||||
/**
|
||||
* Register module
|
||||
*/
|
||||
public function register() {
|
||||
$this->name = esc_html__( 'Instagram Integration', 'powerkit' );
|
||||
$this->desc = esc_html__( 'Display your Instagram feed in your sidebar with a widget or post content via a shortcode, including your Instagram profile image, number of followers, as well as number of comments and likes per each image in the feed.', 'powerkit' );
|
||||
$this->slug = 'instagram_integration';
|
||||
$this->type = 'default';
|
||||
$this->category = 'social';
|
||||
$this->priority = 60;
|
||||
$this->public = true;
|
||||
$this->enabled = true;
|
||||
$this->load_extensions = array(
|
||||
'connect',
|
||||
);
|
||||
$this->links = array(
|
||||
array(
|
||||
'name' => esc_html__( 'Connect', 'powerkit' ),
|
||||
'url' => powerkit_get_page_url( 'connect&tab=instagram' ),
|
||||
),
|
||||
array(
|
||||
'name' => esc_html__( 'Clear cache', 'powerkit' ),
|
||||
'url' => powerkit_get_page_url( $this->slug . '&action=powerkit_reset_cache' ),
|
||||
),
|
||||
array(
|
||||
'name' => esc_html__( 'View documentation', 'powerkit' ),
|
||||
'url' => powerkit_get_setting( 'documentation' ) . '/social-integrations/instagram-integration/',
|
||||
'target' => '_blank',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize module
|
||||
*/
|
||||
public function initialize() {
|
||||
|
||||
/* Load the required dependencies for this module */
|
||||
|
||||
// Helpers Functions for the module.
|
||||
require_once dirname( __FILE__ ) . '/helpers/helper-powerkit-instagram.php';
|
||||
require_once dirname( __FILE__ ) . '/helpers/helper-powerkit-instagram-connect-list.php';
|
||||
|
||||
// The classes responsible for defining all actions.
|
||||
require_once dirname( __FILE__ ) . '/public/class-powerkit-instagram-shortcode.php';
|
||||
require_once dirname( __FILE__ ) . '/public/class-powerkit-instagram-widget.php';
|
||||
|
||||
if ( function_exists( 'register_block_type' ) ) {
|
||||
require_once dirname( __FILE__ ) . '/public/class-powerkit-instagram-block.php';
|
||||
}
|
||||
|
||||
// Admin and public area.
|
||||
require_once dirname( __FILE__ ) . '/admin/class-powerkit-instagram-admin.php';
|
||||
require_once dirname( __FILE__ ) . '/public/class-powerkit-instagram-public.php';
|
||||
|
||||
new Powerkit_Instagram_Admin( $this->slug );
|
||||
new Powerkit_Instagram_Public( $this->slug );
|
||||
}
|
||||
}
|
||||
|
||||
new Powerkit_Instagram();
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* Register Connect List
|
||||
*
|
||||
* @package Powerkit
|
||||
* @subpackage Modules/Helper
|
||||
*/
|
||||
|
||||
/**
|
||||
* Add item instagram to list
|
||||
*
|
||||
* @param array $list Array social list.
|
||||
*/
|
||||
function powerkit_connect_instagram( $list = array() ) {
|
||||
|
||||
// Instagram.
|
||||
$list['instagram'] = array(
|
||||
'id' => 'instagram',
|
||||
'name' => esc_html__( 'Instagram', 'powerkit' ),
|
||||
);
|
||||
|
||||
return $list;
|
||||
}
|
||||
add_filter( 'powerkit_register_connect_list', 'powerkit_connect_instagram' );
|
||||
@@ -0,0 +1,680 @@
|
||||
<?php
|
||||
/**
|
||||
* Helpers Instagram
|
||||
*
|
||||
* @package Powerkit
|
||||
* @subpackage Modules/Helper
|
||||
*/
|
||||
|
||||
/**
|
||||
* Template handler
|
||||
*
|
||||
* @param string $name Specific template.
|
||||
* @param array $feed Array of instagram feed.
|
||||
* @param array $instagram Array of instagram items.
|
||||
* @param array $params Array of params.
|
||||
*/
|
||||
function powerkit_instagram_template_handler( $name, $feed, $instagram, $params ) {
|
||||
$templates = apply_filters( 'powerkit_instagram_templates', array() );
|
||||
|
||||
$new = isset( $templates['default'] ) ? false : true;
|
||||
|
||||
if ( $new && count( $templates ) > 0 ) {
|
||||
$first_item = array_shift( $templates );
|
||||
|
||||
if ( function_exists( $first_item['func'] ) ) {
|
||||
call_user_func( $first_item['func'], $feed, $instagram, $params );
|
||||
} else {
|
||||
call_user_func( 'powerkit_instagram_default_template', $feed, $instagram, $params );
|
||||
}
|
||||
} elseif ( isset( $templates[ $name ] ) && function_exists( $templates[ $name ]['func'] ) ) {
|
||||
call_user_func( $templates[ $name ]['func'], $feed, $instagram, $params );
|
||||
} else {
|
||||
call_user_func( 'powerkit_instagram_default_template', $feed, $instagram, $params );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get templates options
|
||||
*
|
||||
* @return array Items.
|
||||
*/
|
||||
function powerkit_instagram_get_templates_options() {
|
||||
$options = array();
|
||||
|
||||
$templates = apply_filters( 'powerkit_instagram_templates', array() );
|
||||
|
||||
if ( $templates ) {
|
||||
foreach ( $templates as $key => $item ) {
|
||||
if ( isset( $item['name'] ) ) {
|
||||
$options[ $key ] = $item['name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data (from json) of instagram response
|
||||
*
|
||||
* @param string $ins_request Instagram request.
|
||||
* @param array $ins_params Options.
|
||||
*/
|
||||
function powerkit_instagram_json_get_feed( $ins_request, $ins_params ) {
|
||||
|
||||
$user_data = wp_remote_retrieve_body( $ins_request );
|
||||
|
||||
// Json decode of user.
|
||||
$user_data = json_decode( $user_data );
|
||||
|
||||
// Get data of user.
|
||||
if ( is_object( $user_data ) ) {
|
||||
|
||||
if ( isset( $user_data->error->message ) ) {
|
||||
|
||||
return sprintf( '%s <a href="%s">%s</a>', $user_data->error->message . esc_html__( ' Please check your ', 'powerkit' ), powerkit_get_page_url( 'connect&tab=instagram' ), esc_html__( ' Instagram Settings', 'powerkit' ) );
|
||||
|
||||
} elseif ( isset( $user_data->username ) ) {
|
||||
|
||||
if ( $ins_params['user_id'] !== $user_data->username ) {
|
||||
return esc_html__( 'Please check your Instagram User, you do not have access to this account.', 'powerkit' );
|
||||
}
|
||||
} else {
|
||||
|
||||
return sprintf( '%s <a href="%s">%s</a>', esc_html__( 'Instagram data is not set. Please check your Instagram User or ', 'powerkit' ), powerkit_get_page_url( 'connect&tab=instagram' ), esc_html__( ' Instagram Settings', 'powerkit' ) );
|
||||
}
|
||||
} else {
|
||||
return esc_html__( 'Error decoding the instagram json.', 'powerkit' );
|
||||
}
|
||||
|
||||
$media_data = wp_remote_retrieve_body( $ins_request['headers']['recent'] );
|
||||
|
||||
// Json decode of media.
|
||||
$media_data = json_decode( $media_data );
|
||||
|
||||
// Get data of media.
|
||||
if ( is_object( $media_data ) ) {
|
||||
|
||||
if ( isset( $media_data->error->message ) ) {
|
||||
|
||||
return sprintf( '%s <a href="%s">%s</a>', $media_data->error->message . esc_html__( ' Please check your ', 'powerkit' ), powerkit_get_page_url( 'connect&tab=instagram' ), esc_html__( ' Instagram Settings', 'powerkit' ) );
|
||||
|
||||
} elseif ( isset( $media_data ) ) {
|
||||
|
||||
// Images not found.
|
||||
if ( ! is_array( $media_data->data ) || count( $media_data->data ) <= 0 ) {
|
||||
return esc_html__( 'There are no images in your account.', 'powerkit' );
|
||||
}
|
||||
} else {
|
||||
|
||||
return sprintf( '%s <a href="%s">%s</a>', esc_html__( 'Instagram data is not set. Please check your Instagram User or ', 'powerkit' ), powerkit_get_page_url( 'connect&tab=instagram' ), esc_html__( ' Instagram Settings', 'powerkit' ) );
|
||||
}
|
||||
} else {
|
||||
return esc_html__( 'Error decoding the instagram json.', 'powerkit' );
|
||||
}
|
||||
|
||||
/* ------------- PARSE DATA -------------- */
|
||||
|
||||
$feed = array();
|
||||
|
||||
// Full name.
|
||||
$feed['name'] = null;
|
||||
|
||||
if ( isset( $user_data->name ) ) {
|
||||
$feed['name'] = $user_data->name;
|
||||
}
|
||||
|
||||
// Username.
|
||||
$feed['username'] = null;
|
||||
|
||||
if ( isset( $user_data->username ) ) {
|
||||
$feed['username'] = $user_data->username;
|
||||
}
|
||||
|
||||
// Liked count.
|
||||
$feed['following'] = null;
|
||||
|
||||
if ( isset( $user_data->following_count ) ) {
|
||||
$feed['following'] = (int) $user_data->following_count;
|
||||
}
|
||||
|
||||
// Liked count.
|
||||
$feed['followers'] = null;
|
||||
|
||||
if ( isset( $user_data->followers_count ) ) {
|
||||
$feed['followers'] = (int) $user_data->followers_count;
|
||||
}
|
||||
|
||||
// Avatar x1.
|
||||
$feed['avatar_1x'] = null;
|
||||
|
||||
if ( isset( $user_data->profile_picture_url ) ) {
|
||||
$feed['avatar_1x'] = $user_data->profile_picture_url;
|
||||
}
|
||||
|
||||
// Avatar x2.
|
||||
$feed['avatar_2x'] = null;
|
||||
|
||||
if ( isset( $user_data->profile_picture_url ) ) {
|
||||
$feed['avatar_2x'] = $user_data->profile_picture_url;
|
||||
}
|
||||
|
||||
// Images.
|
||||
$feed['images'] = array();
|
||||
|
||||
foreach ( $media_data->data as $key => $media ) {
|
||||
// Thumbnail.
|
||||
$feed['images'][ $key ]['sizes']['thumbnail'] = null;
|
||||
|
||||
if ( isset( $media->media_url ) ) {
|
||||
$feed['images'][ $key ]['sizes']['thumbnail'] = $media->media_url;
|
||||
}
|
||||
|
||||
// Small.
|
||||
$feed['images'][ $key ]['sizes']['small'] = null;
|
||||
|
||||
if ( isset( $media->media_url ) ) {
|
||||
$feed['images'][ $key ]['sizes']['small'] = $media->media_url;
|
||||
}
|
||||
|
||||
// Large.
|
||||
$feed['images'][ $key ]['sizes']['large'] = null;
|
||||
|
||||
if ( isset( $media->media_url ) ) {
|
||||
$feed['images'][ $key ]['sizes']['large'] = $media->media_url;
|
||||
}
|
||||
|
||||
if ( isset( $media->thumbnail_url ) ) {
|
||||
$feed['images'][ $key ]['sizes']['thumbnail'] = $media->thumbnail_url;
|
||||
$feed['images'][ $key ]['sizes']['small'] = $media->thumbnail_url;
|
||||
$feed['images'][ $key ]['sizes']['large'] = $media->thumbnail_url;
|
||||
}
|
||||
|
||||
// Item link.
|
||||
$feed['images'][ $key ]['link'] = null;
|
||||
|
||||
if ( isset( $media->permalink ) ) {
|
||||
$feed['images'][ $key ]['link'] = $media->permalink;
|
||||
}
|
||||
|
||||
// Desc.
|
||||
$feed['images'][ $key ]['text'] = null;
|
||||
|
||||
if ( isset( $media->caption ) ) {
|
||||
$text = strtok( $media->caption, "\n" );
|
||||
|
||||
$feed['images'][ $key ]['text'] = strip_tags( $text );
|
||||
}
|
||||
|
||||
// Timestamp.
|
||||
$feed['images'][ $key ]['timestamp'] = null;
|
||||
|
||||
if ( isset( $media->timestamp ) ) {
|
||||
$feed['images'][ $key ]['timestamp'] = powerkit_relative_time( $media->timestamp );
|
||||
}
|
||||
|
||||
// Comment count.
|
||||
$feed['images'][ $key ]['comment_count'] = null;
|
||||
|
||||
if ( isset( $media->comments_count ) ) {
|
||||
$feed['images'][ $key ]['comment_count'] = (int) $media->comments_count;
|
||||
}
|
||||
|
||||
// Liked count.
|
||||
$feed['images'][ $key ]['liked_count'] = null;
|
||||
|
||||
if ( isset( $media->like_count ) ) {
|
||||
$feed['images'][ $key ]['liked_count'] = (int) $media->like_count;
|
||||
}
|
||||
}
|
||||
|
||||
// Number of images.
|
||||
if ( isset( $ins_params['number'] ) && intval( $ins_params['number'] ) > 0 ) {
|
||||
$feed['images'] = array_slice( $feed['images'], 0, $ins_params['number'], true );
|
||||
}
|
||||
|
||||
return $feed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data (from html) of instagram response
|
||||
*
|
||||
* @param string $ins_request Instagram request.
|
||||
* @param array $ins_params Options.
|
||||
*/
|
||||
function powerkit_instagram_html_get_feed( $ins_request, $ins_params ) {
|
||||
|
||||
$ins_response = wp_remote_retrieve_body( $ins_request );
|
||||
|
||||
$feed = array();
|
||||
|
||||
// Get the serialized data string present in the page script.
|
||||
preg_match( '/window\._sharedData = (.*);<\/script>/', $ins_response, $ins_data );
|
||||
|
||||
$ins_data_full = array_shift( $ins_data );
|
||||
$ins_data_json = array_shift( $ins_data );
|
||||
|
||||
if ( ! $ins_data_json ) {
|
||||
return sprintf( '%s <a href="%s">%s</a> %s', esc_html__( 'Instagram html data cannot be retrieved. Please try adding the ', 'powerkit' ), powerkit_get_page_url( 'connect&tab=instagram' ), esc_html__( 'Instagram Settings', 'powerkit' ), esc_html__( ' on the settings page.', 'powerkit' ) );
|
||||
}
|
||||
|
||||
$instagram_json = json_decode( $ins_data_json, true );
|
||||
|
||||
// Try to decode the json.
|
||||
if ( null === $instagram_json && JSON_ERROR_NONE !== json_last_error() ) {
|
||||
return sprintf( '%s <a href="%s">%s</a> %s', esc_html__( 'Error decoding the instagram json. Please try adding the ', 'powerkit' ), powerkit_get_page_url( 'connect&tab=instagram' ), esc_html__( 'Instagram Token', 'powerkit' ), esc_html__( ' on the settings page.', 'powerkit' ) );
|
||||
}
|
||||
|
||||
// Current instagram data is not set.
|
||||
if ( ! isset( $instagram_json['entry_data']['ProfilePage'][0]['graphql']['user'] ) ) {
|
||||
return sprintf( '%s <a href="%s">%s</a> %s', esc_html__( 'Instagram data is not set, please check the ID. Please try adding the ', 'powerkit' ), powerkit_get_page_url( 'connect&tab=instagram' ), esc_html__( 'Instagram Settings', 'powerkit' ), esc_html__( ' on the settings page.', 'powerkit' ) );
|
||||
}
|
||||
|
||||
$user_data = $instagram_json['entry_data']['ProfilePage'][0]['graphql']['user'];
|
||||
|
||||
// Images not found.
|
||||
if ( ! isset( $user_data['edge_owner_to_timeline_media']['edges'] ) ) {
|
||||
return esc_html__( 'There are no images in your account.', 'powerkit' );
|
||||
}
|
||||
|
||||
/* ------------- PARSE DATA -------------- */
|
||||
|
||||
// Full name.
|
||||
$feed['name'] = null;
|
||||
|
||||
if ( isset( $user_data['full_name'] ) ) {
|
||||
$feed['name'] = $user_data['full_name'];
|
||||
}
|
||||
|
||||
// Username.
|
||||
$feed['username'] = null;
|
||||
|
||||
if ( isset( $user_data['username'] ) ) {
|
||||
$feed['username'] = $user_data['username'];
|
||||
}
|
||||
|
||||
// Liked count.
|
||||
$feed['following'] = null;
|
||||
|
||||
if ( isset( $user_data['edge_follow']['count'] ) ) {
|
||||
$feed['following'] = (int) $user_data['edge_follow']['count'];
|
||||
}
|
||||
|
||||
// Liked count.
|
||||
$feed['followers'] = null;
|
||||
|
||||
if ( isset( $user_data['edge_followed_by']['count'] ) ) {
|
||||
$feed['followers'] = (int) $user_data['edge_followed_by']['count'];
|
||||
}
|
||||
|
||||
// Avatar x1.
|
||||
$feed['avatar_1x'] = null;
|
||||
|
||||
if ( isset( $user_data['profile_pic_url'] ) ) {
|
||||
$feed['avatar_1x'] = $user_data['profile_pic_url'];
|
||||
}
|
||||
|
||||
// Avatar x2.
|
||||
$feed['avatar_2x'] = null;
|
||||
|
||||
if ( isset( $user_data['profile_pic_url_hd'] ) ) {
|
||||
$feed['avatar_2x'] = $user_data['profile_pic_url_hd'];
|
||||
}
|
||||
|
||||
// Images.
|
||||
$edges = $user_data['edge_owner_to_timeline_media']['edges'];
|
||||
|
||||
$feed['images'] = array();
|
||||
|
||||
foreach ( $edges as $key => $edge ) {
|
||||
if ( ! isset( $edge['node']['thumbnail_resources'] ) && $edge['node']['thumbnail_resources'] ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Resources.
|
||||
$resources = $edge['node']['thumbnail_resources'];
|
||||
|
||||
// Get src thumbnail.
|
||||
foreach ( $resources as $resource ) {
|
||||
$feed['images'][ $key ]['sizes']['thumbnail'] = isset( $resource['src'] ) ? $resource['src'] : null;
|
||||
if ( isset( $resource['config_width'] ) && 150 === (int) $resource['config_width'] ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Get src small.
|
||||
foreach ( $resources as $resource ) {
|
||||
$feed['images'][ $key ]['sizes']['small'] = isset( $resource['src'] ) ? $resource['src'] : null;
|
||||
if ( isset( $resource['config_width'] ) && 320 === (int) $resource['config_width'] ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Get src large.
|
||||
foreach ( $resources as $resource ) {
|
||||
$feed['images'][ $key ]['sizes']['large'] = isset( $resource['src'] ) ? $resource['src'] : null;
|
||||
if ( isset( $resource['config_width'] ) && 640 === (int) $resource['config_width'] ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Item link.
|
||||
$feed['images'][ $key ]['link'] = null;
|
||||
|
||||
if ( isset( $edge['node']['shortcode'] ) ) {
|
||||
$feed['images'][ $key ]['link'] = sprintf( 'https://www.instagram.com/p/%s', $edge['node']['shortcode'] );
|
||||
}
|
||||
|
||||
// Desc.
|
||||
$feed['images'][ $key ]['text'] = null;
|
||||
|
||||
if ( isset( $edge['node']['edge_media_to_caption']['edges'][0]['node']['text'] ) ) {
|
||||
$text = strtok( $edge['node']['edge_media_to_caption']['edges'][0]['node']['text'], "\n" );
|
||||
|
||||
$feed['images'][ $key ]['text'] = strip_tags( $text );
|
||||
}
|
||||
|
||||
// Timestamp.
|
||||
$feed['images'][ $key ]['timestamp'] = null;
|
||||
|
||||
if ( isset( $edge['node']['taken_at_timestamp'] ) ) {
|
||||
$feed['images'][ $key ]['timestamp'] = powerkit_relative_time( $edge['node']['taken_at_timestamp'] );
|
||||
}
|
||||
|
||||
// Comment count.
|
||||
$feed['images'][ $key ]['comment_count'] = null;
|
||||
|
||||
if ( isset( $edge['node']['edge_media_to_comment']['count'] ) ) {
|
||||
$feed['images'][ $key ]['comment_count'] = (int) $edge['node']['edge_media_to_comment']['count'];
|
||||
}
|
||||
|
||||
// Liked count.
|
||||
$feed['images'][ $key ]['liked_count'] = null;
|
||||
|
||||
if ( isset( $edge['node']['edge_liked_by']['count'] ) ) {
|
||||
$feed['images'][ $key ]['liked_count'] = (int) $edge['node']['edge_liked_by']['count'];
|
||||
}
|
||||
}
|
||||
|
||||
// Number of images.
|
||||
if ( isset( $ins_params['number'] ) && intval( $ins_params['number'] ) > 0 ) {
|
||||
$feed['images'] = array_slice( $feed['images'], 0, $ins_params['number'], true );
|
||||
}
|
||||
|
||||
return $feed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data of instagram response
|
||||
*
|
||||
* @param string $ins_request Instagram request.
|
||||
* @param array $ins_params Options.
|
||||
*/
|
||||
function powerkit_instagram_get_feed( $ins_request, $ins_params ) {
|
||||
if ( powerkit_connect( 'instagram_app_access_token' ) ) {
|
||||
$feed = powerkit_instagram_json_get_feed( $ins_request, $ins_params );
|
||||
} else {
|
||||
$feed = powerkit_instagram_html_get_feed( $ins_request, $ins_params );
|
||||
}
|
||||
|
||||
/* Manual Override */
|
||||
|
||||
if ( is_array( $feed ) && get_option( 'powerkit_connect_instagram_custom_name' ) ) {
|
||||
$feed['name'] = get_option( 'powerkit_connect_instagram_custom_name' );
|
||||
}
|
||||
|
||||
if ( is_array( $feed ) && get_option( 'powerkit_connect_instagram_following' ) ) {
|
||||
$feed['following'] = (int) get_option( 'powerkit_connect_instagram_following' );
|
||||
}
|
||||
|
||||
if ( is_array( $feed ) && get_option( 'powerkit_connect_instagram_custom_followers' ) ) {
|
||||
$feed['followers'] = (int) get_option( 'powerkit_connect_instagram_custom_followers' );
|
||||
}
|
||||
|
||||
if ( is_array( $feed ) && get_option( 'powerkit_connect_instagram_custom_avatar' ) ) {
|
||||
$feed['avatar_1x'] = get_option( 'powerkit_connect_instagram_custom_avatar' );
|
||||
}
|
||||
|
||||
if ( is_array( $feed ) && get_option( 'powerkit_connect_instagram_custom_avatar' ) ) {
|
||||
$feed['avatar_2x'] = get_option( 'powerkit_connect_instagram_custom_avatar' );
|
||||
}
|
||||
|
||||
return $feed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get recent photos instagram
|
||||
*
|
||||
* @param array $params Recent options.
|
||||
* @param string $cache_name The cache name.
|
||||
*/
|
||||
function powerkit_instagram_get_recent( $params, $cache_name = 'powerkit_instagram_data' ) {
|
||||
|
||||
$params = array_merge( array(
|
||||
'user_id' => '',
|
||||
'header' => false,
|
||||
'button' => false,
|
||||
'number' => 4,
|
||||
'columns' => 1,
|
||||
'size' => 'small',
|
||||
'target' => '_blank',
|
||||
'template' => 'default',
|
||||
'cache_time' => 720,
|
||||
), (array) $params );
|
||||
|
||||
$cache_time = (int) $params['cache_time'];
|
||||
|
||||
// Instagram trans name.
|
||||
$trans_name = $cache_name . '_' . md5( maybe_serialize( $params ) . powerkit_connect( 'instagram_app_access_token' ) );
|
||||
|
||||
// Instagram request.
|
||||
$ins_request = get_transient( $trans_name );
|
||||
|
||||
if ( ( false === $ins_request || 0 === $cache_time ) && apply_filters( 'powerkit_instagram_remote_connect', true ) ) {
|
||||
|
||||
Powerkit_Connect::access_token_refresh( 'instagram' );
|
||||
|
||||
if ( powerkit_connect( 'instagram_app_access_token' ) && powerkit_connect( 'instagram_app_user_id' ) ) {
|
||||
$access_token = powerkit_connect( 'instagram_app_access_token' );
|
||||
$user_id = powerkit_connect( 'instagram_app_user_id' );
|
||||
|
||||
// Get information about.
|
||||
if ( 'business' === powerkit_connect( 'instagram_app_type' ) ) {
|
||||
$ins_link = add_query_arg( array(
|
||||
'fields' => 'biography,id,username,website,followers_count,media_count,profile_picture_url,name',
|
||||
'access_token' => $access_token,
|
||||
), 'https://graph.facebook.com/' . $user_id );
|
||||
} else {
|
||||
$ins_link = add_query_arg( array(
|
||||
'fields' => 'id,username,media_count',
|
||||
'access_token' => $access_token,
|
||||
), 'https://graph.instagram.com/me' );
|
||||
}
|
||||
|
||||
$ins_request = wp_safe_remote_get( $ins_link,
|
||||
array(
|
||||
'timeout' => 120,
|
||||
'httpversion' => '1.1',
|
||||
'redirection' => 10,
|
||||
'sslverify' => false,
|
||||
)
|
||||
);
|
||||
|
||||
usleep( 100000 );
|
||||
|
||||
// Get the most recent media published.
|
||||
if ( 'business' === powerkit_connect( 'instagram_app_type' ) ) {
|
||||
$ins_recent_link = add_query_arg( array(
|
||||
'fields' => 'media_url,thumbnail_url,caption,id,media_type,timestamp,username,comments_count,like_count,permalink',
|
||||
'limit' => min( $params['number'], 200 ),
|
||||
'access_token' => $access_token,
|
||||
), 'https://graph.facebook.com/' . $user_id . '/media' );
|
||||
} else {
|
||||
$ins_recent_link = add_query_arg( array(
|
||||
'fields' => 'media_url,thumbnail_url,caption,id,media_type,timestamp,username,comments_count,like_count,permalink',
|
||||
'limit' => min( $params['number'], 200 ),
|
||||
'access_token' => $access_token,
|
||||
), 'https://graph.instagram.com/' . $user_id . '/media' );
|
||||
}
|
||||
|
||||
$ins_recent_request = wp_safe_remote_get( $ins_recent_link,
|
||||
array(
|
||||
'timeout' => 120,
|
||||
'httpversion' => '1.1',
|
||||
'redirection' => 10,
|
||||
'sslverify' => false,
|
||||
)
|
||||
);
|
||||
|
||||
$ins_request['headers']['recent'] = $ins_recent_request;
|
||||
} else {
|
||||
|
||||
$ins_link = sprintf( 'https://www.instagram.com/%s', $params['user_id'] );
|
||||
|
||||
$ins_request = wp_safe_remote_get( $ins_link,
|
||||
array(
|
||||
'timeout' => 120,
|
||||
'httpversion' => '1.1',
|
||||
'redirection' => 10,
|
||||
'sslverify' => false,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
set_transient( $trans_name, $ins_request, 60 * $cache_time );
|
||||
}
|
||||
|
||||
// Instagram response.
|
||||
|
||||
if ( ! is_wp_error( $ins_request ) ) {
|
||||
|
||||
if ( apply_filters( 'powerkit_instagram_remote_connect', true ) ) {
|
||||
$instagram_feed = powerkit_instagram_get_feed( $ins_request, $params );
|
||||
} else {
|
||||
$instagram_feed = esc_html__( 'The connection to the server is denied.', 'powerkit' );
|
||||
}
|
||||
|
||||
// Apply filters.
|
||||
$instagram_feed = apply_filters( 'powerkit_instagram_feed', $instagram_feed, $ins_request, $params );
|
||||
|
||||
if ( is_string( $instagram_feed ) ) {
|
||||
|
||||
powerkit_alert_warning( $instagram_feed );
|
||||
|
||||
} else {
|
||||
$instagram = array();
|
||||
|
||||
$placeholder_image = apply_filters( 'powerkit_lazyload_instagram_output', false );
|
||||
|
||||
$ins_feed_class = null;
|
||||
|
||||
$ins_feed_class .= ' pk-instagram-template-' . $params['template'];
|
||||
$ins_feed_class .= ' pk-instagram-size-' . $params['size'];
|
||||
$ins_feed_class .= ' pk-instagram-columns-' . $params['columns'];
|
||||
?>
|
||||
<div class="pk-instagram-feed <?php echo esc_attr( $ins_feed_class ); ?>">
|
||||
<?php
|
||||
foreach ( $instagram_feed['images'] as $item ) {
|
||||
|
||||
$item = apply_filters( 'powerkit_instagram_item_data', $item );
|
||||
|
||||
$class = 'pk-instagram-image';
|
||||
|
||||
$image_thumbnail = $item['sizes']['thumbnail'];
|
||||
$image_small = $item['sizes']['small'];
|
||||
$image_large = $item['sizes']['large'];
|
||||
|
||||
// Image Resolution.
|
||||
if ( 'thumbnail' === $params['size'] ) {
|
||||
$user_image = $image_thumbnail;
|
||||
} elseif ( 'small' === $params['size'] ) {
|
||||
$user_image = $image_small;
|
||||
} else {
|
||||
$user_image = $image_large;
|
||||
}
|
||||
|
||||
// Columns.
|
||||
if ( 3 === (int) $params['columns'] ) {
|
||||
$user_image = $image_thumbnail;
|
||||
} elseif ( 2 === (int) $params['columns'] ) {
|
||||
$user_image = $image_small;
|
||||
} elseif ( 1 === (int) $params['columns'] ) {
|
||||
$user_image = $image_small;
|
||||
}
|
||||
|
||||
// Retina sizes.
|
||||
if ( 'auto' === $params['size'] ) {
|
||||
if ( 3 === (int) $params['columns'] ) {
|
||||
$width = 150;
|
||||
} elseif ( 2 === (int) $params['columns'] ) {
|
||||
$width = 320;
|
||||
} elseif ( 1 === (int) $params['columns'] ) {
|
||||
$width = 640;
|
||||
}
|
||||
} elseif ( 'small' === $params['size'] ) {
|
||||
$width = 320;
|
||||
} elseif ( 'thumbnail' === $params['size'] ) {
|
||||
$width = 150;
|
||||
} else {
|
||||
$width = 640;
|
||||
}
|
||||
|
||||
// Placeholder image.
|
||||
if ( $placeholder_image ) {
|
||||
$class .= ' pk-lazyload';
|
||||
}
|
||||
|
||||
// Instagram item.
|
||||
$instagram[] = array(
|
||||
'class' => $class,
|
||||
'description' => $item['text'],
|
||||
'link' => $item['link'],
|
||||
'user_link' => $item['link'],
|
||||
'comments' => $item['comment_count'],
|
||||
'likes' => $item['liked_count'],
|
||||
'time' => $item['timestamp'],
|
||||
'thumbnail' => $image_thumbnail,
|
||||
'small' => $image_small,
|
||||
'large' => $image_large,
|
||||
'user_image' => $placeholder_image ? $placeholder_image : $user_image,
|
||||
'sizes' => $placeholder_image ? 'auto' : sprintf( '(max-width: %1$spx) 100vw, %1$spx', $width ),
|
||||
'srcset' => sprintf( '%s 150w, %s 320w, %s 640w', $image_thumbnail, $image_small, $image_large ),
|
||||
);
|
||||
}
|
||||
|
||||
ob_start();
|
||||
|
||||
powerkit_instagram_template_handler( $params['template'], $instagram_feed, $instagram, $params );
|
||||
|
||||
$template_html = ob_get_clean();
|
||||
|
||||
// Placeholder adaptation.
|
||||
if ( $placeholder_image ) {
|
||||
$placeholder_containers = apply_filters( 'powerkit_instagram_placeholder_containers', array( 'pk-instagram-items' ) );
|
||||
|
||||
foreach ( $placeholder_containers as $container ) {
|
||||
preg_match( '/<div class="' . $container . '">.*?<\/div>/msU', $template_html, $template_match );
|
||||
|
||||
if ( $template_match ) {
|
||||
$template_items = array_shift( $template_match );
|
||||
|
||||
$output_items = str_replace( 'src=', sprintf( 'data-pk-src="%s" src=', $user_image ), $template_items );
|
||||
$output_items = str_replace( 'srcset=', 'data-pk-srcset=', $output_items );
|
||||
$output_items = str_replace( 'sizes=', 'data-pk-sizes=', $output_items );
|
||||
|
||||
$template_html = str_replace( $template_items, $output_items, $template_html );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Template Output.
|
||||
call_user_func( 'printf', '%s', $template_html );
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
} else {
|
||||
powerkit_alert_warning( esc_html__( 'This client has not been approved to access this resource.', 'powerkit' ) );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
* Instagram 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(
|
||||
'user_id' => $attributes['userID'],
|
||||
'header' => $attributes['showHeader'],
|
||||
'button' => $attributes['showFollowButton'],
|
||||
'number' => $attributes['number'],
|
||||
'columns' => $attributes['columns'],
|
||||
'size' => $attributes['size'],
|
||||
'target' => $attributes['target'],
|
||||
'template' => 'default',
|
||||
'cache_time' => apply_filters( 'powerkit_instagram_cache_time', 60 ),
|
||||
'is_block' => true,
|
||||
'block_attrs' => $attributes,
|
||||
);
|
||||
|
||||
echo '<div class="' . esc_attr( $attributes['className'] ) . '" ' . ( isset( $attributes['anchor'] ) ? ' id="' . esc_attr( $attributes['anchor'] ) . '"' : '' ) . '>';
|
||||
|
||||
// Instagram output.
|
||||
if ( $attributes['userID'] ) {
|
||||
powerkit_instagram_get_recent( $params );
|
||||
} else {
|
||||
powerkit_alert_warning( 'Instagram data is not set, please check the User ID.' );
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
+166
@@ -0,0 +1,166 @@
|
||||
<?php
|
||||
/**
|
||||
* The Gutenberg Block.
|
||||
*
|
||||
* @link https://codesupply.co
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package Powerkit
|
||||
* @subpackage Modules/public
|
||||
*/
|
||||
|
||||
/**
|
||||
* The initialize block.
|
||||
*/
|
||||
class Powerkit_Instagram_Block {
|
||||
|
||||
/**
|
||||
* Initialize
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'init', array( $this, 'block' ) );
|
||||
add_filter( 'canvas_register_block_type', array( $this, 'register_block_type' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue the block's assets for the editor.
|
||||
*/
|
||||
public function block() {
|
||||
// Styles.
|
||||
wp_register_style(
|
||||
'powerkit-instagram-block-editor-style',
|
||||
plugins_url( 'css/public-powerkit-instagram.css', __FILE__ ),
|
||||
array( 'wp-edit-blocks' ),
|
||||
filemtime( plugin_dir_path( __FILE__ ) . 'css/public-powerkit-instagram.css' )
|
||||
);
|
||||
|
||||
wp_style_add_data( 'powerkit-instagram-block-editor-style', 'rtl', 'replace' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register block
|
||||
*
|
||||
* @param array $blocks all registered blocks.
|
||||
* @return array
|
||||
*/
|
||||
public function register_block_type( $blocks ) {
|
||||
$blocks[] = array(
|
||||
'name' => 'canvas/instagram',
|
||||
'title' => esc_html__( 'Instagram', 'powerkit' ),
|
||||
'description' => esc_html__( 'The block allows you to display images from your instagram account.', 'powerkit' ),
|
||||
'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 4.622c2.403 0 2.688.01 3.637.052.877.04 1.354.187 1.67.31.42.163.72.358 1.036.673.315.315.51.615.673 1.035.123.317.27.794.31 1.67.043.95.052 1.235.052 3.638s-.01 2.688-.052 3.637c-.04.877-.187 1.354-.31 1.67-.163.42-.358.72-.673 1.036-.315.315-.615.51-1.035.673-.317.123-.794.27-1.67.31-.95.043-1.234.052-3.638.052s-2.688-.01-3.637-.052c-.877-.04-1.354-.187-1.67-.31-.42-.163-.72-.358-1.036-.673-.315-.315-.51-.615-.673-1.035-.123-.317-.27-.794-.31-1.67-.043-.95-.052-1.235-.052-3.638s.01-2.688.052-3.637c.04-.877.187-1.354.31-1.67.163-.42.358-.72.673-1.036.315-.315.615-.51 1.035-.673.317-.123.794-.27 1.67-.31.95-.043 1.235-.052 3.638-.052M12 3c-2.444 0-2.75.01-3.71.054s-1.613.196-2.185.418c-.592.23-1.094.538-1.594 1.04-.5.5-.807 1-1.037 1.593-.223.572-.375 1.226-.42 2.184C3.01 9.25 3 9.555 3 12s.01 2.75.054 3.71.196 1.613.418 2.186c.23.592.538 1.094 1.038 1.594s1.002.808 1.594 1.038c.572.222 1.227.375 2.185.418.96.044 1.266.054 3.71.054s2.75-.01 3.71-.054 1.613-.196 2.186-.418c.592-.23 1.094-.538 1.594-1.038s.808-1.002 1.038-1.594c.222-.572.375-1.227.418-2.185.044-.96.054-1.266.054-3.71s-.01-2.75-.054-3.71-.196-1.613-.418-2.186c-.23-.592-.538-1.094-1.038-1.594s-1.002-.808-1.594-1.038c-.572-.222-1.227-.375-2.185-.418C14.75 3.01 14.445 3 12 3zm0 4.378c-2.552 0-4.622 2.07-4.622 4.622s2.07 4.622 4.622 4.622 4.622-2.07 4.622-4.622S14.552 7.378 12 7.378zM12 15c-1.657 0-3-1.343-3-3s1.343-3 3-3 3 1.343 3 3-1.343 3-3 3zm4.804-8.884c-.596 0-1.08.484-1.08 1.08s.484 1.08 1.08 1.08c.596 0 1.08-.484 1.08-1.08s-.483-1.08-1.08-1.08z" />
|
||||
</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' => 'userID',
|
||||
'label' => esc_html__( 'User ID', 'powerkit' ),
|
||||
'section' => 'general',
|
||||
'type' => 'text',
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'key' => 'showHeader',
|
||||
'label' => esc_html__( 'Display Header', 'powerkit' ),
|
||||
'section' => 'general',
|
||||
'type' => 'toggle',
|
||||
'default' => true,
|
||||
),
|
||||
array(
|
||||
'key' => 'showFollowButton',
|
||||
'label' => esc_html__( 'Display Follow Button', 'powerkit' ),
|
||||
'section' => 'general',
|
||||
'type' => 'toggle',
|
||||
'default' => true,
|
||||
),
|
||||
array(
|
||||
'key' => 'number',
|
||||
'label' => esc_html__( 'Number of Images', 'powerkit' ),
|
||||
'section' => 'general',
|
||||
'type' => 'number',
|
||||
'min' => 1,
|
||||
'max' => 12,
|
||||
'default' => 4,
|
||||
),
|
||||
array(
|
||||
'key' => 'columns',
|
||||
'label' => esc_html__( 'Number of Columns', 'powerkit' ),
|
||||
'section' => 'general',
|
||||
'type' => 'number',
|
||||
'min' => 1,
|
||||
'max' => 7,
|
||||
'default' => 3,
|
||||
),
|
||||
array(
|
||||
'key' => 'size',
|
||||
'label' => esc_html__( 'Photo Size', 'powerkit' ),
|
||||
'section' => 'general',
|
||||
'type' => 'select',
|
||||
'choices' => array(
|
||||
'thumbnail' => esc_html__( 'Thumbnail', 'powerkit' ),
|
||||
'small' => esc_html__( 'Small', 'powerkit' ),
|
||||
'large' => esc_html__( 'Large', 'powerkit' ),
|
||||
),
|
||||
'default' => 'thumbnail',
|
||||
),
|
||||
array(
|
||||
'key' => 'target',
|
||||
'label' => esc_html__( 'Open Links In', 'powerkit' ),
|
||||
'section' => 'general',
|
||||
'type' => 'select',
|
||||
'choices' => array(
|
||||
'_blank' => esc_html__( 'New window (_blank)', 'powerkit' ),
|
||||
'_self' => esc_html__( 'Current window (_self)', 'powerkit' ),
|
||||
),
|
||||
'default' => '_blank',
|
||||
),
|
||||
), powerkit_get_gutenberg_button_fields(
|
||||
'button',
|
||||
'buttonSettings',
|
||||
array(
|
||||
array(
|
||||
'field' => 'showFollowButton',
|
||||
'operator' => '==',
|
||||
'value' => true,
|
||||
),
|
||||
)
|
||||
)
|
||||
),
|
||||
'template' => dirname( __FILE__ ) . '/block/render.php',
|
||||
// enqueue registered scripts/styles.
|
||||
'editor_style' => 'powerkit-instagram-block-editor-style',
|
||||
);
|
||||
|
||||
return $blocks;
|
||||
}
|
||||
}
|
||||
|
||||
new Powerkit_Instagram_Block();
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
<?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_Instagram_Public extends Powerkit_Module_Public {
|
||||
|
||||
/**
|
||||
* Initialize
|
||||
*/
|
||||
public function initialize() {
|
||||
add_action( 'init', array( $this, 'register_templates' ) );
|
||||
add_filter( 'powerkit_instagram_templates', array( $this, 'template_default' ) );
|
||||
add_filter( 'powerkit_pinit_exclude_selectors', array( $this, 'pinit_disable' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* 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/instagram-template.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter Register Templates
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access private
|
||||
*
|
||||
* @param array $templates List of Templates.
|
||||
*/
|
||||
public function template_default( $templates = array() ) {
|
||||
$templates = array(
|
||||
'default' => array(
|
||||
'name' => 'Default',
|
||||
'func' => 'powerkit_instagram_default_template',
|
||||
),
|
||||
);
|
||||
|
||||
return $templates;
|
||||
}
|
||||
|
||||
/**
|
||||
* PinIt disable
|
||||
*
|
||||
* @param string $selectors List selectors.
|
||||
*/
|
||||
public function pinit_disable( $selectors ) {
|
||||
$selectors[] = '.pk-instagram-image';
|
||||
|
||||
return $selectors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the stylesheets for the public-facing side of the site.
|
||||
*/
|
||||
public function wp_enqueue_scripts() {
|
||||
wp_enqueue_style( 'powerkit-instagram', powerkit_style( plugin_dir_url( __FILE__ ) . 'css/public-powerkit-instagram.css' ), array(), powerkit_get_setting( 'version' ), 'all' );
|
||||
|
||||
// Add RTL support.
|
||||
wp_style_add_data( 'powerkit-instagram', 'rtl', 'replace' );
|
||||
}
|
||||
}
|
||||
+134
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
/**
|
||||
* Shortcode Instagram
|
||||
*
|
||||
* @link https://codesupply.co
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package PowerKit
|
||||
* @subpackage PowerKit/shortcodes
|
||||
*/
|
||||
|
||||
/**
|
||||
* Instagram Shortcode
|
||||
*
|
||||
* @param array $atts User defined attributes in shortcode tag.
|
||||
* @param string $content Shorcode tag content.
|
||||
* @return string Shortcode result HTML.
|
||||
*/
|
||||
function powerkit_instagram_shortcode( $atts, $content = '' ) {
|
||||
|
||||
$params = powerkit_shortcode_atts( shortcode_atts( array(
|
||||
'user_id' => '',
|
||||
'header' => true,
|
||||
'button' => true,
|
||||
'number' => 4,
|
||||
'columns' => 1,
|
||||
'size' => 'small',
|
||||
'target' => '_blank',
|
||||
'template' => 'default',
|
||||
'cache_time' => apply_filters( 'powerkit_instagram_cache_time', 60 ),
|
||||
), $atts ) );
|
||||
|
||||
ob_start();
|
||||
|
||||
// Instagram output.
|
||||
powerkit_instagram_get_recent( $params );
|
||||
|
||||
return ob_get_clean();
|
||||
}
|
||||
add_shortcode( 'powerkit_instagram', 'powerkit_instagram_shortcode' );
|
||||
|
||||
/**
|
||||
* Map Instagram Shortcode into the Basic Shortcodes Plugin
|
||||
*/
|
||||
if ( function_exists( 'powerkit_basic_shortcodes_register' ) ) :
|
||||
|
||||
add_action( 'init', function() {
|
||||
|
||||
$shortcode_map = array(
|
||||
'name' => 'instagram',
|
||||
'title' => esc_html__( 'Instagram', 'powerkit' ),
|
||||
'priority' => 100,
|
||||
'base' => 'powerkit_instagram',
|
||||
'autoregister' => false,
|
||||
'fields' => array(
|
||||
array(
|
||||
'type' => 'input',
|
||||
'name' => 'user_id',
|
||||
'label' => esc_html__( 'User ID', 'powerkit' ),
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'checkbox',
|
||||
'name' => 'header',
|
||||
'label' => esc_html__( 'Display header', 'powerkit' ),
|
||||
'default' => true,
|
||||
),
|
||||
array(
|
||||
'type' => 'checkbox',
|
||||
'name' => 'button',
|
||||
'label' => esc_html__( 'Display follow button', 'powerkit' ),
|
||||
'default' => true,
|
||||
),
|
||||
array(
|
||||
'type' => 'input',
|
||||
'name' => 'number',
|
||||
'label' => esc_html__( 'Number of images (maximum 12)', 'powerkit' ),
|
||||
'default' => 4,
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'name' => 'columns',
|
||||
'label' => esc_html__( 'Number of columns', 'powerkit' ),
|
||||
'default' => '1',
|
||||
'options' => array(
|
||||
'1' => esc_html__( '1', 'powerkit' ),
|
||||
'2' => esc_html__( '2', 'powerkit' ),
|
||||
'3' => esc_html__( '3', 'powerkit' ),
|
||||
'4' => esc_html__( '4', 'powerkit' ),
|
||||
'5' => esc_html__( '5', 'powerkit' ),
|
||||
'6' => esc_html__( '6', 'powerkit' ),
|
||||
'7' => esc_html__( '7', 'powerkit' ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'name' => 'size',
|
||||
'label' => esc_html__( 'Photo size', 'powerkit' ),
|
||||
'default' => 'thumbnail',
|
||||
'options' => array(
|
||||
'thumbnail' => esc_html__( 'Thumbnail', 'powerkit' ),
|
||||
'small' => esc_html__( 'Small', 'powerkit' ),
|
||||
'large' => esc_html__( 'Large', 'powerkit' ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'name' => 'target',
|
||||
'label' => esc_html__( 'Open links in', 'powerkit' ),
|
||||
'default' => '_blank',
|
||||
'options' => array(
|
||||
'_blank' => esc_html__( 'New window (_blank)', 'powerkit' ),
|
||||
'_self' => esc_html__( 'Current window (_self)', 'powerkit' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$templates = apply_filters( 'powerkit_instagram_templates', array() );
|
||||
|
||||
if ( count( (array) $templates ) > 1 ) {
|
||||
$shortcode_map['fields'][] = array(
|
||||
'type' => 'select',
|
||||
'name' => 'template',
|
||||
'label' => esc_html__( 'Template', 'powerkit' ),
|
||||
'default' => 'default',
|
||||
'options' => powerkit_instagram_get_templates_options(),
|
||||
);
|
||||
}
|
||||
|
||||
powerkit_basic_shortcodes_register( $shortcode_map );
|
||||
});
|
||||
|
||||
endif;
|
||||
+180
@@ -0,0 +1,180 @@
|
||||
<?php
|
||||
/**
|
||||
* Widget Instagram
|
||||
*
|
||||
* @link https://codesupply.co
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package PowerKit
|
||||
* @subpackage PowerKit/widgets
|
||||
*/
|
||||
|
||||
/**
|
||||
* Widget Instagram Class
|
||||
*/
|
||||
class Powerkit_Instagram_Widget extends WP_Widget {
|
||||
|
||||
/**
|
||||
* Sets up a new widget instance.
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
$this->default_settings = apply_filters( 'powerkit_instagram_widget_settings', array(
|
||||
'title' => esc_html__( 'Instagram', 'powerkit' ),
|
||||
'user_id' => '',
|
||||
'header' => true,
|
||||
'button' => true,
|
||||
'number' => 6,
|
||||
'columns' => 2,
|
||||
'size' => 'auto',
|
||||
'target' => '_blank',
|
||||
'template' => 'default',
|
||||
) );
|
||||
|
||||
$widget_details = array(
|
||||
'classname' => 'powerkit_instagram_widget',
|
||||
'description' => esc_html__( 'Instagram widget.', 'powerkit' ),
|
||||
);
|
||||
parent::__construct( 'powerkit_instagram_widget', esc_html__( 'Instagram', '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 );
|
||||
|
||||
$widget_id = isset( $args['widget_id'] ) ? $args['widget_id'] : 0;
|
||||
|
||||
// Before Widget.
|
||||
echo $args['before_widget']; // XSS OK.
|
||||
?>
|
||||
|
||||
<div class="widget-body">
|
||||
<?php
|
||||
// Title.
|
||||
if ( $params['title'] ) {
|
||||
echo $args['before_title'] . apply_filters( 'widget_title', wp_kses( $params['title'], 'pk-title' ), $instance, $this->id_base ) . $args['after_title']; // XSS.
|
||||
}
|
||||
|
||||
// Instagram output.
|
||||
powerkit_instagram_get_recent( $params, sprintf( 'powerkit_instagram_recent_%s', $widget_id ) );
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
||||
// After Widget.
|
||||
echo $args['after_widget']; // XSS OK.
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 header.
|
||||
if ( ! isset( $instance['header'] ) ) {
|
||||
$instance['header'] = false;
|
||||
}
|
||||
|
||||
// Display follow button.
|
||||
if ( ! isset( $instance['button'] ) ) {
|
||||
$instance['button'] = false;
|
||||
}
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs the widget settings form.
|
||||
*
|
||||
* @param array $instance Current settings.
|
||||
*/
|
||||
public function form( $instance ) {
|
||||
$params = array_merge( $this->default_settings, $instance );
|
||||
|
||||
$templates = apply_filters( 'powerkit_instagram_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>
|
||||
|
||||
<!-- User Id -->
|
||||
<p>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'user_id' ) ); ?>"><?php esc_html_e( 'User ID:', 'powerkit' ); ?></label>
|
||||
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'user_id' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'user_id' ) ); ?>" type="text" value="<?php echo esc_attr( $params['user_id'] ); ?>" />
|
||||
</p>
|
||||
|
||||
<!-- Display header -->
|
||||
<p><input id="<?php echo esc_attr( $this->get_field_id( 'header' ) ); ?>" class="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'header' ) ); ?>" type="checkbox" <?php checked( (bool) $params['header'] ); ?> />
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'header' ) ); ?>"><?php esc_html_e( 'Display header', 'powerkit' ); ?></label></p>
|
||||
|
||||
<!-- Display follow button -->
|
||||
<p><input id="<?php echo esc_attr( $this->get_field_id( 'button' ) ); ?>" class="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'button' ) ); ?>" type="checkbox" <?php checked( (bool) $params['button'] ); ?> />
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'button' ) ); ?>"><?php esc_html_e( 'Display follow button', 'powerkit' ); ?></label></p>
|
||||
|
||||
<!-- Number of photos -->
|
||||
<p>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'number' ) ); ?>"><?php esc_html_e( 'Number of images (maximum 12):', 'powerkit' ); ?></label>
|
||||
<input id="<?php echo esc_attr( $this->get_field_id( 'number' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'number' ) ); ?>" type="text" value="<?php echo absint( $params['number'] ); ?>" size="3" />
|
||||
</p>
|
||||
|
||||
<!-- Number of columns -->
|
||||
<p>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'columns' ) ); ?>"><?php esc_html_e( 'Number of columns:', 'powerkit' ); ?></label>
|
||||
<select id="<?php echo esc_attr( $this->get_field_id( 'columns' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'columns' ) ); ?>" class="widefat">
|
||||
<option value="1" <?php selected( $params['columns'], '1' ); ?>><?php esc_html_e( '1', 'powerkit' ); ?></option>
|
||||
<option value="2" <?php selected( $params['columns'], '2' ); ?>><?php esc_html_e( '2', 'powerkit' ); ?></option>
|
||||
<option value="3" <?php selected( $params['columns'], '3' ); ?>><?php esc_html_e( '3', 'powerkit' ); ?></option>
|
||||
</select>
|
||||
</p>
|
||||
|
||||
<!-- Open links in -->
|
||||
<p>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'target' ) ); ?>"><?php esc_html_e( 'Open links in:', 'powerkit' ); ?></label>
|
||||
<select id="<?php echo esc_attr( $this->get_field_id( 'target' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'target' ) ); ?>" class="widefat">
|
||||
<option value="_blank" <?php selected( $params['target'], '_blank' ); ?>><?php esc_html_e( 'New window (_blank)', 'powerkit' ); ?></option>
|
||||
<option value="_self" <?php selected( $params['target'], '_self' ); ?>><?php esc_html_e( 'Current window (_self)', 'powerkit' ); ?></option>
|
||||
</select>
|
||||
</p>
|
||||
|
||||
<!-- Template -->
|
||||
<?php if ( count( (array) $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
|
||||
if ( $templates ) {
|
||||
foreach ( $templates as $key => $item ) {
|
||||
?>
|
||||
<option value="<?php echo esc_attr( $key ); ?>" <?php selected( $params['template'], $key ); ?>><?php echo esc_attr( $item['name'] ); ?></option>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register Widget
|
||||
*/
|
||||
function powerkit_widget_init_instagram() {
|
||||
register_widget( 'Powerkit_Instagram_Widget' );
|
||||
}
|
||||
add_action( 'widgets_init', 'powerkit_widget_init_instagram' );
|
||||
+280
@@ -0,0 +1,280 @@
|
||||
/**
|
||||
* All of the CSS for your public-facing functionality should be
|
||||
* included in this file.
|
||||
*/
|
||||
/**
|
||||
* Environment for all styles (variables, additions, etc).
|
||||
*/
|
||||
/*--------------------------------------------------------------*/
|
||||
/*--------------------------------------------------------------*/
|
||||
.pk-instagram-feed {
|
||||
--pk-instagram-a-color: inherit;
|
||||
--pk-instagram-info-color: #000000;
|
||||
--pk-instagram-name-a-color: inherit;
|
||||
--pk-instagram-number-color: #000000;
|
||||
--pk-instagram-data-color: rgba(255, 255, 255, 0.9);
|
||||
--pk-instagram-link-opacity: rgba(0, 0, 0, 0.5);
|
||||
--pk-instagram-name-font-size: 0.875rem;
|
||||
--pk-instagram-counters-font-size: 80%;
|
||||
--pk-instagram-number-font-size: 0.875rem;
|
||||
--pk-instagram-number-font-weight: bold;
|
||||
--pk-instagram-meta-font-size: 14px;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------*/
|
||||
.pk-instagram-header {
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.pk-instagram-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.pk-avatar-link {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
box-shadow: none;
|
||||
margin-left: 1rem;
|
||||
flex: 0 0 50px;
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
}
|
||||
|
||||
.pk-instagram-avatar {
|
||||
border-radius: 50%;
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
}
|
||||
|
||||
.pk-instagram-info a {
|
||||
color: var(--pk-instagram-a-color);
|
||||
}
|
||||
|
||||
.pk-instagram-username {
|
||||
color: var(--pk-instagram-info-color);
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.pk-instagram-name {
|
||||
font-size: var(--pk-instagram-name-font-size);
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.pk-instagram-name a {
|
||||
color: var(--pk-instagram-name-a-color);
|
||||
}
|
||||
|
||||
.pk-instagram-counters {
|
||||
display: flex;
|
||||
margin-top: 1rem;
|
||||
font-size: var(--pk-instagram-counters-font-size);
|
||||
}
|
||||
|
||||
.pk-instagram-counters .counter + .counter {
|
||||
margin-right: 0.5rem;
|
||||
}
|
||||
|
||||
.pk-instagram-counters .number {
|
||||
color: var(--pk-instagram-number-color);
|
||||
font-size: var(--pk-instagram-number-font-size);
|
||||
font-weight: var(--pk-instagram-number-font-weight);
|
||||
}
|
||||
|
||||
.pk-instagram-footer {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.pk-instagram-footer .pk-instagram-btn {
|
||||
display: block;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.pk-instagram-items {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.pk-instagram-item {
|
||||
display: block;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.pk-instagram-item:after {
|
||||
position: relative;
|
||||
padding-bottom: 100%;
|
||||
display: block;
|
||||
height: 0;
|
||||
z-index: 0;
|
||||
content: '';
|
||||
}
|
||||
|
||||
.pk-instagram-link img {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
transition: 0.25s;
|
||||
-o-object-fit: cover;
|
||||
object-fit: cover;
|
||||
-webkit-backface-visibility: hidden;
|
||||
backface-visibility: hidden;
|
||||
}
|
||||
|
||||
.pk-instagram-link {
|
||||
position: absolute;
|
||||
display: block;
|
||||
border: none;
|
||||
top: 0;
|
||||
right: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.pk-instagram-link:before {
|
||||
background: var(--pk-instagram-link-opacity);
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
top: 0;
|
||||
right: 0;
|
||||
opacity: 0;
|
||||
content: '';
|
||||
transition: 0.25s;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.pk-instagram-link:hover {
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.pk-instagram-link:hover:before {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.pk-instagram-link:hover img {
|
||||
transform: scale(1.1);
|
||||
}
|
||||
|
||||
.pk-instagram-data {
|
||||
position: absolute;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
top: 0;
|
||||
right: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
color: var(--pk-instagram-data-color);
|
||||
z-index: 3;
|
||||
opacity: 0;
|
||||
transition: 0.25s;
|
||||
}
|
||||
|
||||
.pk-instagram-link:hover .pk-instagram-data {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.pk-instagram-meta {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.pk-instagram-meta .pk-meta {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
font-size: var(--pk-instagram-meta-font-size);
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.pk-instagram-meta .pk-meta i {
|
||||
position: relative;
|
||||
margin-left: 5px;
|
||||
top: 1px;
|
||||
}
|
||||
|
||||
.pk-instagram-meta .pk-meta:first-child {
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
.widget .pk-instagram-meta {
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.widget .pk-instagram-meta .pk-meta {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.pk-instagram-columns-1 .pk-instagram-item {
|
||||
flex: 0 0 100%;
|
||||
}
|
||||
|
||||
.pk-instagram-columns-2 .pk-instagram-item {
|
||||
flex: 0 0 50%;
|
||||
}
|
||||
|
||||
.pk-instagram-columns-3 .pk-instagram-item {
|
||||
flex: 0 0 33.3333333333%;
|
||||
}
|
||||
|
||||
.pk-instagram-columns-4 .pk-instagram-item {
|
||||
flex: 0 0 25%;
|
||||
}
|
||||
|
||||
.pk-instagram-columns-5 .pk-instagram-item {
|
||||
flex: 0 0 20%;
|
||||
}
|
||||
|
||||
.pk-instagram-columns-6 .pk-instagram-item {
|
||||
flex: 0 0 16.6666666667%;
|
||||
}
|
||||
|
||||
.pk-instagram-columns-7 .pk-instagram-item {
|
||||
flex: 0 0 14.2857142857%;
|
||||
}
|
||||
|
||||
.pk-instagram-size-auto .pk-instagram-items {
|
||||
margin-right: -5px;
|
||||
margin-left: -5px;
|
||||
}
|
||||
|
||||
.pk-instagram-size-auto .pk-instagram-items .pk-instagram-item {
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
.pk-instagram-size-auto.pk-instagram-columns-1 .pk-instagram-item {
|
||||
flex: 0 0 calc(100% / 1 - 10px);
|
||||
}
|
||||
|
||||
.pk-instagram-size-auto.pk-instagram-columns-2 .pk-instagram-item {
|
||||
flex: 0 0 calc(100% / 2 - 10px);
|
||||
}
|
||||
|
||||
.pk-instagram-size-auto.pk-instagram-columns-3 .pk-instagram-item {
|
||||
flex: 0 0 calc(100% / 3 - 10px);
|
||||
}
|
||||
|
||||
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
|
||||
.pk-instagram-size-auto .pk-instagram-items {
|
||||
margin: 0;
|
||||
}
|
||||
.pk-instagram-size-auto .pk-instagram-items .pk-instagram-item {
|
||||
margin: 0;
|
||||
}
|
||||
.pk-instagram-size-auto.pk-instagram-columns-1 .pk-instagram-item {
|
||||
flex: 0 0 100%;
|
||||
}
|
||||
.pk-instagram-size-auto.pk-instagram-columns-2 .pk-instagram-item {
|
||||
flex: 0 0 50%;
|
||||
}
|
||||
.pk-instagram-size-auto.pk-instagram-columns-3 .pk-instagram-item {
|
||||
flex: 0 0 33.3333333333%;
|
||||
}
|
||||
}
|
||||
+280
@@ -0,0 +1,280 @@
|
||||
/**
|
||||
* All of the CSS for your public-facing functionality should be
|
||||
* included in this file.
|
||||
*/
|
||||
/**
|
||||
* Environment for all styles (variables, additions, etc).
|
||||
*/
|
||||
/*--------------------------------------------------------------*/
|
||||
/*--------------------------------------------------------------*/
|
||||
.pk-instagram-feed {
|
||||
--pk-instagram-a-color: inherit;
|
||||
--pk-instagram-info-color: #000000;
|
||||
--pk-instagram-name-a-color: inherit;
|
||||
--pk-instagram-number-color: #000000;
|
||||
--pk-instagram-data-color: rgba(255, 255, 255, 0.9);
|
||||
--pk-instagram-link-opacity: rgba(0, 0, 0, 0.5);
|
||||
--pk-instagram-name-font-size: 0.875rem;
|
||||
--pk-instagram-counters-font-size: 80%;
|
||||
--pk-instagram-number-font-size: 0.875rem;
|
||||
--pk-instagram-number-font-weight: bold;
|
||||
--pk-instagram-meta-font-size: 14px;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------*/
|
||||
.pk-instagram-header {
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.pk-instagram-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.pk-avatar-link {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
box-shadow: none;
|
||||
margin-right: 1rem;
|
||||
flex: 0 0 50px;
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
}
|
||||
|
||||
.pk-instagram-avatar {
|
||||
border-radius: 50%;
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
}
|
||||
|
||||
.pk-instagram-info a {
|
||||
color: var(--pk-instagram-a-color);
|
||||
}
|
||||
|
||||
.pk-instagram-username {
|
||||
color: var(--pk-instagram-info-color);
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.pk-instagram-name {
|
||||
font-size: var(--pk-instagram-name-font-size);
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.pk-instagram-name a {
|
||||
color: var(--pk-instagram-name-a-color);
|
||||
}
|
||||
|
||||
.pk-instagram-counters {
|
||||
display: flex;
|
||||
margin-top: 1rem;
|
||||
font-size: var(--pk-instagram-counters-font-size);
|
||||
}
|
||||
|
||||
.pk-instagram-counters .counter + .counter {
|
||||
margin-left: 0.5rem;
|
||||
}
|
||||
|
||||
.pk-instagram-counters .number {
|
||||
color: var(--pk-instagram-number-color);
|
||||
font-size: var(--pk-instagram-number-font-size);
|
||||
font-weight: var(--pk-instagram-number-font-weight);
|
||||
}
|
||||
|
||||
.pk-instagram-footer {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.pk-instagram-footer .pk-instagram-btn {
|
||||
display: block;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.pk-instagram-items {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.pk-instagram-item {
|
||||
display: block;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.pk-instagram-item:after {
|
||||
position: relative;
|
||||
padding-bottom: 100%;
|
||||
display: block;
|
||||
height: 0;
|
||||
z-index: 0;
|
||||
content: '';
|
||||
}
|
||||
|
||||
.pk-instagram-link img {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
transition: 0.25s;
|
||||
-o-object-fit: cover;
|
||||
object-fit: cover;
|
||||
-webkit-backface-visibility: hidden;
|
||||
backface-visibility: hidden;
|
||||
}
|
||||
|
||||
.pk-instagram-link {
|
||||
position: absolute;
|
||||
display: block;
|
||||
border: none;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.pk-instagram-link:before {
|
||||
background: var(--pk-instagram-link-opacity);
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
top: 0;
|
||||
left: 0;
|
||||
opacity: 0;
|
||||
content: '';
|
||||
transition: 0.25s;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.pk-instagram-link:hover {
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.pk-instagram-link:hover:before {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.pk-instagram-link:hover img {
|
||||
transform: scale(1.1);
|
||||
}
|
||||
|
||||
.pk-instagram-data {
|
||||
position: absolute;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
color: var(--pk-instagram-data-color);
|
||||
z-index: 3;
|
||||
opacity: 0;
|
||||
transition: 0.25s;
|
||||
}
|
||||
|
||||
.pk-instagram-link:hover .pk-instagram-data {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.pk-instagram-meta {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.pk-instagram-meta .pk-meta {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
font-size: var(--pk-instagram-meta-font-size);
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.pk-instagram-meta .pk-meta i {
|
||||
position: relative;
|
||||
margin-right: 5px;
|
||||
top: 1px;
|
||||
}
|
||||
|
||||
.pk-instagram-meta .pk-meta:first-child {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.widget .pk-instagram-meta {
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.widget .pk-instagram-meta .pk-meta {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.pk-instagram-columns-1 .pk-instagram-item {
|
||||
flex: 0 0 100%;
|
||||
}
|
||||
|
||||
.pk-instagram-columns-2 .pk-instagram-item {
|
||||
flex: 0 0 50%;
|
||||
}
|
||||
|
||||
.pk-instagram-columns-3 .pk-instagram-item {
|
||||
flex: 0 0 33.3333333333%;
|
||||
}
|
||||
|
||||
.pk-instagram-columns-4 .pk-instagram-item {
|
||||
flex: 0 0 25%;
|
||||
}
|
||||
|
||||
.pk-instagram-columns-5 .pk-instagram-item {
|
||||
flex: 0 0 20%;
|
||||
}
|
||||
|
||||
.pk-instagram-columns-6 .pk-instagram-item {
|
||||
flex: 0 0 16.6666666667%;
|
||||
}
|
||||
|
||||
.pk-instagram-columns-7 .pk-instagram-item {
|
||||
flex: 0 0 14.2857142857%;
|
||||
}
|
||||
|
||||
.pk-instagram-size-auto .pk-instagram-items {
|
||||
margin-left: -5px;
|
||||
margin-right: -5px;
|
||||
}
|
||||
|
||||
.pk-instagram-size-auto .pk-instagram-items .pk-instagram-item {
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
.pk-instagram-size-auto.pk-instagram-columns-1 .pk-instagram-item {
|
||||
flex: 0 0 calc(100% / 1 - 10px);
|
||||
}
|
||||
|
||||
.pk-instagram-size-auto.pk-instagram-columns-2 .pk-instagram-item {
|
||||
flex: 0 0 calc(100% / 2 - 10px);
|
||||
}
|
||||
|
||||
.pk-instagram-size-auto.pk-instagram-columns-3 .pk-instagram-item {
|
||||
flex: 0 0 calc(100% / 3 - 10px);
|
||||
}
|
||||
|
||||
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
|
||||
.pk-instagram-size-auto .pk-instagram-items {
|
||||
margin: 0;
|
||||
}
|
||||
.pk-instagram-size-auto .pk-instagram-items .pk-instagram-item {
|
||||
margin: 0;
|
||||
}
|
||||
.pk-instagram-size-auto.pk-instagram-columns-1 .pk-instagram-item {
|
||||
flex: 0 0 100%;
|
||||
}
|
||||
.pk-instagram-size-auto.pk-instagram-columns-2 .pk-instagram-item {
|
||||
flex: 0 0 50%;
|
||||
}
|
||||
.pk-instagram-size-auto.pk-instagram-columns-3 .pk-instagram-item {
|
||||
flex: 0 0 33.3333333333%;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
/**
|
||||
* Instagram Template
|
||||
*
|
||||
* @link https://codesupply.co
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package PowerKit
|
||||
* @subpackage PowerKit/templates
|
||||
*/
|
||||
|
||||
/**
|
||||
* Default Template
|
||||
*
|
||||
* @param array $feed The instagram feed.
|
||||
* @param array $instagram The instagram items.
|
||||
* @param array $params The user parameters.
|
||||
*/
|
||||
function powerkit_instagram_default_template( $feed, $instagram, $params ) {
|
||||
|
||||
if ( $params['header'] ) {
|
||||
?>
|
||||
<div class="pk-instagram-header">
|
||||
<div class="pk-instagram-container">
|
||||
<?php if ( $feed['avatar_1x'] ) { ?>
|
||||
<a href="<?php echo esc_url( sprintf( 'https://www.instagram.com/%s/', $feed['username'] ) ); ?>" class="pk-avatar-link" target="<?php echo esc_attr( $params['target'] ); ?>">
|
||||
<?php
|
||||
$image_avatar = sprintf(
|
||||
'<img src="%s" alt="avatar" class="pk-instagram-avatar">', esc_url( $feed['avatar_1x'] )
|
||||
);
|
||||
|
||||
echo wp_kses_post( apply_filters( 'powerkit_lazy_process_images', $image_avatar ) );
|
||||
?>
|
||||
</a>
|
||||
<?php } ?>
|
||||
|
||||
<?php $tag = apply_filters( 'powerkit_instagram_username_tag', 'h6' ); ?>
|
||||
|
||||
<div class="pk-instagram-info">
|
||||
<?php if ( $feed['name'] !== $feed['username'] ) { ?>
|
||||
<<?php echo esc_html( $tag ); ?> class="pk-instagram-username pk-title pk-font-heading">
|
||||
<a href="<?php echo esc_url( sprintf( 'https://www.instagram.com/%s/', $feed['username'] ) ); ?>" target="<?php echo esc_attr( $params['target'] ); ?>">
|
||||
<?php echo wp_kses_post( $feed['username'] ); ?>
|
||||
</a>
|
||||
</<?php echo esc_html( $tag ); ?>>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ( $feed['name'] ) { ?>
|
||||
<span class="pk-instagram-name pk-color-secondary">
|
||||
<a href="<?php echo esc_url( sprintf( 'https://www.instagram.com/%s/', $feed['username'] ) ); ?>" target="<?php echo esc_attr( $params['target'] ); ?>">
|
||||
<?php echo esc_html( $feed['name'] ); ?>
|
||||
</a>
|
||||
</span>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ( is_int( $feed['following'] ) || is_int( $feed['followers'] ) ) { ?>
|
||||
<div class="pk-instagram-counters pk-color-secondary">
|
||||
<?php if ( is_int( $feed['following'] ) ) { ?>
|
||||
<div class="counter following">
|
||||
<span class="number"><?php echo esc_html( powerkit_abridged_number( $feed['following'], 0 ) ); ?></span> <?php esc_html_e( 'Following', 'powerkit' ); ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ( is_int( $feed['followers'] ) ) { ?>
|
||||
<div class="counter followers">
|
||||
<span class="number"><?php echo esc_html( powerkit_abridged_number( $feed['followers'], 0 ) ); ?></span> <?php esc_html_e( 'Followers', 'powerkit' ); ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ( is_array( $instagram ) && $instagram ) { ?>
|
||||
<div class="pk-instagram-items">
|
||||
<?php foreach ( $instagram as $item ) { ?>
|
||||
<div class="pk-instagram-item">
|
||||
<a class="pk-instagram-link" href="<?php echo esc_url( $item['user_link'] ); ?>" target="<?php echo esc_attr( $params['target'] ); ?>">
|
||||
<img src="<?php echo esc_attr( $item['user_image'] ); ?>" class="<?php echo esc_attr( $item['class'] ); ?>" alt="<?php echo esc_html( $item['description'] ); ?>" srcset="<?php echo esc_attr( $item['srcset'] ); ?>" sizes="<?php echo esc_attr( $item['sizes'] ); ?>">
|
||||
|
||||
<?php if ( is_int( $item['likes'] ) || is_int( $item['comments'] ) ) { ?>
|
||||
<span class="pk-instagram-data">
|
||||
<span class="pk-instagram-meta">
|
||||
<?php if ( is_int( $item['likes'] ) ) { ?>
|
||||
<span class="pk-meta pk-meta-likes"><i class="pk-icon pk-icon-like"></i> <?php echo esc_attr( powerkit_abridged_number( $item['likes'], 0 ) ); ?></span>
|
||||
<?php } ?>
|
||||
<?php if ( is_int( $item['comments'] ) ) { ?>
|
||||
<span class="pk-meta pk-meta-comments"><i class="pk-icon pk-icon-comment"></i> <?php echo esc_attr( powerkit_abridged_number( $item['comments'], 0 ) ); ?></span>
|
||||
<?php } ?>
|
||||
</span>
|
||||
</span>
|
||||
<?php } ?>
|
||||
</a>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php } else { ?>
|
||||
<p><?php esc_html_e( 'Images Not Found!', 'powerkit' ); ?></p>
|
||||
<?php } ?>
|
||||
|
||||
<?php
|
||||
if ( $params['button'] ) {
|
||||
$href = sprintf( 'https://www.instagram.com/%s/', $feed['username'] );
|
||||
$text = apply_filters( 'powerkit_instagram_follow', esc_html__( 'Follow', 'powerkit' ) );
|
||||
|
||||
if ( isset( $params['is_block'] ) && isset( $params['block_attrs'] ) && $params['is_block'] ) {
|
||||
?>
|
||||
<div class="pk-instagram-footer">
|
||||
<?php powerkit_print_gutenberg_blocks_button( $text, $href, $params['target'], 'button', $params['block_attrs'] ); ?>
|
||||
</div>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<div class="pk-instagram-footer">
|
||||
<a class="pk-instagram-btn button" href="<?php echo esc_url( $href ); ?>" target="<?php echo esc_attr( $params['target'] ); ?>">
|
||||
<span class="pk-instagram-follow"><?php echo wp_kses( $text, 'post' ); ?></span>
|
||||
</a>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
<?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_Justified_Gallery_Admin extends Powerkit_Module_Admin {
|
||||
|
||||
/**
|
||||
* Initialize
|
||||
*/
|
||||
public function initialize() {
|
||||
add_action( 'admin_init', array( $this, 'register_settings_section' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register admin page
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function register_settings_section() {
|
||||
|
||||
add_settings_section( 'powerkit_justified_gallery_settings', sprintf( '<span id="%s">%s</span>', powerkit_get_page_slug( $this->slug ), esc_html__( 'Justified Gallery', 'powerkit' ) ), array( $this, 'powerkit_justified_gallery_settings_callback' ), 'media' );
|
||||
|
||||
add_settings_field( 'powerkit_justified_gallery_margins', esc_html__( 'Space between images', 'powerkit' ), array( $this, 'powerkit_justified_gallery_margins_callback' ), 'media', 'powerkit_justified_gallery_settings' );
|
||||
add_settings_field( 'powerkit_justified_gallery_row_height', esc_html__( 'Row height', 'powerkit' ), array( $this, 'powerkit_justified_gallery_row_height_callback' ), 'media', 'powerkit_justified_gallery_settings' );
|
||||
add_settings_field( 'powerkit_justified_gallery_max_row_height', esc_html__( 'Max row height', 'powerkit' ), array( $this, 'powerkit_justified_gallery_max_row_height_callback' ), 'media', 'powerkit_justified_gallery_settings' );
|
||||
add_settings_field( 'powerkit_justified_gallery_last_row', esc_html__( 'Last row', 'powerkit' ), array( $this, 'powerkit_justified_gallery_last_row_callback' ), 'media', 'powerkit_justified_gallery_settings' );
|
||||
|
||||
register_setting( 'media', 'powerkit_justified_gallery_margins' );
|
||||
register_setting( 'media', 'powerkit_justified_gallery_row_height' );
|
||||
register_setting( 'media', 'powerkit_justified_gallery_max_row_height' );
|
||||
register_setting( 'media', 'powerkit_justified_gallery_last_row' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Section Description.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function powerkit_justified_gallery_settings_callback() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Field | Space between images.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function powerkit_justified_gallery_margins_callback() {
|
||||
?>
|
||||
<input class="small-text" id="powerkit_justified_gallery_margins" name="powerkit_justified_gallery_margins" type="number" min="0" step="1" value="<?php echo esc_attr( get_option( 'powerkit_justified_gallery_margins', '10' ) ); ?>">
|
||||
<span><?php esc_html_e( 'px', 'powerkit' ); ?></span>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Field | Row height.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function powerkit_justified_gallery_row_height_callback() {
|
||||
?>
|
||||
<input class="small-text" id="powerkit_justified_gallery_row_height" name="powerkit_justified_gallery_row_height" type="number" min="0" step="1" value="<?php echo esc_attr( get_option( 'powerkit_justified_gallery_row_height', '160' ) ); ?>">
|
||||
<span><?php esc_html_e( 'px. The preferred height of rows.', 'powerkit' ); ?></span>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Field | Space Max row height.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function powerkit_justified_gallery_max_row_height_callback() {
|
||||
?>
|
||||
<input class="small-text" id="powerkit_justified_gallery_max_row_height" name="powerkit_justified_gallery_max_row_height" type="number" step="1" value="<?php echo esc_attr( get_option( 'powerkit_justified_gallery_max_row_height', '-1' ) ); ?>">
|
||||
<span><?php esc_html_e( 'px. Input -1 to remove the limit of the maximum row height.', 'powerkit' ); ?></span>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Field | Last row.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function powerkit_justified_gallery_last_row_callback() {
|
||||
?>
|
||||
<label><input id="powerkit_justified_gallery_last_row" name="powerkit_justified_gallery_last_row" type="radio" value="nojustify" <?php checked( 'nojustify', get_option( 'powerkit_justified_gallery_last_row', 'justify' ) ); ?>><?php esc_html_e( 'No Justify', 'powerkit' ); ?> </label>
|
||||
<label><input id="powerkit_justified_gallery_last_row" name="powerkit_justified_gallery_last_row" type="radio" value="justify" <?php checked( 'justify', get_option( 'powerkit_justified_gallery_last_row', 'justify' ) ); ?>><?php esc_html_e( 'Justify', 'powerkit' ); ?> </label>
|
||||
<label><input id="powerkit_justified_gallery_last_row" name="powerkit_justified_gallery_last_row" type="radio" value="hide" <?php checked( 'hide', get_option( 'powerkit_justified_gallery_last_row', 'justify' ) ); ?>><?php esc_html_e( 'Hide', 'powerkit' ); ?></label>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* Justified Gallery
|
||||
*
|
||||
* @package Powerkit
|
||||
* @subpackage Modules
|
||||
*/
|
||||
|
||||
if ( class_exists( 'Powerkit_Module' ) ) {
|
||||
/**
|
||||
* Init module
|
||||
*/
|
||||
class Powerkit_Justified_Gallery extends Powerkit_Module {
|
||||
|
||||
/**
|
||||
* Register module
|
||||
*/
|
||||
public function register() {
|
||||
$this->name = esc_html__( 'Justified Gallery', 'powerkit' );
|
||||
$this->desc = esc_html__( 'Create beautiful tiled galleries with the Justified Gallery module. Control the image height and padding between images per gallery or globally.', 'powerkit' );
|
||||
$this->slug = 'justified_gallery';
|
||||
$this->type = 'default';
|
||||
$this->category = 'basic';
|
||||
$this->priority = 90;
|
||||
$this->public = true;
|
||||
$this->enabled = true;
|
||||
$this->links = array(
|
||||
array(
|
||||
'name' => esc_html__( 'Go to settings', 'powerkit' ),
|
||||
'url' => admin_url( sprintf( 'options-media.php#%s', powerkit_get_page_slug( $this->slug ) ) ),
|
||||
),
|
||||
array(
|
||||
'name' => esc_html__( 'View documentation', 'powerkit' ),
|
||||
'url' => powerkit_get_setting( 'documentation' ) . '/content-presentation/justified-gallery/',
|
||||
'target' => '_blank',
|
||||
),
|
||||
);
|
||||
$this->load_extensions = array(
|
||||
'gallery',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize module
|
||||
*/
|
||||
public function initialize() {
|
||||
|
||||
/* Load the required dependencies for this module */
|
||||
|
||||
// Admin and public area.
|
||||
require_once dirname( __FILE__ ) . '/admin/class-powerkit-justified-gallery-admin.php';
|
||||
require_once dirname( __FILE__ ) . '/public/class-powerkit-justified-gallery-public.php';
|
||||
|
||||
new Powerkit_Justified_Gallery_Admin( $this->slug );
|
||||
new Powerkit_Justified_Gallery_Public( $this->slug );
|
||||
}
|
||||
}
|
||||
|
||||
new Powerkit_Justified_Gallery();
|
||||
}
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
<?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_Justified_Gallery_Public extends Powerkit_Module_Public {
|
||||
|
||||
/**
|
||||
* Initialize
|
||||
*/
|
||||
public function initialize() {
|
||||
add_filter( 'powerkit_gallery_types', array( $this, 'gallery_types' ) );
|
||||
add_filter( 'powerkit_gallery_settings', array( $this, 'gallery_settings' ), 10, 2 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add new gallery types
|
||||
*
|
||||
* @param array $types Gallery types.
|
||||
*/
|
||||
public function gallery_types( $types ) {
|
||||
|
||||
$types = array_merge( $types, array(
|
||||
'justified' => esc_html__( 'Justified', 'powerkit' ),
|
||||
) );
|
||||
|
||||
return $types;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set gallery settings
|
||||
*
|
||||
* @param array $settings Gallery settings.
|
||||
* @param array $attr Gallery attr.
|
||||
*/
|
||||
public function gallery_settings( $settings, $attr ) {
|
||||
|
||||
if ( isset( $attr['type'] ) && 'justified' === $attr['type'] ) {
|
||||
|
||||
$data = array(
|
||||
'pk-jg-margins' => (int) get_option( 'powerkit_justified_gallery_margins', '10' ),
|
||||
'pk-jg-row-height' => (int) get_option( 'powerkit_justified_gallery_row_height', '160' ),
|
||||
'pk-jg-max-row-height' => (int) get_option( 'powerkit_justified_gallery_max_row_height', '-1' ),
|
||||
'pk-jg-last-row' => (string) get_option( 'powerkit_justified_gallery_last_row', 'justify' ),
|
||||
);
|
||||
|
||||
$data = array_merge( (array) $data, (array) $attr );
|
||||
|
||||
if ( -1 === $data['pk-jg-max-row-height'] ) {
|
||||
$data['pk-max-row-height'] = 'false';
|
||||
}
|
||||
|
||||
$settings['custom_attrs'] .= sprintf( ' data-jg-margins="%s" data-jg-row-height="%s" data-jg-max-row-height="%s" data-jg-last-row="%s"', $data['pk-jg-margins'], $data['pk-jg-row-height'], $data['pk-jg-max-row-height'], $data['pk-jg-last-row'] );
|
||||
}
|
||||
|
||||
return $settings;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Register the stylesheets for the public-facing side of the site.
|
||||
*/
|
||||
public function wp_enqueue_scripts() {
|
||||
// Styles.
|
||||
wp_enqueue_style( 'powerkit-justified-gallery', powerkit_style( plugin_dir_url( __FILE__ ) . 'css/public-powerkit-justified-gallery.css' ), array(), powerkit_get_setting( 'version' ), 'all' );
|
||||
|
||||
// Add RTL support.
|
||||
wp_style_add_data( 'powerkit-justified-gallery', 'rtl', 'replace' );
|
||||
|
||||
// Scripts.
|
||||
wp_enqueue_script( 'justifiedgallery', plugin_dir_url( __FILE__ ) . 'js/jquery.justifiedGallery.min.js', array( 'jquery' ), powerkit_get_setting( 'version' ), true );
|
||||
|
||||
wp_enqueue_script( 'powerkit-justified-gallery', plugin_dir_url( __FILE__ ) . 'js/public-powerkit-justified-gallery.js', array( 'jquery' ), powerkit_get_setting( 'version' ), true );
|
||||
|
||||
wp_localize_script( 'powerkit-justified-gallery', 'powerkitJG', array(
|
||||
'rtl' => is_rtl(),
|
||||
) );
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user