display-conditions
5 months ago
front
3 days ago
helpers
1 month ago
metas
3 months ago
multisite
5 months ago
palettes
3 years ago
provider
1 month ago
providers
3 days ago
templates
3 years ago
update
5 months ago
class-hustle-admin-page-abstract.php
1 month ago
class-hustle-auth-token.php
5 months ago
class-hustle-condition-factory.php
6 years ago
class-hustle-cross-sell.php
10 months ago
class-hustle-dashboard-admin.php
1 month ago
class-hustle-data.php
1 month 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
1 month ago
class-hustle-module-collection.php
5 months ago
class-hustle-module-fields.php
3 months ago
class-hustle-module-page-abstract.php
1 month ago
class-hustle-module-validator.php
3 months ago
class-hustle-notifications.php
3 days ago
class-hustle-settings-admin.php
1 month ago
class-hustle-wp-dashboard-page.php
5 months ago
class-opt-in.php
3 days ago
hustle-background-conversion-log.php
3 months ago
hustle-deletion.php
3 months ago
hustle-embedded-admin.php
3 years ago
hustle-entries-admin.php
5 months ago
hustle-entry-model.php
1 month ago
hustle-general-data-protection.php
5 months ago
hustle-init.php
1 month ago
hustle-mail.php
5 months ago
hustle-migration.php
5 months ago
hustle-model.php
3 days ago
hustle-module-model.php
1 month ago
hustle-module-widget-legacy.php
5 months ago
hustle-module-widget.php
5 months ago
hustle-modules-common-admin-ajax.php
1 month ago
hustle-popup-admin.php
3 years ago
hustle-providers-admin.php
1 month ago
hustle-providers.php
5 months ago
hustle-settings-admin-ajax.php
1 month ago
hustle-settings-page.php
3 years ago
hustle-slidein-admin.php
3 years ago
hustle-sshare-admin.php
3 days ago
hustle-sshare-model.php
3 days ago
hustle-tracking-model.php
3 months ago
interface-hustle-auth-provider.php
5 months ago
opt-in-geo.php
5 months ago
opt-in-utils.php
3 days ago
opt-in-wpmudev-api.php
5 months ago
class-opt-in.php
121 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Opt_In Entry point |
| 4 | * |
| 5 | * @package Hustle |
| 6 | */ |
| 7 | |
| 8 | /** |
| 9 | * Opt_In class. |
| 10 | */ |
| 11 | class Opt_In { |
| 12 | |
| 13 | const VERSION = '7.8.14'; |
| 14 | |
| 15 | const VIEWS_FOLDER = 'views'; |
| 16 | |
| 17 | /** |
| 18 | * Base file. |
| 19 | * |
| 20 | * @since 1.0.0 |
| 21 | * @var string |
| 22 | */ |
| 23 | public static $plugin_base_file; |
| 24 | |
| 25 | /** |
| 26 | * Plugin URL. |
| 27 | * |
| 28 | * @since 1.0.0 |
| 29 | * @var string |
| 30 | */ |
| 31 | public static $plugin_url; |
| 32 | |
| 33 | /** |
| 34 | * Plugin path. |
| 35 | * |
| 36 | * @since 1.0.0 |
| 37 | * @var string |
| 38 | */ |
| 39 | public static $plugin_path; |
| 40 | |
| 41 | /** |
| 42 | * Path to "vendor". |
| 43 | * |
| 44 | * @since 1.0.0 |
| 45 | * @var string |
| 46 | */ |
| 47 | public static $vendor_path; |
| 48 | |
| 49 | /** |
| 50 | * Path to "views" files. |
| 51 | * |
| 52 | * @since 1.0.0 |
| 53 | * @var string |
| 54 | */ |
| 55 | public static $template_path; |
| 56 | |
| 57 | /** |
| 58 | * Array container for the registered providers. |
| 59 | * |
| 60 | * @since 3.0.5 |
| 61 | * @var array |
| 62 | */ |
| 63 | protected static $registered_providers = array(); |
| 64 | |
| 65 | /** |
| 66 | * Opt_In constructor. |
| 67 | * |
| 68 | * @since 1.0.0 |
| 69 | */ |
| 70 | public function __construct() { |
| 71 | |
| 72 | self::$plugin_base_file = plugin_basename( HUSTLE_BASE_FILE ); |
| 73 | self::$plugin_url = plugin_dir_url( self::$plugin_base_file ); |
| 74 | self::$plugin_path = trailingslashit( dirname( HUSTLE_BASE_FILE ) ); |
| 75 | self::$vendor_path = self::$plugin_path . 'vendor/'; |
| 76 | self::$template_path = trailingslashit( dirname( HUSTLE_BASE_FILE ) ) . 'views/'; |
| 77 | |
| 78 | add_action( 'after_setup_theme', array( $this, 'load_text_domain' ) ); |
| 79 | |
| 80 | // check caps. |
| 81 | add_action( 'admin_init', array( $this, 'hustle_check_caps' ), 999 ); |
| 82 | |
| 83 | new Hustle_Init(); |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * Returns list of optin providers based on their declared classes that implement Opt_In_Provider_Interface |
| 88 | * |
| 89 | * @return array |
| 90 | */ |
| 91 | public function get_providers() { |
| 92 | if ( empty( self::$registered_providers ) ) { |
| 93 | self::$registered_providers = Hustle_Provider_Utils::get_activable_providers_list(); |
| 94 | } |
| 95 | return self::$registered_providers; |
| 96 | } |
| 97 | |
| 98 | /** |
| 99 | * Loads text domain |
| 100 | * |
| 101 | * @since 1.0.0 |
| 102 | */ |
| 103 | public function load_text_domain() { |
| 104 | load_plugin_textdomain( 'hustle', false, dirname( plugin_basename( self::$plugin_base_file ) ) . '/languages/' ); |
| 105 | } |
| 106 | |
| 107 | /** |
| 108 | * Callback function when user migrates from 3x to 4x from ftp. |
| 109 | * The activation hook won't run we'd have to check it in init. |
| 110 | * |
| 111 | * @since 4.0.0 |
| 112 | */ |
| 113 | public function hustle_check_caps() { |
| 114 | $admin = get_role( 'administrator' ); |
| 115 | $roles = get_editable_roles(); |
| 116 | if ( ( $admin && ! $admin->has_cap( 'hustle_menu' ) ) || ( ! $admin && ! empty( $roles ) ) ) { |
| 117 | hustle_activation(); |
| 118 | } |
| 119 | } |
| 120 | } |
| 121 |