/** * Create a data comment with data for a potential new subscriber. * * @since 1.0.0 * * @param Prompt_Interface_Subscribable[]|Prompt_Interface_Subscribable $lists * @param string $email * @param array $user_data */ public function save_subscription_data($lists, $email, $user_data = array()) { $remote_address = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''; $comment_id = wp_insert_comment(array('comment_author_email' => $email, 'comment_author_IP' => preg_replace('/[^0-9a-fA-F:., ]/', '', $remote_address), 'comment_agent' => 'Postmatic/' . Prompt_Core::version(), 'comment_content' => serialize($lists), 'comment_type' => self::$comment_type, 'comment_approved' => 'Postmatic')); if (!empty($user_data)) { add_comment_meta($comment_id, self::$user_data_meta_key, $user_data); } $this->keys = array($comment_id); }
/** * @param array $properties { * Script properties * @type string $handle Unique script identifier * @type string $path Path to script from plugin root * @type array $dependencies Optional dependencies * @type string $version Defaults to plugin version * @type boolean $in_footer Defaults to true * } */ public function __construct($properties) { $defaults = array('dependencies' => array(), 'version' => Prompt_Core::version(), 'in_footer' => true); $properties = wp_parse_args($properties, $defaults); foreach ($properties as $name => $value) { $this->{$name} = $value; } $suffix = '.min'; if (defined('WP_SCRIPT_DEBUG') and WP_SCRIPT_DEBUG) { $suffix = ''; } if (!file_exists(Prompt_Core::$dir_path . '/version')) { $suffix = ''; } if ($suffix) { $this->path = preg_replace('/(\\.[^\\.]*$)/', $suffix . '\\1', $this->path); } $this->url = path_join(Prompt_Core::$url_path, $this->path); }
public function __construct() { $this->prompt_version = Prompt_Core::version($full = true); $this->prompt_options = array_diff_key(Prompt_Core::$options->get(), array('prompt_key' => '')); $this->php_version = phpversion(); $this->php_extensions = get_loaded_extensions(); $this->wp_version = $GLOBALS['wp_version']; $this->db_version = $GLOBALS['wpdb']->db_version(); $this->siteurl = get_option('siteurl'); $this->is_multisite = is_multisite(); $this->active_plugins = get_option('active_plugins'); $this->active_sitewide_plugins = get_option('active_sitewide_plugins'); $this->plugins = get_plugins(); $this->theme = array(); $theme = wp_get_theme(); $theme_fields = array('Name', 'ThemeURI', 'Author', 'AuthorURI', 'Version', 'Template'); foreach ($theme_fields as $field) { $this->theme[$field] = $theme->get($field); } }
/** * Validate a new key and return revised settings to go with it. * * @since 2.0.0 * * @param string $key * @return array */ protected function get_new_key_settings($key) { $key = Prompt_Core::settings_page()->validate_key($key); if (is_wp_error($key)) { add_settings_error('prompt_key', 'invalid_key', $key->get_error_message()); return array(); } $new_settings = Prompt_Core::$options->get(); $new_settings['prompt_key'] = $key; return $new_settings; }
/** * Enqueue scripts and styles. * * @since 1.0.0 */ public function page_head() { wp_enqueue_media(); wp_enqueue_style('prompt-admin', path_join(Prompt_Core::$url_path, 'css/admin.css'), array(), Prompt_Core::version()); wp_enqueue_style('datetimepicker', 'https://cdnjs.cloudflare.com/ajax/libs/jquery-datetimepicker/2.4.5/jquery.datetimepicker.min.css', array(), '2.4.5'); wp_enqueue_script('datetimepicker', 'https://cdnjs.cloudflare.com/ajax/libs/jquery-datetimepicker/2.4.5/jquery.datetimepicker.min.js', array(), '2.4.5'); $script = new Prompt_Script(array('handle' => 'prompt-options-page', 'path' => 'js/options-page.js', 'dependencies' => array('jquery-ui-tabs', 'datetimepicker'))); $script->enqueue(); $script->localize('prompt_options_page_env', array('email_header_image_prompt' => __('Choose an email header image', 'Postmatic'))); }
/** * @return Prompt_Admin_Delivery_Metabox */ public static function text_metabox() { if (!self::$options->get('enable_post_delivery')) { return null; } if (!self::$text_metabox) { self::$text_metabox = new Prompt_Admin_Text_Metabox('prompt_text_version', __('Postmatic Text Version', 'Postmatic'), array('post_type' => self::$options->get('site_subscription_post_types'))); } return self::$text_metabox; }
/** * Make a method agnostic request * * @since 0.1.0 * * @param string $endpoint * @param array $request * @return array|WP_Error The implementation return value, a wp_remote_request() array by default. */ public function send($endpoint, $request = array()) { $url = $this->make_url($endpoint); $request = wp_parse_args($request, $this->defaults); if (!isset($request['headers'])) { $request['headers'] = array(); } if (!isset($request['headers']['Authorization'])) { $request['headers']['Authorization'] = 'Basic ' . base64_encode('api:' . $this->key); } if (!isset($request['headers']['X-Prompt-Core-Version'])) { $request['headers']['X-Prompt-Core-Version'] = Prompt_Core::version($full = true); } $default_timeout = defined('PROMPT_API_TIMEOUT') ? PROMPT_API_TIMEOUT : 30; if (!isset($request['timeout'])) { $request['timeout'] = $default_timeout; } $reply = call_user_func($this->implementation, $url, $request); if (!is_wp_error($reply) and isset($reply['response']['code']) and 410 == $reply['response']['code']) { Prompt_Core::$options->set('upgrade_required', true); } return $reply; }
Copyright (c) 2016 Transitive, Inc This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ if (class_exists('Prompt_Core')) { // Allow others to use Prompt as a dependency return; } require_once dirname(__FILE__) . '/vendor/scribu/scb-framework/load.php'; require_once dirname(__FILE__) . '/core/autoload.php'; Prompt_Autoload::register('Prompt_', dirname(__FILE__) . '/core'); Prompt_Autoload::register('Prompt_', dirname(__FILE__) . '/core/commands', '_Command'); Prompt_Autoload::register('Prompt_', dirname(__FILE__) . '/core/mailers', '_Mailer'); Prompt_Autoload::register('Prompt_', dirname(__FILE__) . '/core/email-batches', '_Email_Batch'); Prompt_Autoload::register('Prompt_', dirname(__FILE__) . '/core/matchers', '_Matcher'); Prompt_Autoload::register('Prompt_', dirname(__FILE__) . '/core/post-rendering-modifiers', '_Post_Rendering_Modifier'); Prompt_Autoload::register('Prompt_Interface_', dirname(__FILE__) . '/interfaces'); Prompt_Autoload::register('Prompt_Admin_', dirname(__FILE__) . '/admin'); Prompt_Autoload::register('Prompt_Enum_', dirname(__FILE__) . '/enums'); Prompt_Core::load();