Elementor Custom Skin - Version 1.0.0

Version Description

Download this release

Release Info

Developer dudaster
Plugin Icon 128x128 Elementor Custom Skin
Version 1.0.0
Comparing to
See all releases

Version 1.0.0

assets/screenshot-1.png ADDED
Binary file
assets/screenshot-2.png ADDED
Binary file
ele-custom-skin.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Plugin Name: Ele Custom Skin
4
+ * Version: 1.0.0
5
+ * Description: Elementor Custom Skin for Posts and Posts Archive. You can create a skin as you want.
6
+ * Plugin URI: https://www.eletemplator.com
7
+ * Author: Liviu Duda
8
+ * Author URI: https://www.leadpro.ro
9
+ * Text Domain: elecustomskin
10
+ * Domain Path: /languages
11
+ * License: GPLv3
12
+ * License URI: http://www.gnu.org/licenses/gpl-3.0
13
+ */
14
+ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
15
+
16
+ define( 'ELECS_DIR', plugin_dir_path( __FILE__ ));
17
+ add_action( 'elementor_pro/init', 'elecs_elementor_init' );
18
+ function elecs_elementor_init(){
19
+ //load templates types
20
+
21
+ //require_once ELECS_DIR.'theme-builder/init.php';
22
+ require_once ELECS_DIR.'theme-builder/init.php';
23
+
24
+ }
25
+
26
+ add_action('elementor/widgets/widgets_registered','elecs_add_skins');
27
+ function elecs_add_skins(){
28
+ require_once ELECS_DIR.'skins/skin-custom.php';
29
+ }
readme.txt ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Elementor Custom Skin ===
2
+ Contributors: dudaster
3
+ Tags: page-builder, elementor
4
+ Requires at least: 4.6
5
+ Tested up to: 4.9.1
6
+ Stable tag: 4.9.1
7
+ License: GPLv2 or later
8
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
+
10
+ Add new skin to Elementor page builder.
11
+
12
+ == Description ==
13
+
14
+ This plugin adds new skin to Elementor Page Builder Posts and Posts Archive widget.
15
+
16
+ You can design a loop item just like a single template and it would be used as a skin.
17
+
18
+ For more details and demo check our official site https://www.eletemplator.com/
19
+
20
+ Note: This plugin is an addon of Elementor Page Builder (https://wordpress.org/plugins/elementor/) and will only work with Elementor Page Builder installed.
21
+
22
+ == Installation ==
23
+
24
+ 1. Upload the plugin files to the `/wp-content/plugins/plugin-name` directory, or install the plugin through the WordPress plugins screen directly.
25
+ 2. Activate the plugin through the 'Plugins' screen in WordPress
26
+
27
+
28
+ == Frequently Asked Questions ==
29
+
30
+ = Where can i find the new Loop Type =
31
+
32
+ The Loop Type would appear in My Templates in Elementor as new type
33
+
34
+ = How can I choose the new Custom Skin =
35
+
36
+ Add to your template a Post or Post Archive widget and from Skins select Custom Skin
37
+
38
+ == Screenshots ==
39
+
40
+ 1. /assets/screenshot-1.png
41
+ 2. /assets/screenshot-2.png
42
+
43
+ == Changelog ==
44
+
45
+
46
+ = 1.0 =
47
+ * Initial Launch with Loop Elementor My Templates Type
skins/skin-custom.php ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace ElementorPro\Modules\Posts\Skins;
3
+
4
+ use Elementor\Controls_Manager;
5
+ use Elementor\Group_Control_Box_Shadow;
6
+ use Elementor\Group_Control_Image_Size;
7
+ use Elementor\Group_Control_Typography;
8
+ use Elementor\Scheme_Color;
9
+ use Elementor\Scheme_Typography;
10
+ use Elementor\Widget_Base;
11
+ use ElementorPro\Plugin;
12
+
13
+ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
14
+
15
+ class Skin_Custom extends Skin_Base {
16
+
17
+ private $template_cache=[];
18
+ private $pid;
19
+
20
+
21
+
22
+ public function get_id() {
23
+ return 'custom';
24
+ }
25
+
26
+ public function get_title() {
27
+ return __( 'Custom', 'elementor-pro' );
28
+ }
29
+
30
+ protected function _register_controls_actions() {
31
+ add_action( 'elementor/element/posts-archive/section_layout/before_section_end', [ $this, 'register_controls' ] );
32
+ add_action( 'elementor/element/posts-archive/section_query/after_section_end', [ $this, 'register_style_sections' ] );
33
+
34
+ add_action( 'elementor/element/posts/section_layout/before_section_end', [ $this, 'register_controls' ] );
35
+ add_action( 'elementor/element/posts/section_query/after_section_end', [ $this, 'register_style_sections' ] );
36
+
37
+ }
38
+
39
+ public function register_controls( Widget_Base $widget ) {
40
+
41
+ $this->parent = $widget;
42
+
43
+
44
+ $this->add_control(
45
+ 'skin_template',
46
+ [
47
+ 'label' => __( 'Select a template', 'elecustomskin' ),
48
+ 'type' => Controls_Manager::SELECT2,
49
+ 'label_block' => true,
50
+ 'default' => [],
51
+ 'options' => $this->get_skin_template(),
52
+ ]
53
+ );
54
+ parent::register_controls($widget);
55
+
56
+ $this->remove_control( 'img_border_radius' );
57
+ $this->remove_control( 'meta_data' );
58
+ $this->remove_control( 'item_ratio' );
59
+ $this->remove_control( 'image_width' );
60
+ $this->remove_control( 'show_title' );
61
+ $this->remove_control( 'title_tag' );
62
+
63
+
64
+ }
65
+
66
+ private function get_post_id(){
67
+ return $this->pid;
68
+ }
69
+ private function get_skin_template(){
70
+ global $wpdb;
71
+ $templates = $wpdb->get_results(
72
+ "SELECT $wpdb->term_relationships.object_id as ID, $wpdb->posts.post_title as post_title FROM $wpdb->term_relationships
73
+ INNER JOIN $wpdb->terms ON
74
+ $wpdb->term_relationships.term_taxonomy_id=$wpdb->terms.term_id AND $wpdb->terms.slug='loop'
75
+ INNER JOIN $wpdb->posts ON
76
+ $wpdb->term_relationships.object_id=$wpdb->posts.ID"
77
+ );
78
+ $options = [ '' => '' ];
79
+ foreach ( $templates as $template ) {
80
+ $options[ $template->ID ] = $template->post_title;
81
+ $this->set_template($template->ID);//this is for termlisting we cache the templates
82
+ }
83
+ return $options;
84
+ }
85
+
86
+
87
+ protected function get_skin_template_sterge() {
88
+ $this->is_in_templates();
89
+ $menus = get_terms( array(
90
+ 'taxonomy' => 'nav_menu',
91
+ 'hide_empty' => false,
92
+ ));
93
+
94
+ $options = [ '' => '' ];
95
+
96
+ foreach ( $menus as $menu ) {
97
+ $options[ $menu->slug ] = $menu->name;
98
+
99
+ }
100
+
101
+ return $options;
102
+ }
103
+
104
+
105
+
106
+ public function render_amp() {
107
+
108
+ }
109
+
110
+ protected function set_template($skin){// this is for terms we don't need passid so we can actually add them in cache
111
+
112
+ if (!$skin) return;
113
+ if ($this->template_cache[$skin]) return $this->template_cache[$skin];
114
+
115
+ $return = \Elementor\Plugin::instance()->frontend->get_builder_content_for_display( $skin );
116
+ $this->template_cache[$skin] = $return;
117
+
118
+ }
119
+
120
+ protected function get_template(){
121
+ $settings = $this->parent->get_settings();
122
+ $this->pid=get_the_ID();//set the current id in private var usefull to passid
123
+ if (!$this->get_instance_value( 'skin_template' )) return;
124
+ //term listing stuff
125
+ /*if($settings['eleplug_eloop_term']=="yes" && $settings['taxonomy']){ // not to mess up with the terms fang shui we choose to get the cache template
126
+ if ($this->template_cache[$this->get_instance_value( 'skin_template' )]) return $this->template_cache[$this->get_instance_value( 'skin_template' )];
127
+ }*/
128
+
129
+ $return = \Elementor\Plugin::instance()->frontend->get_builder_content_for_display( $this->get_instance_value( 'skin_template' ) );
130
+ //$this->template_cache[$this->get_instance_value( 'skin_template' )] = $return;
131
+ return $return;
132
+ }
133
+
134
+ protected function render_post_header() {
135
+ ?>
136
+ <article id="post-<?php the_ID(); ?>" <?php post_class( [ 'elementor-post elementor-grid-item' ] ); ?>>
137
+ <?php
138
+ }
139
+ protected function render_post() {
140
+ $this->render_post_header();
141
+ if ($this->get_instance_value( 'skin_template' )) echo $this->get_template();
142
+
143
+ else echo "Select a Loop template! If you don't have one go to Elementor &gt; My Templates.";
144
+
145
+
146
+ $this->render_post_footer();
147
+
148
+ }
149
+
150
+
151
+ }
152
+
153
+ // Add a custom skin for the POST Archive widget
154
+ add_action( 'elementor/widget/posts-archive/skins_init', function( $widget ) {
155
+ $widget->add_skin( new Skin_Custom( $widget ) );
156
+ } );
157
+ // Add a custom skin for the POSTS widget
158
+ add_action( 'elementor/widget/posts/skins_init', function( $widget ) {
159
+ $widget->add_skin( new Skin_Custom( $widget ) );
160
+ } );
theme-builder/classes/custom-types-manager.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace ElementorPro\Modules\ThemeBuilder\Classes;
3
+
4
+ use Elementor\TemplateLibrary\Source_Local;
5
+ use ElementorPro\Modules\ThemeBuilder\Documents;
6
+ use ElementorPro\Modules\ThemeBuilder\Module;
7
+ use ElementorPro\Plugin;
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit; // Exit if accessed directly
11
+ }
12
+
13
+ class Custom_Types_Manager extends Templates_Types_Manager {
14
+
15
+ public function register_documents() {
16
+ $this->docs_types = [
17
+ 'loop' => Documents\Loop::get_class_full_name(),
18
+ ];
19
+
20
+ foreach ( $this->docs_types as $type => $class_name ) {
21
+ Plugin::elementor()->documents->register_document_type( $type, $class_name );
22
+ Source_Local::add_template_type( $type );
23
+ }
24
+ }
25
+ }
26
+
27
+ new Custom_Types_Manager();
theme-builder/documents/loop.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace ElementorPro\Modules\ThemeBuilder\Documents;
3
+
4
+ if ( ! defined( 'ABSPATH' ) ) {
5
+ exit; // Exit if accessed directly
6
+ }
7
+
8
+ class Loop extends Theme_Document {
9
+
10
+ public static function get_properties() {
11
+ $properties = parent::get_properties();
12
+
13
+ $properties['condition_type'] = 'general';
14
+ $properties['location'] = 'archive';
15
+
16
+ return $properties;
17
+ }
18
+
19
+ public function get_name() {
20
+ return 'loop';
21
+ }
22
+
23
+ public static function get_title() {
24
+ return __( 'Loop', 'elementor-pro' );
25
+ }
26
+
27
+ public static function get_preview_as_default() {
28
+ return '';
29
+ }
30
+
31
+ public static function get_preview_as_options() {
32
+ return array_merge(
33
+ [
34
+ '',
35
+ ],
36
+ Single::get_preview_as_options()
37
+ );
38
+ }
39
+ }
theme-builder/dynamic-tags/ele-tags.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace ElementorPro\Modules\DynamicTags;
4
+
5
+ use Elementor\Modules\DynamicTags\Module as TagsModule;
6
+ use Elementor\Plugin;
7
+
8
+ if ( ! defined( 'ABSPATH' ) ) {
9
+ exit; // Exit if accessed directly
10
+ }
11
+
12
+ require_once('tags/post-summary.php');
13
+
14
+ class Eletags extends TagsModule {
15
+
16
+ public function __construct() {
17
+ parent::__construct();
18
+ }
19
+
20
+ public function get_name() {
21
+ return 'eletags';
22
+ }
23
+
24
+ public function get_tag_classes_names() {
25
+ return [
26
+ 'Post_Summary',
27
+ ];
28
+ }
29
+
30
+ }
theme-builder/dynamic-tags/tags/post-summary.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace ElementorPro\Modules\DynamicTags\Tags;
3
+
4
+ use Elementor\Controls_Manager;
5
+ use Elementor\Core\DynamicTags\Tag;
6
+ use ElementorPro\Modules\DynamicTags\Module;
7
+
8
+ if ( ! defined( 'ABSPATH' ) ) {
9
+ exit; // Exit if accessed directly
10
+ }
11
+
12
+ class Post_Summary extends Tag {
13
+ public function get_name() {
14
+ return 'post-summary';
15
+ }
16
+
17
+ public function get_title() {
18
+ return __( 'Post Summary', 'elementor-pro' );
19
+ }
20
+
21
+ public function get_group() {
22
+ return Module::POST_GROUP;
23
+ }
24
+
25
+ public function get_categories() {
26
+ return [ Module::TEXT_CATEGORY ];
27
+ }
28
+
29
+ protected function _register_controls() {
30
+ $this->add_control(
31
+ 'length',
32
+ [
33
+ 'label' => __( 'Length', 'elementor-pro' ),
34
+ 'type' => Controls_Manager::NUMBER,
35
+ 'default' => 25,
36
+ 'min' => 0,
37
+ 'max' => 1000,
38
+ 'step' => 1,
39
+ ]
40
+ );
41
+ }
42
+
43
+ public function render() {
44
+ add_filter( 'excerpt_more',function(){return '';}, 20 );
45
+ add_filter( 'excerpt_length', function(){$settings = $this->get_settings(); return $settings['length'];}, 20 );
46
+ echo get_the_excerpt();
47
+ }
48
+ }
theme-builder/init.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once ELECS_DIR.'theme-builder/documents/loop.php';
4
+ require_once ELECS_DIR.'theme-builder/dynamic-tags/ele-tags.php';
5
+ //add new tags
6
+ $newtags=new ElementorPro\Modules\DynamicTags\Eletags();
7
+ $newtags::instance();
8
+ //require_once ELECS_DIR.'theme-builder/classes/custom-types-manager.php';
9
+
10
+ use Elementor\TemplateLibrary\Source_Local;
11
+ use ElementorPro\Modules\ThemeBuilder\Documents\Loop;
12
+ use ElementorPro\Plugin;
13
+ use ElementorPro\Modules\ThemeBuilder\Documents\Theme_Document;
14
+
15
+ Plugin::elementor()->documents->register_document_type( 'loop', Loop::get_class_full_name() );
16
+ Source_Local::add_template_type( 'loop' );
17
+
18
+ function elecs_get_document( $post_id ) {
19
+ $document = null;
20
+
21
+ try {
22
+ $document = Plugin::elementor()->documents->get( $post_id );
23
+ } catch ( \Exception $e ) {}
24
+
25
+ if ( ! empty( $document ) && ! $document instanceof Theme_Document ) {
26
+ $document = null;
27
+ }
28
+
29
+ return $document;
30
+ }
31
+
32
+ function elecs_add_more_types($settings){
33
+ $post_id = get_the_ID();
34
+ $document = elecs_get_document( $post_id );
35
+
36
+ if ( ! $document ) {
37
+ return $settings;
38
+ }
39
+
40
+ $new_types=['loop'=>Loop::get_properties()];
41
+ $add_settings=['theme_builder' => ['types' =>$new_types]];
42
+ $settings = array_merge_recursive($settings, $add_settings);
43
+ return $settings;
44
+ }
45
+
46
+ add_filter( 'elementor_pro/editor/localize_settings', 'elecs_add_more_types' );