display-conditions
3 years ago
front
9 months ago
helpers
9 months ago
metas
3 years ago
multisite
3 years ago
palettes
3 years ago
provider
3 years ago
providers
9 months ago
templates
3 years ago
update
3 years ago
class-hustle-admin-page-abstract.php
9 months ago
class-hustle-black-friday-campaign.php
7 months ago
class-hustle-condition-factory.php
6 years ago
class-hustle-cross-sell.php
9 months ago
class-hustle-dashboard-admin.php
3 years ago
class-hustle-data.php
3 years ago
class-hustle-db.php
2 years ago
class-hustle-installer.php
4 years ago
class-hustle-meta.php
3 years ago
class-hustle-module-admin.php
9 months ago
class-hustle-module-collection.php
3 years ago
class-hustle-module-page-abstract.php
2 years ago
class-hustle-notifications.php
3 years ago
class-hustle-settings-admin.php
3 years ago
class-hustle-tutorials-page.php
4 years ago
class-hustle-wp-dashboard-page.php
3 years ago
hustle-deletion.php
3 years ago
hustle-embedded-admin.php
3 years ago
hustle-entries-admin.php
3 years ago
hustle-entry-model.php
3 years ago
hustle-general-data-protection.php
3 years ago
hustle-init.php
7 months ago
hustle-mail.php
3 years ago
hustle-migration.php
3 years ago
hustle-model.php
3 years ago
hustle-module-model.php
9 months ago
hustle-module-widget-legacy.php
3 years ago
hustle-module-widget.php
3 years ago
hustle-modules-common-admin-ajax.php
9 months ago
hustle-popup-admin.php
3 years ago
hustle-providers-admin.php
3 years ago
hustle-providers.php
3 years ago
hustle-settings-admin-ajax.php
3 years ago
hustle-settings-page.php
3 years ago
hustle-slidein-admin.php
3 years ago
hustle-sshare-admin.php
3 years ago
hustle-sshare-model.php
3 years ago
hustle-tracking-model.php
3 years ago
opt-in-geo.php
9 months ago
opt-in-utils.php
3 years ago
opt-in-wpmudev-api.php
3 years ago
class-hustle-dashboard-admin.php
414 lines
| 1 | <?php |
| 2 | /** |
| 3 | * File for Hustle_Dashboard_Admin class. |
| 4 | * |
| 5 | * @package Hustle |
| 6 | * @since unknwon |
| 7 | */ |
| 8 | |
| 9 | /** |
| 10 | * Hustle_Dashboard_Admin. |
| 11 | */ |
| 12 | class Hustle_Dashboard_Admin extends Hustle_Admin_Page_Abstract { |
| 13 | |
| 14 | const WELCOME_MODAL_NAME = 'welcome_modal'; |
| 15 | const MIGRATE_MODAL_NAME = 'migrate_modal'; |
| 16 | const HIGHLIGHT_MODAL_NAME = 'release_highlight_modal_470'; |
| 17 | const MIGRATE_NOTICE_NAME = 'migrate_notice'; |
| 18 | |
| 19 | /** |
| 20 | * Whether we have any module. |
| 21 | * |
| 22 | * @since 4.3.5 |
| 23 | * |
| 24 | * @var boolean |
| 25 | */ |
| 26 | private $has_modules = false; |
| 27 | |
| 28 | /** |
| 29 | * Initiates the page's properties |
| 30 | * Should be overridden by each page. |
| 31 | * |
| 32 | * @since 4.0.1 |
| 33 | */ |
| 34 | protected function init() { |
| 35 | |
| 36 | $this->page = 'hustle'; |
| 37 | |
| 38 | $this->page_title = esc_html__( 'Dashboard', 'hustle' ); |
| 39 | |
| 40 | $this->page_menu_title = $this->page_title; |
| 41 | |
| 42 | $this->page_capability = 'hustle_menu'; |
| 43 | |
| 44 | $this->page_template_path = 'admin/dashboard'; |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Actions to be performed on Dashboard page. |
| 49 | * |
| 50 | * @since 4.0.4 |
| 51 | */ |
| 52 | public function current_page_loaded() { |
| 53 | parent::current_page_loaded(); |
| 54 | $this->export_module(); |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Register Hustle's parent menu. |
| 59 | * Call the parent method to add the submenu page for Dashboard. |
| 60 | * |
| 61 | * @since 4.0.1 |
| 62 | */ |
| 63 | public function register_admin_menu() { |
| 64 | |
| 65 | $parent_menu_title = esc_html( Opt_In_Utils::get_plugin_name() ); |
| 66 | |
| 67 | // Parent menu. |
| 68 | add_menu_page( |
| 69 | $parent_menu_title, |
| 70 | $parent_menu_title, |
| 71 | $this->page_capability, |
| 72 | 'hustle', |
| 73 | array( $this, 'render_main_page' ), |
| 74 | 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMjAi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MTUxMjMgNy41MTIzNyAzLjAzNDczIDcuNzQ3MDMgMyA4VjEyQzMuMDM0NzMgMTIuMjUzIDMuMTUxMjMgMTIuNDg3NiAzLjMzMTc4IDEyLjY2ODJDMy41MTIzNCAxMi44NDg3IDMuNzQ3MDMgMTIuOTY1MyA0IDEzSDdDMTEgMTMgMTcgMTMgMTcgMTcuNUMxNyAxNy42MzI2IDE3LjA1MjcgMTcuNzU5OCAxNy4xNDY0IDE3Ljg1MzVDMTcuMjQwMiAxNy45NDczIDE3LjM2NzQgMTggMTcuNSAxOEMxNy42MzI2IDE4IDE3Ljc1OTggMTcuOTQ3MyAxNy44NTM2IDE3Ljg1MzVDMTcuOTQ3MyAxNy43NTk4IDE4IDE3LjYzMjYgMTggMTcuNVYyLjVDMTggMi4zNjczOSAxNy45NDczIDIuMjQwMjIgMTcuODUzNiAyLjE0NjQ1QzE3Ljc1OTggMi4wNTI2OSAxNy42MzI2IDIgMTcuNSAyQzE3LjM2NzQgMiAxNy4yNDAyIDIuMDUyNjkgMTcuMTQ2NCAyLjE0NjQ1QzE3LjA1MjcgMi4yNDAyMiAxNyAyLjM2NzM5IDE3IDIuNUMxNyA3IDExIDcgNyA3SDRaTTguNTcwMTggMTJWMTAuMjlMMTIuMDAwMiA4VjkuNzFMMTYuMDAwMiA4TDEwLjg2MDIgMTJWMTAuMjlMOC41NzAxOCAxMloiIGZpbGw9IiNBN0FBQUQiLz4KPC9nPgo8ZGVmcz4KPGNsaXBQYXRoIGlkPSJjbGlwMF8xN185Ij4KPHJlY3Qgd2lkdGg9IjIwIiBoZWlnaHQ9IjIwIiBmaWxsPSJ3aGl0ZSIvPgo8L2NsaXBQYXRoPgo8L2RlZnM+Cjwvc3ZnPgo=' |
| 75 | ); |
| 76 | |
| 77 | parent::register_admin_menu(); |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * Get $active variable for get_all method |
| 82 | * |
| 83 | * @param array $settings General settings. |
| 84 | * @param string $type Module type. |
| 85 | * @return boolean|null |
| 86 | */ |
| 87 | private function is_getting_active( $settings, $type ) { |
| 88 | $return = null; |
| 89 | |
| 90 | if ( $settings[ 'published_' . $type . '_on_dashboard' ] && ! $settings[ 'draft_' . $type . '_on_dashboard' ] ) { |
| 91 | $return = true; |
| 92 | } elseif ( ! $settings[ 'published_' . $type . '_on_dashboard' ] && $settings[ 'draft_' . $type . '_on_dashboard' ] ) { |
| 93 | $return = false; |
| 94 | } |
| 95 | |
| 96 | return $return; |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * Get limit from general settings |
| 101 | * |
| 102 | * @param array $settings General settings. |
| 103 | * @param string $type Module type. |
| 104 | * @return string |
| 105 | */ |
| 106 | private static function get_limit( $settings, $type ) { |
| 107 | $limit = $settings[ $type . '_on_dashboard' ]; |
| 108 | if ( $limit < 1 ) { |
| 109 | $limit = 1; |
| 110 | } |
| 111 | return $limit; |
| 112 | } |
| 113 | |
| 114 | |
| 115 | /** |
| 116 | * Get the arguments used when rendering the main page. |
| 117 | * |
| 118 | * @since 4.0.1 |
| 119 | * @return array |
| 120 | */ |
| 121 | public function get_page_template_args() { |
| 122 | |
| 123 | $collection_instance = Hustle_Module_Collection::instance(); |
| 124 | |
| 125 | $general_settings = Hustle_Settings_Admin::get_general_settings(); |
| 126 | $modules = array( |
| 127 | 'popup' => array(), |
| 128 | 'slidein' => array(), |
| 129 | 'embedded' => array(), |
| 130 | 'social_sharing' => array(), |
| 131 | ); |
| 132 | foreach ( $modules as $type => $instances ) { |
| 133 | $active = self::is_getting_active( $general_settings, $type ); |
| 134 | $limit = self::get_limit( $general_settings, $type ); |
| 135 | |
| 136 | $modules[ $type ] = $collection_instance->get_all( $active, array( 'module_type' => $type ), $limit ); |
| 137 | |
| 138 | if ( ! empty( $modules[ $type ] ) ) { |
| 139 | $this->has_modules = true; |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | $active_modules = $collection_instance->get_all( |
| 144 | true, |
| 145 | array( |
| 146 | 'count_only' => true, |
| 147 | ) |
| 148 | ); |
| 149 | |
| 150 | $args = array( |
| 151 | 'metrics' => $this->get_3_top_metrics(), |
| 152 | 'active_modules' => $active_modules, |
| 153 | 'popups' => $modules['popup'], |
| 154 | 'slideins' => $modules['slidein'], |
| 155 | 'embeds' => $modules['embedded'], |
| 156 | 'social_sharings' => $modules['social_sharing'], |
| 157 | 'last_conversion' => '', |
| 158 | 'sui' => $this->get_sui_summary_config(), |
| 159 | ); |
| 160 | |
| 161 | if ( Hustle_Settings_Admin::global_tracking() ) { |
| 162 | $last_conversion = Hustle_Tracking_Model::get_instance()->get_latest_conversion_date( 'all' ); |
| 163 | $args['last_conversion'] = $last_conversion ? date_i18n( 'j M Y @ H:i A', strtotime( $last_conversion ) ) : esc_html__( 'Never', 'hustle' ); |
| 164 | } |
| 165 | |
| 166 | return $args; |
| 167 | } |
| 168 | |
| 169 | /** |
| 170 | * Add data to the current json array. |
| 171 | * |
| 172 | * @since 4.3.1 |
| 173 | * |
| 174 | * @return array |
| 175 | */ |
| 176 | protected function get_vars_to_localize() { |
| 177 | $current_array = parent::get_vars_to_localize(); |
| 178 | |
| 179 | // Register translated strings for datepicker preview. |
| 180 | $current_array['messages']['days_and_months'] = array( |
| 181 | 'days_full' => Hustle_Time_Helper::get_week_days(), |
| 182 | 'days_short' => Hustle_Time_Helper::get_week_days( 'short' ), |
| 183 | 'days_min' => Hustle_Time_Helper::get_week_days( 'min' ), |
| 184 | 'months_full' => Hustle_Time_Helper::get_months(), |
| 185 | 'months_short' => Hustle_Time_Helper::get_months( 'short' ), |
| 186 | ); |
| 187 | |
| 188 | // Also defined in listing. |
| 189 | $current_array['single_module_action_nonce'] = wp_create_nonce( 'hustle_single_action' ); |
| 190 | |
| 191 | return $current_array; |
| 192 | } |
| 193 | |
| 194 | /** |
| 195 | * Get the data for listing the ssharing modules conversions per page. |
| 196 | * |
| 197 | * @since 4.0.0 |
| 198 | * @param int $limit Limit for retrieving the sshare data. |
| 199 | * @return array |
| 200 | */ |
| 201 | private function get_sshare_per_page_conversions( $limit ) { |
| 202 | |
| 203 | $tracking_model = Hustle_Tracking_Model::get_instance(); |
| 204 | $tracking_data = $tracking_model->get_ssharing_per_page_conversion_count( $limit ); |
| 205 | |
| 206 | $data_array = array(); |
| 207 | foreach ( $tracking_data as $data ) { |
| 208 | |
| 209 | if ( '0' !== $data->page_id ) { |
| 210 | $title = get_the_title( $data->page_id ); |
| 211 | $url = get_permalink( $data->page_id ); |
| 212 | } else { |
| 213 | $title = get_bloginfo( 'name', 'display' ); |
| 214 | $url = get_home_url(); |
| 215 | } |
| 216 | |
| 217 | if ( empty( $url ) ) { |
| 218 | continue; |
| 219 | } |
| 220 | $data_array[] = array( |
| 221 | 'title' => $title, |
| 222 | 'url' => $url, |
| 223 | 'count' => $data->tracked_count, |
| 224 | ); |
| 225 | } |
| 226 | |
| 227 | return $data_array; |
| 228 | } |
| 229 | |
| 230 | /** |
| 231 | * Get 3 Top Metrics |
| 232 | * |
| 233 | * @since 4.0.0 |
| 234 | * |
| 235 | * @return array $data Array of 4 top metrics. |
| 236 | */ |
| 237 | private function get_3_top_metrics() { |
| 238 | $names = array( |
| 239 | 'average_conversion_rate' => esc_html__( 'Average Conversion Rate', 'hustle' ), |
| 240 | 'total_conversions' => esc_html__( 'Total Conversions', 'hustle' ), |
| 241 | 'most_conversions' => esc_html__( 'Most Conversions', 'hustle' ), |
| 242 | 'today_conversions' => esc_html__( 'Today\'s Conversion', 'hustle' ), |
| 243 | 'last_week_conversions' => esc_html__( 'Last 7 Day\'s Conversion', 'hustle' ), |
| 244 | 'last_month_conversions' => esc_html__( 'Last 1 Month\'s Conversion', 'hustle' ), |
| 245 | 'inactive_modules_count' => esc_html__( 'Inactive Modules', 'hustle' ), |
| 246 | 'total_modules_count' => esc_html__( 'Total Modules', 'hustle' ), |
| 247 | ); |
| 248 | |
| 249 | if ( ! Hustle_Settings_Admin::global_tracking() ) { |
| 250 | $metrics = array( 'inactive_modules_count', 'total_modules_count' ); |
| 251 | } else { |
| 252 | $keys = array_keys( $names ); |
| 253 | $metrics = Hustle_Settings_Admin::get_top_metrics_settings(); |
| 254 | $metrics = array_values( array_intersect( $keys, $metrics ) ); |
| 255 | |
| 256 | $metrics_count = count( $metrics ); |
| 257 | |
| 258 | while ( 3 > $metrics_count ) { |
| 259 | $key = array_shift( $keys ); |
| 260 | if ( ! in_array( $key, $metrics, true ) ) { |
| 261 | $metrics[] = $key; |
| 262 | } |
| 263 | $metrics_count = count( $metrics ); |
| 264 | } |
| 265 | } |
| 266 | $data = array(); |
| 267 | $tracking = Hustle_Tracking_Model::get_instance(); |
| 268 | $module_instance = Hustle_Module_Collection::instance(); |
| 269 | foreach ( $metrics as $key ) { |
| 270 | |
| 271 | switch ( $key ) { |
| 272 | case 'average_conversion_rate': |
| 273 | $value = $tracking->get_average_conversion_rate(); |
| 274 | break; |
| 275 | case 'total_conversions': |
| 276 | $value = $tracking->get_total_conversions(); |
| 277 | break; |
| 278 | case 'most_conversions': |
| 279 | $module_id = $tracking->get_most_conversions_module_id(); |
| 280 | if ( ! $module_id ) { |
| 281 | $value = esc_html__( 'None', 'hustle' ); |
| 282 | break; |
| 283 | } |
| 284 | $module = new Hustle_Module_Model( $module_id ); |
| 285 | if ( ! is_wp_error( $module ) ) { |
| 286 | $value = $module->module_name; |
| 287 | $url = add_query_arg( 'page', $module->get_wizard_page() ); |
| 288 | if ( ! empty( $url ) ) { |
| 289 | $url = add_query_arg( 'id', $module->module_id, $url ); |
| 290 | $value = sprintf( |
| 291 | '<a href="%s">%s</a>', |
| 292 | esc_url( $url ), |
| 293 | esc_html( $value ) |
| 294 | ); |
| 295 | } |
| 296 | } |
| 297 | break; |
| 298 | case 'today_conversions': |
| 299 | $value = $tracking->get_today_conversions(); |
| 300 | break; |
| 301 | case 'last_week_conversions': |
| 302 | $value = $tracking->get_last_week_conversions(); |
| 303 | break; |
| 304 | case 'last_month_conversions': |
| 305 | $value = $tracking->get_last_month_conversions(); |
| 306 | break; |
| 307 | case 'inactive_modules_count': |
| 308 | $value = $module_instance->get_all( false, array( 'count_only' => true ) ); |
| 309 | break; |
| 310 | case 'total_modules_count': |
| 311 | $value = $module_instance->get_all( 'any', array( 'count_only' => true ) ); |
| 312 | break; |
| 313 | default: |
| 314 | $value = esc_html__( 'Unknown', 'hustle' ); |
| 315 | } |
| 316 | if ( 0 === $value ) { |
| 317 | $value = esc_html__( 'None', 'hustle' ); |
| 318 | } |
| 319 | $data[ $key ] = array( |
| 320 | 'label' => $names[ $key ], |
| 321 | 'value' => $value, |
| 322 | ); |
| 323 | } |
| 324 | return $data; |
| 325 | } |
| 326 | |
| 327 | /** |
| 328 | * Renders the modals for the Dashboard page. |
| 329 | * |
| 330 | * @since 4.3.5 |
| 331 | * |
| 332 | * @todo Move global modals to the base abstract page. |
| 333 | * |
| 334 | * @return void |
| 335 | */ |
| 336 | protected function render_modals() { |
| 337 | parent::render_modals(); |
| 338 | |
| 339 | $needs_migration = Hustle_Migration::check_tracking_needs_migration(); |
| 340 | |
| 341 | // On Boarding (Welcome). |
| 342 | if ( |
| 343 | filter_input( INPUT_GET, 'show-welcome', FILTER_VALIDATE_BOOLEAN ) || |
| 344 | ( ! $this->has_modules && ! Hustle_Notifications::was_notification_dismissed( self::WELCOME_MODAL_NAME ) ) |
| 345 | ) { |
| 346 | $this->get_renderer()->render( 'admin/dashboard/dialogs/fresh-install' ); |
| 347 | } |
| 348 | |
| 349 | // Migration. |
| 350 | if ( |
| 351 | filter_input( INPUT_GET, 'show-migrate', FILTER_VALIDATE_BOOLEAN ) || |
| 352 | ( $needs_migration && ! Hustle_Notifications::was_notification_dismissed( self::MIGRATE_MODAL_NAME ) ) |
| 353 | ) { |
| 354 | $this->get_renderer()->render( 'admin/dashboard/dialogs/migrate-data' ); |
| 355 | } |
| 356 | |
| 357 | // Release highlights. |
| 358 | if ( $this->should_show_highlight_modal( $needs_migration ) ) { |
| 359 | $this->get_renderer()->render( 'admin/dashboard/dialogs/release-highlight' ); |
| 360 | } |
| 361 | |
| 362 | // Dissmiss migrate tracking notice modal confirmation. |
| 363 | if ( Hustle_Notifications::is_show_migrate_tracking_notice() ) { |
| 364 | $this->get_renderer()->render( 'admin/dialogs/migrate-dismiss-confirmation' ); |
| 365 | } |
| 366 | |
| 367 | // Visibility behavior updated. |
| 368 | if ( |
| 369 | filter_input( INPUT_GET, 'review-conditions', FILTER_VALIDATE_BOOLEAN ) && |
| 370 | Hustle_Migration::is_migrated( 'hustle_40_migrated' ) && |
| 371 | ! Hustle_Notifications::was_notification_dismissed( '41_visibility_behavior_update' ) |
| 372 | ) { |
| 373 | $this->get_renderer()->render( 'admin/dashboard/dialogs/review-conditions' ); |
| 374 | } |
| 375 | |
| 376 | // Delete. |
| 377 | $this->get_renderer()->render( 'admin/commons/sui-listing/dialogs/delete-module' ); |
| 378 | } |
| 379 | |
| 380 | /** |
| 381 | * Returns whether the highlight modal should show up, enqueues scripts, or dismiss otherwise. |
| 382 | * |
| 383 | * @todo Separate the check from the enqueueing and the dismissal. |
| 384 | * @todo Retrieve $has_modules and $need_migrate from here, instead of recieving them as params. |
| 385 | * |
| 386 | * @since 4.3.0 |
| 387 | * |
| 388 | * @param boolean $need_migrate Whether the metas migration from 3.x to 4.x is pending. |
| 389 | * @return boolean |
| 390 | */ |
| 391 | private function should_show_highlight_modal( $need_migrate ) { |
| 392 | $hide = apply_filters( 'wpmudev_branding_hide_doc_link', false ); |
| 393 | if ( $hide ) { |
| 394 | return false; |
| 395 | } |
| 396 | |
| 397 | $is_force_highlight = filter_input( INPUT_GET, 'show-release-highlight', FILTER_VALIDATE_BOOLEAN ); |
| 398 | $was_highlight_dismissed = Hustle_Notifications::was_notification_dismissed( self::HIGHLIGHT_MODAL_NAME ); |
| 399 | |
| 400 | if ( ! $was_highlight_dismissed || $is_force_highlight ) { |
| 401 | |
| 402 | // Only display when it's not a fresh install and no 3.x to 4.x migration is needed. |
| 403 | // Check for $previous_installed_version in 4.2.1. For now, we assume that if there are modules it's not a fresh install. |
| 404 | if ( $is_force_highlight || ( $this->has_modules && ! $need_migrate ) ) { |
| 405 | return true; |
| 406 | } else { |
| 407 | // Fresh install or focus on migration. Dismiss the notification. |
| 408 | Hustle_Notifications::add_dismissed_notification( self::HIGHLIGHT_MODAL_NAME ); |
| 409 | } |
| 410 | } |
| 411 | return false; |
| 412 | } |
| 413 | } |
| 414 |