/** * Dispatcher of module */ public function init() { if (empty($_REQUEST['module']) || empty($_REQUEST['hook'])) { wp_redirect(home_url()); exit; } $module_name = $_REQUEST['module']; $hook = $_REQUEST['hook']; $extension = !empty($_REQUEST['extension']) ? in_array($_REQUEST['extension'], array(WYSIJA, WYSIJANLP)) ? $_REQUEST['extension'] : WYSIJA : WYSIJA; $hook_params = array_merge($_REQUEST, array('controller_object' => $this)); $this->subtitle = WYSIJA_module::get_instance_by_name($module_name, $extension)->{'hook_' . $hook}($hook_params); }
function __construct() { parent::__construct(); // wysija form shortcode add_shortcode('wysija_form', array($this, 'scan_form_shortcode')); // wysija total of subscribers shortcode add_shortcode('wysija_subscribers_count', array($this, 'scan_subscribers_count_shortcode')); // init shortcode [wysija_archive] require_once WYSIJA_CORE . 'controller.php'; require_once WYSIJA_CORE . 'module' . DS . 'module.php'; // @todo: move to autoloader $archive_std = WYSIJA_module::get_instance_by_name('archive_std'); // implement hook "wysija_front_init() if (!empty($archive_std) && is_a($archive_std, 'WYSIJA_module')) { $archive_std->front_init(); } /* We try to process the least possible code */ if (isset($_REQUEST['wysija-page']) || isset($_REQUEST['wysija-launch'])) { if (defined('DOING_AJAX')) { add_action('wp_ajax_nopriv_wysija_ajax', array($this, 'ajax')); } else { $paramscontroller = $_REQUEST['controller']; //this is an exception on one server this params stats was not accepted if ($paramscontroller == 'stat') { $paramscontroller = 'stats'; } $this->controller = WYSIJA::get($paramscontroller, 'controller'); if (isset($_REQUEST['action']) && method_exists($this->controller, $_REQUEST['action'])) { add_action('init', array($this->controller, $_REQUEST['action'])); //$this->controller->$_REQUEST['action'](); } else { $this->error('Action does not exist.'); } if (isset($_REQUEST['wysija-page'])) { /* set the content filter to replace the shortcode */ add_filter('wp_title', array($this, 'meta_page_title')); add_filter('the_title', array($this, 'scan_title')); add_filter('the_content', array($this, 'scan_content'), 98); if (isset($_REQUEST['message_success'])) { add_filter('the_content', array($this, 'scan_content_NLform'), 99); } } } } else { add_filter('the_content', array($this, 'scan_content_NLform'), 99); //if the comment form checkbox option is activated we add some hooks to process it $model_config = WYSIJA::get('config', 'model'); if ($model_config->getValue('commentform')) { add_action('comment_form', array($this, 'comment_form_extend')); add_action('comment_post', array($this, 'comment_posted'), 60, 2); } // if the register form checkbox option is activated we add some hooks to process it if ($model_config->getValue('registerform')) { if (is_multisite()) { add_action('signup_extra_fields', array($this, 'register_form_extend')); // we need this condition otherwise we will send two confirmation emails when on ms with buddypress if (!WYSIJA::is_plugin_active('buddypress/bp-loader.php')) { add_filter('wpmu_validate_user_signup', array($this, 'registerms_posted'), 60, 3); } } else { add_action('register_form', array($this, 'register_form_extend')); add_action('register_post', array($this, 'register_posted'), 60, 3); } // special case when buddypress is activated if (WYSIJA::is_plugin_active('buddypress/bp-loader.php')) { add_action('bp_after_signup_profile_fields', array($this, 'register_form_bp_extend')); add_action('bp_signup_validate', array($this, 'register_bp'), 60, 3); // we can have just one confirmation email for the wp user and the wysija confirmation when bp and multisite are activated if (is_multisite()) { add_action('wpmu_activate_user', array($this, 'wpmu_activate_user')); } } } } }