first commit

This commit is contained in:
CHIEFSOFT\ameye
2023-11-30 13:20:54 -05:00
commit e9e5c0546c
5833 changed files with 1801865 additions and 0 deletions
@@ -0,0 +1,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();
}
@@ -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();
}
@@ -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' );
}
}
@@ -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: &laquo;travel, lifestyle, food&raquo;. 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: &laquo;worth-reading, top-5, playlists&raquo;. 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: &laquo;2 months&raquo;, &laquo;14 days&raquo; or even &laquo;1 year&raquo;', '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;
@@ -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;
}
}
@@ -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
}