Ejemplo n.º 1
0
function stcr_transition()
{
    $plugin = plugin();
    // Reference needed below.
    # Have we already done this?
    if ($plugin->options['stcr_transition_complete']) {
        return;
        // Not applicable.
    }
    # Do we have StCR options that we can import?
    if (!get_option('subscribe_reloaded_version')) {
        return;
        // Not applicable.
    }
    # StCR to consider during a transition.
    $subscribe_reloaded_show_subscription_box = get_option('subscribe_reloaded_show_subscription_box');
    $subscribe_reloaded_checked_by_default = get_option('subscribe_reloaded_checked_by_default');
    $subscribe_reloaded_enable_advanced_subscriptions = get_option('subscribe_reloaded_enable_advanced_subscriptions');
    $subscribe_reloaded_default_subscription_type = get_option('subscribe_reloaded_default_subscription_type');
    $subscribe_reloaded_from_name = get_option('subscribe_reloaded_from_name');
    $subscribe_reloaded_from_email = get_option('subscribe_reloaded_from_email');
    $subscribe_reloaded_enable_double_check = get_option('subscribe_reloaded_enable_double_check');
    $subscribe_reloaded_notify_authors = get_option('subscribe_reloaded_notify_authors');
    $subscribe_reloaded_admin_bcc = get_option('subscribe_reloaded_admin_bcc');
    $subscribe_reloaded_enable_admin_messages = get_option('subscribe_reloaded_enable_admin_messages');
    # Transition StCR site owners to Comment Mail.
    if (!filter_var($subscribe_reloaded_show_subscription_box, FILTER_VALIDATE_BOOLEAN)) {
        $plugin->options['comment_form_sub_template_enable'] = '0';
    }
    if (filter_var($subscribe_reloaded_enable_advanced_subscriptions, FILTER_VALIDATE_BOOLEAN)) {
        if ($subscribe_reloaded_default_subscription_type === '0') {
            $plugin->options['comment_form_default_sub_type_option'] = '';
        }
        if ($subscribe_reloaded_default_subscription_type === '1') {
            $plugin->options['comment_form_default_sub_type_option'] = 'comments';
        }
        if ($subscribe_reloaded_default_subscription_type === '2') {
            $plugin->options['comment_form_default_sub_type_option'] = 'comment';
        }
    }
    if (!filter_var($subscribe_reloaded_checked_by_default, FILTER_VALIDATE_BOOLEAN)) {
        $plugin->options['comment_form_default_sub_type_option'] = '';
    }
    if ($subscribe_reloaded_from_name && is_string($subscribe_reloaded_from_name)) {
        $plugin->options['from_name'] = trim($subscribe_reloaded_from_name);
    }
    if ($subscribe_reloaded_from_email && is_string($subscribe_reloaded_from_email)) {
        $plugin->options['from_email'] = trim($subscribe_reloaded_from_email);
    }
    if (!filter_var($subscribe_reloaded_enable_double_check, FILTER_VALIDATE_BOOLEAN)) {
        $plugin->options['auto_confirm_force_enable'] = '1';
    }
    if (!filter_var($subscribe_reloaded_notify_authors, FILTER_VALIDATE_BOOLEAN)) {
        $plugin->options['auto_subscribe_post_author_enable'] = '0';
    }
    if (filter_var($subscribe_reloaded_admin_bcc, FILTER_VALIDATE_BOOLEAN)) {
        $plugin->options['auto_subscribe_recipients'] = get_bloginfo('admin_email');
    }
    if (filter_var($subscribe_reloaded_enable_admin_messages, FILTER_VALIDATE_BOOLEAN)) {
        $plugin->options['auto_subscribe_recipients'] = get_bloginfo('admin_email');
    }
    # Save option changes, if any.
    $plugin->optionsSave($plugin->options);
    # Notice to existing StCR users now upgrading to Comment Mail.
    $notice = sprintf(__('<h3 style="font-weight:400; margin:0 0 1em 0;">Upgrading from <strong>Subscribe to Comments Reloaded</strong> (StCR) to <strong>%1$s&trade;</strong> %2$s — Welcome! :-)</h3>', 'comment-mail'), esc_html(NAME), $plugin->utils_fs->inlineIconSvg());
    $notice .= '<ul style="margin:0 0 1.3em 3em; list-style:disc;">' . '   <li>' . sprintf(__('%1$s automatically imported many of your StCR options (to learn what was imported, see <a href="http://comment-mail.com/r/kb-article-stcr-options-transitioned-by-comment-mail/" target="_blank">this article</a>). It\'s still a good idea to review your %1$s configuration though.', 'comment-mail'), esc_html(NAME)) . '</li>' . (ImportStcr::dataExists() ? '   <li>' . sprintf(__('<strong>IMPORTANT TIP:</strong> %1$s can import your existing StCR subscribers automatically too! <strong><a href="%2$s">Click here to review the StCR → %1$s import process</a></strong>.', 'comment-mail'), esc_html(NAME), esc_attr($plugin->utils_url->importExportMenuPageOnly())) . '</li>' : '') . '</ul>';
    $plugin->enqueueNotice($notice, ['persistent' => true, 'persistent_id' => 'upgrading-from-stcr']);
}
Ejemplo n.º 2
0
 /**
  * Constructs menu page heading.
  *
  * @since 141111 First documented version.
  *
  * @param string $title     Title of this menu page.
  * @param string $logo_icon Logo/icon for this menu page.
  *
  * @return string The heading for this menu page.
  */
 protected function heading($title, $logo_icon = '')
 {
     $title = (string) $title;
     $logo_icon = (string) $logo_icon;
     $heading = '';
     // Initialize.
     $heading .= '<div class="pmp-heading">' . "\n";
     $heading .= '  <div class="pmp-heading-options">' . "\n";
     if (IS_PRO) {
         // Display Pro Updater link?
         $heading .= '     <a href="' . esc_attr($this->plugin->utils_url->proUpdaterMenuPageOnly()) . '" ><i class="fa fa-magic"></i> ' . __('Pro Updater', 'comment-mail') . '</a>' . "\n";
     }
     $heading .= '     <a href="' . esc_attr($this->plugin->utils_url->subscribePage()) . '" target="_blank"><i class="fa fa-envelope-o"></i> ' . __('Newsletter (Subscribe)', 'comment-mail') . '</a>' . "\n";
     $heading .= '     <a href="' . esc_attr($this->plugin->utils_url->betaTesterPage()) . '" target="_blank"><i class="fa fa-envelope-o"></i> ' . __('Beta Testers', 'comment-mail') . '</a>' . "\n";
     $heading .= '  </div>' . "\n";
     $heading .= '  <div class="pmp-heading-options">' . "\n";
     $heading .= '     <a href="' . esc_attr('https://twitter.com/CommentMail') . '" target="_blank"><i class="si si-twitter"></i> ' . __('Twitter', 'comment-mail') . '</a>' . "\n";
     $heading .= '     <a href="' . esc_attr('https://www.facebook.com/Comment-Mail-565683256946855/') . '" target="_blank"><i class="si si-facebook"></i> ' . __('Facebook', 'comment-mail') . '</a>' . "\n";
     $heading .= '  </div>' . "\n";
     $heading .= '  <div class="pmp-version">' . "\n";
     $heading .= '     <span> ' . sprintf(__('%1$s&trade;%2$s v%3$s (<a href="https://comment-mail.com/changelog/" target="_blank">changelog</a>)', 'comment-mail'), esc_html(NAME), IS_PRO ? ' Pro' : '', esc_html(VERSION)) . '</span>' . "\n";
     $heading .= '  </div>' . "\n";
     if ($logo_icon && $this->plugin->options['menu_pages_logo_icon_enable']) {
         $heading .= '  <img class="pmp-logo-icon" src="' . $this->plugin->utils_url->to('/src/client-s/images/' . $logo_icon) . '" alt="' . esc_attr($title) . '" />' . "\n";
     }
     $heading .= '  <div class="pmp-heading-links">' . "\n";
     $heading .= '  <a href="' . esc_attr($this->plugin->utils_url->mainMenuPageOnly()) . '"' . ($this->plugin->utils_env->isMenuPage(GLOBAL_NS) ? ' class="pmp-active"' : '') . '>' . '<i class="fa fa-gears"></i> ' . __('Options', 'comment-mail') . '</a>' . "\n";
     if (IS_PRO) {
         // Display import options for pro users.
         $heading .= '  <a href="' . esc_attr($this->plugin->utils_url->importExportMenuPageOnly()) . '"' . ($this->plugin->utils_env->isMenuPage(GLOBAL_NS . '_import_export') ? ' class="pmp-active"' : '') . '>' . '<i class="fa fa-upload"></i> ' . __('Import/Export', 'comment-mail') . (!$this->plugin->utils_env->isMenuPage(GLOBAL_NS . '_import_export') && ImportStcr::dataExists() && !ImportStcr::everImported() ? '<span class="pmp-blink">' . __('StCR Auto-Import', 'comment-mail') . '</span>' : '') . '</a>' . "\n";
     } elseif (ImportStcr::dataExists()) {
         // Lite version exposes import functionality for StCR users.
         $heading .= '  <a href="' . esc_attr($this->plugin->utils_url->importExportMenuPageOnly()) . '"' . ($this->plugin->utils_env->isMenuPage(GLOBAL_NS . '_import_export') ? ' class="pmp-active"' : '') . '>' . '<i class="fa fa-upload"></i> ' . __('Import/Export', 'comment-mail') . (!$this->plugin->utils_env->isMenuPage(GLOBAL_NS . '_import_export') && ImportStcr::dataExists() && !ImportStcr::everImported() ? '<span class="pmp-blink">' . __('StCR Auto-Import', 'comment-mail') . '</span>' : '') . '</a>' . "\n";
     }
     $heading .= '  <a href="' . esc_attr($this->plugin->utils_url->emailTemplatesMenuPageOnly()) . '"' . ($this->plugin->utils_env->isMenuPage(GLOBAL_NS . '_email_templates') ? ' class="pmp-active"' : '') . '>' . '<i class="fa fa-code"></i> ' . __('Email Templates', 'comment-mail') . '</a>' . "\n";
     $heading .= '  <a href="' . esc_attr($this->plugin->utils_url->siteTemplatesMenuPageOnly()) . '"' . ($this->plugin->utils_env->isMenuPage(GLOBAL_NS . '_site_templates') ? ' class="pmp-active"' : '') . '>' . '<i class="fa fa-code"></i> ' . __('Site Templates', 'comment-mail') . '</a>' . "\n";
     $heading .= '  <a href="#" data-pmp-action="' . esc_attr($this->plugin->utils_url->restoreDefaultOptions()) . '" data-pmp-confirmation="' . esc_attr(__('Restore default plugin options? You will lose all of your current settings! Are you absolutely sure?', 'comment-mail')) . '"> ' . __('Restore', 'comment-mail') . ' <i class="fa fa-ambulance"></i></button>' . '</a>' . "\n";
     if (!IS_PRO) {
         // Display pro preview/upgrade related links?
         $heading .= '  <a href="' . esc_attr($this->plugin->utils_url->proPreview()) . '"' . ($this->plugin->utils_env->isProPreview() ? ' class="pmp-active"' : '') . '>' . '<i class="fa fa-eye"></i> ' . __('Preview Pro Features', 'comment-mail') . '</a>' . "\n";
         $heading .= '  <a href="' . esc_attr($this->plugin->utils_url->productPage()) . '" target="_blank"><i class="fa fa-heart-o"></i> ' . __('Pro Upgrade', 'comment-mail') . '</a>' . "\n";
     }
     $heading .= '  </div>' . "\n";
     $heading .= '</div>' . "\n";
     return $heading;
     // Menu page heading.
 }
Ejemplo n.º 3
0
 /**
  * Restores defaults options.
  *
  * @since 141111 First documented version.
  *
  * @param mixed $request_args Input argument(s).
  */
 protected function restoreDefaultOptions($request_args)
 {
     $request_args = null;
     // Not used here.
     if (!current_user_can($this->plugin->cap)) {
         return;
         // Unauthenticated; ignore.
     }
     delete_option(GLOBAL_NS . '_options');
     $this->plugin->options = $this->plugin->default_options;
     ImportStcr::deletePostMetaKeys();
     // Reset import tracking.
     $notice_markup = sprintf(__('%1$s&trade; default options restored successfully.', 'comment-mail'), esc_html(NAME));
     $this->plugin->enqueueUserNotice($notice_markup, ['transient' => true]);
     wp_redirect($this->plugin->utils_url->defaultOptionsRestored());
     exit;
 }
Ejemplo n.º 4
0
 /**
  * Creates admin menu pages.
  *
  * @since       141111 First documented version.
  *
  * @attaches-to `admin_menu` action.
  */
 public function addMenuPages()
 {
     if (!current_user_can($this->manage_cap)) {
         if (!current_user_can($this->cap)) {
             return;
             // Do not add meta boxes.
         }
     }
     // Menu page icon uses an SVG graphic.
     $icon = $this->utils_fs->inlineIconSvg();
     $icon = $this->utils_markup->colorSvgMenuIcon($icon);
     $divider = '<span style="display:block; padding:0; margin:0 0 12px 0; height:1px; line-height:1px; background:#CCCCCC; opacity:0.1;"></span>';
     $child_branch_indent = '<span style="display:inline-block; margin-left:.5em; position:relative; top:-.2em; left:-.2em; font-weight:normal; opacity:0.2;">&#42774;</span> ';
     $current_menu_page = $this->utils_env->currentMenuPage();
     // Current menu page slug.
     // Menu page titles use UTF-8 char: `⥱`; <http://unicode-table.com/en/2971/>.
     /* ----------------------------------------- */
     $_menu_title = NAME . (IS_PRO ? ' <sup style="font-size:60%; line-height:1;">Pro</sup>' : '');
     $_page_title = NAME . '&trade;';
     $_menu_position = apply_filters(__METHOD__ . '_position', '25.00001');
     $this->menu_page_hooks[GLOBAL_NS] = add_menu_page($_page_title, $_menu_title, $this->cap, GLOBAL_NS, [$this, 'menuPageOptions'], 'data:image/svg+xml;base64,' . base64_encode($icon), $_menu_position);
     add_action('load-' . $this->menu_page_hooks[GLOBAL_NS], [$this, 'menuPageOptionsScreen']);
     unset($_menu_title, $_page_title, $_menu_position);
     // Housekeeping.
     /* ----------------------------------------- */
     $_menu_title = __('Config. Options', 'comment-mail');
     $_page_title = NAME . '&trade; &#8594; ' . __('Config. Options', 'comment-mail');
     add_submenu_page(GLOBAL_NS, $_page_title, $_menu_title, $this->cap, GLOBAL_NS, [$this, 'menuPageOptions']);
     if (IS_PRO || ImportStcr::dataExists()) {
         $_menu_title = '<small><em>' . $child_branch_indent . __('Import/Export', 'comment-mail') . '</em></small>';
         $_page_title = NAME . '&trade; &#8594; ' . __('Import/Export', 'comment-mail');
         //$_menu_parent                                          = $current_menu_page === GLOBAL_NS.'_import_export' ? GLOBAL_NS : NULL;
         $this->menu_page_hooks[GLOBAL_NS . '_import_export'] = add_submenu_page(GLOBAL_NS, $_page_title, $_menu_title, $this->cap, GLOBAL_NS . '_import_export', [$this, 'menuPageImportExport']);
         add_action('load-' . $this->menu_page_hooks[GLOBAL_NS . '_import_export'], [$this, 'menuPageImportExportScreen']);
     }
     $_menu_title = '<small><em>' . $child_branch_indent . __('Email Templates', 'comment-mail') . '</em></small>';
     $_page_title = NAME . '&trade; &#8594; ' . __('Email Templates', 'comment-mail');
     //$_menu_parent                                            = $current_menu_page === GLOBAL_NS.'_email_templates' ? GLOBAL_NS : NULL;
     $this->menu_page_hooks[GLOBAL_NS . '_email_templates'] = add_submenu_page(GLOBAL_NS, $_page_title, $_menu_title, $this->cap, GLOBAL_NS . '_email_templates', [$this, 'menuPageEmailTemplates']);
     add_action('load-' . $this->menu_page_hooks[GLOBAL_NS . '_email_templates'], [$this, 'menuPageEmailTemplatesScreen']);
     $_menu_title = '<small><em>' . $child_branch_indent . __('Site Templates', 'comment-mail') . '</em></small>';
     $_page_title = NAME . '&trade; &#8594; ' . __('Site Templates', 'comment-mail');
     //$_menu_parent                                           = $current_menu_page === GLOBAL_NS.'_site_templates' ? GLOBAL_NS : NULL;
     $this->menu_page_hooks[GLOBAL_NS . '_site_templates'] = add_submenu_page(GLOBAL_NS, $_page_title, $_menu_title, $this->cap, GLOBAL_NS . '_site_templates', [$this, 'menuPageSiteTemplates']);
     add_action('load-' . $this->menu_page_hooks[GLOBAL_NS . '_site_templates'], [$this, 'menuPageSiteTemplatesScreen']);
     unset($_menu_title, $_page_title, $_menu_parent);
     // Housekeeping.
     /* ----------------------------------------- */
     $_menu_title = $divider . __('Subscriptions', 'comment-mail');
     $_page_title = NAME . '&trade; &#8594; ' . __('Subscriptions', 'comment-mail');
     $this->menu_page_hooks[GLOBAL_NS . '_subs'] = add_submenu_page(GLOBAL_NS, $_page_title, $_menu_title, $this->manage_cap, GLOBAL_NS . '_subs', [$this, 'menuPageSubs']);
     add_action('load-' . $this->menu_page_hooks[GLOBAL_NS . '_subs'], [$this, 'menuPageSubsScreen']);
     $_menu_title = $child_branch_indent . __('Event Log', 'comment-mail');
     $_page_title = NAME . '&trade; &#8594; ' . __('Sub. Event Log', 'comment-mail');
     $this->menu_page_hooks[GLOBAL_NS . '_sub_event_log'] = add_submenu_page(GLOBAL_NS, $_page_title, $_menu_title, $this->manage_cap, GLOBAL_NS . '_sub_event_log', [$this, 'menuPageSubEventLog']);
     add_action('load-' . $this->menu_page_hooks[GLOBAL_NS . '_sub_event_log'], [$this, 'menuPageSubEventLogScreen']);
     unset($_menu_title, $_page_title);
     // Housekeeping.
     /* ----------------------------------------- */
     $_menu_title = $divider . __('Mail Queue', 'comment-mail');
     $_page_title = NAME . '&trade; &#8594; ' . __('Mail Queue', 'comment-mail');
     $this->menu_page_hooks[GLOBAL_NS . '_queue'] = add_submenu_page(GLOBAL_NS, $_page_title, $_menu_title, $this->manage_cap, GLOBAL_NS . '_queue', [$this, 'menuPageQueue']);
     add_action('load-' . $this->menu_page_hooks[GLOBAL_NS . '_queue'], [$this, 'menuPageQueueScreen']);
     $_menu_title = $child_branch_indent . __('Event Log', 'comment-mail');
     $_page_title = NAME . '&trade; &#8594; ' . __('Queue Event Log', 'comment-mail');
     $this->menu_page_hooks[GLOBAL_NS . '_queue_event_log'] = add_submenu_page(GLOBAL_NS, $_page_title, $_menu_title, $this->manage_cap, GLOBAL_NS . '_queue_event_log', [$this, 'menuPageQueueEventLog']);
     add_action('load-' . $this->menu_page_hooks[GLOBAL_NS . '_queue_event_log'], [$this, 'menuPageQueueEventLogScreen']);
     unset($_menu_title, $_page_title);
     // Housekeeping.
     /* ----------------------------------------- */
     /* ----------------------------------------- */
 }