display-conditions
5 months ago
front
2 days ago
helpers
1 month ago
metas
3 months ago
multisite
5 months ago
palettes
3 years ago
provider
1 month ago
providers
2 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
2 days ago
class-hustle-settings-admin.php
1 month ago
class-hustle-wp-dashboard-page.php
5 months ago
class-opt-in.php
2 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
2 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
2 days ago
hustle-sshare-model.php
2 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
2 days ago
opt-in-wpmudev-api.php
5 months ago
hustle-sshare-admin.php
115 lines
| 1 | <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName |
| 2 | /** |
| 3 | * Hustle_SShare_Admin |
| 4 | * |
| 5 | * @package Hustle |
| 6 | */ |
| 7 | |
| 8 | if ( ! class_exists( 'Hustle_SShare_Admin' ) ) : |
| 9 | |
| 10 | /** |
| 11 | * Class Hustle_SShare_Admin |
| 12 | */ |
| 13 | class Hustle_SShare_Admin extends Hustle_Module_Page_Abstract { |
| 14 | |
| 15 | /** |
| 16 | * Established the properties for the page. |
| 17 | * |
| 18 | * @since 7.8.14 |
| 19 | */ |
| 20 | protected function init() { |
| 21 | parent::init(); |
| 22 | add_action( 'hustle_after_create_module', array( $this, 'delete_sshare_modules_transient' ) ); |
| 23 | add_action( 'hustle_after_update_module', array( $this, 'delete_sshare_modules_transient' ) ); |
| 24 | } |
| 25 | |
| 26 | /** |
| 27 | * Deletes the social sharing modules transient when a social sharing module is created or updated. |
| 28 | * |
| 29 | * @since 7.8.14 |
| 30 | * |
| 31 | * @param string $module_type Module type. |
| 32 | */ |
| 33 | public function delete_sshare_modules_transient( $module_type ) { |
| 34 | if ( Hustle_Module_Model::SOCIAL_SHARING_MODULE === $module_type ) { |
| 35 | delete_transient( 'hustle_social_sharing_modules' ); |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * Set page properties |
| 41 | */ |
| 42 | protected function set_page_properties() { |
| 43 | |
| 44 | $this->module_type = Hustle_Module_Model::SOCIAL_SHARING_MODULE; |
| 45 | |
| 46 | $this->page_title = Opt_In_Utils::get_module_type_display_name( $this->module_type, false, true ); |
| 47 | |
| 48 | $this->page_template_path = '/admin/sshare/listing'; |
| 49 | $this->page_edit_template_path = '/admin/sshare/wizard'; |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Gets the JS variables to be localized in Wizard for Social Sharing modules. |
| 54 | * |
| 55 | * @since 4.3.0 |
| 56 | * |
| 57 | * @return array |
| 58 | */ |
| 59 | protected function get_wizard_js_variables_to_localize() { |
| 60 | $variables = array( |
| 61 | 'social_platforms' => Hustle_SShare_Model::get_social_platform_names(), |
| 62 | 'social_platforms_with_endpoints' => Hustle_SShare_Model::get_sharing_endpoints(), |
| 63 | 'social_platforms_with_api' => Hustle_SShare_Model::get_networks_counter_endpoint(), |
| 64 | 'social_platforms_data' => array( |
| 65 | 'email_message_default' => __( "I've found an excellent article on {post_url} which may interest you.", 'hustle' ), |
| 66 | ), |
| 67 | 'palettes' => array( |
| 68 | 'sshare_defaults' => $this->module->get_design()->get_defaults(), |
| 69 | ), |
| 70 | ); |
| 71 | return $variables; |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * Get the args for the wizard page. |
| 76 | * |
| 77 | * @since 4.0.1 |
| 78 | * @return array |
| 79 | */ |
| 80 | protected function get_page_edit_template_args() { |
| 81 | return array( |
| 82 | 'section' => $this->get_current_section( 'services' ), |
| 83 | 'module_id' => $this->module->module_id, |
| 84 | 'module' => $this->module, |
| 85 | 'is_active' => (bool) $this->module->active, |
| 86 | ); |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * Loads preview styles used only by the Ssharing wizard. |
| 91 | * |
| 92 | * @since 4.3.1 |
| 93 | */ |
| 94 | protected function on_listing_and_wizard_actions() { |
| 95 | parent::on_listing_and_wizard_actions(); |
| 96 | |
| 97 | // Load preview scripts used only by ssharing wizard. |
| 98 | if ( $this->page_edit === $this->current_page ) { |
| 99 | add_action( 'admin_print_styles', array( $this, 'print_preview_styles' ) ); |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | /** |
| 104 | * Prints the styles for Ssharing inline modules. |
| 105 | * |
| 106 | * @since 4.3.1 |
| 107 | */ |
| 108 | public function print_preview_styles() { |
| 109 | $module_types = array( Hustle_Module_Model::SOCIAL_SHARING_MODULE, Hustle_SShare_Model::INLINE_MODULE ); |
| 110 | Hustle_Module_Front::print_front_styles( $module_types ); |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | endif; |
| 115 |