PluginProbe ʕ •ᴥ•ʔ
Hustle – Email Marketing, Lead Generation, Optins, Popups / trunk
Hustle – Email Marketing, Lead Generation, Optins, Popups vtrunk
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 1 month ago class-hustle-decorator-non-sshare.php 3 months ago class-hustle-decorator-sshare.php 3 months ago class-hustle-decorator_abstract.php 3 years ago class-hustle-module-preview.php 1 year ago hustle-module-front-ajax.php 1 month ago hustle-module-front.php 1 month ago hustle-module-inline-style-queue.php 3 months ago hustle-module-renderer.php 1 month ago hustle-renderer-abstract.php 3 months ago hustle-renderer-sshare.php 5 months ago
class-hustle-module-preview.php
158 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 if ( 'posts' === get_option( 'show_on_front' ) ) {
31 add_filter( 'the_excerpt', array( $this, 'show_after_page_post_content' ) );
32 } else {
33 add_filter( 'the_content', array( $this, 'show_after_page_post_content' ) );
34 }
35
36 // With a priority of 20 to override possible WC's filter.
37 add_filter( 'show_admin_bar', '__return_false', 20 );
38
39 // Remove WordPress emoji - it generates JS error in Mozilla https://core.trac.wordpress.org/ticket/53529 .
40 remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
41 remove_action( 'wp_print_styles', 'print_emoji_styles' );
42 }
43
44 /**
45 * Registers the script used in the preview iframe.
46 *
47 * @since 4.3.1
48 */
49 public function register_preview_scripts() {
50 Hustle_Module_Front::add_hui_scripts();
51
52 wp_register_script(
53 'hustle_preview_script',
54 Opt_In::$plugin_url . 'assets/js/preview.min.js',
55 array( 'jquery' ),
56 Opt_In::VERSION,
57 true
58 );
59
60 $vars = array(
61 'ajaxurl' => admin_url( 'admin-ajax.php', is_ssl() ? 'https' : 'http' ),
62 'nonce' => wp_create_nonce( 'hustle-preview' ),
63 'days_and_months' => array(
64 'days_full' => Hustle_Time_Helper::get_week_days(),
65 'days_short' => Hustle_Time_Helper::get_week_days( 'short' ),
66 'days_min' => Hustle_Time_Helper::get_week_days( 'min' ),
67 'months_full' => Hustle_Time_Helper::get_months(),
68 'months_short' => Hustle_Time_Helper::get_months( 'short' ),
69 ),
70 );
71
72 wp_localize_script(
73 'hustle_preview_script',
74 'hustleVars',
75 $vars
76 );
77 wp_enqueue_script( 'hustle_preview_script' );
78 wp_enqueue_script( 'jquery-ui-datepicker' );
79 }
80
81 /**
82 * Set of actions to run on the wp_footer.
83 *
84 * @since 4.3.1
85 */
86 public function wp_footer() {
87 Hustle_Module_Front::print_front_styles();
88 $this->render_non_inline_preview_container();
89 $this->maybe_print_forminator_scripts();
90 }
91
92 /**
93 * Print forminator scripts for preview.
94 * Used by Dashboard, Wizards, and Listings.
95 *
96 * @since 4.3.1
97 */
98 private function maybe_print_forminator_scripts() {
99 // Add Forminator's front styles and scripts for preview.
100 if ( defined( 'FORMINATOR_VERSION' ) ) {
101 forminator_print_front_styles( FORMINATOR_VERSION );
102 forminator_print_front_scripts( FORMINATOR_VERSION );
103
104 }
105 }
106
107 /**
108 * Set the amount of posts to 1 per page.
109 * Useful when the first page is one containing posts.
110 *
111 * @since 4.3.1
112 *
113 * @param WP_Query $query The WP_Query instance.
114 */
115 public function pre_get_posts( $query ) {
116 $query->set( 'posts_per_page', 1 );
117 }
118
119 /**
120 * Adds a custom title for the page/post.
121 *
122 * @since 4.3.1
123 *
124 * @param string $title Title to be displayed.
125 * @return string
126 */
127 public function the_title( $title ) {
128 if ( ! in_the_loop() ) {
129 return $title;
130 }
131 /* translators: Plugin name */
132 return esc_html( sprintf( __( '%s Preview', 'hustle' ), Opt_In_Utils::get_plugin_name() ) );
133 }
134
135 /**
136 * Replaces the_content by a container to render inline modules in.
137 * Used for rendering embeds.
138 *
139 * @since 4.3.1
140 *
141 * @param string $content Current post/page content.
142 * @return string
143 */
144 public function show_after_page_post_content( $content ) {
145 return '<div id="module-preview-inline-container"></div>' . $content;
146 }
147
148 /**
149 * Adds a container at the bottom of the page to render non-inline modules in.
150 * Used for popups and slide-ins.
151 *
152 * @since 4.3.1
153 */
154 private function render_non_inline_preview_container() {
155 echo '<div id="module-preview-container"></div>';
156 }
157 }
158