Elementor Custom Skin - Version 2.0.2

Version Description

  • Fixing issues
Download this release

Release Info

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

Code changes from version 1.4.0 to 2.0.2

assets/css/ecs-style.css CHANGED
@@ -2,4 +2,40 @@
2
  /* https://www.dudaster.com */
3
  article .elementor-page-title{
4
  display:block;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  }
2
  /* https://www.dudaster.com */
3
  article .elementor-page-title{
4
  display:block;
5
+ }
6
+
7
+ .ecs-loop-preview{
8
+ height:100%;
9
+ width:100%;
10
+ background:lightgray;
11
+ border:solid 1px gray;
12
+ padding:5px;
13
+ }
14
+ .ecs-loop-preview h3{
15
+ font-size:16px;
16
+ font-weight:500;
17
+
18
+ }
19
+ .ecs-loop-preview span{
20
+ font-size:12px;
21
+ }
22
+ .ecs-loop-preview .ecs-image-holder{
23
+ width: 100%;
24
+ line-height: 113px;
25
+ background-color: #808080;
26
+ font-size: 45px;
27
+ text-align: center;
28
+ vertical-align: middle;
29
+ font-weight: 900;
30
+ color: #929191;
31
+ }
32
+
33
+ .ecs-link-wrapper{
34
+ cursor: pointer;
35
+ }
36
+ .elementor-widget-ele-loop-item, .elementor-widget-ele-loop-item > .elementor-widget-container,
37
+ .elementor-element-edit-mode.elementor-widget-ele-loop-item, .elementor-element-edit-mode.elementor-widget-ele-loop-item > .elementor-widget-container{
38
+
39
+ height: 100%;
40
+
41
  }
assets/js/ecs_admin_bar_menu.js ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ function ECS_update_admin_bar_menu(items){
2
+
3
+ for (i = 0; i < items.length; i++) {
4
+ if ( !jQuery( "#"+items[i].id ).length ) {
5
+
6
+ itemtemplate='<li id="'+items[i].id+'"><a class="ab-item" href="'+items[i].href+'">'+items[i].title+'</a></li>';
7
+ jQuery( "#"+items[i].parent).append( itemtemplate );
8
+
9
+ }
10
+ }
11
+ }
assets/js/ecs_preview.js ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var EleCustomSkinPreview = elementorModules.frontend.handlers.Base.extend({
2
+
3
+ loadedTemplates:{
4
+ article:`<article class="elementor-post elementor-grid-item post type-post status-publish format-standard has-post-thumbnail hentry">
5
+ [content]</article>`,
6
+ wrapper:`<div id="ecs-preview" class="elementor-element elementor-posts--thumbnail-top elementor-grid-[columns] elementor-grid-tablet-[columns_tablet] elementor-grid-mobile-[columns_mobile] elementor-widget elementor-widget-posts" data-element_type="widget" data-settings="{&quot;custom_is_display_conditions&quot;:&quot;yes&quot;,&quot;custom_columns&quot;:&quot;[columns]&quot;,&quot;custom_columns_tablet&quot;:&quot;[columns_tablet]&quot;,&quot;custom_columns_mobile&quot;:&quot;[columns_mobile]&quot;,&quot;custom_row_gap&quot;:{&quot;unit&quot;:&quot;px&quot;,&quot;size&quot;:35,&quot;sizes&quot;:[]}}" data-widget_type="posts.custom">
7
+ <style>
8
+ #ecs-preview article{margin:7px; }
9
+ </style>
10
+ <h1>Preview</h1>
11
+ <div class="elementor-widget-container"> <div class="elementor-posts-container elementor-posts elementor-grid elementor-posts--skin-custom">
12
+ [content]
13
+ </div></div>
14
+ </div>`
15
+ },
16
+ wrapper_template:{
17
+ header:"",
18
+ footer:""
19
+ },
20
+ article_template:{
21
+ header:"",
22
+ footer:""
23
+ },
24
+ previewArguments:{
25
+ columns:3,
26
+ columns_tablet:2,
27
+ columns_mobile:1
28
+ },
29
+ originalContent:"",
30
+ previewContent:"",
31
+
32
+ parseTemplate: function parseTemplate(content){
33
+ for (const [key, value] of Object.entries(this.previewArguments)) {
34
+ replace = '\\['+key+'\\]';
35
+ re = new RegExp(replace,"g");
36
+ content = content.replace(re, value);
37
+ }
38
+ //console.log(content);
39
+ return content;
40
+ },
41
+ setTemplate:function setTemplate(target){
42
+ var templatePart = this.loadedTemplates[target].split("[content]");
43
+
44
+ this[target + '_template'].header = templatePart[0];
45
+ this[target + '_template'].footer = templatePart[1] ;
46
+ },
47
+ generateArticles:function generateArticles(){
48
+ for(i=0; i < this.previewArguments.columns; i++){
49
+ this.previewContent += this.article_template.header + this.originalContent + this.article_template.footer;
50
+ }
51
+ },
52
+ generateContent: function generateContent(){
53
+ this.generateArticles();
54
+ this.previewContent = this.parseTemplate(this.wrapper_template.header) + this.previewContent + this.wrapper_template.footer;
55
+ },
56
+ destroyContent: function destroyContent(){
57
+ this.previewContent="";
58
+ jQuery('#ecs-preview').remove();
59
+ },
60
+ onInit: function onInit() {
61
+
62
+ elementorModules.frontend.handlers.Base.prototype.onInit.apply(this, arguments);
63
+ this.initPreview();
64
+ this.run();
65
+ },
66
+ initPreview: function initPreview(){
67
+ this.setTemplate('wrapper');
68
+ this.setTemplate('article');
69
+ },
70
+ writePreview: function writePreview(){
71
+ jQuery( this.previewContent ).insertAfter( "#elementor-add-new-section" );
72
+ jQuery('#ecs-preview .elementor-element-overlay').remove();
73
+ jQuery('#ecs-preview .elementor-element-edit-mode').removeClass( "elementor-element-edit-mode" );
74
+ jQuery('#ecs-preview .elementor-element-editable').removeClass( "elementor-element-editable" );
75
+ },
76
+ checkArguments: function checkArguments(){
77
+ //add ability to add remove columns
78
+ columns = 4;
79
+ this.previewArguments.columns = columns;
80
+ },
81
+ onElementChange: function onElementChange() {
82
+ this.run();
83
+ },
84
+ getOriginal: function getOriginal(){
85
+ this.originalContent=jQuery('.page-content .elementor-section-wrap').html();
86
+ },
87
+ run: function run(){
88
+ this.destroyContent();
89
+ this.checkArguments();
90
+ this.getOriginal();
91
+ this.generateContent();
92
+ this.writePreview();
93
+ //console.log(this.previewContent+" sunt aici");
94
+ }
95
+
96
+ });
97
+
98
+ //now let's see if we can call it
99
+ jQuery(window).on('elementor/frontend/init', () => {
100
+
101
+ const addHandler = ($element) => {
102
+ elementorFrontend.elementsHandler.addHandler(EleCustomSkinPreview, {
103
+ $element,
104
+ });
105
+ };
106
+ elementorFrontend.hooks.addAction('frontend/element_ready/global', addHandler);
107
+
108
+ });
assets/screenshot-3.png ADDED
Binary file
ele-custom-skin.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
  * Plugin Name: Ele Custom Skin
4
- * Version: 1.4.0
5
  * Description: Elementor Custom Skin for Posts and Archive Posts. You can create a skin as you want.
6
  * Plugin URI: https://dudaster.com
7
  * Author: Dudaster.com
@@ -18,7 +18,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
18
  define( 'ELECS_DIR', plugin_dir_path( __FILE__ ));
19
  define( 'ELECS_NAME', plugin_basename( __FILE__ ));
20
  define( 'ELECS_URL', plugin_dir_url( __FILE__ ));
21
- define ('ELECS_VER','1.4.0');
22
 
23
  include_once ELECS_DIR.'includes/ecs-notices.php';
24
  include_once ELECS_DIR.'includes/ecs-dependencies.php';
@@ -29,10 +29,10 @@ include_once ELECS_DIR.'includes/enqueue-styles.php';
29
  if (ecs_dependencies()) {
30
  add_action( 'elementor_pro/init', 'elecs_elementor_init' );
31
  function elecs_elementor_init(){
32
- //load templates types
33
 
34
- //require_once ELECS_DIR.'theme-builder/init.php';
35
  require_once ELECS_DIR.'theme-builder/init.php';
 
36
 
37
  }
38
 
1
  <?php
2
  /*
3
  * Plugin Name: Ele Custom Skin
4
+ * Version: 2.0.2
5
  * Description: Elementor Custom Skin for Posts and Archive Posts. You can create a skin as you want.
6
  * Plugin URI: https://dudaster.com
7
  * Author: Dudaster.com
18
  define( 'ELECS_DIR', plugin_dir_path( __FILE__ ));
19
  define( 'ELECS_NAME', plugin_basename( __FILE__ ));
20
  define( 'ELECS_URL', plugin_dir_url( __FILE__ ));
21
+ define ('ELECS_VER','2.0.2');
22
 
23
  include_once ELECS_DIR.'includes/ecs-notices.php';
24
  include_once ELECS_DIR.'includes/ecs-dependencies.php';
29
  if (ecs_dependencies()) {
30
  add_action( 'elementor_pro/init', 'elecs_elementor_init' );
31
  function elecs_elementor_init(){
 
32
 
33
+ include_once ELECS_DIR.'includes/admin-bar-menu.php';
34
  require_once ELECS_DIR.'theme-builder/init.php';
35
+ require_once ELECS_DIR.'modules/loop-item/module.php';
36
 
37
  }
38
 
includes/admin-bar-menu.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
4
+
5
+ class ECS_Admin_Bar_Menu {
6
+
7
+ private static $admin_bar_edit_documents = [];
8
+ private static $wp_admin_bar=[];
9
+
10
+ public static function instance() {
11
+
12
+ if ( is_null( self::$_instance ) ) {
13
+ self::$_instance = new self();
14
+ }
15
+ return self::$_instance;
16
+
17
+ }
18
+
19
+ public function __construct() {
20
+
21
+ $this->init();
22
+
23
+ }
24
+
25
+ public function init() {
26
+
27
+ }
28
+
29
+ public static function add_document( $post_id ) {
30
+ if ( post_password_required( $post_id ) ) {
31
+ return '';
32
+ }
33
+
34
+ if ( ! \Elementor\Plugin::$instance->db->is_built_with_elementor( $post_id ) ) {
35
+ return '';
36
+ }
37
+
38
+ $document = \Elementor\Plugin::$instance->documents->get_doc_for_frontend( $post_id );
39
+
40
+ // Change the current post, so widgets can use `documents->get_current`.
41
+ \Elementor\Plugin::$instance->documents->switch_to_document( $document );
42
+
43
+ if ( $document->is_editable_by_current_user() ) {
44
+ self::$admin_bar_edit_documents[ $document->get_main_id() ] = $document;
45
+ }
46
+ }
47
+
48
+ private static function add_menu_in_admin_bar() {
49
+ if ( empty( self::$admin_bar_edit_documents ) ) {
50
+ return;
51
+ }
52
+
53
+ $queried_object_id = get_queried_object_id();
54
+
55
+
56
+ if ( is_singular() && isset( self::$admin_bar_edit_documents[ $queried_object_id ] ) ) {
57
+ $menu_args['href'] = self::$admin_bar_edit_documents[ $queried_object_id ]->get_edit_url();
58
+ unset( self::$admin_bar_edit_documents[ $queried_object_id ] );
59
+ }
60
+
61
+
62
+
63
+ foreach ( self::$admin_bar_edit_documents as $document ) {
64
+ self::$wp_admin_bar[] = [
65
+ 'id' => 'wp-admin-bar-elementor_edit_doc_' . $document->get_main_id(),
66
+ 'parent' => 'wp-admin-bar-elementor_edit_page-default',
67
+ 'title' => sprintf( '<span class="elementor-edit-link-title">%s</span><span class="elementor-edit-link-type">%s</span>', $document->get_post()->post_title, $document::get_title() ),
68
+ 'href' => $document->get_edit_url(),
69
+ ] ;
70
+ }
71
+ }
72
+ public static function get_menu_args(){
73
+ self::add_menu_in_admin_bar();
74
+ return json_encode(self::$wp_admin_bar);
75
+ }
76
+
77
+ public static function write_js(){
78
+ if(is_admin_bar_showing()){
79
+
80
+ echo '<script src="'.ELECS_URL.'assets/js/ecs_admin_bar_menu.js"></script><script>';
81
+ echo 'ECS_update_admin_bar_menu('.self::get_menu_args().');';
82
+ echo '</script>';
83
+ }
84
+ }
85
+
86
+ }
87
+
88
+ add_action('wp_footer',function(){
89
+ ECS_Admin_Bar_Menu::write_js();
90
+ });
includes/pro-preview.php CHANGED
@@ -24,7 +24,27 @@ add_action( 'ECS_after_control', function($skin){
24
  ]
25
  );
26
 
27
- $skin->add_control(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  'alternating_templates',
29
  [
30
  'label' => '<i class="fa fa-lock" aria-hidden="true"></i> '.__( '<b>Alternating templates</b>', 'ele-custom-skin' ),
@@ -274,6 +294,43 @@ add_action( 'ECS_after_control', function($skin){
274
  ]
275
  );
276
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
277
  $skin->add_control(
278
  'upgrade_note',
279
  [
24
  ]
25
  );
26
 
27
+ $skin->add_control(
28
+ 'is_display_conditions',
29
+ [
30
+ 'label' => '<i class="fa fa-lock" aria-hidden="true"></i> '.__( '<b>Enable Display Conditions</b>', 'ele-custom-skin' ),
31
+ 'description' => __( 'Use templates based on Display Conditions set on Loop Templates', 'ele-custom-skin' ),
32
+ 'type' => \Elementor\Controls_Manager::SWITCHER,
33
+ 'label_off' => __( 'No', 'ele-custom-skin' ),
34
+ 'label_on' => __( 'Yes', 'ele-custom-skin' ),
35
+ 'return_value' => 'yes',
36
+ 'separator' => 'before',
37
+ 'default' => '',
38
+ 'frontend_available' => true,
39
+ 'selectors' =>[' '=>' '],
40
+ 'condition' => [
41
+ $skin->get_id().'_pro_features' => 'yes'
42
+ ],
43
+
44
+ ]
45
+ );
46
+
47
+ $skin->add_control(
48
  'alternating_templates',
49
  [
50
  'label' => '<i class="fa fa-lock" aria-hidden="true"></i> '.__( '<b>Alternating templates</b>', 'ele-custom-skin' ),
294
  ]
295
  );
296
 
297
+ $skin->add_control(
298
+ 'link_to',
299
+ [
300
+ 'label' => '<i class="fa fa-lock" aria-hidden="true"></i> '.__( '<b>Make entire post a link?</b>', 'ele-custom-skin' ),
301
+ 'description' => __( 'Make the entire Loop Template clickable.', 'ele-custom-skin' ),
302
+ 'type' => \Elementor\Controls_Manager::SWITCHER,
303
+ 'label_off' => __( 'No', 'ele-custom-skin' ),
304
+ 'label_on' => __( 'Yes', 'ele-custom-skin' ),
305
+ 'return_value' => 'yes',
306
+ 'separator' => 'before',
307
+ 'default' => '',
308
+ 'frontend_available' => true,
309
+ 'selectors' =>[' '=>' '],
310
+ 'condition' => [
311
+ $skin->get_id().'_pro_features' => 'yes'
312
+ ],
313
+ ]
314
+ );
315
+
316
+ $skin->add_control(
317
+ 'postlink',
318
+ [
319
+ 'label' => __( 'Link', 'ele-custom-skin' ),
320
+ 'description' => __( 'For this link to be SEO friendly please add a link to title or other widgets inside Loop Template.', 'ele-custom-skin' ),
321
+ 'type' => \Elementor\Controls_Manager::URL,
322
+ 'dynamic' => [
323
+ 'active' => true,
324
+ ],
325
+ 'placeholder' => __( 'https://your-link.com', 'ele-custom-skin' ),
326
+ 'condition' => [
327
+ $skin->get_id().'_link_to' => 'yes',
328
+ $skin->get_id().'_pro_features' => 'yes',
329
+ ],
330
+ 'show_label' => false,
331
+ ]
332
+ );
333
+
334
  $skin->add_control(
335
  'upgrade_note',
336
  [
modules/loop-item/module.php ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Plugin Name: Ele Custom Skin Loop Item
4
+ * Version: 1.0.1
5
+ */
6
+
7
+
8
+ if ( ! defined( 'ABSPATH' ) ) {
9
+ exit; // Exit if accessed directly.
10
+ }
11
+
12
+ /**
13
+ * Main Elementor Test Extension Class
14
+ *
15
+ * The main class that initiates and runs the plugin.
16
+ *
17
+ * @since 1.0.0
18
+ */
19
+ final class Ele_Custom_Loop_Item{
20
+
21
+
22
+ /**
23
+ * Instance
24
+ *
25
+ * @since 1.0.0
26
+ *
27
+ * @access private
28
+ * @static
29
+ *
30
+ * @var Elementor_Test_Extension The single instance of the class.
31
+ */
32
+ private static $_instance = null;
33
+
34
+ /**
35
+ * Instance
36
+ *
37
+ * Ensures only one instance of the class is loaded or can be loaded.
38
+ *
39
+ * @since 1.0.0
40
+ *
41
+ * @access public
42
+ * @static
43
+ *
44
+ * @return Elementor_Test_Extension An instance of the class.
45
+ */
46
+ public static function instance() {
47
+
48
+ if ( is_null( self::$_instance ) ) {
49
+ self::$_instance = new self();
50
+ }
51
+ return self::$_instance;
52
+
53
+ }
54
+
55
+ /**
56
+ * Constructor
57
+ *
58
+ * @since 1.0.0
59
+ *
60
+ * @access public
61
+ */
62
+ public function __construct() {
63
+
64
+ $this->init();
65
+
66
+ }
67
+
68
+ /**
69
+ * Initialize the plugin
70
+ *
71
+ * Load the plugin only after Elementor (and other plugins) are loaded.
72
+ * Checks for basic plugin requirements, if one check fail don't continue,
73
+ * if all check have passed load the files required to run the plugin.
74
+ *
75
+ * Fired by `plugins_loaded` action hook.
76
+ *
77
+ * @since 1.0.0
78
+ *
79
+ * @access public
80
+ */
81
+ public function init() {
82
+
83
+ // Add Plugin actions
84
+ add_action( 'elementor/widgets/widgets_registered', [ $this, 'init_widgets' ] );
85
+ add_action( 'elementor/controls/controls_registered', [ $this, 'init_controls' ] );
86
+ $this->init_includes();
87
+
88
+ }
89
+
90
+
91
+ /**
92
+ * Init Widgets
93
+ *
94
+ * Include widgets files and register them
95
+ *
96
+ * @since 1.0.0
97
+ *
98
+ * @access public
99
+ */
100
+ public function init_widgets() {
101
+
102
+ // Include Widget files
103
+ require_once( __DIR__ . '/widgets/loop-item.php' );
104
+
105
+ // Register widget
106
+ \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Ele_Custom_Loop_Item_Widget() );
107
+
108
+ }
109
+ /**
110
+ * Init Includes
111
+ *
112
+ * Include the necessary files and register them
113
+ *
114
+ * @since 1.0.0
115
+ *
116
+ * @access public
117
+ */
118
+ public function init_includes() {
119
+
120
+ /* foreach (glob( __DIR__ . "/includes/*.php") as $filename)
121
+ {
122
+ require_once( $filename );
123
+ }*/
124
+
125
+ }
126
+
127
+ /**
128
+ * Init Controls
129
+ *
130
+ * Include controls files and register them
131
+ *
132
+ * @since 1.0.0
133
+ *
134
+ * @access public
135
+ */
136
+ public function init_controls() {
137
+
138
+ // Include Control files
139
+ // require_once( __DIR__ . '/controls/test-control.php' );
140
+
141
+ // Register control
142
+ // \Elementor\Plugin::$instance->controls_manager->register_control( 'control-type-', new \Test_Control() );
143
+
144
+ }
145
+
146
+ }
147
+
148
+ \Ele_Custom_Loop_Item::instance();
modules/loop-item/widgets/loop-item.php ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
+ exit; // Exit if accessed directly
4
+ }
5
+
6
+ class Ele_Custom_Loop_Item_Widget extends \Elementor\Widget_Base {
7
+
8
+ /**
9
+ * Get widget name.
10
+ *
11
+ * Retrieve Term List widget name.
12
+ *
13
+ * @since 0.1
14
+ * @access public
15
+ *
16
+ * @return string Widget name.
17
+ */
18
+ public function get_name() {
19
+ return 'ele-loop-item';
20
+ }
21
+
22
+ /**
23
+ * Get widget title.
24
+ *
25
+ * Retrieve Term List widget title.
26
+ *
27
+ * @since 0.1
28
+ * @access public
29
+ *
30
+ * @return string Widget title.
31
+ */
32
+ public function get_title() {
33
+ return __( 'Loop Item', 'ele-custom-skin' );
34
+ }
35
+
36
+ /**
37
+ * Get widget icon.
38
+ *
39
+ * Retrieve Term List widget icon.
40
+ *
41
+ * @since 0.1
42
+ * @access public
43
+ *
44
+ * @return string Widget icon.
45
+ */
46
+ public function get_icon() {
47
+ return 'eicon-info-box';
48
+ }
49
+
50
+ /**
51
+ * Get widget categories.
52
+ *
53
+ * Retrieve the list of categories the Term List widget belongs to.
54
+ *
55
+ * @since 0.1
56
+ * @access public
57
+ *
58
+ * @return array Widget categories.
59
+ */
60
+ public function get_categories() {
61
+ return [ 'ele-custom-grid'];
62
+ }
63
+
64
+ /**
65
+ * Register Term List widget controls.
66
+ *
67
+ * Adds different input fields to allow the user to change and customize the widget settings.
68
+ *
69
+ * @since 0.1
70
+ * @access protected
71
+ */
72
+ protected function _register_controls() {
73
+
74
+ $this->start_controls_section(
75
+ 'content_section',
76
+ [
77
+ 'label' => __( 'Content', 'ele-term-list' ),
78
+ 'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
79
+ ]
80
+ );
81
+
82
+ $this->add_control(
83
+ 'important_note',
84
+ [
85
+ 'label' => __( 'Loop Item Place Holder', 'ele-term-list' ),
86
+ 'type' => \Elementor\Controls_Manager::RAW_HTML,
87
+ 'raw' => __( 'Place this widget where the Loop Item you want to show in Ele Custom Skin.', 'ele-term-list' ),
88
+ 'content_classes' => 'your-class',
89
+ 'selector'=>'{{wrapper}} .ecs-loop-preview'
90
+ ]
91
+ );
92
+
93
+
94
+ $this->end_controls_section();
95
+
96
+
97
+ }
98
+
99
+ /**
100
+ * Render Term List widget output on the frontend.
101
+ *
102
+ * Written in PHP and used to generate the final HTML.
103
+ *
104
+ * @since 0.1
105
+ * @access protected
106
+ */
107
+ protected function render() {
108
+
109
+ if ( $this->show_nice() ) {
110
+ $this->_content_template();
111
+ } else {
112
+ echo "{{ecs-article}}";
113
+ }
114
+
115
+ }
116
+
117
+ protected function show_nice(){
118
+ $is_preview=false;
119
+ $document = elecs_get_document( get_the_ID() );
120
+ //print_r($document->get_location());
121
+ if($document) if('custom_grid' == $document->get_location()){
122
+ if (isset($_GET['action'])) $is_preview = $_GET['action'] == 'elementor' ? true : false;
123
+ }
124
+ return $is_preview;
125
+ }
126
+
127
+ protected function _content_template() {
128
+
129
+ ?>
130
+ <div class="ecs-loop-preview">
131
+ <div class="ecs-image-holder">=^_^=</div>
132
+ <h3>
133
+ Lorem Ipsum
134
+ </h3>
135
+ <span>Nunc vos habere ultimum potentiae, ad excogitandum vestri malesuada euismod. Liber esto atque exprimere te.</span>
136
+ </div>
137
+ <?php
138
+ }
139
+
140
+ }
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: dudaster
3
  Tags: page-builder, elementor, loop, archive list, post widget, skin, custom, post grid
4
  Donate link: https://www.paypal.me/dudaster
5
  Requires at least: 5.0
6
- Tested up to: 5.3.2
7
- Stable tag: 1.4.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -16,6 +16,12 @@ This plugin adds new skin to Elementor Page Builder Posts and Posts Archive widg
16
 
17
  You can design a loop item just like a single template and it would be used as a skin so you can be able to create a post grid the way you like.
18
 
 
 
 
 
 
 
19
  [youtube http://www.youtube.com/watch?v=DwLFdaZ69KU&t=94]
20
 
21
  For a quick tutorial see Frequently Asked Questions!
@@ -56,14 +62,28 @@ Add to your template a Post or Post Archive widget and from Skins select Custom
56
 
57
  1. /assets/screenshot-1.png
58
  2. /assets/screenshot-2.png
 
59
 
60
  == Changelog ==
61
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  = 1.4.0 =
63
- * Added ability to use dynamic background to Elementor Widgets
64
- * Added ability to use dynamic color on Widgets
65
- * Added ability to use dynamic color on Sections and Columns
66
- * Added ability to use dynamic color on borders, backgrounds and shape dividers
 
67
 
68
  = 1.3.11 =
69
  * Fixing compatibility issues Elementor Pro 2.9.0
3
  Tags: page-builder, elementor, loop, archive list, post widget, skin, custom, post grid
4
  Donate link: https://www.paypal.me/dudaster
5
  Requires at least: 5.0
6
+ Tested up to: 5.4.2
7
+ Stable tag: 2.0.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
16
 
17
  You can design a loop item just like a single template and it would be used as a skin so you can be able to create a post grid the way you like.
18
 
19
+ New in version 2.0.0
20
+
21
+ The biggest newest feature is the Custom Grid. No more boring grid with fixed number of columns.
22
+
23
+ All you have to do is to create a Custom Grid Template and place the Post Item Widget (placeholder) in your template made with sections and columns, and why not other widgets.
24
+
25
  [youtube http://www.youtube.com/watch?v=DwLFdaZ69KU&t=94]
26
 
27
  For a quick tutorial see Frequently Asked Questions!
62
 
63
  1. /assets/screenshot-1.png
64
  2. /assets/screenshot-2.png
65
+ 2. /assets/screenshot-3.png
66
 
67
  == Changelog ==
68
 
69
+ = 2.0.2 =
70
+ * Fixing issues
71
+
72
+ = 2.0.1 =
73
+ * Fixing issues
74
+
75
+ = 2.0.0 =
76
+ * NEW!! You can create your own Custom Grid with Custom Grid Template.
77
+ * Fixed issue with Dynamic Conditions causing "No Content" Error in Elementor editor.
78
+ * Added a little preview in Loop Template editor.
79
+ * Fixed issue with missing Loops from Wordpress Admin Bar.
80
+
81
  = 1.4.0 =
82
+ * Added ability to use dynamic background to Elementor Widgets.
83
+ * Added ability to use dynamic color on Widgets.
84
+ * Added ability to use dynamic color on Sections and Columns.
85
+ * Added ability to use dynamic color on borders, backgrounds and shape dividers.
86
+
87
 
88
  = 1.3.11 =
89
  * Fixing compatibility issues Elementor Pro 2.9.0
skins/skin-custom.php CHANGED
@@ -9,14 +9,23 @@ 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_Posts_ECS extends Skin_Base {
16
 
17
- private $template_cache=[];
 
18
  private $pid;
19
  public $settings;
 
 
 
 
 
 
 
20
 
21
 
22
 
@@ -28,6 +37,12 @@ class Skin_Posts_ECS extends Skin_Base {
28
  return __( 'Custom', 'ele-custom-skin' );
29
  }
30
 
 
 
 
 
 
 
31
  protected function _register_controls_actions() {
32
  parent::_register_controls_actions();
33
  add_action( 'elementor/element/posts/'.$this->get_id().'_section_design_layout/after_section_end', [ $this, 'register_navigation_design_controls' ] );
@@ -68,7 +83,38 @@ class Skin_Posts_ECS extends Skin_Base {
68
  'prefix_class' => 'elementor-posts--thumbnail-',
69
  ]
70
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  do_action( 'ECS_after_control', $this );
73
 
74
  $this->add_control(
@@ -99,7 +145,7 @@ class Skin_Posts_ECS extends Skin_Base {
99
  private function get_post_id(){
100
  return $this->pid;
101
  }
102
- function get_skin_template(){
103
  global $wpdb;
104
  $templates = $wpdb->get_results(
105
  "SELECT $wpdb->term_relationships.object_id as ID, $wpdb->posts.post_title as post_title FROM $wpdb->term_relationships
@@ -117,13 +163,33 @@ class Skin_Posts_ECS extends Skin_Base {
117
  }
118
  return $options;
119
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
120
 
121
 
122
  public function render_amp() {
123
 
124
  }
125
 
126
- protected function set_template($skin){// this is for terms we don't need passid so we can actually add them in cache
127
 
128
  if (!$skin) return;
129
  if (isset($this->template_cache[$skin])) return $this->template_cache[$skin];
@@ -131,12 +197,55 @@ class Skin_Posts_ECS extends Skin_Base {
131
  $return = \Elementor\Plugin::instance()->frontend->get_builder_content_for_display( $skin );
132
  $this->template_cache[$skin] = $return;
133
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135
 
136
  protected function get_template(){
137
  global $ecs_render_loop, $wp_query,$ecs_index;
138
  $ecs_index++;
139
  $old_query=$wp_query;
 
 
140
  $new_query=new \WP_Query( array( 'p' => get_the_ID(), 'post_type' => get_post_type() ) );
141
  $wp_query = $new_query;
142
  $settings = $this->parent->get_settings();
@@ -144,6 +253,10 @@ class Skin_Posts_ECS extends Skin_Base {
144
  $default_template = $this->get_instance_value( 'skin_template' ) ;
145
  $template = $default_template;
146
  /* move to pro */
 
 
 
 
147
  $template = apply_filters( 'ECS_action_template', $template,$this,$ecs_index );
148
  $template = $this->get_current_ID($template);
149
 
@@ -153,8 +266,12 @@ class Skin_Posts_ECS extends Skin_Base {
153
 
154
  /* end pro */
155
  if (!$template) return;
 
 
 
156
  $return = \Elementor\Plugin::instance()->frontend->get_builder_content_for_display( $template );
157
  $ecs_render_loop=false;
 
158
  $wp_query = $old_query;
159
  return $return;
160
  }
@@ -166,13 +283,31 @@ class Skin_Posts_ECS extends Skin_Base {
166
  }
167
 
168
  protected function render_post_header() {
169
- $classes = 'elementor-post elementor-grid-item';
170
  $parent_settings = $this->parent->get_settings();
171
  $parent_settings[$this->get_id().'_post_slider'] = isset($parent_settings[$this->get_id().'_post_slider'])? $parent_settings[$this->get_id().'_post_slider'] : "";
172
- if($parent_settings[$this->get_id().'_post_slider'] == "yes") $classes .= ' swiper-slide'
 
 
 
 
 
 
 
173
  ?>
174
  <article id="post-<?php the_ID(); ?>" <?php post_class( [ $classes ] ); ?>>
175
  <?php
 
 
 
 
 
 
 
 
 
 
 
176
  }
177
 
178
  protected function render_post() {
@@ -183,8 +318,9 @@ class Skin_Posts_ECS extends Skin_Base {
183
  if ($this->get_instance_value( 'skin_template' )){
184
  if ($this->get_instance_value( 'use_keywords' ) == "yes") {
185
  global $post;
 
186
  $template = $this->get_template();
187
- $new_template = apply_filters( 'ecs_dynamic_filter', $template, $post );
188
  echo $new_template ? $new_template : $template;
189
  }
190
  else echo $this->get_template();
@@ -201,19 +337,33 @@ class Skin_Posts_ECS extends Skin_Base {
201
 
202
 
203
  protected function render_loop_header() {
 
204
  $parent_settings = $this->parent->get_settings();
205
  $parent_settings[$this->get_id().'_post_slider'] = isset($parent_settings[$this->get_id().'_post_slider'])? $parent_settings[$this->get_id().'_post_slider'] : "";
206
- $this->parent->add_render_attribute( 'container', [
 
 
 
 
 
 
 
 
 
 
 
207
  'class' => [
208
  'elementor-posts-container',
209
  'elementor-posts',
210
- $parent_settings[$this->get_id().'_post_slider'] == "yes" ? 'swiper-wrapper' : 'elementor-grid',
 
 
211
  $this->get_container_class(),
212
  ],
213
  ] );
214
- if($parent_settings[$this->get_id().'_post_slider'] == "yes") {
215
- echo '<div class="swiper-container">';
216
- }
217
  ?>
218
  <div <?php echo $this->parent->get_render_attribute_string( 'container' ); ?>>
219
  <?php
@@ -221,12 +371,19 @@ class Skin_Posts_ECS extends Skin_Base {
221
 
222
  protected function render_loop_footer() {
223
 
224
- ?>
225
- </div>
226
- <?php
227
 
228
  $parent_settings = $this->parent->get_settings();
229
  $parent_settings[$this->get_id().'_post_slider'] = isset($parent_settings[$this->get_id().'_post_slider'])? $parent_settings[$this->get_id().'_post_slider'] : "";
 
 
 
 
 
 
 
 
 
230
  if($parent_settings[$this->get_id().'_post_slider'] == "yes") {
231
  $this->slider_elements();
232
  echo '</div>';
@@ -314,6 +471,13 @@ class Skin_Posts_ECS extends Skin_Base {
314
  $query = $this->parent->get_query();
315
 
316
  do_action("ECS_before_loop_query",$query,$this);
 
 
 
 
 
 
 
317
 
318
  if ( ! $query->found_posts ) {
319
  $this->nothing_found();
@@ -342,6 +506,24 @@ class Skin_Posts_ECS extends Skin_Base {
342
  $this->render_loop_footer();
343
 
344
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
345
 
346
  }
347
 
9
  use Elementor\Scheme_Typography;
10
  use Elementor\Widget_Base;
11
  use ElementorPro\Plugin;
12
+ use ElementorPro\Modules\ThemeBuilder\Module as ThemeBuilderModule;
13
 
14
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
15
 
16
  class Skin_Posts_ECS extends Skin_Base {
17
 
18
+ // private $template_cache=[];
19
+ private $used_templates=[];
20
  private $pid;
21
  public $settings;
22
+ public $conditions;
23
+ public $grid=[];
24
+ public $grid_settings=[
25
+ 'length' => 0,
26
+ 'current' => 0,
27
+ 'allow' => false,
28
+ ];
29
 
30
 
31
 
37
  return __( 'Custom', 'ele-custom-skin' );
38
  }
39
 
40
+ private function admin_bar_menu(){
41
+ foreach($this->used_templates as $post_id){
42
+ \ECS_Admin_Bar_Menu::add_document($post_id);
43
+ }
44
+ }
45
+
46
  protected function _register_controls_actions() {
47
  parent::_register_controls_actions();
48
  add_action( 'elementor/element/posts/'.$this->get_id().'_section_design_layout/after_section_end', [ $this, 'register_navigation_design_controls' ] );
83
  'prefix_class' => 'elementor-posts--thumbnail-',
84
  ]
85
  );
86
+
87
+ $this->add_control(
88
+ 'use_custom_grid',
89
+ [
90
+ 'label' => __( 'Use custom grid?', 'ele-custom-skin' ),
91
+ 'type' => \Elementor\Controls_Manager::SWITCHER,
92
+ 'label_off' => __( 'No', 'ele-custom-skin' ),
93
+ 'label_on' => __( 'Yes', 'ele-custom-skin' ),
94
+ 'return_value' => 'yes',
95
+ 'separator' => 'before',
96
+ 'default' =>'',
97
+
98
+ ]
99
+ );
100
 
101
+ $this->add_control(
102
+ 'custom_grid',
103
+ [
104
+ 'label' => __( 'Select a default template', 'ele-custom-skin' ),
105
+ 'description' => '<div style="text-align:center;"><a target="_blank" style="text-align: center;font-style: normal;" href="' . esc_url( admin_url( '/edit.php?post_type=elementor_library&tabs_group=theme&elementor_library_type=custom_grid' ) ) .
106
+ '" class="elementor-button elementor-button-default elementor-repeater-add">' .
107
+ __( 'Create/edit a Custom Grid', 'ele-custom-skin' ) . '</a></div>',
108
+ 'type' => Controls_Manager::SELECT2,
109
+ 'label_block' => true,
110
+ 'default' => [],
111
+ 'options' => $this->get_custom_grid(),
112
+ 'condition' => [
113
+ $this->get_id().'_use_custom_grid' => 'yes'
114
+ ],
115
+ ]
116
+ );
117
+
118
  do_action( 'ECS_after_control', $this );
119
 
120
  $this->add_control(
145
  private function get_post_id(){
146
  return $this->pid;
147
  }
148
+ public function get_skin_template(){
149
  global $wpdb;
150
  $templates = $wpdb->get_results(
151
  "SELECT $wpdb->term_relationships.object_id as ID, $wpdb->posts.post_title as post_title FROM $wpdb->term_relationships
163
  }
164
  return $options;
165
  }
166
+
167
+
168
+ public function get_custom_grid(){
169
+ global $wpdb;
170
+ $templates = $wpdb->get_results(
171
+ "SELECT $wpdb->term_relationships.object_id as ID, $wpdb->posts.post_title as post_title FROM $wpdb->term_relationships
172
+ INNER JOIN $wpdb->term_taxonomy ON
173
+ $wpdb->term_relationships.term_taxonomy_id=$wpdb->term_taxonomy.term_taxonomy_id
174
+ INNER JOIN $wpdb->terms ON
175
+ $wpdb->term_taxonomy.term_id=$wpdb->terms.term_id AND $wpdb->terms.slug='custom_grid'
176
+ INNER JOIN $wpdb->posts ON
177
+ $wpdb->term_relationships.object_id=$wpdb->posts.ID
178
+ WHERE $wpdb->posts.post_status='publish'"
179
+ );
180
+ $options = [ 0 => 'Select a template' ];
181
+ foreach ( $templates as $template ) {
182
+ $options[ $template->ID ] = $template->post_title;
183
+ }
184
+ return $options;
185
+ }
186
 
187
 
188
  public function render_amp() {
189
 
190
  }
191
 
192
+ /*protected function set_template($skin){// this is for terms we don't need passid so we can actually add them in cache
193
 
194
  if (!$skin) return;
195
  if (isset($this->template_cache[$skin])) return $this->template_cache[$skin];
197
  $return = \Elementor\Plugin::instance()->frontend->get_builder_content_for_display( $skin );
198
  $this->template_cache[$skin] = $return;
199
 
200
+ }*/
201
+
202
+ protected function set_used_template($skin){// this is for terms we don't need passid so we can actually add them in cache
203
+
204
+ if (!$skin) return;
205
+ $this->used_templates[$skin]=$skin;
206
+
207
+ }
208
+
209
+ protected function set_custom_grid($grid){// this is for terms we don't need passid so we can actually add them in cache
210
+
211
+ if (!$grid) return;
212
+
213
+ $custom_grid = \Elementor\Plugin::instance()->frontend->get_builder_content_for_display( $grid );
214
+
215
+ $this->set_used_template($grid);
216
+
217
+ $this->grid = explode('{{ecs-article}}',$custom_grid);
218
+ $this->grid_settings['length'] = count($this->grid);
219
+
220
  }
221
+ public function get_grid(){
222
+ $grid="<!-- start part [".$this->grid_settings['current']."] -->";
223
+ if($this->grid_settings['current'] >= $this->grid_settings['length']-1){
224
+ $grid.=$this->grid[$this->grid_settings['current']];
225
+ $this->grid_settings['current']=0;
226
+ }
227
+ // print_r($this->grid_settings);
228
+ $grid.=$this->grid[$this->grid_settings['current']];
229
+ $grid.="<!-- end part [".$this->grid_settings['current']."] -->";
230
+ $this->grid_settings['current']++;
231
+ return $grid;
232
+ }
233
+ public function end_grid(){
234
+
235
+ if($this->grid_settings['current']) for($i = $this->grid_settings['current']; $i < $this->grid_settings['length'];$i++){
236
+ echo "<!-- start part [".$i."] finishing -->";
237
+ echo $this->grid[$i];
238
+ echo "<!-- end part [".$i."] finishing -->";
239
+ }
240
+
241
+ }
242
 
243
  protected function get_template(){
244
  global $ecs_render_loop, $wp_query,$ecs_index;
245
  $ecs_index++;
246
  $old_query=$wp_query;
247
+ //\Elementor\Plugin::$instance->documents->switch_to_document( get_the_ID() );
248
+ //\Elementor\Plugin::$instance->db->switch_to_post( get_the_ID() );
249
  $new_query=new \WP_Query( array( 'p' => get_the_ID(), 'post_type' => get_post_type() ) );
250
  $wp_query = $new_query;
251
  $settings = $this->parent->get_settings();
253
  $default_template = $this->get_instance_value( 'skin_template' ) ;
254
  $template = $default_template;
255
  /* move to pro */
256
+ //print_r(ThemeBuilderModule::instance()->get_conditions_manager()->get_documents_for_location( 'loop' ));
257
+
258
+ //print_r($this->conditions->get_template());echo "aici";print_r($template);
259
+
260
  $template = apply_filters( 'ECS_action_template', $template,$this,$ecs_index );
261
  $template = $this->get_current_ID($template);
262
 
266
 
267
  /* end pro */
268
  if (!$template) return;
269
+
270
+ $this->set_used_template($template);
271
+
272
  $return = \Elementor\Plugin::instance()->frontend->get_builder_content_for_display( $template );
273
  $ecs_render_loop=false;
274
+ //\Elementor\Plugin::$instance->documents->restore_document();
275
  $wp_query = $old_query;
276
  return $return;
277
  }
283
  }
284
 
285
  protected function render_post_header() {
286
+ $classes = 'elementor-post elementor-grid-item ecs-post-loop';
287
  $parent_settings = $this->parent->get_settings();
288
  $parent_settings[$this->get_id().'_post_slider'] = isset($parent_settings[$this->get_id().'_post_slider'])? $parent_settings[$this->get_id().'_post_slider'] : "";
289
+ if($parent_settings[$this->get_id().'_post_slider'] == "yes") $classes .= ' swiper-slide';
290
+ if ($this->grid_settings['allow']) {
291
+ echo $this->get_grid();
292
+ ?>
293
+ <div id="post-<?php the_ID(); ?>" <?php post_class( [ $classes ] ); ?>>
294
+ <?php
295
+ }
296
+ else {
297
  ?>
298
  <article id="post-<?php the_ID(); ?>" <?php post_class( [ $classes ] ); ?>>
299
  <?php
300
+ }
301
+ }
302
+
303
+ protected function render_post_footer() {
304
+ if (!$this->grid_settings['allow']){
305
+ ?>
306
+ </article>
307
+ <?php
308
+ }else {
309
+ ?></div><?php
310
+ }
311
  }
312
 
313
  protected function render_post() {
318
  if ($this->get_instance_value( 'skin_template' )){
319
  if ($this->get_instance_value( 'use_keywords' ) == "yes") {
320
  global $post;
321
+ apply_filters( 'ecs_dynamic_filter', "", $post,"",$this->parent->get_settings());//this is for pre-use of custom values
322
  $template = $this->get_template();
323
+ $new_template = apply_filters( 'ecs_dynamic_filter', $template, $post,"",$this->parent->get_settings());
324
  echo $new_template ? $new_template : $template;
325
  }
326
  else echo $this->get_template();
337
 
338
 
339
  protected function render_loop_header() {
340
+
341
  $parent_settings = $this->parent->get_settings();
342
  $parent_settings[$this->get_id().'_post_slider'] = isset($parent_settings[$this->get_id().'_post_slider'])? $parent_settings[$this->get_id().'_post_slider'] : "";
343
+
344
+ if($parent_settings[$this->get_id().'_post_slider'] == "yes") {
345
+ echo '<div class="swiper-container">';
346
+ $this->grid_settings['allow'] = false;
347
+ } else {// we don't use custom grid if slider is activated
348
+ if($parent_settings[$this->get_id().'_use_custom_grid'] == "yes" && $parent_settings[$this->get_id().'_custom_grid'] ){
349
+ $this->set_custom_grid($parent_settings[$this->get_id().'_custom_grid']);
350
+ $this->grid_settings['allow'] = true;
351
+ } else $this->grid_settings['allow'] = false;
352
+ }
353
+
354
+ $this->parent->add_render_attribute( 'container', [
355
  'class' => [
356
  'elementor-posts-container',
357
  'elementor-posts',
358
+ $parent_settings[$this->get_id().'_post_slider'] == "yes" ? 'swiper-wrapper' : "",
359
+ $this->grid_settings['allow'] ? "ecs-custom-grid" : '',
360
+ $parent_settings[$this->get_id().'_post_slider'] != "yes" && !$this->grid_settings['allow'] ? 'elementor-grid':'',
361
  $this->get_container_class(),
362
  ],
363
  ] );
364
+
365
+
366
+
367
  ?>
368
  <div <?php echo $this->parent->get_render_attribute_string( 'container' ); ?>>
369
  <?php
371
 
372
  protected function render_loop_footer() {
373
 
374
+ $this->admin_bar_menu();// let's pass the templates we used so far to tha admin-bar-menu
 
 
375
 
376
  $parent_settings = $this->parent->get_settings();
377
  $parent_settings[$this->get_id().'_post_slider'] = isset($parent_settings[$this->get_id().'_post_slider'])? $parent_settings[$this->get_id().'_post_slider'] : "";
378
+
379
+ if($this->grid_settings['allow']){
380
+ $this->end_grid();
381
+ }
382
+
383
+ ?>
384
+ </div>
385
+ <?php
386
+
387
  if($parent_settings[$this->get_id().'_post_slider'] == "yes") {
388
  $this->slider_elements();
389
  echo '</div>';
471
  $query = $this->parent->get_query();
472
 
473
  do_action("ECS_before_loop_query",$query,$this);
474
+
475
+ // start de incercat de bagat in action ECS_before_loop_query
476
+ if (class_exists('ECS_Conditions_Manager'))
477
+ if($this->get_instance_value( 'is_display_conditions' )) $this->conditions = new \ECS_Conditions_Manager();
478
+
479
+ // end de bagat
480
+
481
 
482
  if ( ! $query->found_posts ) {
483
  $this->nothing_found();
506
  $this->render_loop_footer();
507
 
508
  }
509
+
510
+ public function get_settings_for_display( $setting_key = null ) {
511
+
512
+ if ( $setting_key ) {
513
+ $settings = [
514
+ $setting_key => $this->parent->get_settings( $setting_key ),
515
+ ];
516
+ } else {
517
+ $settings = $this->parent->get_active_settings();
518
+
519
+ }
520
+ $parsed_settings = @$this->parent->parse_dynamic_settings( $settings );// @it throws that nasty Warning: Invalid argument ...
521
+ if ( $setting_key ) {
522
+ return $parsed_settings[ $setting_key ];
523
+ }
524
+
525
+ return $parsed_settings;
526
+ }
527
 
528
  }
529
 
theme-builder/documents/custom-grid.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ use ElementorPro\Modules\ThemeBuilder\Documents\Theme_Section_Document;
4
+
5
+ if ( ! defined( 'ABSPATH' ) ) {
6
+ exit; // Exit if accessed directly
7
+ }
8
+
9
+ class customGrid extends Theme_Section_Document {
10
+
11
+ public static function get_properties() {
12
+ $properties = parent::get_properties();
13
+
14
+ $properties['condition_type'] = '';
15
+ $properties['location'] = 'custom_grid';
16
+
17
+ return $properties;
18
+ }
19
+
20
+ public function get_name() {
21
+ return 'custom_grid';
22
+ }
23
+
24
+ public static function get_title() {
25
+ return __( 'Custom Grid', 'ele-custom-skin' );
26
+ }
27
+
28
+ protected static function get_editor_panel_categories() {
29
+ $categories = [
30
+ 'ele-custom-grid' => [
31
+ 'title' => __( 'Custom Grid', 'elementor-pro' ),
32
+ ],
33
+ ];
34
+ return $categories + parent::get_editor_panel_categories();
35
+
36
+ }
37
+
38
+ /*
39
+
40
+ I want a preview like the template not default
41
+
42
+ */
43
+
44
+
45
+ }
46
+
theme-builder/documents/loop.php CHANGED
@@ -12,9 +12,9 @@ class Loop extends Single {
12
  public static function get_properties() {
13
  $properties = parent::get_properties();
14
 
15
- $properties['condition_type'] = 'general';
16
- $properties['location'] = 'archive';
17
- //$properties['location'] = 'loop';
18
 
19
  return $properties;
20
  }
12
  public static function get_properties() {
13
  $properties = parent::get_properties();
14
 
15
+ $properties['condition_type'] = 'singular';
16
+ //$properties['location'] = 'archive';
17
+ $properties['location'] = 'loop';
18
 
19
  return $properties;
20
  }
theme-builder/init.php CHANGED
@@ -1,6 +1,7 @@
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();
@@ -11,6 +12,9 @@ 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' );
@@ -58,4 +62,41 @@ function elecs_register_elementor_locations( $elementor_theme_manager ) {
58
  );
59
 
60
  }
61
- //add_action( 'elementor/theme/register_locations', 'elecs_register_elementor_locations' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
 
3
  require_once ELECS_DIR.'theme-builder/documents/loop.php';
4
+ require_once ELECS_DIR.'theme-builder/documents/custom-grid.php';
5
  require_once ELECS_DIR.'theme-builder/dynamic-tags/ele-tags.php';
6
  //add new tags
7
  $newtags=new ElementorPro\Modules\DynamicTags\Eletags();
12
  use ElementorPro\Modules\ThemeBuilder\Documents\Loop;
13
  use ElementorPro\Plugin;
14
  use ElementorPro\Modules\ThemeBuilder\Documents\Theme_Document;
15
+ use Elementor\Core\Documents_Manager;
16
+ use ElementorPro\Modules\ThemeBuilder\Classes\Locations_Manager;
17
+
18
 
19
  Plugin::elementor()->documents->register_document_type( 'loop', Loop::get_class_full_name() );
20
  Source_Local::add_template_type( 'loop' );
62
  );
63
 
64
  }
65
+ add_action( 'elementor/theme/register_locations', 'elecs_register_elementor_locations' );
66
+
67
+ function elecs_enqueue_scripts($post){
68
+ $document = elecs_get_document( $post->get_post_id() );
69
+ //print_r($document->get_location());
70
+ if($document)
71
+ if('loop' == $document->get_location()){
72
+ wp_enqueue_script(
73
+ 'ecs-preview',
74
+ ELECS_URL.'assets/js/ecs_preview.js',
75
+ array( 'jquery', 'elementor-frontend' ),
76
+ ELECS_VER,
77
+ true
78
+ );
79
+ }
80
+ }
81
+ add_action( 'elementor/preview/init', 'elecs_enqueue_scripts' );
82
+
83
+ /* register custom grid document */
84
+ function elecs_register_documents_grid( Documents_Manager $documents_manager ) {
85
+ $documents_manager->register_document_type( 'custom_grid', customGrid::get_class_full_name() );
86
+ }
87
+
88
+
89
+ add_action( 'elementor/documents/register', 'elecs_register_documents_grid' );
90
+
91
+ function elecs_register_location_grid( Locations_Manager $location_manager ) {
92
+ $location_manager->register_location(
93
+ 'custom_grid',
94
+ [
95
+ 'label' => __( 'Custom Grid', 'ele-custom-skin' ),
96
+ 'multiple' => true,
97
+ 'edit_in_content' => true,
98
+ ]
99
+ );
100
+ }
101
+
102
+ add_action( 'elementor/theme/register_locations', 'elecs_register_location_grid' );