PluginProbe ʕ •ᴥ•ʔ
Hustle – Email Marketing, Lead Generation, Optins, Popups / trunk
Hustle – Email Marketing, Lead Generation, Optins, Popups vtrunk
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 7 months ago block-unsubscribe.php 7 months ago
block-unsubscribe.php
143 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 * Get popups
89 *
90 * @return array
91 */
92 public function get_popups() {
93 $module_list = $this->get_modules_by_type( 'popup' );
94 unset( $module_list[0] );
95 return $module_list;
96 }
97
98 /**
99 * Get slide-ins
100 *
101 * @return array
102 */
103 public function get_slideins() {
104 $module_list = $this->get_modules_by_type( 'slidein' );
105 unset( $module_list[0] );
106 return $module_list;
107 }
108
109 /**
110 * Get Embeds
111 *
112 * @return array
113 */
114 public function get_embeds() {
115 $module_list = $this->get_modules_by_type( 'embedded' );
116 unset( $module_list[0] );
117 return $module_list;
118 }
119
120 /**
121 * Get texts
122 *
123 * @return array
124 */
125 private function localize() {
126 return array(
127 'popups' => esc_html__( 'Pop-ups', 'hustle' ),
128 'slideins' => esc_html__( 'Slide-ins', 'hustle' ),
129 'embeds' => esc_html__( 'Embeds', 'hustle' ),
130 'modules' => esc_html__( 'Modules', 'hustle' ),
131 'customize_settings' => esc_html__( 'Customize Settings', 'hustle' ),
132 'rendering' => esc_html__( 'Rendering...', 'hustle' ),
133 'block_name' => esc_html__( 'Unsubscribe', 'hustle' ),
134 /* translators: Plugin name */
135 'block_description' => esc_html( sprintf( __( 'Display %s Unsubscribe form.', 'hustle' ), Opt_In_Utils::get_plugin_name() ) ),
136 'skip_confirmation' => esc_html__( 'Skip confirmation step', 'hustle' ),
137 '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' ),
138 );
139 }
140 }
141
142 new Hustle_GHBlock_Unsubscribe();
143