/** * Class constructor. * * @since 141111 First documented version. */ public function __construct() { parent::__construct(); $this->maybeDoSubActions(); $this->maybeDoWebhookActions(); $this->maybeDoMenuPageActions(); }
/** * Class constructor. * * @since 141111 First documented version. * * @param array $request_args Arguments to the constructor. * These should NOT be trusted; they come from a `$_REQUEST` action. * * @throws \exception If a security flag is triggered on `$this->data_file`. */ public function __construct(array $request_args = []) { parent::__construct(); $default_request_args = ['data' => '', 'data_file' => '', 'process_confirmations' => false, 'max_limit' => 5000]; $request_args = array_merge($default_request_args, $request_args); $request_args = array_intersect_key($request_args, $default_request_args); $this->data = trim((string) $request_args['data']); $this->data_file = trim((string) $request_args['data_file']); if ($this->data_file) { // Run security flag checks on the path. $this->plugin->utils_fs->checkPathSecurity($this->data_file, true); } if ($this->data_file) { $this->data = ''; // Favor file over raw data. } $this->process_confirmations = (bool) $request_args['process_confirmations']; $this->max_limit = (int) $request_args['max_limit']; if ($this->max_limit < 1) { $this->max_limit = 1; // At least one. } $upper_max_limit = (int) apply_filters(__CLASS__ . '_upper_max_limit', 5000); if ($this->max_limit > $upper_max_limit) { $this->max_limit = $upper_max_limit; } $this->total_imported_subs = 0; // Initialize. $this->errors = []; // Initialize. $this->maybeImport(); }
/** * Class constructor. * * @since 141111 First documented version. * * @param string $file Template file. * @param string|null $type Template type. Defaults to an empty string. * An empty string (or `NULL`) indicates the currently configured type. * @param bool $force_default Force default template? * * @throws \exception If `$file` is empty. */ public function __construct($file, $type = '', $force_default = false) { parent::__construct(); if ($type) { // Use a specific type? $this->type = trim(strtolower((string) $type)); } if (!$this->type) { $this->type = $this->plugin->options['template_type']; } if (!$this->type) { // Empty type property? throw new \exception(__('Empty type.', 'comment-mail')); } $this->file = (string) $file; // Initialize. $this->file = $this->plugin->utils_string->trimDeep($this->file, '', '/'); $this->file = $this->plugin->utils_fs->nSeps($this->file); if (!$this->file) { // Empty file property? throw new \exception(__('Empty file.', 'comment-mail')); } $this->snippet_sub_dir = dirname($this->file) . '/snippet'; $this->file_path = $this->getFilePath(); $this->force_default = (bool) $force_default; $this->file_contents = $this->getFileContents(); $this->current_vars = []; // Initialize. }
/** * Class constructor. * * @since 141111 First documented version. * * @param array $entry Log entry data; w/ sub. now. * @param array $before Log entry data; w/ sub. before. * Not applicable w/ insertions. * * @throws \exception If `$entry` is missing required keys. */ public function __construct(array $entry, array $before = []) { parent::__construct(); $defaults = ['sub_id' => 0, 'key' => '', 'oby_sub_id' => 0, 'user_id' => 0, 'post_id' => 0, 'comment_id' => 0, 'deliver' => '', 'fname' => '', 'lname' => '', 'email' => '', 'ip' => '', 'region' => '', 'country' => '', 'status' => '', 'event' => '', 'user_initiated' => 0, 'time' => time(), 'key_before' => '', 'user_id_before' => 0, 'post_id_before' => 0, 'comment_id_before' => 0, 'deliver_before' => '', 'fname_before' => '', 'lname_before' => '', 'email_before' => '', 'ip_before' => '', 'region_before' => '', 'country_before' => '', 'status_before' => '']; # Sub ID auto-fill from subscription data. if (empty($entry['sub_id']) && !empty($entry['ID'])) { $entry['sub_id'] = $entry['ID']; } # IP, region, country; auto-fill from subscription data. foreach (['ip', 'region', 'country'] as $_key) { if (empty($entry[$_key])) { // Coalesce; giving precedence to the `last_` value. $entry[$_key] = $this->notEmptyCoalesce($entry['last_' . $_key], $entry['insertion_' . $_key]); } if (empty($before[$_key])) { // Coalesce; giving precedence to the `last_` value. $before[$_key] = $this->notEmptyCoalesce($before['last_' . $_key], $before['insertion_' . $_key]); } } unset($_key); // Just a little housekeeping. # Auto-suffix subscription data from `_before`. foreach ($before as $_key => $_value) { $before[$_key . '_before'] = $_value; unset($before[$_key]); // Unset. } unset($_key, $_value); // Housekeeping. $this->entry = array_merge($defaults, $entry, $before); $this->entry = array_intersect_key($this->entry, $defaults); $this->entry = $this->plugin->utils_db->typifyDeep($this->entry); $this->maybeInsert(); // Record event; if applicable. }
/** * Class constructor. * * @since 141111 First documented version. * * @param string $prev_version Version they are upgrading from. */ public function __construct($prev_version) { parent::__construct(); $this->prev_version = (string) $prev_version; $this->runHandlers(); // Run upgrade(s). }
/** * Class constructor. * * @since 141111 First documented version. * * @param array $request_args Arguments to the constructor. * These should NOT be trusted; they come from a `$_REQUEST` action. */ public function __construct(array $request_args = []) { parent::__construct(); $default_request_args = ['max_post_ids_limit' => 15]; $request_args = array_merge($default_request_args, $request_args); $request_args = array_intersect_key($request_args, $default_request_args); $this->max_post_ids_limit = (int) $request_args['max_post_ids_limit']; if ($this->max_post_ids_limit < 1) { $this->max_post_ids_limit = 1; // At least one. } $upper_max_post_ids_limit = (int) apply_filters(__CLASS__ . '_upper_max_post_ids_limit', 1000); if ($this->max_post_ids_limit > $upper_max_post_ids_limit) { $this->max_post_ids_limit = $upper_max_post_ids_limit; } $this->has_more_posts_to_import = false; // Initialize. $this->unimported_post_ids = $this->unimportedPostIds($this->max_post_ids_limit + 1); if (count($this->unimported_post_ids) > $this->max_post_ids_limit) { $this->has_more_posts_to_import = true; // Yes, there are more to import later. $this->unimported_post_ids = array_slice($this->unimported_post_ids, 0, $this->max_post_ids_limit); } $this->imported_post_ids = []; // Initialize. $this->total_imported_post_ids = $this->total_imported_subs = $this->total_created_subs = $this->total_skipped_subs = 0; $this->maybeImport(); // Handle importation. }
/** * Class constructor. * * @since 141111 First documented version. * * @param int|string $post_id Post ID. * @param array $args Any additional behavioral args. */ public function __construct($post_id, array $args = []) { parent::__construct(); $post_id = (int) $post_id; if ($post_id) { // Need to have this. $this->post = get_post($post_id); } $defaults_args = ['process_events' => true]; $args = array_merge($defaults_args, $args); $args = array_intersect_key($args, $defaults_args); if ($this->post && $this->post->post_author) { if ($this->plugin->options['auto_subscribe_post_author_enable']) { $this->post_author = new \WP_User($this->post->post_author); } } $this->post_types = strtolower($this->plugin->options['auto_subscribe_post_types']); $this->post_types = preg_split('/[;,\\s]+/', $this->post_types, null, PREG_SPLIT_NO_EMPTY); $enabled_post_types = strtolower($this->plugin->options['enabled_post_types']); $enabled_post_types = preg_split('/[;,\\s]+/', $enabled_post_types, null, PREG_SPLIT_NO_EMPTY); if ($enabled_post_types && $this->post_types) { foreach ($this->post_types as $_key => $_post_type) { if (!in_array($_post_type, $enabled_post_types, true)) { unset($this->post_types[$_key]); } } unset($_key, $_post_type); // Housekeeping. } $this->process_events = (bool) $args['process_events']; $this->maybeAutoInject(); }
/** * Class constructor. * * @param int|string $user_id User ID. * * @since 141111 First documented version. */ public function __construct($user_id) { parent::__construct(); if ($user_id = (int) $user_id) { $this->user = new \WP_User($user_id); } $this->maybeUpdateSubs(); }
/** * Class constructor. * * @param int|string $user_id User ID. * @param int|string $blog_id Blog ID. Defaults to `0` (current blog). * * @since 141111 First documented version. */ public function __construct($user_id, $blog_id = 0) { parent::__construct(); $this->switched_blog = false; $this->user_id = (int) $user_id; $this->blog_id = (int) $blog_id; $this->maybePurgeSubs(); }
/** * Class constructor. * * @since 150422 Rewrite. */ public function __construct() { parent::__construct(); $this->home_url = home_url('/'); $this->default_feed = get_default_feed(); $this->seo_friendly_permalinks = (bool) get_option('permalink_structure'); $this->feed_types = array_unique(array($this->default_feed, 'rdf', 'rss', 'rss2', 'atom')); }
/** * Class constructor. * * @since 141111 First documented version. * * @param array $request_args Arguments to the constructor. * These should NOT be trusted; they come from a `$_REQUEST` action. */ public function __construct(array $request_args = []) { parent::__construct(); $default_request_args = []; $request_args = array_merge($default_request_args, $request_args); $request_args = array_intersect_key($request_args, $default_request_args); $this->maybeExport(); }
/** * Class constructor. * * @since 141111 First documented version. * * @param int|string $comment_id Comment ID. * @param int|string $comment_status Initial comment status. * * One of the following: * - `0` (aka: ``, `hold`, `unapprove`, `unapproved`, `moderated`), * - `1` (aka: `approve`, `approved`), * - or `trash`, `post-trashed`, `spam`, `delete`. */ public function __construct($comment_id, $comment_status) { parent::__construct(); $this->comment_id = (int) $comment_id; $this->comment_status = $this->plugin->utils_db->commentStatusI18n($comment_status); $this->maybeInjectSub(); $this->maybeInjectQueue(); $this->maybeProcessQueueInRealtime(); }
/** * Class constructor. * * @since 141111 First documented version. */ public function __construct() { parent::__construct(); $this->plugin->setup(); $this->createDbTables(); $this->maybeEnqueueNotice(); $this->setInstallTime(); stcr_transition(); }
/** * Class constructor. * * @since 141111 First documented version. */ public function __construct() { parent::__construct(); if ($this->plugin->enable_hooks) { return; // Not a good idea. } $this->plugin->setup(); // Setup. if (!defined('WP_UNINSTALL_PLUGIN')) { return; // Disallow. } if (empty($GLOBALS[GLOBAL_NS . '_uninstalling'])) { return; // Expecting uninstall file. } if ($this->plugin->options['uninstall_safeguards_enable']) { return; // Nothing to do here; safeguarding. } if (!current_user_can($this->plugin->uninstall_cap)) { return; // Extra layer of security. } if (!current_user_can($this->plugin->cap)) { return; // Extra layer of security. } $this->deleteOptions(); $this->deleteNotices(); $this->deleteInstallTime(); $this->deleteOptionKeys(); $this->deleteTransientKeys(); $this->deletePostMetaKeys(); $this->deleteUserMetaKeys(); $this->clearCronHooks(); $this->dropDbTables(); if (is_multisite() && is_array($child_blogs = wp_get_sites())) { foreach ($child_blogs as $_child_blog) { switch_to_blog($_child_blog['blog_id']); $this->deleteOptions(); $this->deleteNotices(); $this->deleteInstallTime(); $this->deleteOptionKeys(); $this->deleteTransientKeys(); $this->deletePostMetaKeys(); $this->deleteUserMetaKeys(); $this->clearCronHooks(); $this->dropDbTables(); restore_current_blog(); } } unset($_child_blog); // Housekeeping. }
/** * Class constructor. * * @since 141111 First documented version. * * @param array $args Configuration args. */ public function __construct(array $args = []) { parent::__construct(); $default_args = ['ns_id_suffix' => '', 'ns_name_suffix' => '', 'class_prefix' => '']; $args = array_merge($default_args, $args); $args = array_intersect_key($args, $default_args); $this->ns_id_suffix = trim((string) $args['ns_id_suffix']); $this->ns_name_suffix = trim((string) $args['ns_name_suffix']); $this->class_prefix = trim((string) $args['class_prefix']); }
/** * Class constructor. * * @param int|string $comment_id Comment ID. * * @since 141111 First documented version. */ public function __construct($comment_id) { parent::__construct(); $comment_id = (int) $comment_id; if ($comment_id) { // If possible. $this->comment = get_comment($comment_id); } $this->maybeInject(); }
/** * Class constructor. * * @since 141111 First documented version. * * @param int|string $new_comment_status New comment status. * * One of the following: * - `0` (aka: ``, `hold`, `unapprove`, `unapproved`, `moderated`), * - `1` (aka: `approve`, `approved`), * - or `trash`, `post-trashed`, `spam`, `delete`. * @param int|string $old_comment_status Old comment status. * * One of the following: * - `0` (aka: ``, `hold`, `unapprove`, `unapproved`, `moderated`), * - `1` (aka: `approve`, `approved`), * - or `trash`, `post-trashed`, `spam`, `delete`. * @param \WP_Comment|null $comment Comment object (now). */ public function __construct($new_comment_status, $old_comment_status, \WP_Comment $comment = null) { parent::__construct(); $this->comment = $comment; // \WP_Comment|null. $this->new_comment_status = $this->plugin->utils_db->commentStatusI18n($new_comment_status); $this->old_comment_status = $this->plugin->utils_db->commentStatusI18n($old_comment_status); $this->maybeInjectQueue(); $this->maybePurgeSubs(); }
/** * Class constructor. * * @since 141111 First documented version. */ public function __construct() { parent::__construct(); if (is_admin()) { return; // Not applicable. } $this->maybeEnqueueLoginFormSsoScripts(); $this->maybeEnqueueCommentFormSsoScripts(); $this->maybeEnqueueCommentFormSubScripts(); }
/** * Class constructor. * * @param int|string $post_id Post ID. * @param int|string $comment_id Comment ID. * @param int|string $user_id User ID. * * @since 141111 First documented version. */ public function __construct($post_id, $comment_id = 0, $user_id = 0) { parent::__construct(); $this->post_id = (int) $post_id; $this->comment_id = (int) $comment_id; $this->user_id = (int) $user_id; $this->purged = 0; // Initialize. $this->maybePurge(); // If applicable. }
/** * Constructor. * * @since 150422 Rewrite. * * @param string $menu_page Menu page. */ public function __construct($menu_page = '') { parent::__construct(); if ($menu_page) { switch ($menu_page) { case 'options': new MenuPageOptions(); break; } } }
/** * Class constructor. * * @since 141111 First documented version. * * @param string $which Which menu page to display? */ public function __construct($which) { parent::__construct(); $which = $this->plugin->utils_string->trim(strtolower((string) $which), '', '_'); $which = preg_replace_callback('/_(.)/', function ($m) { return strtoupper($m[1]); }, $which); if ($which && method_exists($this, $which . 'X')) { $this->{$which . 'X'}(); } }
/** * Class constructor. * * @since 141111 First documented version. * * @param string $string String to parse. * @param array $vars Any contextual vars needed by expressions. */ public function __construct($string, array $vars = []) { parent::__construct(); $this->string = (string) $string; $this->vars = (array) $vars; $this->tokens = []; # Accept shortcode variable keys too. foreach ($this->vars as $_key => &$_value) { $this->vars[trim($_key, '[]')] =& $_value; } unset($_key, $_value); // Housekeeping. }
/** * Class constructor. * * @since 150422 Rewrite. */ public function __construct() { parent::__construct(); $closures_dir = dirname(dirname(__FILE__)) . '/closures/Shared'; $self = $this; // Reference for closures. foreach (scandir($closures_dir) as $_closure) { if (substr($_closure, -4) === '.php') { require $closures_dir . '/' . $_closure; } } unset($_closure); // Housekeeping. }
/** * Class constructor. * * @since 150422 Rewrite. */ public function __construct() { parent::__construct(); if (empty($_REQUEST[GLOBAL_NS])) { return; // Not applicable. } foreach ((array) $_REQUEST[GLOBAL_NS] as $_action => $_args) { if (is_string($_action) && method_exists($this, $_action)) { if (in_array($_action, $this->allowed_actions, true)) { $this->{$_action}($_args); } } } unset($_action, $_args); // Housekeeping. }
/** * Class constructor. * * @since 141111 First documented version. * * @param int $sub_id Subscription ID. */ public function __construct($sub_id = null) { parent::__construct(); if (isset($sub_id)) { // Editing? $this->is_edit = true; // Flag as `TRUE`. $sub_id = (int) $sub_id; // Force integer. $this->sub = $this->plugin->utils_sub->get($sub_id); if (!$this->sub) { // Unexpected scenario; fail w/ message. wp_die(__('Subscription ID not found.', 'comment-mail')); } } $this->form_fields = new FormFields(static::$form_field_args); $this->maybeDisplay(); }
/** * Class constructor. * * @since 141111 First documented version. * * @param array $entry Log entry data. * * @throws \exception If `$entry` is missing required keys. */ public function __construct(array $entry) { parent::__construct(); $defaults = ['queue_id' => 0, 'dby_queue_id' => 0, 'sub_id' => 0, 'user_id' => 0, 'post_id' => 0, 'comment_parent_id' => 0, 'comment_id' => 0, 'fname' => '', 'lname' => '', 'email' => '', 'ip' => '', 'region' => '', 'country' => '', 'status' => '', 'event' => '', 'note_code' => '', 'time' => time()]; # IP, region, country; auto-fill from subscription data. foreach (['ip', 'region', 'country'] as $_key) { if (empty($entry[$_key])) { // Coalesce; giving precedence to the `last_` value. $entry[$_key] = $this->notEmptyCoalesce($entry['last_' . $_key], $entry['insertion_' . $_key]); } } unset($_key); // Just a little housekeeping. $this->entry = array_merge($defaults, $entry); $this->entry = array_intersect_key($this->entry, $defaults); $this->entry = $this->plugin->utils_db->typifyDeep($this->entry); $this->maybeInsert(); // Record event; if applicable. }
/** * Class constructor. * * @since 141111 First documented version. * * @param int $sub_id Subscriber ID. * @param array $args Any additional behavioral args. */ public function __construct($sub_id, array $args = []) { parent::__construct(); $sub_id = (int) $sub_id; $this->sub = $this->plugin->utils_sub->get($sub_id); $defaults_args = ['auto_confirm' => null, 'process_events' => true, 'process_list_server' => false, 'user_initiated' => false]; $args = array_merge($defaults_args, $args); $args = array_intersect_key($args, $defaults_args); if (isset($args['auto_confirm'])) { $this->auto_confirm = (bool) $args['auto_confirm']; } $this->process_events = (bool) $args['process_events']; $this->process_list_server = (bool) $args['process_list_server']; $this->user_initiated = (bool) $args['user_initiated']; $this->user_initiated = $this->plugin->utils_sub->checkUserInitiatedByAdmin($this->sub ? $this->sub->email : '', $this->user_initiated); $this->auto_confirmed = false; $this->confirming_via_email = false; $this->sent_email_successfully = false; $this->maybeSendConfirmationRequest(); }
/** * Class constructor. * * @since 141111 First documented version. * * @param array $request_args Arguments to the constructor. * These should NOT be trusted; they come from a `$_REQUEST` action. */ public function __construct(array $request_args = []) { parent::__construct(); $default_request_args = ['start_from' => 1, 'max_limit' => 1000, 'include_utf8_bom' => false]; $request_args = array_merge($default_request_args, $request_args); $request_args = array_intersect_key($request_args, $default_request_args); $this->start_from = (int) $request_args['start_from']; $this->max_limit = (int) $request_args['max_limit']; $this->include_utf8_bom = filter_var($request_args['include_utf8_bom'], FILTER_VALIDATE_BOOLEAN); if ($this->start_from < 1) { $this->start_from = 1; } if ($this->max_limit < 1) { $this->max_limit = 1; } $upper_max_limit = (int) apply_filters(__CLASS__ . '_upper_max_limit', 5000); if ($this->max_limit > $upper_max_limit) { $this->max_limit = $upper_max_limit; } $this->maybeExport(); }
/** * Class constructor. * * @since 141111 First documented version. * * @param int|null $max_time Max time (in seconds). * * This cannot be less than `10` seconds. * This cannot be greater than `3600` seconds. */ public function __construct($max_time = null) { parent::__construct(); $this->start_time = time(); if (isset($max_time)) { $this->max_time = (int) $max_time; } else { $this->max_time = (int) $this->plugin->options['log_cleaner_max_time']; } if ($this->max_time < 10) { $this->max_time = 10; } if ($this->max_time > 3600) { $this->max_time = 3600; } $this->cleaned = 0; // Initialize. $this->prepCronJob(); $this->maybeCleanSubEventLogEntries(); $this->maybeCleanQueueEventLogEntries(); }
/** * Class constructor. * * @since 141111 First documented version. * * @param array $args Configuration arguments. * * @throws \exception If a security flag is triggered on `$this->data_file`. */ public function __construct(array $args) { parent::__construct(); $default_args = ['data' => '', 'data_file' => '', 'file_name' => '', 'content_type' => '', 'content_disposition' => 'attachment', 'chunk_size' => 2097152]; $args = array_merge($default_args, $args); $args = array_intersect_key($args, $default_args); $this->data = (string) $args['data']; $this->data_file = (string) $args['data_file']; if ($this->data_file) { // Run security flag checks on the path. $this->plugin->utils_fs->checkPathSecurity($this->data_file); } if ($this->data_file && is_file($this->data_file) && is_readable($this->data_file)) { $this->data = ''; // Favor the data file over raw data. } $this->file_name = (string) $args['file_name']; $this->content_type = (string) $args['content_type']; $this->content_disposition = (string) $args['content_disposition']; $this->chunk_size = (int) $args['chunk_size']; $this->chunk_size = $this->chunk_size < 1 ? 1 : $this->chunk_size; $this->maybeOutput(); }