'keydesign_templates',
'category_name' => esc_html__( 'Ekko Templates', 'keydesign' ),
'category_weight' => 1,
'templates' => $this->getAllTemplates(),
);
$data[] = $TemplatesCategory;
return $data;
}
public function getKeyDesignTemplates() {
$templates = getTemplatesFile();
return $templates;
}
public function filters_list() {
$output = '';
$output .= '
';
$output .= '- All245
';
$output .= '- Intro Section17
';
$output .= '- Creative Blocks45
';
$output .= '- Sticky navigation1
';
$output .= '- Blog Posts4
';
$output .= '- Call to Action10
';
$output .= '- Cards14
';
$output .= '- Charts16
';
$output .= '- Clients6
';
$output .= '- Contact Form23
';
$output .= '- Counters8
';
$output .= '- Faq11
';
$output .= '- Gallery4
';
$output .= '- Icon Boxes14
';
$output .= '- Maps4
';
$output .= '- Mobile App5
';
$output .= '- Process8
';
$output .= '- Pricing11
';
$output .= '- Portfolio6
';
$output .= '- Shop4
';
$output .= '- Tabs7
';
$output .= '- Team8
';
$output .= '- Testimonials10
';
$output .= '- Title4
';
$output .= '- Video6
';
$output .= '
';
return $output; }
public function renderTemplateBlock( $category ) {
if ( 'keydesign_templates' === $category['category'] ) {
$category['output'] = '';
$category['output'] .= $this->filters_list();
$category['output'] .= '
';
if ( ! empty( $category['templates'] ) ) {
foreach ( $category['templates'] as $template ) {
$category['output'] .= $this->renderTemplateListItem( $template );
}
}
$category['output'] .= '
';
}
return $category;
}
function renderTemplateWindow( $template_name, $template_data ) {
if ( 'keydesign_templates' === $template_data['type'] ) {
return $this->renderTemplateWindowKeydesign( $template_name, $template_data );
}
return $template_name;
}
public function renderTemplateWindowKeydesign( $template_name, $template_data ) {
ob_start();
$template_id = esc_attr( $template_data['unique_id'] );
$template_id_hash = md5( $template_id ); // needed for jquery target for TTA
$template_name = esc_html( $template_name );
$preview_template_title = esc_attr__( 'Preview template', 'keydesign' );
$add_template_title = esc_attr__( 'Add template', 'keydesign' );
echo <<$template_name
HTML;
return ob_get_clean();
}
public function renderUITemplate() {
vc_include_template( 'editors/popups/vc_ui-panel-templates.tpl.php', array(
'box' => $this,
) );
return '';
}
public function renderBackendTemplate() {
$template_id = vc_post_param( 'template_unique_id' );
$template_type = vc_post_param( 'template_type' );
if ( ! isset( $template_id, $template_type ) || '' === $template_id || '' === $template_type ) {
die( 'Error: Vc_Templates_Panel_Editor::renderBackendTemplate:1' );
}
WPBMap::addAllMappedShortcodes();
$this->getBackendDefaultTemplate();
die();
}
public function loadDefaultTemplatesLimit( $templates ) {
$start_index = 0;
$total_templates_to_show = apply_filters( 'vc_load_default_templates_limit_total', 6 );
return array_slice( $templates, $start_index, $total_templates_to_show );
}
public function getUserTemplates() {
return apply_filters( 'vc_get_user_templates', get_option( $this->option_name ) );
}
public function getAllTemplates() {
$data = array();
$keydesign_templates = $this->getKeyDesignTemplates();
$category_templates = array();
if ( ! empty( $keydesign_templates ) ) {
foreach ( $keydesign_templates as $template_id => $template_data ) {
$category_templates[] = array(
'unique_id' => $template_id,
'name' => $template_data['name'],
'weight' => $template_data['weight'],
'content' => $template_data['content'],
'custom_class' => $template_data['custom_class'],
'type' => 'keydesign_templates',
'image_path' => $template_data['image_path'],
);
$data = $category_templates;
}
}
return $data;
}
public function loadDefaultTemplates() {
return $this->keydesign_templates;
}
public function getDefaultTemplates() {
return $this->loadDefaultTemplates();
}
public function getDefaultTemplate( $template_index ) {
$this->loadDefaultTemplates();
if ( ! is_numeric( $template_index ) || ! is_array( $this->keydesign_templates ) || ! isset( $this->keydesign_templates[ $template_index ] ) ) {
return false;
}
return $this->keydesign_templates[ $template_index ];
}
public function addDefaultTemplates( $data ) {
if ( is_array( $data ) && ! empty( $data ) && isset( $data['name'], $data['content'] ) ) {
if ( ! is_array( $this->keydesign_templates ) ) {
$this->keydesign_templates = array();
}
$this->keydesign_templates[] = $data;
return true;
}
return false;
}
public function getBackendDefaultTemplate( $return = false ) {
$template_index = (int) vc_request_param( 'template_unique_id' );
$data = $this->getDefaultTemplate( $template_index );
if ( ! $data ) {
die( 'Error: Vc_Templates_Panel_Editor::getBackendDefaultTemplate:1' );
}
if ( $return ) {
return trim( $data['content'] );
} else {
echo trim( $data['content'] );
die();
}
}
public function sortTemplatesByCategories( array $data ) {
$buffer = $data;
uasort( $buffer, array(
$this,
'cmpCategory',
) );
return $buffer;
}
public function sortTemplatesByNameWeight( array $data ) {
$buffer = $data;
uasort( $buffer, array(
$this,
'cmpNameWeight',
) );
return $buffer;
}
public function getAllCategoriesNames( array $categories ) {
$categories_names = array();
foreach ( $categories as $category ) {
if ( isset( $category['category'] ) ) {
$categories_names[ $category['category'] ] = isset( $category['category_name'] ) ? $category['category_name'] : $category['category'];
}
}
return $categories_names;
}
public function getAllTemplatesSorted() {
$data = $this->getAllTemplates();
// firstly we need to sort by categories
$data = $this->sortTemplatesByCategories( $data );
// secondly we need to sort templates by their weight or name
foreach ( $data as $key => $category ) {
$data[ $key ]['templates'] = $this->sortTemplatesByNameWeight( $category['templates'] );
}
return $data;
}
protected function cmpCategory( $a, $b ) {
$a_k = isset( $a['category'] ) ? $a['category'] : '*';
$b_k = isset( $b['category'] ) ? $b['category'] : '*';
$a_category_weight = isset( $a['category_weight'] ) ? $a['category_weight'] : 0;
$b_category_weight = isset( $b['category_weight'] ) ? $b['category_weight'] : 0;
return $a_category_weight == $b_category_weight ? strcmp( $a_k, $b_k ) : $a_category_weight - $b_category_weight;
}
protected function cmpNameWeight( $a, $b ) {
$a_k = isset( $a['name'] ) ? $a['name'] : '*';
$b_k = isset( $b['name'] ) ? $b['name'] : '*';
$a_weight = isset( $a['weight'] ) ? $a['weight'] : 0;
$b_weight = isset( $b['weight'] ) ? $b['weight'] : 0;
return $a_weight == $b_weight ? strcmp( $a_k, $b_k ) : $a_weight - $b_weight;
}
public function frontendDoTemplatesShortcodes( $content ) {
return do_shortcode( $content );
}
public function addFrontendTemplatesShortcodesCustomCss() {
$output = $shortcodes_custom_css = '';
$shortcodes_custom_css = visual_composer()->parseShortcodesCustomCss( vc_frontend_editor()->getTemplateContent() );
if ( ! empty( $shortcodes_custom_css ) ) {
$shortcodes_custom_css = strip_tags( $shortcodes_custom_css );
$output .= '';
}
echo $output;
}
public function renderTemplateListItem( $template ) {
$name = isset( $template['name'] ) ? esc_html( $template['name'] ) : esc_html( __( 'No title', 'keydesign' ) );
$template_id = esc_attr( $template['unique_id'] );
$template_id_hash = md5( $template_id ); // needed for jquery target for TTA
$template_name = esc_html( $name );
$template_name_lower = esc_attr( vc_slugify( $template_name ) );
$template_type = esc_attr( isset( $template['type'] ) ? $template['type'] : 'custom' );
$custom_class = esc_attr( isset( $template['custom_class'] ) ? $template['custom_class'] : '' );
$output = <<
HTML;
$output .= '
 . ')
';
$output .= '
'.$template['name'].'
';
$output .= apply_filters( 'vc_templates_render_template', $name, $template );
$output .= <<
HTML;
return $output;
}
public function getOptionName() {
return $this->option_name;
}
}