Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial work to add Elementor widget versions of our core page shortcodes #3075

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 52 additions & 6 deletions includes/compatibility/elementor/class-pmpro-elementor.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,20 @@ class PMPro_Elementor {
* Register new section for PMPro Required Membership Levels.
*/
public function __construct() {

require_once( __DIR__ . '/class-pmpro-elementor-content-restriction.php' );
// Register new section to display restriction controls
$this->register_sections();

$this->content_restriction();
}
require_once( __DIR__ . '/class-pmpro-elementor-content-restriction.php' );

// Register our custom widgets.
add_action( 'elementor/widgets/widgets_registered', array( $this, 'init' ) );

// Create a new category for our widgets.
add_action( 'elementor/elements/categories_registered', array( $this, 'add_widget_categories' ) );

// Register new section to display restriction controls
$this->register_sections();
$this->content_restriction();

}

/**
*
Expand All @@ -51,6 +58,45 @@ public static function instance() {
return self::$_instance;
}

/**
* Initialize the widgets.
*/
public function init() {
require_once __DIR__ . '/widgets/class-pmpro-elementor-widget-base.php';
require_once __DIR__ . '/widgets/class-pmpro-elementor-widget-account.php';
require_once __DIR__ . '/widgets/class-pmpro-elementor-widget-billing.php';
require_once __DIR__ . '/widgets/class-pmpro-elementor-widget-cancel.php';
require_once __DIR__ . '/widgets/class-pmpro-elementor-widget-checkout.php';
require_once __DIR__ . '/widgets/class-pmpro-elementor-widget-confirmation.php';
require_once __DIR__ . '/widgets/class-pmpro-elementor-widget-order.php';
require_once __DIR__ . '/widgets/class-pmpro-elementor-widget-levels.php';
require_once __DIR__ . '/widgets/class-pmpro-elementor-widget-login.php';
require_once __DIR__ . '/widgets/class-pmpro-elementor-widget-member-profile-edit.php';

\Elementor\Plugin::instance()->widgets_manager->register( new PMPro_Elementor_Widget_Account() );
\Elementor\Plugin::instance()->widgets_manager->register( new PMPro_Elementor_Widget_Billing() );
\Elementor\Plugin::instance()->widgets_manager->register( new PMPro_Elementor_Widget_Cancel() );
\Elementor\Plugin::instance()->widgets_manager->register( new PMPro_Elementor_Widget_Checkout() );
\Elementor\Plugin::instance()->widgets_manager->register( new PMPro_Elementor_Widget_Confirmation() );
\Elementor\Plugin::instance()->widgets_manager->register( new PMPro_Elementor_Widget_Order() );
\Elementor\Plugin::instance()->widgets_manager->register( new PMPro_Elementor_Widget_Levels() );
\Elementor\Plugin::instance()->widgets_manager->register( new PMPro_Elementor_Widget_Login() );
\Elementor\Plugin::instance()->widgets_manager->register( new PMPro_Elementor_Widget_Member_Profile_Edit() );
}

/**
* Add a new category for our widgets.
*/
public function add_widget_categories( $elements_manager ) {
$elements_manager->add_category(
'paid-memberships-pro',
[
'title' => __( 'Paid Memberships Pro', 'paid-memberships-pro' ),
'icon' => 'dashicons-before admin-users',
]
);
}

private function register_sections() {
foreach( $this->locations as $where ) {
add_action( 'elementor/element/'.$where['element'].'/'.$where['action'].'/after_section_end', array( $this, 'add_section' ), 10, 2 );
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

class PMPro_Elementor_Widget_Account extends PMPro_Elementor_Widget_Base {

public function get_name() {
return 'pmpro_account_widget';
}

public function get_title() {
return __( 'PMPro Page: Account (Full)', 'paid-memberships-pro' );
}

protected function _register_controls() {
$this->start_controls_section(
'content_section',
array(
'label' => __( 'PMPro Page: Account (Full)', 'paid-memberships-pro' ),
'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
)
);

$this->add_control(
'description',
array(
'label' => esc_html__( 'Displays all sections of the Membership Account page including Memberships, Profile, Orders, and Member Links. These sections can also be added via separate widgets.', 'paid-memberships-pro' ),
'type' => \Elementor\Controls_Manager::HEADING,
'separator' => 'before',
)
);

$this->add_footer_promo_control();

$this->end_controls_section();
}

protected function render() {
$settings = $this->get_settings_for_display();

echo do_shortcode( '[pmpro_account]' );
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

abstract class PMPro_Elementor_Widget_Base extends \Elementor\Widget_Base {

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

public function get_icon() {
return 'dashicons-before dashicons-admin-users';
}

public function get_categories() {
return array( 'paid-memberships-pro' );
}

protected function add_footer_promo_control() {

$this->add_control(
'pmpro_footer_promo',
array(
'label' => '',
'type' => \Elementor\Controls_Manager::RAW_HTML,
'raw' => '<hr><p style="margin-top: 20px;">' . sprintf( esc_html__( 'Learn more about %1$sediting your PMPro-powered membership site with Elementor%2$s', 'paid-memberships-pro' ), '<a target="_blank" href="#">', '</a>' ) . '</p>',
'content_classes' => 'pmpro-footer-promo',
)
);
}

protected function render() {
$settings = $this->get_settings_for_display();

echo 'hi';
}

protected function _content_template() {
// Define your template variables here
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

class PMPro_Elementor_Widget_Billing extends PMPro_Elementor_Widget_Base {

public function get_name() {
return 'pmpro_billing_widget';
}

public function get_title() {
return __( 'PMPro Page: Billing', 'paid-memberships-pro' );
}

protected function _register_controls() {
$this->start_controls_section(
'content_section',
array(
'label' => __( 'PMPro Page: Billing', 'paid-memberships-pro' ),
'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
)
);

$this->add_control(
'description',
array(
'label' => esc_html__( 'Dynamic page section to display the member billing information. Members can update their subscription payment method from this form.', 'paid-memberships-pro' ),
'type' => \Elementor\Controls_Manager::HEADING,
'separator' => 'before',
)
);

$this->add_footer_promo_control();

$this->end_controls_section();
}

protected function render() {
$settings = $this->get_settings_for_display();

echo do_shortcode( '[pmpro_billing]' );
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

class PMPro_Elementor_Widget_Cancel extends PMPro_Elementor_Widget_Base {

public function get_name() {
return 'pmpro_cancel_widget';
}

public function get_title() {
return __( 'PMPro Page: Cancel', 'paid-memberships-pro' );
}

protected function _register_controls() {
$this->start_controls_section(
'content_section',
array(
'label' => __( 'PMPro Page: Cancel', 'paid-memberships-pro' ),
'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
)
);

$this->add_control(
'description',
array(
'label' => esc_html__( 'Dynamic page section where members can cancel their membership and active subscription if applicable.', 'paid-memberships-pro' ),
'type' => \Elementor\Controls_Manager::HEADING,
'separator' => 'before',
)
);

$this->add_footer_promo_control();

$this->end_controls_section();
}

protected function render() {
$settings = $this->get_settings_for_display();

echo do_shortcode( '[pmpro_cancel]' );
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

class PMPro_Elementor_Widget_Checkout extends PMPro_Elementor_Widget_Base {

public function get_name() {
return 'pmpro_checkout_widget';
}

public function get_title() {
return __( 'Membership Checkout Form', 'paid-memberships-pro' );
}

protected function _register_controls() {
$this->start_controls_section(
'content_section',
array(
'label' => __( 'Membership Checkout Form', 'paid-memberships-pro' ),
'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
)
);

$this->add_control(
'description',
array(
'label' => esc_html__( 'Dynamic form that allows users to complete free registration or paid checkout for the selected membership level.', 'paid-memberships-pro' ),
'type' => \Elementor\Controls_Manager::HEADING,
'separator' => 'before',
)
);

$this->add_footer_promo_control();

$this->end_controls_section();
}

protected function render() {
$settings = $this->get_settings_for_display();

echo do_shortcode( '[pmpro_checkout]' );
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

class PMPro_Elementor_Widget_Confirmation extends PMPro_Elementor_Widget_Base {

public function get_name() {
return 'pmpro_confirmation_widget';
}

public function get_title() {
return __( 'PMPro Page: Confirmation', 'paid-memberships-pro' );
}

protected function _register_controls() {
$this->start_controls_section(
'content_section',
array(
'label' => __( 'PMPro Page: Confirmation', 'paid-memberships-pro' ),
'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
)
);

$this->add_control(
'description',
array(
'label' => esc_html__( 'Dynamic page section that displays a confirmation message and purchase information for the active member immediately after membership registration and checkout.', 'paid-memberships-pro' ),
'type' => \Elementor\Controls_Manager::HEADING,
'separator' => 'before',
)
);

$this->add_footer_promo_control();

$this->end_controls_section();
}

protected function render() {
$settings = $this->get_settings_for_display();

echo do_shortcode( '[pmpro_confirmation]' );
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

class PMPro_Elementor_Widget_Levels extends PMPro_Elementor_Widget_Base {

public function get_name() {
return 'pmpro_levels_widget';
}

public function get_title() {
return __( 'Membership Levels and Pricing Table', 'paid-memberships-pro' );
}

protected function _register_controls() {
$this->start_controls_section(
'content_section',
array(
'label' => __( 'Membership Levels and Pricing Table', 'paid-memberships-pro' ),
'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
)
);

$this->add_control(
'description',
array(
'label' => esc_html__( 'Dynamic page section that displays a list of membership levels and pricing, linked to membership checkout. To reorder the display, navigate to Memberships > Settings > Levels.', 'paid-memberships-pro' ),
'type' => \Elementor\Controls_Manager::HEADING,
'separator' => 'before',
)
);

$this->add_footer_promo_control();

$this->end_controls_section();
}

protected function render() {
$settings = $this->get_settings_for_display();

echo do_shortcode( '[pmpro_levels]' );
}
}
Loading