示例#1
0
 function wpresponder_init_method()
 {
     //load the scripts only for the administrator.
     global $current_user;
     global $db_checker;
     $activationDate = get_option("_wpr_NEWAGE_activation");
     if (empty($activationDate) || !$activationDate) {
         $timeNow = time();
         update_option("_wpr_NEWAGE_activation", $timeNow);
         /*
          * Because of the lack of tracking that was done in previous versions
          * of the blog category subscriptions, this version will deliver
          * blog posts to blog category subscribers ONLY after this date 
          * This was done to prevent triggering a full delivery of all 
          * blog posts in all categories to the respective category subscribers
          * on upgrade to this version.
          * I came up with the lousy name. Was a good idea at the time. 
          */
     }
     if (isset($_GET['wpr-optin']) && $_GET['wpr-optin'] == 1) {
         require "optin.php";
         exit;
     }
     if (isset($_GET['wpr-optin']) && $_GET['wpr-optin'] == 2) {
         require "verify.php";
         exit;
     }
     //a subscriber is trying to confirm their subscription.
     if (isset($_GET['wpr-confirm']) && $_GET['wpr-confirm'] != 2) {
         include "confirm.php";
         exit;
     }
     if (isset($_GET['wpr-vb'])) {
         $vb = intval($_GET['wpr-vb']);
         if (isset($_GET['wpr-vb']) && $vb > 0) {
             require "broadcast_html_frame.php";
             exit;
         }
     }
     require WPR_PLUGIN_DIR . "/proxy.php";
     do_action("_wpr_init");
     $admin_page_definitions = $GLOBALS['admin_pages_definitions'];
     foreach ($admin_page_definitions as $item) {
         if (isset($item['legacy']) && $item['legacy'] === 0) {
             $slug = str_replace("_wpr/", "", $item['menu_slug']);
             $actionName = "_wpr_" . $slug . "_handle";
             $handler = "_wpr_" . $slug . "_handler";
             add_action($actionName, $handler);
         }
     }
     _wpr_attach_cron_actions_to_functions();
     add_action('admin_menu', 'wpr_admin_menu');
     /*
      * This is needed until all the pages are migrated to the
      * MVC format. 
      */
     if (isset($_GET['page']) && (preg_match("@^wpresponder/.*@", $_GET['page']) || preg_match("@^_wpr/.*@", $_GET['page']))) {
         _wpr_handle_post();
         _wpr_run_controller();
     }
     //a visitor is trying to subscribe.
     $directory = str_replace(basename(__FILE__), "", __FILE__);
     $containingdirectory = basename($directory);
     $url = get_bloginfo("url");
     wp_register_script("jqueryui-full", "{$url}/?wpr-file=jqui.js");
     wp_register_script("wpresponder-tabber", "{$url}/?wpr-file=tabber.js");
     wp_register_script("wpresponder-ckeditor", "/" . PLUGINDIR . "/" . $containingdirectory . "/ckeditor/ckeditor.js");
     wp_register_script("wpresponder-addedit", "/" . PLUGINDIR . "/" . $containingdirectory . "/script.js");
     /*
      * The following code ensures that the WP Responder's crons are always scheduled no matter what
      * Sometimes the crons go missing from cron's registry. Only the great zeus knows why that happens. 
      * The following code ensures that the crons are always scheduled immediately after they go missing. 
      * It also unenqueues duplicate crons that get enqueued when the plugin is deactivated and then reactivated.
      */
     //run the single instances every day once:
     $last_run_esic = intval(_wpr_option_get("_wpr_ensure_single_instances_of_crons_last_run"));
     $timeSinceLast = time() - $last_run_esic;
     if ($timeSinceLast > WPR_ENSURE_SINGLE_INSTANCE_CHECK_PERIODICITY) {
         do_action("_wpr_ensure_single_instances_of_crons");
         $currentTime = time();
         _wpr_option_set("_wpr_ensure_single_instances_of_crons_last_run", $currentTime);
     }
     if (isset($_GET['wpr-confirm']) && $_GET['wpr-confirm'] == 2) {
         include "confirmed.php";
         exit;
     }
     if (isset($_GET['wpr-manage'])) {
         include "manage.php";
         exit;
     }
     if (isset($_GET['wpr-admin-action'])) {
         switch ($_GET['wpr-admin-action']) {
             case 'preview_email':
                 include "preview_email.php";
                 exit;
                 break;
             case 'view_recipients':
                 include "view_recipients.php";
                 exit;
                 break;
             case 'filter':
                 include "filter.php";
                 exit;
                 break;
             case 'delete_mailout':
                 include "delmailout.php";
                 exit;
                 break;
             case '':
                 break;
         }
     }
     if (isset($_GET['wpr-template'])) {
         include "templateproxy.php";
         exit;
     }
     add_action('admin_init', 'wpr_enqueue_admin_scripts');
     add_action('admin_menu', 'wpresponder_meta_box_add');
     //count all non-WP Autoresponder emails so that the hourly limit can be suitably adjusted
     add_filter("wp_mail", "_wpr_non_wpr_email_sent");
     add_action('edit_post', "wpr_edit_post_save");
     add_action('load-post-new.php', 'wpr_enqueue_post_page_scripts');
     add_action('admin_action_edit', 'wpr_enqueue_post_page_scripts');
     add_action('publish_post', "wpr_add_post_save");
 }
示例#2
0
function _wpr_ensure_single_instance_of_cron_is_registered()
{
    /*
     * The following code ensures that the WP Responder's crons are always scheduled no matter what
     * Sometimes the crons go missing from cron's registry. Only the great zeus knows why that happens.
     * The following code ensures that the crons are always scheduled immediately after they go missing.
     * It also unenqueues duplicate crons that get enqueued when the plugin is deactivated and then reactivated.
     */
    $last_run_esic = intval(_wpr_option_get("_wpr_ensure_single_instances_of_crons_last_run"));
    $timeSinceLast = time() - $last_run_esic;
    if ($timeSinceLast > WPR_ENSURE_SINGLE_INSTANCE_CHECK_PERIODICITY) {
        do_action("_wpr_ensure_single_instances_of_crons");
        $currentTime = time();
        _wpr_option_set("_wpr_ensure_single_instances_of_crons_last_run", $currentTime);
    }
}