Skip to content

Commit

Permalink
v1.0.1 new widgets and controls registration
Browse files Browse the repository at this point in the history
  • Loading branch information
Micemade committed Jan 23, 2023
1 parent 9880bc2 commit 656beba
Show file tree
Hide file tree
Showing 17 changed files with 67 additions and 117 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Contributors: Micemade
Tags: elementor, elementor addon, elementor extension, elements, widgets, posts grid, woocommerce, catalog, products, product, micemade
Requires at least: 5.5
Tested up to: 6.0
Stable Tag: 1.0.0
Stable Tag: 1.0.1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -55,6 +55,8 @@ Our tests indicate that the elements work well with most themes that are well co
Time will tell. When we estimate plugin has enough added functionalities to Elementor, or some other reason, it will be available on wp.org. So far, install it from GitHub (Download zip or clone the repository) .

**Changelog**
*** v.1.0.1 ***
* Fixed deprecated elementor/widgets/widgets_registered and elementor/controls/controls_registered hooks and methods (Elementor ^ v3.5)

*** v.1.0.0 ***
* Dynamic creation of plugin CSS to wp-content/uploads dir, upon activation or breakpoints change.
Expand Down
113 changes: 59 additions & 54 deletions includes/class-micemade-elements.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,13 @@ public function init() {
add_action( 'elementor/elements/categories_registered', array( $this, 'add_widget_categories' ) );

// Register "Micemade elements" widgets.
add_action( 'elementor/widgets/widgets_registered', array( $this, 'widgets_registered' ) );
add_action( 'elementor/widgets/register', array( $this, 'register_micemade_widgets' ) ); // TODO
add_action( 'elementor/widgets/register', array( $this, 'register_micemade_widgets' ) );

// Custom Kenburns effect on Elementor Section background controls.
add_action( 'elementor/element/before_section_end', array( $this, 'kenburns_effect' ), 80, 3 );

// Register custom controls - sorting.
add_action( 'elementor/controls/controls_registered', array( $this, 'register_controls' ) );
add_action( 'elementor/controls/register', array( $this, 'register_controls' ) );

// Shared controls between various widgets/elements.
$this->shared_controls();
Expand Down Expand Up @@ -96,8 +95,61 @@ public function init() {

}

public function register_micemade_widgets( $widgets_manager ) {
/**
* Register widgets in this plugin.
*
* @param object $widgets_manager object with methods to register widgets.
*
* @return void
*/
public function register_micemade_widgets( $widgets_manager ) {
// Widgets directory plus widget prefix "class-micemade".
$prefix = MICEMADE_ELEMENTS_DIR . 'widgets/class-micemade-';

require_once $prefix . 'posts-grid.php';
require_once $prefix . 'posts-slider.php';
require_once $prefix . 'buttons.php';

// "Revolution Slider" plugin widget.
if ( MICEMADE_ELEMENTS_REVSLIDER_ON ) {
require_once $prefix . 'rev-slider.php';
$widgets_manager->register( new Elementor\Micemade_Rev_Slider() );
}

// "WooCommerce" plugin widgets.
if ( MICEMADE_ELEMENTS_WOO_ACTIVE ) {
require_once $prefix . 'wc-categories.php';
require_once $prefix . 'wc-products.php';
require_once $prefix . 'wc-products-slider.php';
require_once $prefix . 'wc-single-product.php';
require_once $prefix . 'wc-products-tabs.php';
require_once $prefix . 'wc-cat-menu.php';
$widgets_manager->register( new Elementor\Micemade_WC_Categories() );
$widgets_manager->register( new Elementor\Micemade_WC_Products() );
$widgets_manager->register( new Elementor\Micemade_WC_Products_Slider() );
$widgets_manager->register( new Elementor\Micemade_WC_Single_Product() );
$widgets_manager->register( new Elementor\Micemade_WC_Products_Tabs() );
$widgets_manager->register( new Elementor\Micemade_WC_Cat_Menu() );
}

// "Contact Form 7" plugin widget.
if ( MICEMADE_ELEMENTS_CF7_ON ) {
require_once $prefix . 'contact-form-7.php';
$widgets_manager->register( new Elementor\Micemade_CF7_Forms() );
}
// "MailChimp 4 WP" plugin widget.
if ( MICEMADE_ELEMENTS_MC4WP_ON ) {
require_once $prefix . 'mailchimp.php';
$widgets_manager->register( new Elementor\Micemade_Mailchimp() );
}

// Micemade slider.
require_once $prefix . 'slider.php';

$widgets_manager->register( new Elementor\Micemade_Buttons() );
$widgets_manager->register( new Elementor\Micemade_Posts_Grid() );
$widgets_manager->register( new Elementor\Micemade_Posts_Slider() );
$widgets_manager->register( new Elementor\Micemade_Slider() );
}

/**
Expand Down Expand Up @@ -150,9 +202,7 @@ private function elementor_activation_check() {

$micemade_elements_is_active = false;

// if ( defined( 'ELEMENTOR_PATH' ) && class_exists( 'Elementor\Widget_Base' ) ) {
if ( in_array( 'elementor/elementor.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ), true ) ) {

$micemade_elements_is_active = true;
$this->define( 'ELEMENTOR_IS_ACTIVE', true );
} else {
Expand Down Expand Up @@ -211,51 +261,6 @@ public function register_controls_group( $controls_manager ) {
$controls_manager->add_group_control( 'mmposts', new Group_Control_Posts() );
}

/**
* Register widgets (elements) for Elementor
*
* @return void
*/
public function widgets_registered() {

// Widgets directory plus widget prefix "class-micemade".
$prefix = MICEMADE_ELEMENTS_DIR . 'widgets/class-micemade-';

require_once $prefix . 'posts-grid.php';
require_once $prefix . 'posts-slider.php';
require_once $prefix . 'buttons.php';

// "Revolution Slider" plugin widget.
if ( MICEMADE_ELEMENTS_REVSLIDER_ON ) {
require_once $prefix . 'rev-slider.php';
}
// "WooCommerce" plugin widgets.
if ( MICEMADE_ELEMENTS_WOO_ACTIVE ) {
require_once $prefix . 'wc-categories.php';
require_once $prefix . 'wc-products.php';
require_once $prefix . 'wc-products-slider.php';
require_once $prefix . 'wc-single-product.php';
require_once $prefix . 'wc-products-tabs.php';
require_once $prefix . 'wc-cat-menu.php';
}

// "Contact Form 7" plugin widget.
if ( MICEMADE_ELEMENTS_CF7_ON ) {
require_once $prefix . 'contact-form-7.php';
}
// "MailChimp 4 WP" plugin widget.
if ( MICEMADE_ELEMENTS_MC4WP_ON ) {
require_once $prefix . 'mailchimp.php';
}

// Micemade slider.
require_once $prefix . 'slider.php';

// Micemade header widgets - for v.1.0.0
// require_once $prefix . 'header-logo.php';
// require_once $prefix . 'nav.php';
}

/**
* Kenburns effect
*
Expand Down Expand Up @@ -343,13 +348,13 @@ public function kenburns_effect( $element, $section_id, $args ) {
*
* @return void
*/
public function register_controls() {
public function register_controls( $controls_manager ) {

// Custom control for soriting.
require MICEMADE_ELEMENTS_INCLUDES . 'class-micemade-control-sorting.php';

$controls_manager = \Elementor\Plugin::$instance->controls_manager;
$controls_manager->register_control( 'sorter_label', new Micemade_Control_Sorter() );
// $controls_manager = \Elementor\Plugin::$instance->controls_manager;
$controls_manager->register( new Micemade_Control_Sorter() );

}

Expand Down
4 changes: 3 additions & 1 deletion includes/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ function micemade_elements_grid( $columns = array() ) {
// Element settings for columns number.
foreach ( $columns as $device => $num_columns ) { // or: 'columns_tablet' => '3'.
if ( $device && strpos( $device, $bp_name ) ) {
$selectors .= $sel_array_for_bp[ $num_columns ] . ' ';
if ( isset( $sel_array_for_bp[ $num_columns ] ) ) {
$selectors .= $sel_array_for_bp[ $num_columns ] . ' ';
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions micemade-elements.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Micemade Elements
* Description: Extension plugin with custom elements for Elementor, created by Micemade. Elementor plugin required.
* Plugin URI: https://github.com/Micemade/micemade-elements/
* Version: 1.0.0
* Version: 1.0.1
* Author: micemade
* Author URI: http://micemade.com
* Text Domain: micemade-elements
Expand All @@ -20,7 +20,7 @@

// Plugin version constant.
if ( ! defined( 'MICEMADE_ELEMENTS_VERSION' ) ) {
define( 'MICEMADE_ELEMENTS_VERSION', '1.0.0' );
define( 'MICEMADE_ELEMENTS_VERSION', '1.0.1' );
}

// Define MICEMADE_ELEMENTS_PLUGIN_FILE.
Expand Down
2 changes: 0 additions & 2 deletions widgets/class-micemade-buttons.php
Original file line number Diff line number Diff line change
Expand Up @@ -629,5 +629,3 @@ public function on_import( $element ) {
}

}

Plugin::instance()->widgets_manager->register_widget_type( new Micemade_Buttons() );
2 changes: 0 additions & 2 deletions widgets/class-micemade-contact-form-7.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,3 @@ protected function render() {

}
}

Plugin::instance()->widgets_manager->register_widget_type( new Micemade_CF7_Forms() );
2 changes: 0 additions & 2 deletions widgets/class-micemade-mailchimp.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,5 +185,3 @@ protected function render() {

}
}

Plugin::instance()->widgets_manager->register_widget_type( new Micemade_Mailchimp() );
2 changes: 0 additions & 2 deletions widgets/class-micemade-posts-grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -1397,5 +1397,3 @@ protected function content_template() {}
public function render_plain_content( $instance = array() ) {}

}

Plugin::instance()->widgets_manager->register_widget_type( new Micemade_Posts_Grid() );
2 changes: 0 additions & 2 deletions widgets/class-micemade-posts-slider.php
Original file line number Diff line number Diff line change
Expand Up @@ -1203,5 +1203,3 @@ protected function content_template() {}
public function render_plain_content( $instance = [] ) {}

}

Plugin::instance()->widgets_manager->register_widget_type( new Micemade_Posts_Slider() );
2 changes: 0 additions & 2 deletions widgets/class-micemade-rev-slider.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,3 @@ protected function content_template() {}
public function render_plain_content( $instance = [] ) {}

}

Plugin::instance()->widgets_manager->register_widget_type( new Micemade_Rev_Slider() );
11 changes: 0 additions & 11 deletions widgets/class-micemade-slider.php
Original file line number Diff line number Diff line change
Expand Up @@ -1282,15 +1282,4 @@ protected function render() {

<?php
}

/**
* Render slides widget output in the editor.
*
* Written as a Backbone JavaScript template and used to generate the live preview.
*
* @access protected
*/
// protected function content_template() {}
}

Plugin::instance()->widgets_manager->register_widget_type( new Micemade_Slider() );
7 changes: 0 additions & 7 deletions widgets/class-micemade-wc-cat-menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -911,11 +911,4 @@ protected function render() {
</ul>
<?php
}

// protected function content_template() {}

// public function render_plain_content( $instance = [] ) {}

}

Plugin::instance()->widgets_manager->register_widget_type( new Micemade_WC_Cat_Menu() );
2 changes: 0 additions & 2 deletions widgets/class-micemade-wc-categories.php
Original file line number Diff line number Diff line change
Expand Up @@ -1412,5 +1412,3 @@ public function array_flatten( $arr, $out = array() ) {
}

}

Plugin::instance()->widgets_manager->register_widget_type( new Micemade_WC_Categories() );
8 changes: 0 additions & 8 deletions widgets/class-micemade-wc-products-slider.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
*/
class Micemade_WC_Products_Slider extends \Elementor\Widget_Base {



public function __construct( $data = array(), $args = null ) {
parent::__construct( $data, $args );

Expand Down Expand Up @@ -1333,10 +1331,4 @@ function ( $classes ) {

}

// protected function content_template() {}

// public function render_plain_content( $instance = [] ) {}

}

Plugin::instance()->widgets_manager->register_widget_type( new Micemade_WC_Products_Slider() );
10 changes: 0 additions & 10 deletions widgets/class-micemade-wc-products-tabs.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@

class Micemade_WC_Products_Tabs extends \Elementor\Widget_Base {


/*
public function __construct( $data = [], $args = null ) {
parent::__construct( $data, $args );
$this->add_actions();
}
*/

public function get_name() {
return 'micemade-wc-products-tabs';
}
Expand Down Expand Up @@ -821,5 +813,3 @@ function ( $classes ) {
*/
// protected function content_template() {}
}

Plugin::instance()->widgets_manager->register_widget_type( new Micemade_WC_Products_Tabs() );
2 changes: 0 additions & 2 deletions widgets/class-micemade-wc-products.php
Original file line number Diff line number Diff line change
Expand Up @@ -1255,5 +1255,3 @@ protected function content_template() {}
public function render_plain_content( $instance = array() ) {}

}

Plugin::instance()->widgets_manager->register_widget_type( new Micemade_WC_Products() );
7 changes: 0 additions & 7 deletions widgets/class-micemade-wc-single-product.php
Original file line number Diff line number Diff line change
Expand Up @@ -684,11 +684,4 @@ protected function render() {
wp_reset_postdata();

}

// protected function content_template() {}

// public function render_plain_content( $instance = [] ) {}

}

Plugin::instance()->widgets_manager->register_widget_type( new Micemade_WC_Single_Product() );

0 comments on commit 656beba

Please sign in to comment.