Esempio n. 1
0
 public function addActions()
 {
     if (function_exists("add_action")) {
         // Hook for PHPMailer to detect for any SMTP plugins that might be configured to send mail via SSL (Ex. AWS SES).
         // add_action( 'phpmailer_init', array('MM_Email', 'mm_phpMailer'), 5 );
         add_filter("plugin_action_links", array($this, "updateVersion"), 5, 3);
         $user_hooks = new MM_UserHooks();
         add_action('wp_login_failed', array($user_hooks, 'loginFailed'), 9999);
         add_action('authenticate', array($user_hooks, 'authenticateLogin'));
         //session functions
         add_action('init', function () {
             if (MM_Session::sessionExists()) {
                 MM_Session::sessionStart();
             }
         });
         add_action('shutdown', array('MM_Session', 'sessionWrite'));
         add_action('wp_logout', array($this, "reapSession"));
         add_action('init', array($user_hooks, "doAutoLogin"));
         add_action('init', array($user_hooks, "doAutoLogout"));
         add_action('init', array($user_hooks, "removeWPAutoPOnCorePages"));
         add_action("init", array($user_hooks, "setupDefinitions"));
         add_action("template_redirect", array($user_hooks, "checkCorePageTypeInput"));
         add_action("wp_footer", array($user_hooks, "pageBasedActions"));
         add_action('delete_user', array($user_hooks, "deleteUser"));
         add_action('profile_update', array($user_hooks, "handleProfileUpdate"));
         add_action("wp_head", array($this, "loadPreviewBar"));
         add_action("admin_bar_menu", array($this, "customizeAdminBar"));
         add_action("wp_enqueue_scripts", array($this, 'loadResources'));
         if (MM_Utils::inAdmin()) {
             add_action("admin_enqueue_scripts", array($this, 'loadResources'));
             add_action('admin_init', array($user_hooks, "checkEmployeeAccess"));
             add_action('admin_menu', array($this, 'buildAdminMenu'));
             add_action("admin_notices", array($this, "showNotices"));
             add_action("admin_notices", array($this, "activationFailed"));
             add_action("admin_init", array($this, 'configurePostMeta'));
         }
         if (class_exists("MM_SmartTagLibraryView")) {
             $smartTagLibrary = new MM_SmartTagLibraryView();
             add_action("admin_footer", array($smartTagLibrary, "addDialogContainers"));
             add_action('media_buttons_context', array($smartTagLibrary, "customMediaButtons"));
         }
         if (class_exists("MM_PaymentUtilsView")) {
             $paymentUtils = new MM_PaymentUtilsView();
             add_action("admin_footer", array($paymentUtils, "addDialogContainers"));
             add_action("wp_footer", array($paymentUtils, "addDialogContainers"));
         }
         $post_hook = new MM_PostHooks();
         add_action("trashed_post", array($post_hook, "trashPostHandler"));
         add_action("deleted_post", array($post_hook, "deletePostHandler"));
         add_action('manage_posts_custom_column', array($post_hook, 'postCustomColumns'), 5, 2);
         add_action('manage_pages_custom_column', array($post_hook, 'postCustomColumns'), 5, 2);
         add_action('restrict_manage_posts', array($post_hook, 'editPostsFilter'));
         add_action('publish_page', array($post_hook, 'publishPageHandler'), 10, 2);
         /// saveCorePages
         if (class_exists("MM_CorePageEngine")) {
             $corePageEngine = new MM_CorePageEngine();
             add_action('save_post', array($corePageEngine, 'saveCorePages'), 10, 2);
             if (MM_Utils::inAdmin()) {
                 add_action('update_option_permalink_structure', array("MM_CorePageEngine", "createCorePageCache"));
             }
         }
         if (class_exists("MM_ProtectedContentEngine")) {
             $protectedContent = new MM_ProtectedContentEngine();
             add_action('save_post', array($protectedContent, 'saveSmartContent'), 10, 2);
         }
         add_action('wp_ajax_module-handle', array($this, 'handleAjaxCallback'));
         add_action('wp_ajax_nopriv_module-handle', array($this, 'handleAjaxCallback'));
         add_action('wp_ajax_member-types', array($this, 'handleAjaxCallback'));
         // load MemberMouse widgets
         if (class_exists("MM_SmartWidget")) {
             add_action('widgets_init', create_function('', 'return register_widget("MM_SmartWidget");'));
         }
         if (class_exists("MM_DripContentWidget")) {
             add_action('widgets_init', create_function('', 'return register_widget("MM_DripContentWidget");'));
         }
         // add event listeners
         if (class_exists("MM_Event")) {
             if (class_exists("MM_PushNotificationEngine")) {
                 $pne = new MM_PushNotificationEngine();
                 add_action(MM_Event::$MEMBER_ADD, array($pne, 'memberAdded'), 100, 2);
                 add_action(MM_Event::$MEMBER_STATUS_CHANGE, array($pne, 'memberStatusChanged'), 100, 2);
                 add_action(MM_Event::$MEMBER_MEMBERSHIP_CHANGE, array($pne, 'memberMembershipChanged'), 100, 2);
                 add_action(MM_Event::$MEMBER_ACCOUNT_UPDATE, array($pne, 'memberAccountUpdated'), 100, 2);
                 add_action(MM_Event::$MEMBER_DELETE, array($pne, 'memberDeleted'), 100, 2);
                 add_action(MM_Event::$BUNDLE_ADD, array($pne, 'bundleAdded'), 100, 2);
                 add_action(MM_Event::$BUNDLE_STATUS_CHANGE, array($pne, 'bundleStatusChanged'), 100, 2);
                 add_action(MM_Event::$PAYMENT_RECEIVED, array($pne, 'paymentReceived'), 100, 2);
                 add_action(MM_Event::$PAYMENT_REBILL, array($pne, 'rebillPaymentReceived'), 100, 2);
                 add_action(MM_Event::$PAYMENT_REBILL_DECLINED, array($pne, 'rebillPaymentDeclined'), 100, 2);
                 add_action(MM_Event::$REFUND_ISSUED, array($pne, 'refundIssued'), 100, 2);
                 add_action(MM_Event::$BILLING_SUBSCRIPTION_UPDATED, array($pne, 'billingSubscriptionUpdated'), 100, 2);
                 add_action(MM_Event::$COMMISSION_INITIAL, array($pne, 'initialCommission'), 100, 2);
                 add_action(MM_Event::$COMMISSION_REBILL, array($pne, 'rebillCommission'), 100, 2);
                 add_action(MM_Event::$CANCEL_COMMISSION, array($pne, 'cancelCommission'), 100, 2);
                 // isset methods are only necessary when customers are upgrading from MM 2.1.1 to 2.1.2. This can safely be removed
                 // once all customers are on 2.1.2 or above
                 if (isset(MM_Event::$BILLING_SUBSCRIPTION_REBILL_DATE_CHANGED)) {
                     add_action(MM_Event::$BILLING_SUBSCRIPTION_REBILL_DATE_CHANGED, array($pne, 'billingSubscriptionRebillDateChanged'), 100, 2);
                 }
                 if (isset(MM_Event::$BILLING_SUBSCRIPTION_CANCELED)) {
                     add_action(MM_Event::$BILLING_SUBSCRIPTION_CANCELED, array($pne, 'billingSubscriptionCanceled'), 100, 2);
                 }
                 if (isset(MM_Event::$AFFILIATE_INFO_CHANGED)) {
                     add_action(MM_Event::$AFFILIATE_INFO_CHANGED, array($pne, 'affiliateInfoChanged'), 100, 2);
                 }
             }
             if (class_exists("MM_CronEngine")) {
                 //add a special filter for the scheduled event queue check
                 add_filter('cron_schedules', array('MM_CronEngine', 'addQueueCheckIntervalRecurrenceOption'));
                 MM_CronEngine::setup();
             }
             if (class_exists("MM_AffiliateController")) {
                 MM_AffiliateController::setup();
             }
             if (class_exists("MM_EmailServiceProviderController")) {
                 MM_EmailServiceProviderController::setup();
             }
             if (class_exists("MM_MemberDetailsView")) {
                 $mdv = new MM_MemberDetailsView();
                 add_action(MM_Event::$PAYMENT_REBILL, array($mdv, 'handleRebillPaymentReceivedEvent'), 10, 2);
                 add_action(MM_Event::$PAYMENT_REBILL_DECLINED, array($mdv, 'handleRebillPaymentDeclinedEvent'), 10, 2);
             }
         }
         //add payment service hooks
         if (class_exists("MM_PaymentService")) {
             add_action('init', array('MM_PaymentService', "performInitActions"), 9);
         }
         //add extension hooks
         if (class_exists("MM_Extension")) {
             add_action("init", array('MM_Extension', "performInitActions"), 9);
         }
         register_activation_hook(__FILE__, array($this, 'install'));
         register_deactivation_hook(__FILE__, array($this, 'onDeactivate'));
         add_action('wp_footer', function () {
             if (MM_Session::sessionExists() && MM_Session::$MM_SESSION_DELAYED_CREATE === true) {
                 echo MM_Session::generateDelayedCreateJavascript();
             }
         });
     }
 }