PluginProbe
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell / 3.13.3
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell v3.13.3
3.13.3 3.13.2 3.13.1 3.13.0 3.12.13 3.12.12 3.12.11 3.12.10 3.12.9 3.12.8 3.12.7 3.12.6 3.12.5 3.12.4 3.12.3 3.12.1 3.12.2 3.12.0 3.11.1 3.11.0 3.10.9 3.10.8 3.10.7 3.10.6 2.8.16 All 261 releases
← All changes | includes/core/widgets/class-manager.php +83 -8 2.8.16 → 3.13.3 View file →
@@ -8,8 +8,9 @@
8 8
9 9 use WPFunnels\Base_Manager;
10 10 use WPFunnels\Traits\SingletonTrait;
11 11 use WPFunnels\Widgets\Gutenberg\BlockTypes\Gutenberg_Editor;
12 +use WPFunnels\Wpfnl;
12 13 use WPFunnels\Wpfnl_functions;
13 14
14 15 class Wpfnl_Widgets_Manager extends Base_Manager
15 16 {
@@ -17,13 +18,18 @@
17 18 use SingletonTrait;
18 19
19 20 private $widgets = [];
20 21
22 + /**
23 + * Initializes modules based on available builders.
24 + *
25 + * @since Unknown
26 + */
21 27 public function init()
22 28 {
23 29 $modules_namespace_prefix = $this->get_namespace_prefix();
24 30 $builders = $this->get_builders();
25 -
31 +
26 32 foreach ($builders as $builder) {
27 33 $class_name = str_replace('-', ' ', $builder);
28 34 $class_name = str_replace(' ', '', ucwords($class_name));
29 35 $class_name = $modules_namespace_prefix . '\\Widgets\\' . $class_name . '\Manager';
@@ -28,21 +34,90 @@
28 34 $class_name = str_replace(' ', '', ucwords($class_name));
29 35 $class_name = $modules_namespace_prefix . '\\Widgets\\' . $class_name . '\Manager';
30 36 $this->widgets[$builder] = $class_name::instance();
31 37 }
38 +
32 39 }
33 40
34 -
41 + /**
42 + * Retrieves a list of builders available within WordPress, including Oxygen if enabled.
43 + *
44 + * @return array An array containing the list of available builders.
45 + * @since Unknown
46 + */
35 47 public function get_builders()
36 48 {
37 - $builder = array(
38 - 'elementor',
39 - 'gutenberg',
40 - 'diviModules',
41 - );
49 + $selected_builder = Wpfnl_functions::get_builder_type();
50 + $builder = array();
51 +
42 52 $oxygen_capability = Wpfnl_functions::oxygen_builder_version_capability();
43 - if ($oxygen_capability){
53 +
54 + if ('oxygen' === $selected_builder && $oxygen_capability){
44 55 array_push($builder,'oxygen');
56 + }elseif ('divi-builder' === $selected_builder ){
57 + if ( Wpfnl_functions::is_divi5_active() ) {
58 + array_push($builder,'diviModulesV5');
59 + } else {
60 + array_push($builder,'diviModules');
61 + }
62 + }elseif ('elementor' === $selected_builder ){
63 + array_push($builder,'elementor');
64 + }elseif ( 'bricks' === $selected_builder && 'bricks' === wp_get_theme()->template ){
65 + array_push($builder,'bricks');
66 + }elseif ('gutenberg' === $selected_builder ){
67 + array_push($builder,'gutenberg');
45 68 }
69 +
46 70 return apply_filters('wpfunnels/builders',$builder);
71 + }
72 +
73 + /**
74 + * Retrieves MailMint forms' IDs and titles.
75 + *
76 + * @return array An array containing MailMint forms' IDs and titles.
77 + * @since 2.8.15
78 + */
79 + public static function get_mailmint_forms() {
80 + $mailmint_forms = method_exists( 'Mint\MRM\DataBase\Models\FormModel', 'get_all_id_title' ) ? \Mint\MRM\DataBase\Models\FormModel::get_all_id_title() : [];
81 +
82 + if ( is_array( $mailmint_forms ) && !empty( $mailmint_forms[ 'data' ] ) ) {
83 + foreach( $mailmint_forms[ 'data' ] as $form ) {
84 + if ( !empty( $form[ 'id' ] ) && !empty( $form[ 'title' ] ) ) {
85 + $forms[ $form[ 'id' ] ] = $form[ 'title' ];
86 + }
87 + }
88 + }
89 + return $forms ?? [];
90 + }
91 +
92 + /**
93 + * Renders a Mail Mint form based on the provided form ID.
94 + *
95 + * This protected function checks for the existence of the \Mint\MRM\Internal\ShortCode\ContactForm class and utilizes it to render the content of a Mail Mint form specified by the provided form ID.
96 + *
97 + * @param string|int $form_id Represents the unique identifier of the Mail Mint form to be rendered.
98 + * @param array $options Represents widget settings.
99 + *
100 + * @return void Outputs the rendered content of the Mail Mint form or an empty string if rendering fails.
101 + * @since 2.8.15
102 + */
103 + public static function render_mailmint_form( $form_id, $options = [] ) {
104 + if ( class_exists( '\Mint\MRM\Internal\ShortCode\ContactForm' ) ) {
105 + $mailmint_contact_form = new \Mint\MRM\Internal\ShortCode\ContactForm( [] );
106 + ob_start();
107 + echo method_exists( $mailmint_contact_form, 'render_content' ) ? $mailmint_contact_form->render_content( $form_id ) : '';
108 + $mailmint_form = ob_get_clean();
109 + $replace = 'id="mrm-form">';
110 + $replace .= '<input type="hidden" name="step_id" value="'.get_the_ID().'"/>';
111 +
112 + $replace .= !empty( $options[ 'admin_email' ] ) ? '<input type="hidden" name="admin_email" value="'.$options[ 'admin_email' ].'"/>' : '';
113 + $replace .= !empty( $options[ 'admin_email_subject' ] ) ? '<input type="hidden" name="admin_email_subject" value="'.$options[ 'admin_email_subject' ].'"/>' : '';
114 + $replace .= !empty( $options[ 'notification_text' ] ) ? '<input type="hidden" name="notification_text" value="'.$options[ 'notification_text' ].'"/>' : '';
115 + $replace .= !empty( $options[ 'other_action' ] ) ? '<input type="hidden" name="post_action" value="'.$options[ 'other_action' ].'"/>' : '';
116 + $replace .= !empty( $options[ 'redirect_url' ] ) ? '<input type="hidden" name="redirect_url" value="'.$options[ 'redirect_url' ].'"/>' : '';
117 + $replace .= !empty( $options[ 'data_to_checkout' ] ) && 'on' === $options[ 'data_to_checkout' ] ? '<input type="hidden" name="data_to_checkout" value="yes"/>' : '';
118 + $replace .= !empty( $options[ 'register_as_subscriber' ] ) && 'on' === $options[ 'register_as_subscriber' ] ? '<input type="hidden" name="optin_allow_registration" value="yes"/>' : '';
119 +
120 + echo str_replace( 'id="mrm-form">', $replace, $mailmint_form );
121 + }
47 122 }
48 123 }