PluginProbe ʕ •ᴥ•ʔ
Hustle – Email Marketing, Lead Generation, Optins, Popups / 7.8.9
Hustle – Email Marketing, Lead Generation, Optins, Popups v7.8.9
7.8.14 7.8.14.1 7.8.13 7.8.13.1 trunk 3.0 3.1 3.1.1 3.1.2 3.1.3 3.1.4 4.3.2 4.4.4 4.4.5 4.4.5.1 4.4.5.4 4.6 4.6.1.1 4.6.1.4 4.7.0.2 4.7.0.3 4.7.0.7 4.7.0.9 4.7.1.0 4.7.1.1 4.8.0.0 5.0.0 5.0.1 5.0.1.1 5.0.1.2 5.1 5.1.1 5.1.2 5.1.3 5.1.3.1 5.1.3.2 5.1.4 5.1.5 6.0 6.0.1 6.0.2 6.0.3 6.0.4.2 6.0.5 6.0.6.1 6.0.7 6.0.8.1 6.0.9 7.0.0.1 7.0.2 7.0.3 7.0.4 7.1.0 7.1.1 7.2.0 7.2.1 7.3.0 7.3.1 7.3.3 7.3.5 7.3.6 7.3.7 7.4.0 7.4.1 7.4.11 7.4.13 7.4.13.1 7.4.2 7.4.3 7.4.4 7.4.5 7.4.5.1 7.4.5.2 7.4.6 7.4.7 7.5.0 7.6.0 7.6.1 7.6.3 7.6.4 7.6.6 7.7.0 7.7.1 7.8.0 7.8.1 7.8.10 7.8.10.1 7.8.10.2 7.8.11 7.8.12 7.8.12.1 7.8.2 7.8.3 7.8.4 7.8.5 7.8.6 7.8.7 7.8.8 7.8.9 7.8.9.1 7.8.9.2 7.8.9.3
wordpress-popup / inc / providers / gutenberg / blocks / block-unsubscribe.php
wordpress-popup / inc / providers / gutenberg / blocks Last commit date
block-embeds.php 3 years ago block-popup-trigger.php 3 years ago block-slidein-trigger.php 3 years ago block-social-share.php 3 years ago block-unsubscribe.php 3 years ago
block-unsubscribe.php
144 lines
1 <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
2 /**
3 * Hustle_GHBlock_Unsubscribe class
4 *
5 * @package Hustle
6 */
7
8 /**
9 * Class Hustle_GHBlock_Unsubscribe
10 *
11 * @since 4.5 Gutenberg Addon
12 */
13 class Hustle_GHBlock_Unsubscribe extends Hustle_GHBlock_Abstract {
14
15 /**
16 * Block identifier
17 *
18 * @var string
19 */
20 protected $slug = 'unsubscribe';
21
22 /**
23 * Constructor.
24 */
25 public function __construct() {
26 // Initialize block.
27 $this->init();
28 }
29
30 /**
31 * Render block markup on front-end
32 *
33 * @param array $properties Block properties.
34 * @return string
35 */
36 public function render_block( $properties = array() ) {
37 $ids = isset( $properties['id'] ) && is_array( $properties['id'] ) ? implode( ', ', $properties['id'] ) : '';
38
39 $skip = ! empty( $properties['skipConfirmation'] ) ? ' skip_confirmation="true"' : '';
40
41 return '[wd_hustle_unsubscribe id="' . esc_attr( $ids ) . '"' . $skip . ' /]';
42 }
43
44 /**
45 * Enqueue assets ( scritps / styles )
46 * Should be overriden in block class
47 */
48 public function load_assets() {
49 // Scripts.
50 wp_enqueue_script(
51 'hustle-block-unsubscribe',
52 Hustle_Gutenberg::get_plugin_url() . '/js/unsubscribe-block.min.js',
53 array( 'wp-blocks', 'wp-i18n', 'wp-element' ),
54 filemtime( Hustle_Gutenberg::get_plugin_dir() . 'js/unsubscribe-block.min.js' ),
55 true
56 );
57
58 // Localize scripts.
59 wp_localize_script(
60 'hustle-block-unsubscribe',
61 'hustle_unsubscribe_data',
62 array(
63 'popups' => $this->get_popups(),
64 'slideins' => $this->get_slideins(),
65 'embeds' => $this->get_embeds(),
66 'settings_url' => add_query_arg(
67 array(
68 'page' => 'hustle_settings',
69 'section' => 'unsubscribe',
70 ),
71 admin_url( 'admin.php' )
72 ),
73 'nonce' => wp_create_nonce( 'hustle_gutenberg_get_unsubscribe_form' ),
74 'shortcode_tag' => 'wd_hustle_unsubscribe',
75 'l10n' => $this->localize(),
76 )
77 );
78
79 wp_enqueue_style(
80 'hustle-block-unsubscribe',
81 Hustle_Gutenberg::get_plugin_url() . '/css/unsubscribe-block.css',
82 array(),
83 filemtime( Hustle_Gutenberg::get_plugin_dir() . 'css/unsubscribe-block.css' )
84 );
85
86 }
87
88 /**
89 * Get popups
90 *
91 * @return array
92 */
93 public function get_popups() {
94 $module_list = $this->get_modules_by_type( 'popup' );
95 unset( $module_list[0] );
96 return $module_list;
97 }
98
99 /**
100 * Get slide-ins
101 *
102 * @return array
103 */
104 public function get_slideins() {
105 $module_list = $this->get_modules_by_type( 'slidein' );
106 unset( $module_list[0] );
107 return $module_list;
108 }
109
110 /**
111 * Get Embeds
112 *
113 * @return array
114 */
115 public function get_embeds() {
116 $module_list = $this->get_modules_by_type( 'embedded' );
117 unset( $module_list[0] );
118 return $module_list;
119 }
120
121 /**
122 * Get texts
123 *
124 * @return array
125 */
126 private function localize() {
127 return array(
128 'popups' => esc_html__( 'Pop-ups', 'hustle' ),
129 'slideins' => esc_html__( 'Slide-ins', 'hustle' ),
130 'embeds' => esc_html__( 'Embeds', 'hustle' ),
131 'modules' => esc_html__( 'Modules', 'hustle' ),
132 'customize_settings' => esc_html__( 'Customize Settings', 'hustle' ),
133 'rendering' => esc_html__( 'Rendering...', 'hustle' ),
134 'block_name' => esc_html__( 'Unsubscribe', 'hustle' ),
135 /* translators: Plugin name */
136 'block_description' => esc_html( sprintf( __( 'Display %s Unsubscribe form.', 'hustle' ), Opt_In_Utils::get_plugin_name() ) ),
137 'skip_confirmation' => esc_html__( 'Skip confirmation step', 'hustle' ),
138 'block_instruction' => esc_html__( 'By default, the Unsubscribe form allows users to unsubscribe from all modules, but you can specify the modules you want to enable the unsubscribe option for.', 'hustle' ),
139 );
140 }
141 }
142
143 new Hustle_GHBlock_Unsubscribe();
144