PluginProbe ʕ •ᴥ•ʔ
Hustle – Email Marketing, Lead Generation, Optins, Popups / 7.8.14
Hustle – Email Marketing, Lead Generation, Optins, Popups v7.8.14
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 / free / inc / class-wordpress-popup-module-admin.php
wordpress-popup / free / inc Last commit date
class-wordpress-popup-module-admin.php 1 month ago
class-wordpress-popup-module-admin.php
143 lines
1 <?php
2 /**
3 * File for Hustle_Module_Admin class.
4 *
5 * @package Hustle
6 * @since unknown
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit; // Exit if accessed directly.
11 }
12
13 if ( class_exists( 'WordPress_Popup_Module_Admin' ) ) {
14 return;
15 }
16
17 /**
18 * Class for WordPress_Popup_Module_Admin. Adds the free-specific functionality.
19 *
20 * @package Hustle
21 * @since unknown
22 */
23 class WordPress_Popup_Module_Admin {
24
25 const LISTING_PAGES = array(
26 'hustle_page_' . Hustle_Data::POPUP_LISTING_PAGE,
27 'hustle_page_' . Hustle_Data::SLIDEIN_LISTING_PAGE,
28 'hustle_page_' . Hustle_Data::EMBEDDED_LISTING_PAGE,
29 'hustle_page_' . Hustle_Data::SOCIAL_SHARING_LISTING_PAGE,
30 );
31
32 /**
33 * Constructor.
34 *
35 * @since unknown
36 */
37 public function __construct() {
38 add_filter( 'hustle_locate_file', array( $this, 'locate_file' ), 10, 2 );
39 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ) );
40 add_action( 'admin_menu', array( $this, 'add_upsell_menu_item' ), 99 );
41 add_action( 'admin_print_styles', array( $this, 'print_upsell_menu_item_styles' ) );
42 add_action( 'admin_print_footer_scripts', array( $this, 'print_upsell_menu_item_script' ) );
43 // Initialize the cross-sell class to add the cross-sell notice in the free module.
44 new Hustle_Cross_Sell();
45 }
46
47 /**
48 * Locate the file for the given layout. If the file exists in the free module, it will be returned. Otherwise, the original file will be returned.
49 *
50 * @since unknown
51 *
52 * @param string $template_file The original template file path.
53 * @param string $layout The layout name, which is used to create the file name.
54 * @return string
55 */
56 public function locate_file( $template_file, $layout ) {
57
58 $free_template_file = trailingslashit( Opt_In::$plugin_path ) . 'free/views/' . $layout . '.php';
59
60 if ( file_exists( $free_template_file ) ) {
61 return $free_template_file;
62 }
63
64 return $template_file;
65 }
66
67 /**
68 * Enqueue the admin scripts for the free module.
69 *
70 * @since unknown
71 */
72 public function enqueue_admin_scripts() {
73 $screen = get_current_screen();
74
75 if ( ! $screen || ! in_array( $screen->base, self::LISTING_PAGES, true ) ) {
76 return;
77 }
78
79 wp_enqueue_script(
80 'wordpress-popup',
81 trailingslashit( Opt_In::$plugin_url ) . '/assets/js/wordpress-popup.min.js',
82 array(
83 'jquery',
84 'optin_admin_scripts',
85 'shared-ui',
86 ),
87 '1.0.0',
88 true
89 );
90 }
91
92 /**
93 * Adds Upsell menu item.
94 *
95 * @since 7.8.8
96 */
97 public function add_upsell_menu_item() {
98 add_submenu_page(
99 'hustle',
100 __( 'Get Hustle Pro', 'hustle' ),
101 __( 'Get Hustle Pro', 'hustle' ),
102 'hustle_menu',
103 'https://wpmudev.com/project/hustle/?utm_source=hustle&utm_medium=plugin&utm_campaign=hustle_submenu_upsell',
104 );
105 }
106
107 /**
108 * Prints styles for Upsell menu item.
109 *
110 * @since 7.8.8
111 */
112 public function print_upsell_menu_item_styles() {
113 ?>
114 <style id="hustle-upsell">
115 #adminmenu #toplevel_page_hustle .wp-submenu li:last-child a[href^="https://wpmudev.com"] {
116 background-color: #8d00b1 !important; color: #fff !important; font-weight: 500 !important; letter-spacing: -0.2px;
117 }
118 </style>
119 <?php
120 }
121
122 /**
123 * Prints scripts for Upsell menu item.
124 *
125 * @since 7.8.8
126 */
127 public function print_upsell_menu_item_script() {
128 ?>
129 <script>
130 jQuery( document ).ready( function ( $ ) {
131 /**
132 * Open the upsell link in a new tab.
133 */
134 $( '#toplevel_page_hustle .wp-submenu li:last-child a[href^="https://wpmudev.com"]' ).on( 'click', function ( e ) {
135 e.preventDefault();
136 window.open( $( this ).attr( 'href' ), '_blank' );
137 } );
138 } );
139 </script>
140 <?php
141 }
142 }
143