PluginProbe ʕ •ᴥ•ʔ
Hustle – Email Marketing, Lead Generation, Optins, Popups / 7.3.7
Hustle – Email Marketing, Lead Generation, Optins, Popups v7.3.7
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 / front / class-hustle-module-preview.php
wordpress-popup / inc / front Last commit date
non-sshare-styles 5 years ago class-hustle-decorator-non-sshare.php 5 years ago class-hustle-decorator-sshare.php 5 years ago class-hustle-decorator_abstract.php 5 years ago class-hustle-module-preview.php 5 years ago hustle-module-front-ajax.php 5 years ago hustle-module-front.php 5 years ago hustle-module-renderer.php 5 years ago hustle-renderer-abstract.php 5 years ago hustle-renderer-sshare.php 5 years ago
class-hustle-module-preview.php
148 lines
1 <?php
2 /**
3 * Module's preview page handler.
4 *
5 * @package Hustle
6 * @since 4.3.1
7 */
8
9 /**
10 * Hustle_Module_Preview class.
11 *
12 * @since 4.3.1
13 */
14 class Hustle_Module_Preview {
15
16 /**
17 * Hustle_Module_Preview constructor.
18 *
19 * @since 4.3.1
20 */
21 public function __construct() {
22 add_action( 'wp_enqueue_scripts', array( $this, 'register_preview_scripts' ) );
23
24 add_action( 'wp_footer', array( $this, 'wp_footer' ) );
25
26 add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ) );
27
28 add_filter( 'the_title', array( $this, 'the_title' ) );
29
30 add_filter( 'the_content', array( $this, 'show_after_page_post_content' ) );
31
32 // With a priority of 20 to override possible WC's filter.
33 add_filter( 'show_admin_bar', '__return_false', 20 );
34 }
35
36 /**
37 * Registers the script used in the preview iframe.
38 *
39 * @since 4.3.1
40 */
41 public function register_preview_scripts() {
42 Hustle_Module_Front::add_hui_scripts();
43
44 $file_suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? 'debug' : 'min';
45 wp_register_script(
46 'hustle_preview_script',
47 Opt_In::$plugin_url . 'assets/js/preview.' . $file_suffix . '.js',
48 array( 'jquery' ),
49 Opt_In::VERSION,
50 true
51 );
52
53 $vars = array(
54 'ajaxurl' => admin_url( 'admin-ajax.php', is_ssl() ? 'https' : 'http' ),
55 'days_and_months' => array(
56 'days_full' => Hustle_Time_Helper::get_week_days(),
57 'days_short' => Hustle_Time_Helper::get_week_days( 'short' ),
58 'days_min' => Hustle_Time_Helper::get_week_days( 'min' ),
59 'months_full' => Hustle_Time_Helper::get_months(),
60 'months_short' => Hustle_Time_Helper::get_months( 'short' ),
61 ),
62 );
63
64 wp_localize_script(
65 'hustle_preview_script',
66 'hustleVars',
67 $vars
68 );
69 wp_enqueue_script( 'hustle_preview_script' );
70 }
71
72 /**
73 * Set of actions to run on the wp_footer.
74 *
75 * @since 4.3.1
76 */
77 public function wp_footer() {
78 Hustle_Module_Front::print_front_styles();
79 $this->render_non_inline_preview_container();
80 $this->maybe_print_forminator_scripts();
81 }
82
83 /**
84 * Print forminator scripts for preview.
85 * Used by Dashboard, Wizards, and Listings.
86 *
87 * @since 4.3.1
88 */
89 private function maybe_print_forminator_scripts() {
90 // Add Forminator's front styles and scripts for preview.
91 if ( defined( 'FORMINATOR_VERSION' ) ) {
92 forminator_print_front_styles( FORMINATOR_VERSION );
93 forminator_print_front_scripts( FORMINATOR_VERSION );
94
95 }
96 }
97
98 /**
99 * Set the amount of posts to 1 per page.
100 * Useful when the first page is one containing posts.
101 *
102 * @since 4.3.1
103 *
104 * @param WP_Query $query The WP_Query instance.
105 */
106 public function pre_get_posts( $query ) {
107 $query->set( 'posts_per_page', 1 );
108 }
109
110 /**
111 * Adds a custom title for the page/post.
112 *
113 * @since 4.3.1
114 *
115 * @param string $title Title to be displayed.
116 * @return string
117 */
118 public function the_title( $title ) {
119 if ( ! in_the_loop() ) {
120 return $title;
121 }
122 return esc_html__( 'Hustle Preview', 'hustle' );
123 }
124
125 /**
126 * Replaces the_content by a container to render inline modules in.
127 * Used for rendering embeds.
128 *
129 * @since 4.3.1
130 *
131 * @param string $content Current post/page content.
132 * @return string
133 */
134 public function show_after_page_post_content( $content ) {
135 return '<div id="module-preview-inline-container"></div>' . $content;
136 }
137
138 /**
139 * Adds a container at the bottom of the page to render non-inline modules in.
140 * Used for popups and slide-ins.
141 *
142 * @since 4.3.1
143 */
144 private function render_non_inline_preview_container() {
145 echo '<div id="module-preview-container"></div>';
146 }
147 }
148