first commit
This commit is contained in:
122
wp-content/themes/thinkai/includes/classes/ajax.php
Normal file
122
wp-content/themes/thinkai/includes/classes/ajax.php
Normal file
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
namespace THINKAI\Includes\Classes;
|
||||
|
||||
class Ajax {
|
||||
|
||||
function actions() {
|
||||
add_action( 'wp_ajax_thinkai_ajax', array( $this, 'ajax_handler' ) );
|
||||
add_action( 'wp_ajax_nopriv_thinkai_ajax', array( $this, 'ajax_handler' ) );
|
||||
}
|
||||
|
||||
function ajax_handler() {
|
||||
|
||||
$method = thinkai_set( $_REQUEST, 'subaction' );
|
||||
if ( method_exists( $this, $method ) ) {
|
||||
$this->$method();
|
||||
}
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
function thinkai_project_loadmore() {
|
||||
$allowed_html = wp_kses_allowed_html( 'post' );
|
||||
if ( class_exists( 'Douens_Resizer' ) ) {
|
||||
$img_obj = new \Thinkai_Resizer();
|
||||
}
|
||||
$args = thinkai_set( $_POST, 'query' );
|
||||
if ( ! empty( $args['paged'] ) AND ! empty( $args['posts_per_page'] ) AND ! empty( $args['order'] ) ) {
|
||||
$args['paged'] = $args['paged'] + 1;
|
||||
$args['post_type'] = 'project';
|
||||
$query = new \WP_Query( $args );
|
||||
if ( $query->have_posts() ) {
|
||||
$count = 0;
|
||||
ob_start();
|
||||
while ( $query->have_posts() ) {
|
||||
$query->the_post();
|
||||
if ( $count == 0 ) {
|
||||
$anim = array( 4, 5 );
|
||||
} else {
|
||||
$anim = array( 6, 5 );
|
||||
}
|
||||
?>
|
||||
<div class="col-md-6 col-sm-12 col-lg-6 wow zoomIn" data-wow-delay=".<?php echo esc_attr( $anim[0] ); ?>s" data-wow-duration=".<?php echo esc_attr( $anim[1] ); ?>s">
|
||||
<div class="portfolio-item">
|
||||
<?php echo wp_kses( $img_obj->resize( wp_get_attachment_url( get_post_thumbnail_id(), 'full' ), 585, 420, true ), $allowed_html ); ?>
|
||||
<div class="portfolio-cap">
|
||||
<h2><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute() ?>"><?php the_title(); ?></a></h2>
|
||||
<span><?php the_terms( get_the_ID(), 'project_cat', '', ', ', '' ); ?></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
if ( $count == 1 ) {
|
||||
$count = - 1;
|
||||
}
|
||||
$count ++;
|
||||
}
|
||||
wp_reset_postdata();
|
||||
$output = ob_get_clean();
|
||||
$button = '<a class="loadmore-btn" href="javascript:void(0)" data-attr=\'' . json_encode($args) . '\' ><i class="flaticon-load theme-bg"></i>' . esc_html__( "Load More", "thinkai" ) . '</a>';
|
||||
wp_send_json( [
|
||||
'post' => $output,
|
||||
'button' => $button,
|
||||
] );
|
||||
} else {
|
||||
wp_reset_postdata();
|
||||
wp_send_json( [ 'button' => '<a class="loadmore-btn" href="javascript:void(0)"><i class="flaticon-load theme-bg"></i>' . esc_html__( "No More Post", "thinkai" ) . '</a>' ] );
|
||||
}
|
||||
exit;
|
||||
} else {
|
||||
wp_send_json( [ 'button' => '<a class="loadmore-btn" href="javascript:void(0)"><i class="flaticon-load theme-bg"></i>' . esc_html__( "No More Post", "thinkai" ) . '</a>' ] );
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
function thinkai_project_loadmore2() {
|
||||
if ( class_exists( 'Thinkai_Resizer' ) ) {
|
||||
$img_obj = new \Thinkai_Resizer();
|
||||
}
|
||||
$args = thinkai_set( $_POST, 'query' );
|
||||
$args['post_type'] = 'project';
|
||||
$query = new \WP_Query( $args );
|
||||
if ( $query->have_posts() ) {
|
||||
$count = 0;
|
||||
ob_start();
|
||||
while ( $query->have_posts() ) {
|
||||
$query->the_post();
|
||||
if ( $count == 0 ) {
|
||||
$anim = 8;
|
||||
} elseif ( $count == 1 ) {
|
||||
$anim = 1;
|
||||
} else {
|
||||
$anim = '1.2';
|
||||
}
|
||||
?>
|
||||
<div class="col-md-4 col-sm-6 col-lg-4 fltr-itm wow zoomIn " data-wow-delay=".<?php echo esc_attr( $anim ); ?>s" data-wow-duration=".5s">
|
||||
<div class="portfolio-item2">
|
||||
<a href="<?php the_permalink(); ?>" data-fancybox="gallery">
|
||||
<?php echo wp_kses( $img_obj->resize( wp_get_attachment_url( get_post_thumbnail_id( get_the_ID() ), 'full' ), 357, 428, true ), $allowed_html ); ?>
|
||||
</a>
|
||||
<h4><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute() ?>"><?php the_title(); ?></a></h4>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
if ( $count == 2 ) {
|
||||
$count = - 1;
|
||||
}
|
||||
$count ++;
|
||||
}
|
||||
wp_reset_postdata();
|
||||
$output = ob_get_clean();
|
||||
$button = '<a class="loadmore-btn" href="javascript:void(0)" data-offset="' . ( thinkai_set( $args, 'offset' ) + thinkai_set( $args, 'showposts' ) ) . '" data-order="' . thinkai_set( $args, 'order' ) . '" data-orderby="' . thinkai_set( $args, 'orderby' ) . '" data-count="' . thinkai_set( $args, 'showposts' ) . '"><i class="flaticon-load theme-bg"></i>' . esc_html__( "Load More", "thinkai" ) . '</a>';
|
||||
wp_send_json( [
|
||||
'post' => $output,
|
||||
'button' => $button,
|
||||
] );
|
||||
} else {
|
||||
wp_send_json( [ 'button' => $button = '<a class="loadmore-btn" href="javascript:void(0)"><i class="flaticon-load theme-bg"></i>' . esc_html__( "No More Post", "thinkai" ) . '</a>' ] );
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
114
wp-content/themes/thinkai/includes/classes/base.php
Normal file
114
wp-content/themes/thinkai/includes/classes/base.php
Normal file
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
namespace THINKAI\Includes\Classes;
|
||||
|
||||
use THINKAI\Includes\Classes\Header_Enqueue;
|
||||
use THINKAI\Includes\Classes\Options;
|
||||
|
||||
/**
|
||||
* Header and Enqueue class
|
||||
*/
|
||||
class Base {
|
||||
|
||||
public static $instance;
|
||||
public $protocol;
|
||||
|
||||
/**
|
||||
* Set this value for theme options key
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $option_key = 'thinkai';
|
||||
|
||||
function __construct() {
|
||||
|
||||
}
|
||||
|
||||
function loadDefaults() {
|
||||
|
||||
$this->protocol = ( is_ssl() ) ? 'https' : 'http';
|
||||
|
||||
Header_Enqueue::init();
|
||||
|
||||
( new Options )->init();
|
||||
}
|
||||
|
||||
public static function instance() {
|
||||
|
||||
if ( isset( $GLOBALS['thinkai_base'] ) ) {
|
||||
return $GLOBALS['thinkai_base'];
|
||||
}
|
||||
|
||||
if ( is_null( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
$GLOBALS['taon_base'] = self::$instance;
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the theme options.
|
||||
*
|
||||
* @param string $key [description]
|
||||
* @return [type] [description]
|
||||
*/
|
||||
function option( $key = '' ) {
|
||||
|
||||
$options = (array) get_theme_mod( 'thinkai' . '_options-mods' );
|
||||
|
||||
$dn = thinkai_dot( $options );
|
||||
|
||||
if ( $key ) {
|
||||
return $dn->get( $key );
|
||||
}
|
||||
|
||||
return $dn;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [config description]
|
||||
*
|
||||
* @param string $name [description].
|
||||
* @return array [description]
|
||||
*/
|
||||
function config( $name = '' ) {
|
||||
|
||||
$config = include get_template_directory() . '/includes/config.php';
|
||||
|
||||
$dn = new DotNotation( $config );
|
||||
$found = $dn->get( $name );
|
||||
|
||||
if ( $found ) {
|
||||
return $found;
|
||||
}
|
||||
|
||||
return $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* [get_meta description]
|
||||
*
|
||||
* @param string $key [description].
|
||||
* @param string $id [description].
|
||||
* @return [type] [description]
|
||||
*/
|
||||
function get_meta( $key = '', $id = '' ) {
|
||||
global $post, $post_type;
|
||||
|
||||
if ( ! $post_type ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$id = ( $id ) ? $id : thinkai_set( $post, 'ID' );
|
||||
|
||||
$key = ( $key ) ? $key : '_sh_'.$post_type.'_settings';
|
||||
|
||||
$meta = get_post_meta( $id, $key, true );
|
||||
|
||||
return ( $meta ) ? $meta : false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,401 @@
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* Class Name: wp_bootstrap_navwalker
|
||||
|
||||
* GitHub URI: https://github.com/twittem/wp-bootstrap-navwalker
|
||||
|
||||
* Description: A custom WordPress nav walker class to implement the Bootstrap 3 navigation style in a custom theme using the WordPress built in menu manager.
|
||||
|
||||
* Version: 2.0.4
|
||||
|
||||
* Author: Edward McIntyre - @twittem
|
||||
|
||||
* License: GPL-2.0+
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
class Bootstrap_walker_Mobile extends Walker_Nav_Menu {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* @see Walker::start_lvl()
|
||||
|
||||
* @since 3.0.0
|
||||
|
||||
*
|
||||
|
||||
* @param string $output Passed by reference. Used to append additional content.
|
||||
|
||||
* @param int $depth Depth of page. Used for padding.
|
||||
|
||||
*/
|
||||
|
||||
public function start_lvl( &$output, $depth = 0, $args = array() ) {
|
||||
|
||||
$indent = str_repeat( "\t", $depth );
|
||||
|
||||
$output .= "\n$indent<ul role=\"menu\" class=\"nav-dropdown-sm\">\n";
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* @see Walker::start_el()
|
||||
|
||||
* @since 3.0.0
|
||||
|
||||
*
|
||||
|
||||
* @param string $output Passed by reference. Used to append additional content.
|
||||
|
||||
* @param object $item Menu item data object.
|
||||
|
||||
* @param int $depth Depth of menu item. Used for padding.
|
||||
|
||||
* @param int $current_page Menu item ID.
|
||||
|
||||
* @param object $args
|
||||
|
||||
*/
|
||||
|
||||
public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
|
||||
|
||||
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* Dividers, Headers or Disabled
|
||||
|
||||
* =============================
|
||||
|
||||
* Determine whether the item is a Divider, Header, Disabled or regular
|
||||
|
||||
* menu item. To prevent errors we use the strcasecmp() function to so a
|
||||
|
||||
* comparison that is not case sensitive. The strcasecmp() function returns
|
||||
|
||||
* a 0 if the strings are equal.
|
||||
|
||||
*/
|
||||
|
||||
if ( strcasecmp( $item->attr_title, 'divider' ) == 0 && $depth === 1 ) {
|
||||
|
||||
$output .= $indent . '<li role="presentation" class="divider">';
|
||||
|
||||
} else if ( strcasecmp( $item->title, 'divider') == 0 && $depth === 1 ) {
|
||||
|
||||
$output .= $indent . '<li role="presentation" class="divider">';
|
||||
|
||||
} else if ( strcasecmp( $item->attr_title, 'dropdown-header') == 0 && $depth === 1 ) {
|
||||
|
||||
$output .= $indent . '<li role="presentation" class="dropdown-header">' . esc_attr( $item->title );
|
||||
|
||||
} else if ( strcasecmp($item->attr_title, 'disabled' ) == 0 ) {
|
||||
|
||||
$output .= $indent . '<li role="presentation" class="disabled"><a href="#">' . esc_attr( $item->title ) . '</a>';
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
|
||||
$class_names = $value = '';
|
||||
|
||||
|
||||
|
||||
$classes = empty( $item->classes ) ? array() : (array) $item->classes;
|
||||
|
||||
$classes[] = 'menu-item-' . $item->ID;
|
||||
|
||||
|
||||
|
||||
$class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) );
|
||||
|
||||
|
||||
|
||||
if ( $args->has_children )
|
||||
|
||||
$class_names .= ' group/step-one';
|
||||
|
||||
$class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';
|
||||
|
||||
|
||||
|
||||
$id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args );
|
||||
|
||||
$id = $id ? ' id="' . esc_attr( $id ) . '"' : '';
|
||||
|
||||
|
||||
|
||||
$output .= $indent . '<li' . $id . $value . $class_names .'>';
|
||||
|
||||
|
||||
|
||||
$atts = array();
|
||||
|
||||
$atts['title'] = ! empty( $item->title ) ? $item->title : '';
|
||||
|
||||
$atts['target'] = ! empty( $item->target ) ? $item->target : '';
|
||||
|
||||
$atts['rel'] = ! empty( $item->xfn ) ? $item->xfn : '';
|
||||
|
||||
|
||||
|
||||
// If item has_children add atts to a.
|
||||
|
||||
if ( $args->has_children && $depth === 0 ) {
|
||||
|
||||
$atts['href'] = ! empty( $item->url ) ? $item->url : '';
|
||||
$atts['class'] = 'has-dropdown nav-link nav-link-sm';
|
||||
|
||||
}elseif( $depth == 0 ){
|
||||
$atts['href'] = ! empty( $item->url ) ? $item->url : '';
|
||||
$atts['class'] = 'nav-link nav-link-sm';
|
||||
|
||||
} else {
|
||||
|
||||
$atts['href'] = ! empty( $item->url ) ? $item->url : '';
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
$atts = apply_filters( 'nav_menu_link_attributes', $atts, $item, $args );
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$attributes = '';
|
||||
|
||||
foreach ( $atts as $attr => $value ) {
|
||||
|
||||
if ( ! empty( $value ) ) {
|
||||
|
||||
$value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );
|
||||
|
||||
$attributes .= ' ' . $attr . '="' . $value . '"';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
$item_output = $args->before;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
* Glyphicons
|
||||
|
||||
* ===========
|
||||
|
||||
* Since the the menu item is NOT a Divider or Header we check the see
|
||||
|
||||
* if there is a value in the attr_title property. If the attr_title
|
||||
|
||||
* property is NOT null we apply it as the class name for the glyphicon.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if ( $args->has_children && 0 === $depth )
|
||||
|
||||
$item_output .= '<a'. $attributes .'>'.$args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . '' . $args->link_after.'</a>';
|
||||
|
||||
else
|
||||
|
||||
$item_output .= '<a'. $attributes .'>'.$args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after.'</a>';
|
||||
|
||||
|
||||
|
||||
$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* Traverse elements to create list from elements.
|
||||
|
||||
*
|
||||
|
||||
* Display one element if the element doesn't have any children otherwise,
|
||||
|
||||
* display the element and its children. Will only traverse up to the max
|
||||
|
||||
* depth and no ignore elements under that depth.
|
||||
|
||||
*
|
||||
|
||||
* This method shouldn't be called directly, use the walk() method instead.
|
||||
|
||||
*
|
||||
|
||||
* @see Walker::start_el()
|
||||
|
||||
* @since 2.5.0
|
||||
|
||||
*
|
||||
|
||||
* @param object $element Data object
|
||||
|
||||
* @param array $children_elements List of elements to continue traversing.
|
||||
|
||||
* @param int $max_depth Max depth to traverse.
|
||||
|
||||
* @param int $depth Depth of current element.
|
||||
|
||||
* @param array $args
|
||||
|
||||
* @param string $output Passed by reference. Used to append additional content.
|
||||
|
||||
* @return null Null on failure with no changes to parameters.
|
||||
|
||||
*/
|
||||
|
||||
public function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) {
|
||||
|
||||
if ( ! $element )
|
||||
|
||||
return;
|
||||
|
||||
|
||||
|
||||
$id_field = $this->db_fields['id'];
|
||||
|
||||
|
||||
|
||||
// Display this element.
|
||||
|
||||
if ( is_object( $args[0] ) )
|
||||
|
||||
$args[0]->has_children = ! empty( $children_elements[ $element->$id_field ] );
|
||||
|
||||
|
||||
|
||||
parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* Menu Fallback
|
||||
|
||||
* =============
|
||||
|
||||
* If this function is assigned to the wp_nav_menu's fallback_cb variable
|
||||
|
||||
* and a manu has not been assigned to the theme location in the WordPress
|
||||
|
||||
* menu manager the function with display nothing to a non-logged in user,
|
||||
|
||||
* and will add a link to the WordPress menu manager if logged in as an admin.
|
||||
|
||||
*
|
||||
|
||||
* @param array $args passed from the wp_nav_menu function.
|
||||
|
||||
*
|
||||
|
||||
*/
|
||||
|
||||
public static function fallback( $args ) {
|
||||
|
||||
if ( current_user_can( 'manage_options' ) ) {
|
||||
|
||||
|
||||
|
||||
extract( $args );
|
||||
|
||||
|
||||
|
||||
$fb_output = null;
|
||||
|
||||
|
||||
|
||||
if ( $container ) {
|
||||
|
||||
$fb_output = '<' . $container;
|
||||
|
||||
|
||||
|
||||
if ( $container_id )
|
||||
|
||||
$fb_output .= ' id="' . $container_id . '"';
|
||||
|
||||
|
||||
|
||||
if ( $container_class )
|
||||
|
||||
$fb_output .= ' class="' . $container_class . '"';
|
||||
|
||||
|
||||
|
||||
$fb_output .= '>';
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
$fb_output .= '<ul';
|
||||
|
||||
|
||||
|
||||
if ( $menu_id )
|
||||
|
||||
$fb_output .= ' id="' . $menu_id . '"';
|
||||
|
||||
|
||||
|
||||
if ( $menu_class )
|
||||
|
||||
$fb_output .= ' class="' . $menu_class . '"';
|
||||
|
||||
|
||||
|
||||
$fb_output .= '>';
|
||||
|
||||
$fb_output .= '<li><a href="' . esc_url(admin_url( 'nav-menus.php' )) . '">Add a menu</a></li>';
|
||||
|
||||
$fb_output .= '</ul>';
|
||||
|
||||
|
||||
|
||||
if ( $container )
|
||||
|
||||
$fb_output .= '</' . $container . '>';
|
||||
|
||||
|
||||
|
||||
echo wp_kses($fb_output, true);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
171
wp-content/themes/thinkai/includes/classes/bootstrap_walker.php
Normal file
171
wp-content/themes/thinkai/includes/classes/bootstrap_walker.php
Normal file
@@ -0,0 +1,171 @@
|
||||
<?php
|
||||
/**
|
||||
* Class Name: wp_bootstrap_navwalker
|
||||
* GitHub URI: https://github.com/twittem/wp-bootstrap-navwalker
|
||||
* Description: A custom WordPress nav walker class to implement the Bootstrap 3 navigation style in a custom theme using the WordPress built in menu manager.
|
||||
* Version: 2.0.4
|
||||
* Author: Edward McIntyre - @twittem
|
||||
* License: GPL-2.0+
|
||||
*/
|
||||
class Bootstrap_walker extends Walker_Nav_Menu {
|
||||
/**
|
||||
* @see Walker::start_lvl()
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param string $output Passed by reference. Used to append additional content.
|
||||
* @param int $depth Depth of page. Used for padding.
|
||||
*/
|
||||
public function start_lvl( &$output, $depth = 0, $args = array() ) {
|
||||
$indent = str_repeat( "\t", $depth );
|
||||
$output .= "\n$indent<ul role=\"menu\" class=\"nav-dropdown\">\n";
|
||||
}
|
||||
/**
|
||||
* @see Walker::start_el()
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param string $output Passed by reference. Used to append additional content.
|
||||
* @param object $item Menu item data object.
|
||||
* @param int $depth Depth of menu item. Used for padding.
|
||||
* @param int $current_page Menu item ID.
|
||||
* @param object $args
|
||||
*/
|
||||
public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
|
||||
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
|
||||
/**
|
||||
* Dividers, Headers or Disabled
|
||||
* =============================
|
||||
* Determine whether the item is a Divider, Header, Disabled or regular
|
||||
* menu item. To prevent errors we use the strcasecmp() function to so a
|
||||
* comparison that is not case sensitive. The strcasecmp() function returns
|
||||
* a 0 if the strings are equal.
|
||||
*/
|
||||
if ( strcasecmp( $item->attr_title, 'divider' ) == 0 && $depth === 1 ) {
|
||||
$output .= $indent . '<li role="presentation" class="divider">';
|
||||
} else if ( strcasecmp( $item->title, 'divider') == 0 && $depth === 1 ) {
|
||||
$output .= $indent . '<li role="presentation" class="divider">';
|
||||
} else if ( strcasecmp( $item->attr_title, 'dropdown-header') == 0 && $depth === 1 ) {
|
||||
$output .= $indent . '<li role="presentation" class="dropdown-header">' . esc_attr( $item->title );
|
||||
} else if ( strcasecmp($item->attr_title, 'disabled' ) == 0 ) {
|
||||
$output .= $indent . '<li role="presentation" class="disabled"><a href="#">' . esc_attr( $item->title ) . '</a>';
|
||||
} else {
|
||||
$class_names = $value = '';
|
||||
$classes = empty( $item->classes ) ? array() : (array) $item->classes;
|
||||
$classes[] = 'menu-item-' . $item->ID;
|
||||
$class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) );
|
||||
if ( $args->has_children )
|
||||
$class_names .= ' dropdown';
|
||||
|
||||
if (in_array('current-menu-ancestor', $classes)) {
|
||||
$class_names .= ' current';
|
||||
}
|
||||
$class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';
|
||||
$id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args );
|
||||
$id = $id ? ' id="' . esc_attr( $id ) . '"' : '';
|
||||
$output .= $indent . '<li' . $id . $value . $class_names .'>';
|
||||
$atts = array();
|
||||
$atts['title'] = ! empty( $item->title ) ? $item->title : '';
|
||||
$atts['target'] = ! empty( $item->target ) ? $item->target : '';
|
||||
$atts['rel'] = ! empty( $item->xfn ) ? $item->xfn : '';
|
||||
// If item has_children add atts to a.
|
||||
if ( $args->has_children && $depth === 0 ) {
|
||||
$atts['href'] = ! empty( $item->url ) ? $item->url : '';
|
||||
$atts['class'] = 'has-dropdown';
|
||||
}elseif( $depth == 0 ){
|
||||
$atts['href'] = ! empty( $item->url ) ? $item->url : '';
|
||||
$atts['class'] = '';
|
||||
} else {
|
||||
$atts['href'] = ! empty( $item->url ) ? $item->url : '';
|
||||
|
||||
}
|
||||
$atts = apply_filters( 'nav_menu_link_attributes', $atts, $item, $args );
|
||||
$attributes = '';
|
||||
foreach ( $atts as $attr => $value ) {
|
||||
if ( ! empty( $value ) ) {
|
||||
$value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );
|
||||
$attributes .= ' ' . $attr . '="' . $value . '"';
|
||||
}
|
||||
}
|
||||
$item_output = $args->before;
|
||||
/*
|
||||
* Glyphicons
|
||||
* ===========
|
||||
* Since the the menu item is NOT a Divider or Header we check the see
|
||||
* if there is a value in the attr_title property. If the attr_title
|
||||
* property is NOT null we apply it as the class name for the glyphicon.
|
||||
*/
|
||||
|
||||
|
||||
if ( $args->has_children && 0 === $depth )
|
||||
$item_output .= '<a'. $attributes .'>'.$args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . '' . $args->link_after.'</a>';
|
||||
else
|
||||
$item_output .= '<a'. $attributes .'>'.$args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after.'</a>';
|
||||
|
||||
$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Traverse elements to create list from elements.
|
||||
*
|
||||
* Display one element if the element doesn't have any children otherwise,
|
||||
* display the element and its children. Will only traverse up to the max
|
||||
* depth and no ignore elements under that depth.
|
||||
*
|
||||
* This method shouldn't be called directly, use the walk() method instead.
|
||||
*
|
||||
* @see Walker::start_el()
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param object $element Data object
|
||||
* @param array $children_elements List of elements to continue traversing.
|
||||
* @param int $max_depth Max depth to traverse.
|
||||
* @param int $depth Depth of current element.
|
||||
* @param array $args
|
||||
* @param string $output Passed by reference. Used to append additional content.
|
||||
* @return null Null on failure with no changes to parameters.
|
||||
*/
|
||||
public function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) {
|
||||
if ( ! $element )
|
||||
return;
|
||||
$id_field = $this->db_fields['id'];
|
||||
// Display this element.
|
||||
if ( is_object( $args[0] ) )
|
||||
$args[0]->has_children = ! empty( $children_elements[ $element->$id_field ] );
|
||||
parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
|
||||
}
|
||||
/**
|
||||
* Menu Fallback
|
||||
* =============
|
||||
* If this function is assigned to the wp_nav_menu's fallback_cb variable
|
||||
* and a manu has not been assigned to the theme location in the WordPress
|
||||
* menu manager the function with display nothing to a non-logged in user,
|
||||
* and will add a link to the WordPress menu manager if logged in as an admin.
|
||||
*
|
||||
* @param array $args passed from the wp_nav_menu function.
|
||||
*
|
||||
*/
|
||||
public static function fallback( $args ) {
|
||||
if ( current_user_can( 'manage_options' ) ) {
|
||||
extract( $args );
|
||||
$fb_output = null;
|
||||
if ( $container ) {
|
||||
$fb_output = '<' . $container;
|
||||
if ( $container_id )
|
||||
$fb_output .= ' id="' . $container_id . '"';
|
||||
if ( $container_class )
|
||||
$fb_output .= ' class="' . $container_class . '"';
|
||||
$fb_output .= '>';
|
||||
}
|
||||
$fb_output .= '<ul';
|
||||
if ( $menu_id )
|
||||
$fb_output .= ' id="' . $menu_id . '"';
|
||||
if ( $menu_class )
|
||||
$fb_output .= ' class="' . $menu_class . '"';
|
||||
$fb_output .= '>';
|
||||
$fb_output .= '<li><a href="' . esc_url(admin_url( 'nav-menus.php' )) . '">Add a menu</a></li>';
|
||||
$fb_output .= '</ul>';
|
||||
if ( $container )
|
||||
$fb_output .= '</' . $container . '>';
|
||||
echo wp_kses($fb_output, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
171
wp-content/themes/thinkai/includes/classes/common.php
Normal file
171
wp-content/themes/thinkai/includes/classes/common.php
Normal file
@@ -0,0 +1,171 @@
|
||||
<?php
|
||||
namespace THINKAI\Includes\Classes;
|
||||
/**
|
||||
* Common functions
|
||||
*/
|
||||
class Common {
|
||||
public static $instance;
|
||||
public $template;
|
||||
function __construct() {
|
||||
}
|
||||
public static function instance() {
|
||||
if ( is_null( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
/**
|
||||
* [data description]
|
||||
*
|
||||
* @param string $emplate [description]
|
||||
*
|
||||
* @return [type] [description]
|
||||
*/
|
||||
function data( $template = 'blog' ) {
|
||||
$this->template = $template;
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* [get description]
|
||||
*
|
||||
* @return [type] [description]
|
||||
*/
|
||||
function get() {
|
||||
$data = (array) $this->blog();
|
||||
switch ( $this->template ) {
|
||||
case 'blog':
|
||||
case 'author':
|
||||
case 'search':
|
||||
case 'tag':
|
||||
case '404':
|
||||
case 'category':
|
||||
case 'archive':
|
||||
return $this->blog( $this->template );
|
||||
break;
|
||||
case 'product':
|
||||
return $this->single( $this->template );
|
||||
break;
|
||||
case 'single':
|
||||
return $this->single( $this->template );
|
||||
break;
|
||||
case 'single-team':
|
||||
return $this->single( $this->template );
|
||||
break;
|
||||
case 'single-project':
|
||||
return $this->single( $this->template );
|
||||
break;
|
||||
case 'single-service':
|
||||
return $this->single( $this->template );
|
||||
break;
|
||||
default:
|
||||
#code...
|
||||
break;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Blog pages banner, sidebar and layout data.
|
||||
*
|
||||
* @param string $template The tempalte need to return the data for.
|
||||
*
|
||||
* @return [type] [description]
|
||||
*/
|
||||
function blog( $template = 'blog' ) {
|
||||
global $wp_query;
|
||||
$options = thinkai_WSH()->option();
|
||||
if ( ( $wp_query->is_posts_page && 'blog' == $template ) || $template == 'page' ) {
|
||||
$page_id = ( $wp_query->is_posts_page ) ? $wp_query->queried_object->ID : get_the_ID();
|
||||
|
||||
$return = [
|
||||
'layout' => thinkai_meta( 'sidebar_sidebar_layout', $page_id, 'right' ),
|
||||
'sidebar_type' => thinkai_meta( 'sidebar_source_type', $page_id, 'd' ),
|
||||
'sidebar_elementor' => thinkai_meta( 'sidebar_elementor_template', $page_id ),
|
||||
'sidebar' => thinkai_meta( 'sidebar_page_sidebar', $page_id, 'default-sidebar' ),
|
||||
'banner_type' => thinkai_meta( 'banner_source_type', $page_id ),
|
||||
'banner_elementor' => thinkai_meta( 'banner_elementor_template', $page_id ),
|
||||
'banner' => thinkai_set( thinkai_meta( 'banner_page_background', $page_id ), 'url' ),
|
||||
'banner_image' => thinkai_set( thinkai_meta( 'banner_banner_image', $page_id ), 'url' ),
|
||||
'title' => thinkai_meta( 'banner_banner_title', $page_id ),
|
||||
'features_list' => thinkai_meta( 'banner_banner_list', $page_id ),
|
||||
'enable_banner' => thinkai_meta( 'banner_page_banner', $page_id ),
|
||||
];
|
||||
} else {
|
||||
$enable_banner = $template . '_page_banner';
|
||||
$title = $template . '_banner_title';
|
||||
$features_list = $template . '_banner_list';
|
||||
$banner = $template . '_page_background';
|
||||
$banner_image = $template . '_banner_banner_image';
|
||||
$layout = $template . '_sidebar_layout';
|
||||
$sidebar = $template . '_page_sidebar';
|
||||
$bg = $options->get( $banner );
|
||||
|
||||
$return = [
|
||||
'enable_banner' => $options->get( $enable_banner ),
|
||||
'title' => $options->get( $title ) ? $options->get( $title ) : thinkai_the_title( $template ),
|
||||
'features_list' => $options->get( $features_list ) ? $options->get( $features_list ) : thinkai_the_title( $template ),
|
||||
'banner' => thinkai_set( $bg, 'url' ),
|
||||
'banner_image' => thinkai_set( $banner_image, 'url' ),
|
||||
'sidebar' => $options->get( $sidebar, 'default-sidebar' ),
|
||||
'layout' => $options->get( $layout, 'right' ),
|
||||
];
|
||||
}
|
||||
$return['tpl-type'] = $options->get( $template . '_source_type' );
|
||||
$return['tpl-elementor'] = $options->get( $template . '_elementor_template' );
|
||||
$return['author'] = $options->get( $template . '_post_author' );
|
||||
$return['date'] = $options->get( $template . '_post_date' );
|
||||
$return['comments'] = $options->get( $template . '_post_comments' );
|
||||
return new DotNotation( $return );
|
||||
}
|
||||
/**
|
||||
* Post detail and custom post types datail meta.
|
||||
*
|
||||
* @param string $template The template for which data is need to be returned.
|
||||
*
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function single( $template = 'single' ) {
|
||||
global $wp_query;
|
||||
$options = thinkai_WSH()->option();
|
||||
|
||||
$page_id = ( $wp_query->is_posts_page ) ? $wp_query->queried_object->ID : get_the_ID();
|
||||
if(is_woocommerce()) {
|
||||
if(is_shop()){
|
||||
$page_id = get_option( 'woocommerce_shop_page_id' );
|
||||
}elseif(is_cart()){
|
||||
$page_id = get_option( 'woocommerce_cart_page_id' );
|
||||
}elseif(is_checkout()){
|
||||
$page_id = get_option( 'woocommerce_checkout_page_id' );
|
||||
}elseif(is_account_page()){
|
||||
$page_id = get_option( 'woocommerce_myaccount_page_id' );
|
||||
}else{
|
||||
$page_id = ( $wp_query->is_posts_page ) ? $wp_query->queried_object->ID : get_the_ID();
|
||||
}
|
||||
}
|
||||
|
||||
$title = thinkai_meta( 'banner_banner_title', $page_id );
|
||||
$features_list = thinkai_meta( 'banner_banner_list', $page_id );
|
||||
$banner_image = thinkai_meta( 'banner_banner_image', $page_id );
|
||||
$return = [
|
||||
'tpl-type' => $options->get( $template . '_source_type', 'd' ),
|
||||
'tpl-elementor' => $options->get( $template . '_elementor_template' ),
|
||||
'layout' => thinkai_meta( 'sidebar_sidebar_layout', $page_id, 'right' ),
|
||||
'sidebar_type' => thinkai_meta( 'sidebar_source_type', $page_id, 'd' ),
|
||||
'sidebar_elementor' => thinkai_meta( 'sidebar_elementor_template', $page_id ),
|
||||
'sidebar' => thinkai_meta( 'sidebar_page_sidebar', $page_id, 'default-sidebar' ),
|
||||
'banner_type' => thinkai_meta( 'banner_source_type', $page_id ),
|
||||
'banner_elementor' => thinkai_meta( 'banner_elementor_template', $page_id ),
|
||||
'banner' => thinkai_set( thinkai_meta( 'banner_page_background', $page_id ), 'url' ),
|
||||
'banner_image' => thinkai_set( thinkai_meta( 'banner_banner_image', $page_id ), 'url' ),
|
||||
'title' => ($title),
|
||||
'features_list' => ($features_list),
|
||||
'enable_banner' => thinkai_meta( 'banner_page_banner', $page_id ),
|
||||
'date' => $options->get( 'single_post_date', 1 ),
|
||||
'author' => $options->get( 'single_post_author', 1 ),
|
||||
'comments' => $options->get( 'single_post_comments', 1 ),
|
||||
'tag' => $options->get( 'single_post_tag' ),
|
||||
'share' => $options->get( 'single_post_share' ),
|
||||
'share_list' => $options->get( 'single_social_share' ),
|
||||
'author_box' => $options->get( 'single_post_author_box' ),
|
||||
];
|
||||
return new DotNotation( $return );
|
||||
}
|
||||
}
|
||||
194
wp-content/themes/thinkai/includes/classes/dotnotation.php
Normal file
194
wp-content/themes/thinkai/includes/classes/dotnotation.php
Normal file
@@ -0,0 +1,194 @@
|
||||
<?php
|
||||
|
||||
namespace THINKAI\Includes\Classes;
|
||||
|
||||
/**
|
||||
* Dot notation for access multidimensional arrays.
|
||||
*
|
||||
* $dn = new DotNotation(['bar'=>['baz'=>['foo'=>true]]]);
|
||||
*
|
||||
* $value = $dn->get('bar.baz.foo'); // $value == true
|
||||
*
|
||||
* $dn->set('bar.baz.foo', false); // ['foo'=>false]
|
||||
*
|
||||
* $dn->add('bar.baz', ['boo'=>true]); // ['foo'=>false,'boo'=>true]
|
||||
*
|
||||
* @author Anton Medvedev <anton (at) elfet (dot) ru>
|
||||
* @version 2.0
|
||||
* @license MIT
|
||||
*/
|
||||
class DotNotation
|
||||
{
|
||||
const SEPARATOR = '/[:\.]/';
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $values = array();
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public function __construct(array $values)
|
||||
{
|
||||
$this->values = $values;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param string $default
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($path, $default = null)
|
||||
{
|
||||
$array = $this->values;
|
||||
|
||||
if (!empty($path)) {
|
||||
$keys = $this->explode($path);
|
||||
foreach ($keys as $key) {
|
||||
if (isset($array[$key]) && ! empty( $array[$key] ) ) {
|
||||
$array = $array[$key];
|
||||
} else {
|
||||
return $default;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function set($path, $value)
|
||||
{
|
||||
if (!empty($path)) {
|
||||
$at = & $this->values;
|
||||
$keys = $this->explode($path);
|
||||
|
||||
while (count($keys) > 0) {
|
||||
if (count($keys) === 1) {
|
||||
if (is_array($at)) {
|
||||
$at[array_shift($keys)] = $value;
|
||||
} else {
|
||||
throw new \RuntimeException("Can not set value at this path ($path) because is not array.");
|
||||
}
|
||||
} else {
|
||||
$key = array_shift($keys);
|
||||
|
||||
if (!isset($at[$key])) {
|
||||
$at[$key] = array();
|
||||
}
|
||||
|
||||
$at = & $at[$key];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->values = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $path
|
||||
* @param array $values
|
||||
*/
|
||||
public function add($path, array $values)
|
||||
{
|
||||
$get = (array)$this->get($path);
|
||||
$this->set($path, $this->arrayMergeRecursiveDistinct($get, $values));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @return bool
|
||||
*/
|
||||
public function have($path)
|
||||
{
|
||||
$keys = $this->explode($path);
|
||||
$array = $this->values;
|
||||
foreach ($keys as $key) {
|
||||
if (isset($array[$key])) {
|
||||
$array = $array[$key];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $values
|
||||
*/
|
||||
public function setValues($values)
|
||||
{
|
||||
$this->values = $values;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getValues()
|
||||
{
|
||||
return $this->values;
|
||||
}
|
||||
|
||||
protected function explode($path)
|
||||
{
|
||||
return preg_split(self::SEPARATOR, $path);
|
||||
}
|
||||
|
||||
/**
|
||||
* array_merge_recursive does indeed merge arrays, but it converts values with duplicate
|
||||
* keys to arrays rather than overwriting the value in the first array with the duplicate
|
||||
* value in the second array, as array_merge does. I.e., with array_merge_recursive,
|
||||
* this happens (documented behavior):
|
||||
*
|
||||
* array_merge_recursive(array('key' => 'org value'), array('key' => 'new value'));
|
||||
* => array('key' => array('org value', 'new value'));
|
||||
*
|
||||
* arrayMergeRecursiveDistinct does not change the datatypes of the values in the arrays.
|
||||
* Matching keys' values in the second array overwrite those in the first array, as is the
|
||||
* case with array_merge, i.e.:
|
||||
*
|
||||
* arrayMergeRecursiveDistinct(array('key' => 'org value'), array('key' => 'new value'));
|
||||
* => array('key' => array('new value'));
|
||||
*
|
||||
* Parameters are passed by reference, though only for performance reasons. They're not
|
||||
* altered by this function.
|
||||
*
|
||||
* If key is integer, it will be merged like array_merge do:
|
||||
* arrayMergeRecursiveDistinct(array(0 => 'org value'), array(0 => 'new value'));
|
||||
* => array(0 => 'org value', 1 => 'new value');
|
||||
*
|
||||
* @param array $array1
|
||||
* @param array $array2
|
||||
* @return array
|
||||
* @author Daniel <daniel (at) danielsmedegaardbuus (dot) dk>
|
||||
* @author Gabriel Sobrinho <gabriel (dot) sobrinho (at) gmail (dot) com>
|
||||
* @author Anton Medvedev <anton (at) elfet (dot) ru>
|
||||
*/
|
||||
protected function arrayMergeRecursiveDistinct(array &$array1, array &$array2)
|
||||
{
|
||||
$merged = $array1;
|
||||
|
||||
foreach ($array2 as $key => &$value) {
|
||||
if (is_array($value) && isset ($merged[$key]) && is_array($merged[$key])) {
|
||||
if (is_int($key)) {
|
||||
$merged[] = $this->arrayMergeRecursiveDistinct($merged[$key], $value);
|
||||
} else {
|
||||
$merged[$key] = $this->arrayMergeRecursiveDistinct($merged[$key], $value);
|
||||
}
|
||||
} else {
|
||||
if (is_int($key)) {
|
||||
$merged[] = $value;
|
||||
} else {
|
||||
$merged[$key] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $merged;
|
||||
}
|
||||
}
|
||||
204
wp-content/themes/thinkai/includes/classes/header-enqueue.php
Normal file
204
wp-content/themes/thinkai/includes/classes/header-enqueue.php
Normal file
@@ -0,0 +1,204 @@
|
||||
<?php
|
||||
|
||||
namespace THINKAI\Includes\Classes;
|
||||
|
||||
|
||||
/**
|
||||
* Header and Enqueue class
|
||||
*/
|
||||
class Header_Enqueue {
|
||||
|
||||
|
||||
public static function init() {
|
||||
add_action( 'wp_enqueue_scripts', array( __CLASS__, 'enqueue' ) );
|
||||
|
||||
add_filter( 'wp_resource_hints', array( __CLASS__, 'resource_hints' ), 10, 2 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the arrays from method scripts and styles and process them to load.
|
||||
* Styles are being loaded by default while scripts only enqueue and can be loaded where required.
|
||||
*
|
||||
* @return void This function returns nothing.
|
||||
*/
|
||||
public static function enqueue() {
|
||||
|
||||
self::scripts();
|
||||
|
||||
self::styles();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The major scripts loader to load all the scripts of the theme. Developer can hookup own scripts.
|
||||
* All the scripts are being load in footer.
|
||||
*
|
||||
* @return array Returns the array of scripts to load
|
||||
*/
|
||||
public static function scripts() {
|
||||
$options = get_theme_mod( 'thinkai' . '_options-mods' );
|
||||
$ssl = is_ssl() ? 'https' : 'http';
|
||||
|
||||
$scripts = array(
|
||||
);
|
||||
|
||||
$scripts = apply_filters( 'THINKAI/includes/classes/header_enqueue/scripts', $scripts );
|
||||
/**
|
||||
* Enqueue the scripts
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
foreach ( $scripts as $name => $js ) {
|
||||
|
||||
if ( strstr( $js, 'http' ) || strstr( $js, 'https' ) || strstr( $js, 'googleapis.com' ) ) {
|
||||
|
||||
wp_register_script( "{$name}", $js, '', '', true );
|
||||
} else {
|
||||
wp_register_script( "{$name}", get_template_directory_uri() . '/' . $js, '', '', true );
|
||||
}
|
||||
}
|
||||
|
||||
wp_enqueue_script( array(
|
||||
) );
|
||||
|
||||
|
||||
$header_data = array(
|
||||
'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ),
|
||||
'nonce' => wp_create_nonce( THINKAI_NONCE ),
|
||||
);
|
||||
|
||||
wp_localize_script( 'jquery', 'thinkai_data', $header_data );
|
||||
|
||||
if ( thinkai_set( $options, 'footer_js' ) ) {
|
||||
|
||||
wp_add_inline_script( 'jquery', thinkai_set( $options, 'footer_js' ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The major styles loader to load all the styles of the theme. Developer can hookup own styles.
|
||||
* All the styles are being load in head.
|
||||
*
|
||||
* @return array Returns the array of styles to load
|
||||
*/
|
||||
public static function styles() {
|
||||
$options = thinkai_WSH()->option();
|
||||
$header_meta = get_post_meta( get_the_ID(), 'header_style_settings');
|
||||
$header_option = $options->get( 'header_style_settings' );
|
||||
$header = ( $header_meta ) ? $header_meta['0'] : $header_option;
|
||||
|
||||
if ( $header == 'header_v1' ) {
|
||||
$color_scheme = 'assets/css/color.css';
|
||||
} elseif ( $header == 'header_v2' ) {
|
||||
$color_scheme = 'assets/css/color-2.css';
|
||||
} elseif ( $header == 'header_v3' ) {
|
||||
$color_scheme = 'assets/css/color-3.css';
|
||||
} elseif ( $header == 'header_v4' ) {
|
||||
$color_scheme = 'assets/css/color-4.css';
|
||||
} elseif ( $header == 'header_v5' ) {
|
||||
$color_scheme = 'assets/css/color-5.css';
|
||||
} else {
|
||||
$color_scheme = 'assets/css/color.css';
|
||||
}
|
||||
$styles = array(
|
||||
//'google-fonts' => self::fonts_url(),
|
||||
);
|
||||
|
||||
|
||||
$styles = apply_filters( 'THINKAI/includes/classes/header_enqueue/styles', $styles );
|
||||
|
||||
/**
|
||||
* Enqueue the styles
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
foreach ( $styles as $name => $style ) {
|
||||
|
||||
if ( strstr( $style, 'http' ) || strstr( $style, 'https' ) || strstr( $style, 'fonts.googleapis' ) ) {
|
||||
wp_enqueue_style( "thinkai-{$name}", $style );
|
||||
} else {
|
||||
wp_enqueue_style( "thinkai-{$name}", get_template_directory_uri() . '/' . $style );
|
||||
}
|
||||
}
|
||||
$options = thinkai_WSH()->option();
|
||||
$custom_style = '';
|
||||
|
||||
wp_add_inline_style( 'color', $custom_style );
|
||||
|
||||
$header_styles = self::header_styles();
|
||||
|
||||
if ( $custom_font = $options->get('theme_custom_font') ) {
|
||||
$header_styles .= thinkai_custom_fonts_load( $custom_font );
|
||||
}
|
||||
|
||||
wp_add_inline_style( 'thinkai-main-style', $header_styles );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register custom fonts.
|
||||
*/
|
||||
public static function fonts_url() {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add preconnect for Google Fonts.
|
||||
*
|
||||
* @since THINKAI 1.0
|
||||
*
|
||||
* @param array $urls URLs to print for resource hints.
|
||||
* @param string $relation_type The relation type the URLs are printed.
|
||||
*
|
||||
* @return array $urls URLs to print for resource hints.
|
||||
*/
|
||||
public static function resource_hints( $urls, $relation_type ) {
|
||||
if ( wp_style_is( 'thinkai-fonts', 'queue' ) && 'preconnect' === $relation_type ) {
|
||||
$urls[] = array(
|
||||
'href' => 'https://fonts.gstatic.com',
|
||||
'crossorigin',
|
||||
);
|
||||
}
|
||||
|
||||
return $urls;
|
||||
}
|
||||
|
||||
/**
|
||||
* header_styles
|
||||
*
|
||||
* @since THINKAI 1.0
|
||||
*
|
||||
* @param array $urls URLs to print for resource hints.
|
||||
*/
|
||||
public static function header_styles() {
|
||||
|
||||
$data = \THINKAI\Includes\Classes\Common::instance()->data( 'blog' )->get();
|
||||
|
||||
$options = thinkai_WSH()->option();
|
||||
|
||||
$styles = '';
|
||||
if ( $options->get( 'footer_top_button' ) ) :
|
||||
$styles .= "#topcontrol {
|
||||
background: " . $options->get( 'button_bg' ) . " none repeat scroll 0 0 !important;
|
||||
opacity: 0.5;
|
||||
|
||||
color: " . $options->get( 'button_color' ) . " !important;
|
||||
|
||||
}";
|
||||
|
||||
endif;
|
||||
|
||||
$settings = get_theme_mod( 'thinkai' . '_options-mods' );
|
||||
|
||||
if ( $custom_font = thinkai_set( $settings, 'theme_custom_font' ) ) {
|
||||
|
||||
$styles .= apply_filters('thinkai_redux_custom_fonts_load', $custom_font );
|
||||
|
||||
|
||||
}
|
||||
|
||||
return $styles;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
29
wp-content/themes/thinkai/includes/classes/helpers.php
Normal file
29
wp-content/themes/thinkai/includes/classes/helpers.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace THINKAI\Includes\Classes;
|
||||
|
||||
|
||||
/**
|
||||
* Header and Enqueue class
|
||||
*/
|
||||
class Helpers {
|
||||
|
||||
|
||||
function __construct() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook up main headers with different header styles
|
||||
*
|
||||
* @return void This function returns nothing.
|
||||
*/
|
||||
function header() {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
52
wp-content/themes/thinkai/includes/classes/hooks.php
Normal file
52
wp-content/themes/thinkai/includes/classes/hooks.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace THINKAI\Includes\Classes;
|
||||
|
||||
|
||||
/**
|
||||
* Header and Enqueue class
|
||||
*/
|
||||
class Hooks {
|
||||
|
||||
|
||||
function __construct() {
|
||||
|
||||
add_action( 'thinkai_main_header', array( $this, 'header' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook up main headers with different header styles
|
||||
*
|
||||
* @return void This function returns nothing.
|
||||
*/
|
||||
function header() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Footer and Enqueue class
|
||||
*/
|
||||
class Hooks {
|
||||
|
||||
|
||||
function __construct() {
|
||||
|
||||
add_action( 'thinkai_main_footer', array( $this, 'footer' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook up main footer with different footer styles
|
||||
*
|
||||
* @return void This function returns nothing.
|
||||
*/
|
||||
function footer() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
311
wp-content/themes/thinkai/includes/classes/options.php
Normal file
311
wp-content/themes/thinkai/includes/classes/options.php
Normal file
@@ -0,0 +1,311 @@
|
||||
<?php
|
||||
|
||||
namespace THINKAI\Includes\Classes;
|
||||
|
||||
|
||||
/**
|
||||
* Header and Enqueue class
|
||||
*/
|
||||
class Options {
|
||||
|
||||
public static $instance;
|
||||
|
||||
/**
|
||||
* Set this value for theme options key
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $opt_name = 'thinkai' . '_options';
|
||||
|
||||
private $menu_title = '';
|
||||
|
||||
private $page_title = '';
|
||||
|
||||
private $menu_type = 'submenu';
|
||||
|
||||
private $page_slug = 'thinkai' . '_options';
|
||||
|
||||
private $customizer = true;
|
||||
|
||||
private $admin_bar_icon = 'dashicons-portfolio';
|
||||
|
||||
private $page_parent = 'themes.php';
|
||||
|
||||
private $menu_icon = 'dashicons-settings';
|
||||
|
||||
private $docs_link = 'https://docs.themekalia.com';
|
||||
|
||||
private $google_api_key = '';
|
||||
|
||||
function init() {
|
||||
|
||||
if ( ! class_exists( 'Redux' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->opt_name = apply_filters( 'redux_demo/opt_name', $this->opt_name );
|
||||
$this->menu_title = esc_html__( 'THINKAI Options', 'thinkai' );
|
||||
$this->page_title = esc_html__( 'THINKAI Options', 'thinkai' );
|
||||
|
||||
$this->args();
|
||||
|
||||
$this->sections();
|
||||
}
|
||||
|
||||
public static function instance() {
|
||||
|
||||
if ( is_null( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* [args description]
|
||||
*
|
||||
* @return [type] [description]
|
||||
*/
|
||||
function args() {
|
||||
|
||||
/**s
|
||||
* ---> SET ARGUMENTS
|
||||
* All the possible arguments for Redux.
|
||||
* For full documentation on arguments, please refer to: https://github.com/ReduxFramework/ReduxFramework/wiki/Arguments
|
||||
* */
|
||||
|
||||
$theme = wp_get_theme(); // For use with some settings. Not necessary.
|
||||
|
||||
$args = array(
|
||||
/*TYPICAL -> Change these values as you need/desire*/
|
||||
'opt_name' => $this->opt_name,
|
||||
/*This is where your data is stored in the database and also becomes your global variable name.*/
|
||||
'display_name' => $theme->get( 'Name' ),
|
||||
/*Name that appears at the top of your panel*/
|
||||
'display_version' => $theme->get( 'Version' ),
|
||||
/*Version that appears at the top of your panel*/
|
||||
'menu_type' => $this->menu_type,
|
||||
/*Specify if the admin menu should appear or not. Options: menu or submenu (Under appearance only)*/
|
||||
'allow_sub_menu' => true,
|
||||
/*Show the sections below the admin menu item or not*/
|
||||
'menu_title' => $this->menu_title,
|
||||
'page_title' => $this->page_title,
|
||||
/*You will need to generate a Google API key to use this feature.
|
||||
Please visit: https://developers.google.com/fonts/docs/developer_api#Auth*/
|
||||
'google_api_key' => $this->google_api_key,
|
||||
/*Set it you want google fonts to update weekly. A google_api_key value is required.*/
|
||||
'google_update_weekly' => false,
|
||||
/*Must be defined to add google fonts to the typography module*/
|
||||
'async_typography' => true,
|
||||
/*Use a asynchronous font on the front end or font string
|
||||
'disable_google_fonts_link' => true, Disable this in case you want to create your own google fonts loader*/
|
||||
'admin_bar' => true,
|
||||
/*Show the panel pages on the admin bar*/
|
||||
'admin_bar_icon' => $this->admin_bar_icon,
|
||||
/*Choose an icon for the admin bar menu*/
|
||||
'admin_bar_priority' => 50,
|
||||
/*Choose an priority for the admin bar menu*/
|
||||
'global_variable' => 'thinkai_options',
|
||||
/*Set a different name for your global variable other than the opt_name*/
|
||||
'dev_mode' => false,
|
||||
/*Show the time the page took to load, etc*/
|
||||
'update_notice' => false,
|
||||
/*If dev_mode is enabled, will notify developer of updated versions available in the GitHub Repo*/
|
||||
'customizer' => $this->customizer,
|
||||
/*Enable basic customizer support
|
||||
'open_expanded' => true, // Allow you to start the panel in an expanded way initially.
|
||||
'disable_save_warn' => true, // Disable the save warning when a user changes a field*/
|
||||
|
||||
/*OPTIONAL -> Give you extra features*/
|
||||
'page_priority' => null,
|
||||
/*Order where the menu appears in the admin area. If there is any conflict, something will not show. Warning.*/
|
||||
'page_parent' => $this->page_parent,
|
||||
/*For a full list of options, visit: http://codex.wordpress.org/Function_Reference/add_submenu_page#Parameters*/
|
||||
'page_permissions' => 'manage_options',
|
||||
/*Permissions needed to access the options panel.*/
|
||||
'menu_icon' => '',
|
||||
/*Specify a custom URL to an icon*/
|
||||
'last_tab' => '',
|
||||
/*Force your panel to always open to a specific tab (by id)*/
|
||||
'page_icon' => 'icon-themes',
|
||||
/*Icon displayed in the admin panel next to your menu_title*/
|
||||
'page_slug' => $this->page_slug,
|
||||
/*Page slug used to denote the panel, will be based off page title then menu title then opt_name if not provided*/
|
||||
'save_defaults' => true,
|
||||
/*On load save the defaults to DB before user clicks save or not*/
|
||||
'default_show' => false,
|
||||
/*If true, shows the default value next to each field that is not the default value.*/
|
||||
'default_mark' => '',
|
||||
/*What to print by the field's title if the value shown is default. Suggested: **/
|
||||
'show_import_export' => true,
|
||||
/*Shows the Import/Export panel when not used as a field.*/
|
||||
/*CAREFUL -> These options are for advanced use only*/
|
||||
'transient_time' => 60 * MINUTE_IN_SECONDS,
|
||||
'output' => true,
|
||||
/*Global shut-off for dynamic CSS output by the framework. Will also disable google fonts output*/
|
||||
'output_tag' => true,
|
||||
/*Allows dynamic CSS to be generated for customizer and google fonts, but stops the dynamic CSS from going to the head
|
||||
'footer_credit' => '', Disable the footer credit of Redux. Please leave if you can help it.
|
||||
|
||||
FUTURE -> Not in use yet, but reserved or partially implemented. Use at your own risk.*/
|
||||
'database' => 'theme_mods',
|
||||
/*possible: options, theme_mods, theme_mods_expanded, transient. Not fully functional, warning!*/
|
||||
'use_cdn' => true,
|
||||
/*If you prefer not to use the CDN for Select2, Ace Editor, and others, you may download the Redux Vendor Support plugin yourself and run locally or embed it in your code.
|
||||
|
||||
HINTS*/
|
||||
'hints' => array(
|
||||
'icon' => 'el el-question-sign',
|
||||
'icon_position' => 'right',
|
||||
'icon_color' => 'lightgray',
|
||||
'icon_size' => 'normal',
|
||||
'tip_style' => array(
|
||||
'color' => 'red',
|
||||
'shadow' => true,
|
||||
'rounded' => false,
|
||||
'style' => '',
|
||||
),
|
||||
'tip_position' => array(
|
||||
'my' => 'top left',
|
||||
'at' => 'bottom right',
|
||||
),
|
||||
'tip_effect' => array(
|
||||
'show' => array(
|
||||
'effect' => 'slide',
|
||||
'duration' => '500',
|
||||
'event' => 'mouseover',
|
||||
),
|
||||
'hide' => array(
|
||||
'effect' => 'slide',
|
||||
'duration' => '500',
|
||||
'event' => 'click mouseleave',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
|
||||
// SOCIAL ICONS -> Setup custom links in the footer for quick links in your panel footer icons.
|
||||
$args['share_icons'][] = array(
|
||||
'url' => 'https://www.pinterest.com/themekalia_/',
|
||||
'title' => 'Visit us on Pinterest',
|
||||
'icon' => 'el el-pinterest',
|
||||
);
|
||||
$args['share_icons'][] = array(
|
||||
'url' => 'https://www.facebook.com/people/@/themekalia',
|
||||
'title' => 'Like us on Facebook',
|
||||
'icon' => 'el el-facebook',
|
||||
);
|
||||
$args['share_icons'][] = array(
|
||||
'url' => 'https://twitter.com/themekalia',
|
||||
'title' => 'Follow us on Twitter',
|
||||
'icon' => 'el el-twitter',
|
||||
);
|
||||
$args['share_icons'][] = array(
|
||||
'url' => 'https://www.linkedin.com/company/themekalia-web-arcade',
|
||||
'title' => 'Find us on LinkedIn',
|
||||
'icon' => 'el el-linkedin',
|
||||
);
|
||||
|
||||
// Panel Intro text -> before the form
|
||||
if ( ! isset( $args['global_variable'] ) || $args['global_variable'] !== false ) {
|
||||
if ( ! empty( $args['global_variable'] ) ) {
|
||||
$v = $args['global_variable'];
|
||||
} else {
|
||||
$v = str_replace( '-', '_', $args['opt_name'] );
|
||||
}
|
||||
$args['intro_text'] = '';
|
||||
} else {
|
||||
$args['intro_text'] = '';
|
||||
}
|
||||
|
||||
// Add content after the form.
|
||||
$args['footer_text'] = '';
|
||||
\Redux::setArgs( $this->opt_name, $args );
|
||||
do_action( 'templatepath/themes/after_redux_setup', $this->opt_name, $args );
|
||||
}
|
||||
|
||||
|
||||
function helpTabs() {
|
||||
|
||||
/*
|
||||
* ---> START HELP TABS
|
||||
*/
|
||||
|
||||
$tabs = array(
|
||||
array(
|
||||
'id' => 'redux-help-tab-1',
|
||||
'title' => esc_html__( 'Theme Information 1', 'thinkai' ),
|
||||
'content' => esc_html__( '<p>This is the tab content, HTML is allowed.</p>', 'thinkai' ),
|
||||
),
|
||||
array(
|
||||
'id' => 'redux-help-tab-2',
|
||||
'title' => esc_html__( 'Theme Information 2', 'thinkai' ),
|
||||
'content' => esc_html__( '<p>This is the tab content, HTML is allowed.</p>', 'thinkai' ),
|
||||
),
|
||||
);
|
||||
Redux::setHelpTab( $opt_name, $tabs );
|
||||
|
||||
// Set the help sidebar
|
||||
$content = '<p>' . esc_html__( 'This is the sidebar content, HTML is allowed.', 'thinkai' ) . '</p>';
|
||||
Redux::setHelpSidebar( $opt_name, $content );
|
||||
}
|
||||
|
||||
|
||||
function sections() {
|
||||
|
||||
$sections = array(
|
||||
'general_setting',
|
||||
'logo_setting',
|
||||
'headers_setting',
|
||||
'mobile_setting',
|
||||
'sidebar_setting',
|
||||
'footer_setting',
|
||||
'blog_setting',
|
||||
'tag_setting',
|
||||
'archive_setting',
|
||||
'author_setting',
|
||||
'category_setting',
|
||||
'search_setting',
|
||||
'404_setting',
|
||||
'single_post_setting',
|
||||
'language_setting',
|
||||
'custom_sidebar_setting',
|
||||
'social_setting',
|
||||
'custom_fonts_setting',
|
||||
'typography_setting',
|
||||
'body_font_setting',
|
||||
);
|
||||
|
||||
|
||||
$sections_path = array();
|
||||
|
||||
// Set the path for options.
|
||||
foreach ( $sections as $sec ) {
|
||||
$sections_path[ $sec ] = get_template_directory() . '/includes/resource/options/' . $sec . '.php';
|
||||
}
|
||||
|
||||
$sections_path = apply_filters( 'thinkai_redux_sections', $sections_path );
|
||||
|
||||
$count = 1;
|
||||
|
||||
|
||||
foreach ( $sections_path as $key => $file ) {
|
||||
|
||||
if ( file_exists( $file ) ) {
|
||||
|
||||
$options = include( $file );
|
||||
|
||||
$options['priority'] = $count;
|
||||
|
||||
$options = apply_filters( "thinkai_redux_sections_{$key}", $options );
|
||||
|
||||
\Redux::setSection( $this->opt_name, $options );
|
||||
}
|
||||
|
||||
$count ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
246
wp-content/themes/thinkai/includes/classes/visual-composer.php
Normal file
246
wp-content/themes/thinkai/includes/classes/visual-composer.php
Normal file
@@ -0,0 +1,246 @@
|
||||
<?php
|
||||
|
||||
namespace THINKAI\Includes\Classes;
|
||||
|
||||
/**
|
||||
* Visual Composer array mapper and render the output.
|
||||
*/
|
||||
class Visual_Composer {
|
||||
|
||||
/**
|
||||
* [$maps description]
|
||||
* @var array
|
||||
*/
|
||||
protected $maps = array(
|
||||
'heading1',
|
||||
'our_services',
|
||||
'choose_us',
|
||||
'projects',
|
||||
'blog',
|
||||
'testimonial',
|
||||
'brands',
|
||||
'slider',
|
||||
'get_in_touch',
|
||||
'our_services2',
|
||||
'services_news',
|
||||
'circled_services',
|
||||
'custom_info',
|
||||
'services_icon',
|
||||
'our_experts',
|
||||
'pricing_plan',
|
||||
'projects2',
|
||||
'faqs',
|
||||
'contact_info',
|
||||
'contact_form',
|
||||
'map',
|
||||
'estimated_time',
|
||||
'pricing_plan2',
|
||||
'about_us',
|
||||
'widget_contact',
|
||||
'useful_links',
|
||||
'store_hours',
|
||||
'get_offer',
|
||||
'header_logo',
|
||||
'contact_us',
|
||||
'main_menu',
|
||||
'simple_info',
|
||||
'header_button',
|
||||
'search_box',
|
||||
'header_contact_info',
|
||||
'header_social_icons',
|
||||
'reparing',
|
||||
'about_us_carousel',
|
||||
'repair_video',
|
||||
'problem_fix_form',
|
||||
'widget_blog',
|
||||
'widget_newsletter',
|
||||
'widget_social_profiles',
|
||||
'funfacts',
|
||||
'repaired_parallax',
|
||||
'appointment_banner',
|
||||
'repair_device',
|
||||
'best_opertunity',
|
||||
'simple_banner',
|
||||
'states',
|
||||
'repair_model',
|
||||
'parts_price',
|
||||
'supported_models',
|
||||
'branches',
|
||||
'latest_articles',
|
||||
'projects3',
|
||||
'pricing_plans3',
|
||||
'funfact2',
|
||||
'services3',
|
||||
'contact_infobar',
|
||||
'services4',
|
||||
'about_us2',
|
||||
'choose_us2',
|
||||
'team',
|
||||
'funfacts3',
|
||||
'specialized_services',
|
||||
'services5',
|
||||
'pricing_plans4',
|
||||
'blog2',
|
||||
'call_back',
|
||||
'sponsors',
|
||||
'fun_facts_boxes',
|
||||
'gallery',
|
||||
'portfolio',
|
||||
'featured_banner',
|
||||
'video_banner',
|
||||
'featured_carousel'
|
||||
);
|
||||
|
||||
/**
|
||||
* [__construct description]
|
||||
*/
|
||||
function __construct() {
|
||||
|
||||
if ( ! function_exists( 'vc_map' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
vc_set_default_editor_post_types( array( 'page', 'static_block' ) );
|
||||
|
||||
|
||||
add_action( 'vc_before_init', array( $this, 'init' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* VC Map main init
|
||||
* @return void [description]
|
||||
*/
|
||||
function init() {
|
||||
|
||||
// set vc as theme.
|
||||
vc_set_as_theme();
|
||||
|
||||
if ( function_exists( 'vc_addshortcode_param' ) ) {
|
||||
vc_addshortcode_param( 'toggle', array( $this, 'toggle' ) );
|
||||
}
|
||||
|
||||
$dir = get_stylesheet_directory() . '/shortcodes'; // First, set new directory for templates
|
||||
vc_set_shortcodes_templates_dir( $dir );
|
||||
|
||||
// Map the params of existing elements.
|
||||
$this->map_params();
|
||||
|
||||
$maps = apply_filters( 'thinkai_vc_map', $this->maps );
|
||||
|
||||
foreach ( $maps as $value) {
|
||||
|
||||
$file = $this->get_file( $value );
|
||||
|
||||
if ( file_exists( $file ) ) {
|
||||
|
||||
$data = include $file;
|
||||
|
||||
vc_map( $data );
|
||||
|
||||
if ( function_exists( 'wpthinkai_shortcode' ) ) {
|
||||
$tag = esc_attr( thinkai_set( $data, 'base' ) );
|
||||
|
||||
wpthinkai_shortcode( $tag, array( $this, 'output' ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function output( $atts, $content = null, $tag ) {
|
||||
|
||||
$params = $this->shortcodeParams( $tag );
|
||||
|
||||
ob_start();
|
||||
|
||||
thinkai_template_load( 'shortcodes/' . $tag . '.php', compact( 'atts', 'content', 'tag' ) );
|
||||
|
||||
return ob_get_clean();
|
||||
|
||||
}
|
||||
|
||||
function get_file( $tag ) {
|
||||
|
||||
$file = thinkai_template( 'includes/resource/vc_map/'.$tag . '.php' );
|
||||
$file = apply_filters( "thinkai_vc_map_file_{$tag}", $file );
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* shortcode params from vc array.
|
||||
*
|
||||
* @param string $tag shortcode tag
|
||||
* @return array params
|
||||
*/
|
||||
function shortcodeParams( $tag ) {
|
||||
|
||||
$file = $this->get_file( $tag );
|
||||
|
||||
if ( file_exists( $file ) ) {
|
||||
$data = include $file;
|
||||
|
||||
return thinkai_set( $data, 'params' );
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
function map_params() {
|
||||
|
||||
$array = array(
|
||||
'vc_row',
|
||||
);
|
||||
|
||||
foreach( $array as $file ) {
|
||||
|
||||
$file = $this->get_file( $file );
|
||||
|
||||
if ( file_exists( $file ) ) {
|
||||
$data = include $file;
|
||||
|
||||
foreach ( $data as $key => $value) {
|
||||
|
||||
foreach( $value as $param ) {
|
||||
vc_add_param( $key, $param );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checkbox shortcode attribute type generator.
|
||||
*
|
||||
* @param $settings
|
||||
* @param string $value
|
||||
*
|
||||
* @since 4.4
|
||||
* @return string - html string.
|
||||
*/
|
||||
function toggle( $settings, $value ) {
|
||||
$output = '';
|
||||
if ( is_array( $value ) ) {
|
||||
$value = '';
|
||||
}
|
||||
$current_value = strlen( $value ) > 0 ? explode( ',', $value ) : array();
|
||||
$values = isset( $settings['value'] ) && is_array( $settings['value'] ) ? $settings['value'] : array( esc_html__( 'Yes', 'thinkai' ) => 'true' );
|
||||
if ( ! empty( $values ) ) {
|
||||
foreach ( $values as $label => $v ) {
|
||||
$checked = count( $current_value ) > 0 && in_array( $v, $current_value ) ? ' checked' : '';
|
||||
$output .= ' <label class="vc_checkbox-label"><input id="'
|
||||
. $settings['param_name'] . '-' . $v . '" value="'
|
||||
. $v . '" class="wpb_vc_param_value tgl tgl-ios '
|
||||
. $settings['param_name'] . ' ' . $settings['type'] . '" type="checkbox" name="'
|
||||
. $settings['param_name'] . '"'
|
||||
|
||||
. $checked . '> '
|
||||
. '<span class="tgl-btn" for="cb2"></span>'
|
||||
. $label . '</label>';
|
||||
}
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user