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,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
}