first commit
This commit is contained in:
@@ -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 );
|
||||
Reference in New Issue
Block a user